• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python functional.combine_dicts函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.functional.combine_dicts函数的典型用法代码示例。如果您正苦于以下问题:Python combine_dicts函数的具体用法?Python combine_dicts怎么用?Python combine_dicts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了combine_dicts函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: bookmarks

def bookmarks(request, username, category_id = None):
    
    user = get_object_or_404(User, username__iexact=username)
    is_owner = request.user.is_authenticated and user == request.user
    
    '''
    if is_owner and request.POST and "create_cat" in request.POST:
        form_bookmark_category = BookmarkCategoryForm(request.POST, instance=BookmarkCategory(user=user))
        if form_bookmark_category.is_valid():
            form_bookmark_category.save()
        
        form_bookmark_category = BookmarkCategoryForm()
        
    form_bookmark_category = BookmarkCategoryForm()
    '''    
    
    n_uncat = Bookmark.objects.select_related("sound").filter(user=user,category=None).count()
    
    if not category_id:
        bookmarked_sounds = Bookmark.objects.select_related("sound").filter(user=user,category=None)
    else:
        category = get_object_or_404(BookmarkCategory,id=category_id,user=user)
        bookmarked_sounds = category.bookmarks.select_related("sound").all()
    
    bookmark_categories = BookmarkCategory.objects.filter(user=user)
    
    return render_to_response('bookmarks/bookmarks.html', combine_dicts(locals(),paginate(request, bookmarked_sounds, 30)), context_instance=RequestContext(request))
开发者ID:digitalzoomstudio,项目名称:freesound,代码行数:27,代码来源:views.py


示例2: packs_for_user

def packs_for_user(request, username):
    user = get_object_or_404(User, username__iexact=username)
    order = request.GET.get("order", "name")
    if order not in ["name", "-last_update", "-created", "-num_sounds", "-num_downloads"]:
        order = "name"
    qs = Pack.objects.select_related().filter(user=user, sound__moderation_state="OK", sound__processing_state="OK").annotate(num_sounds=Count('sound'), last_update=Max('sound__created')).filter(num_sounds__gt=0).order_by(order)
    return render_to_response('sounds/packs.html', combine_dicts(paginate(request, qs, settings.PACKS_PER_PAGE), locals()), context_instance=RequestContext(request))
开发者ID:digitalzoomstudio,项目名称:freesound,代码行数:7,代码来源:views.py


示例3: pack

def pack(request, username, pack_id):
    try:
        pack = Pack.objects.select_related().annotate(num_sounds=Count('sound')).get(user__username__iexact=username, id=pack_id)
    except Pack.DoesNotExist:
        raise Http404
    qs = Sound.objects.select_related('pack', 'user', 'license', 'geotag').filter(pack=pack, moderation_state="OK", processing_state="OK")
    num_sounds_ok = len(qs)
    # TODO: refactor: This list of geotags is only used to determine if we need to show the geotag map or not
    pack_geotags = Sound.public.select_related('license', 'pack', 'geotag', 'user', 'user__profile').filter(pack=pack).exclude(geotag=None).exists()
    google_api_key = settings.GOOGLE_API_KEY
    
    if num_sounds_ok == 0 and pack.num_sounds != 0:
        messages.add_message(request, messages.INFO, 'The sounds of this pack have <b>not been moderated</b> yet.')
    else :
        if num_sounds_ok < pack.num_sounds :
            messages.add_message(request, messages.INFO, 'This pack contains more sounds that have <b>not been moderated</b> yet.')

    # If user is owner of pack, display form to add description
    enable_description_form = False
    if request.user.username == username:
        enable_description_form = True
        form = PackDescriptionForm(instance = pack)

    # Manage POST info (if adding a description)
    if request.method == 'POST':
        form = PackDescriptionForm(request.POST, pack)
        if form.is_valid():
            pack.description = form.cleaned_data['description']
            pack.save()
        else:
            pass

    file_exists = os.path.exists(pack.locations("license_path"))

    return render_to_response('sounds/pack.html', combine_dicts(locals(), paginate(request, qs, settings.SOUNDS_PER_PAGE)), context_instance=RequestContext(request))
开发者ID:digitalzoomstudio,项目名称:freesound,代码行数:35,代码来源:views.py


示例4: remixed

def remixed(request):
    # TODO: this doesn't return the right results after remix_group merge
    qs = RemixGroup.objects.all().order_by("-group_size")
    return render_to_response(
        "sounds/remixed.html",
        combine_dicts(locals(), paginate(request, qs, settings.SOUND_COMMENTS_PER_PAGE)),
        context_instance=RequestContext(request),
    )
开发者ID:harish211,项目名称:freesound,代码行数:8,代码来源:views.py


示例5: moderation_tary_moderators_sounds

def moderation_tary_moderators_sounds(request):
    if request.user.id :
        sounds_in_moderators_queue_count = Ticket.objects.select_related().filter(assignee=request.user.id).exclude(status='closed').exclude(content=None).order_by('status', '-created').count()
    else :
        sounds_in_moderators_queue_count = -1

    tardy_moderators_tickets = list(__get_tardy_moderator_tickets_all())

    return render_to_response('tickets/moderation_tardy_moderators.html', combine_dicts(paginate(request, tardy_moderators_tickets, 10), locals()), context_instance=RequestContext(request))
开发者ID:takuya1981,项目名称:freesound,代码行数:9,代码来源:views.py


示例6: forum

def forum(request, forum_name_slug):
    try:
        forum = Forum.objects.get(name_slug=forum_name_slug)
    except Forum.DoesNotExist: #@UndefinedVariable
        raise Http404

    paginator = paginate(request, Thread.objects.filter(forum=forum, first_post__moderation_state="OK").select_related('last_post', 'last_post__author'), settings.FORUM_THREADS_PER_PAGE)

    return render_to_response('forum/threads.html', combine_dicts(locals(), paginator), context_instance=RequestContext(request))
开发者ID:giuband,项目名称:freesound,代码行数:9,代码来源:views.py


示例7: pack_downloaders

def pack_downloaders(request, username, pack_id):
    pack = get_object_or_404(Pack, id=pack_id)

    # Retrieve all users that downloaded a sound
    qs = Download.objects.filter(pack=pack_id)
    return render_to_response(
        "sounds/pack_downloaders.html",
        combine_dicts(paginate(request, qs, 32, object_count=pack.num_downloads), locals()),
        context_instance=RequestContext(request),
    )
开发者ID:takuya1981,项目名称:freesound,代码行数:10,代码来源:views.py


示例8: packs

def packs(request):
    order = request.GET.get("order", "name")
    if order not in ["name", "-last_updated", "-created", "-num_sounds", "-num_downloads"]:
        order = "name"
    qs = Pack.objects.select_related() \
                     .filter(num_sounds__gt=0) \
                     .order_by(order)
    return render_to_response('sounds/browse_packs.html',
                              combine_dicts(paginate(request, qs, settings.PACKS_PER_PAGE, cache_count=True), locals()),
                              context_instance=RequestContext(request))
开发者ID:uofajillian,项目名称:freesound,代码行数:10,代码来源:views.py


示例9: thread

def thread(request, forum_name_slug, thread_id):
    forum = get_object_or_404(Forum, name_slug=forum_name_slug)
    thread = get_object_or_404(Thread, forum=forum, id=thread_id, first_post__moderation_state="OK")

    paginator = paginate(request, Post.objects.select_related('author', 'author__profile').filter(thread=thread, moderation_state="OK"), settings.FORUM_POSTS_PER_PAGE)

    # a logged in user watching a thread can activate his subscription to that thread!
    # we assume the user has seen the latest post if he is browsing the thread
    # this is not entirely correct, but should be close enough
    if request.user.is_authenticated():
        Subscription.objects.filter(thread=thread, subscriber=request.user, is_active=False).update(is_active=True)

    return render_to_response('forum/thread.html', combine_dicts(locals(), paginator), context_instance=RequestContext(request))
开发者ID:giuband,项目名称:freesound,代码行数:13,代码来源:views.py


示例10: all

def all(request):
    """ This is all very hacky because GenericRelations don't allow you to span
    relations with select_related... hence we get the content_objects and then
    load all the sounds related to those in a big lookup. If we don't do this
    the page generates about 90+ queries, with it we only generate 4 queries :-) """
    sound_type = ContentType.objects.get_for_model(Sound)
    qs = Comment.objects.filter(content_type=sound_type).select_related("user", "user__profile")
    paginator_obj = paginate(request, qs, 30)
    comments = paginator_obj["page"].object_list
    sound_ids = set([comment.object_id for comment in comments])
    sound_lookup = dict([(sound.id, sound) for sound in list(Sound.objects.filter(id__in=sound_ids).select_related("user"))])
    for comment in comments:
        comment.sound_object = sound_lookup[comment.object_id]
    return render_to_response('sounds/comments.html', combine_dicts(paginator_obj, locals()), context_instance=RequestContext(request))
开发者ID:takuya1981,项目名称:freesound,代码行数:14,代码来源:views.py


示例11: pending_tickets_per_user

def pending_tickets_per_user(request, username):

    user = get_object_or_404(User, username=username)
    tickets_sounds = get_pending_sounds(user)
    pendings = []
    for ticket, sound in tickets_sounds:
        last_comments = ticket.get_n_last_non_moderator_only_comments(3)
        pendings.append( (ticket, sound, last_comments) )

    show_pagination = len(pendings) > settings.SOUNDS_PENDING_MODERATION_PER_PAGE

    n_unprocessed_sounds = Sound.objects.select_related().filter(user=user).exclude(processing_state="OK").count()
    if n_unprocessed_sounds:
        messages.add_message(request, messages.WARNING, '%i of %s\'s recently uploaded sounds are still in processing '
                                                        'phase and therefore are not yet ready for moderation. These '
                                                        'sounds won\'t appear in this list until they are successfully '
                                                        'processed.' % (n_unprocessed_sounds, user.username))

    moderators_version = True
    return render_to_response('accounts/pending.html', combine_dicts(paginate(request, pendings, settings.SOUNDS_PENDING_MODERATION_PER_PAGE), locals()), context_instance=RequestContext(request))
开发者ID:takuya1981,项目名称:freesound,代码行数:20,代码来源:views.py


示例12: send_mail_template

                    send_mail_template(u'You have a new comment.', 'sounds/email_new_comment.txt',
                                       {'sound': sound, 'user': request.user, 'comment': comment_text},
                                       None, sound.user.email)
                except Exception, e:
                    # if the email sending fails, ignore...
                    logger.error("Problem sending email to '%s' about new comment: %s" \
                                 % (request.user.email, e))

                return HttpResponseRedirect(sound.get_absolute_url())
    else:
        form = CommentForm(request)

    qs = Comment.objects.select_related("user", "user__profile").filter(content_type=sound_content_type, object_id=sound_id)
    display_random_link = request.GET.get('random_browsing')
    #facebook_like_link = urllib.quote_plus('http://%s%s' % (Site.objects.get_current().domain, reverse('sound', args=[sound.user.username, sound.id])))
    return render_to_response('sounds/sound.html', combine_dicts(locals(), paginate(request, qs, settings.SOUND_COMMENTS_PER_PAGE)), context_instance=RequestContext(request))


def sound_download(request, username, sound_id):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('%s?next=%s' % (reverse("accounts-login"),
                                                    reverse("sound", args=[username, sound_id])))
    sound = get_object_or_404(Sound, user__username__iexact=username, id=sound_id, moderation_state="OK", processing_state="OK")
    Download.objects.get_or_create(user=request.user, sound=sound)
    return sendfile(sound.locations("path"), sound.friendly_filename(), sound.locations("sendfile_url"))


def pack_download(request, username, pack_id):
    from django.http import HttpResponse

    if not request.user.is_authenticated():
开发者ID:digitalzoomstudio,项目名称:freesound,代码行数:31,代码来源:views.py


示例13: downloaded_packs

def downloaded_packs(request, username):
    user=get_object_or_404(User, username__iexact=username)
    qs = Download.objects.filter(user=user.id, pack__isnull=False)
    return render_to_response('accounts/downloaded_packs.html', combine_dicts(paginate(request, qs, settings.PACKS_PER_PAGE), locals()), context_instance=RequestContext(request))
开发者ID:djzikario,项目名称:freesound,代码行数:4,代码来源:views.py


示例14: attribution

def attribution(request):
    qs = Download.objects.filter(user=request.user)
    format = request.GET.get("format", "regular")
    return render_to_response('accounts/attribution.html', combine_dicts(paginate(request, qs, 40), locals()), context_instance=RequestContext(request))
开发者ID:djzikario,项目名称:freesound,代码行数:4,代码来源:views.py


示例15: for_user

def for_user(request, username):
    user = get_object_or_404(User, username__iexact=username)
    qs = Sound.public.filter(user=user)
    return render_to_response('sounds/for_user.html', combine_dicts(paginate(request, qs, settings.SOUNDS_PER_PAGE), locals()), context_instance=RequestContext(request))
开发者ID:digitalzoomstudio,项目名称:freesound,代码行数:4,代码来源:views.py


示例16: moderation_assigned

def moderation_assigned(request, user_id):
    
    can_view_moderator_only_messages = __can_view_mod_msg(request)
    clear_forms = True
    if request.method == 'POST':
        mod_sound_form = SoundModerationForm(request.POST)
        msg_form = ModerationMessageForm(request.POST)

        if mod_sound_form.is_valid() and msg_form.is_valid():

            ticket = Ticket.objects.get(id=mod_sound_form.cleaned_data.get("ticket", False))
            invalidate_template_cache("user_header", ticket.sender.id)
            invalidate_all_moderators_header_cache()
            action = mod_sound_form.cleaned_data.get("action")
            msg = msg_form.cleaned_data.get("message", False)
            moderator_only = msg_form.cleaned_data.get("moderator_only", False)

            if msg:
                tc = TicketComment(sender=ticket.assignee,
                                   text=msg,
                                   ticket=ticket,
                                   moderator_only=moderator_only)
                tc.save()

            if action == "Approve":
                ticket.status = TICKET_STATUS_CLOSED
                ticket.content.content_object.change_moderation_state("OK")  # change_moderation_state does the saving
                ticket.save()
                ticket.content.content_object.mark_index_dirty()
                if msg:
                    ticket.send_notification_emails(Ticket.NOTIFICATION_APPROVED_BUT,
                                                    Ticket.USER_ONLY)
                else:
                    ticket.send_notification_emails(Ticket.NOTIFICATION_APPROVED,
                                                    Ticket.USER_ONLY)
            elif action == "Defer":
                ticket.status = TICKET_STATUS_DEFERRED
                ticket.save()
                # only send a notification if a message was added
                if msg:
                    ticket.send_notification_emails(Ticket.NOTIFICATION_QUESTION,
                                                    Ticket.USER_ONLY)
            elif action == "Return":
                ticket.assignee = None
                ticket.status = TICKET_STATUS_NEW
                # no notification here
                ticket.save()
            elif action == "Delete":
                ticket.send_notification_emails(Ticket.NOTIFICATION_DELETED,
                                                Ticket.USER_ONLY)
                # to prevent a crash if the form is resubmitted
                if ticket.content:
                    ticket.content.content_object.delete()
                    ticket.content.delete()
                    ticket.content = None
                ticket.status = TICKET_STATUS_CLOSED
                ticket.save()
            elif action == "Whitelist":

                th = Thread(target=call_command, args=('whitelist_user', ticket.id,))
                th.start()
                ticket.send_notification_emails(Ticket.NOTIFICATION_WHITELISTED,
                                                Ticket.USER_ONLY)

                messages.add_message(request, messages.INFO, 'User %s has been whitelisted but some of his tickets might '
                                                             'still appear on this list for some time. Please reload the page in a few '
                                                             'seconds to see the updated list of pending tickets' % ticket.sender.username)

        else:
            clear_forms = False
    if clear_forms:
        mod_sound_form = SoundModerationForm(initial={'action': 'Approve'})
        msg_form = ModerationMessageForm()

    qs = Ticket.objects.select_related() \
                       .filter(assignee=user_id) \
                       .exclude(status=TICKET_STATUS_CLOSED) \
                       .exclude(content=None) \
                       .order_by('status', '-created')
    paginaion_response = paginate(request, qs, settings.MAX_TICKETS_IN_MODERATION_ASSIGNED_PAGE)
    paginaion_response['page'].object_list = list(paginaion_response['page'].object_list)
    for ticket in paginaion_response['page'].object_list:
        sound_id = ticket.content.object_id
        try:
            Sound.objects.get(id=sound_id)
        except:
            paginaion_response['page'].object_list.remove(ticket)
            try:
                # Try to delete ticket so error does not happen again
                ticket.delete()
            except:
                pass

    moderator_tickets_count = qs.count()
    moderation_texts = MODERATION_TEXTS
    show_pagination = moderator_tickets_count > settings.MAX_TICKETS_IN_MODERATION_ASSIGNED_PAGE

    return render_to_response('tickets/moderation_assigned.html',
                              combine_dicts(paginaion_response, locals()),
                              context_instance=RequestContext(request))
开发者ID:takuya1981,项目名称:freesound,代码行数:100,代码来源:views.py


示例17: latest_posts

def latest_posts(request):
    paginator = paginate(request, Post.objects.select_related('author', 'author__profile', 'thread', 'thread__forum').filter(moderation_state="OK").order_by('-created').all(), settings.FORUM_POSTS_PER_PAGE)
    hide_search = True
    return render_to_response('forum/latest_posts.html', combine_dicts(locals(), paginator), context_instance=RequestContext(request))
开发者ID:giuband,项目名称:freesound,代码行数:4,代码来源:views.py


示例18: downloaders

def downloaders(request, username, sound_id):
    sound = get_object_or_404(Sound, id=sound_id)
    
    # Retrieve all users that downloaded a sound
    qs = Download.objects.filter(sound=sound_id)
    return render_to_response('sounds/downloaders.html', combine_dicts(paginate(request, qs, 32), locals()), context_instance=RequestContext(request))
开发者ID:digitalzoomstudio,项目名称:freesound,代码行数:6,代码来源:views.py


示例19: reverse

    qs = Comment.objects.select_related("user", "user__profile").filter(
        content_type=sound_content_type, object_id=sound_id
    )
    display_random_link = request.GET.get("random_browsing")
    do_log = settings.LOG_CLICKTHROUGH_DATA

    is_following = False
    if request.user.is_authenticated():
        users_following = follow_utils.get_users_following(request.user)
        if sound.user in users_following:
            is_following = True

    # facebook_like_link = urllib.quote_plus('http://%s%s' % (Site.objects.get_current().domain, reverse('sound', args=[sound.user.username, sound.id])))
    return render_to_response(
        "sounds/sound.html",
        combine_dicts(locals(), paginate(request, qs, settings.SOUND_COMMENTS_PER_PAGE)),
        context_instance=RequestContext(request),
    )


def sound_download(request, username, sound_id):
    if not request.user.is_authenticated():
        return HttpResponseRedirect(
            "%s?next=%s" % (reverse("accounts-login"), reverse("sound", args=[username, sound_id]))
        )
    if settings.LOG_CLICKTHROUGH_DATA:
        click_log(request, click_type="sounddownload", sound_id=sound_id)

    sound = get_object_or_404(Sound, id=sound_id, moderation_state="OK", processing_state="OK")
    if sound.user.username.lower() != username.lower():
        raise Http404
开发者ID:harish211,项目名称:freesound,代码行数:31,代码来源:views.py



注:本文中的utils.functional.combine_dicts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python globals.GlobalData类代码示例发布时间:2022-05-26
下一篇:
Python forms.BaseFormHelper类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap