Beispiel #1
0
def pending(request):
    user = request.user
    tickets_sounds = TicketViews.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 your recently uploaded sounds are still in processing' %
            n_unprocessed_sounds)
    moderators_version = False
    tvars = {
        'user': user,
        'show_pagination': show_pagination,
        'moderators_version': moderators_version,
        'own_page': True,
    }
    tvars.update(
        paginate(request, pendings,
                 settings.SOUNDS_PENDING_MODERATION_PER_PAGE))
    return render(request, 'accounts/pending.html', tvars)
Beispiel #2
0
def home(request):
    user = request.user

    # Tagcloud
    tags = user.profile.get_user_tags()

    # Sounds
    latest_sounds = Sound.objects.bulk_sounds_for_user(user_id=user.id,
                                                       limit=5)
    unprocessed_sounds = Sound.objects.select_related().filter(
        user=user).exclude(processing_state="OK")
    unmoderated_sounds = TicketViews.get_pending_sounds(request.user)
    unmoderated_sounds_count = len(unmoderated_sounds)
    num_more_unmoderated_sounds = 0
    if unmoderated_sounds_count > settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE:
        num_more_unmoderated_sounds = unmoderated_sounds_count - settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE
        unmoderated_sounds = unmoderated_sounds[:settings.
                                                MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE]

    # Packs
    latest_packs = Pack.objects.select_related().filter(user=user).filter(
        num_sounds__gt=0).order_by("-last_updated")[0:5]
    packs_without_sounds = Pack.objects.select_related().filter(
        user=user).filter(num_sounds=0)
    # 'packs_without_sounds' also includes packs that only contain unmoderated or unprocessed sounds

    # Moderation stats
    new_support = new_posts = 0
    if request.user.has_perm('tickets.can_moderate'):
        new_support = new_support_tickets_count()
    if request.user.has_perm('forum.can_moderate_forum'):
        new_posts = Post.objects.filter(moderation_state='NM').count()

    # Followers
    following, followers, following_tags, following_count, followers_count, following_tags_count \
        = follow_utils.get_vars_for_home_view(user)

    tvars = {
        'home': True,
        'latest_sounds': latest_sounds,
        'unprocessed_sounds': unprocessed_sounds,
        'unmoderated_sounds': unmoderated_sounds,
        'unmoderated_sounds_count': unmoderated_sounds_count,
        'num_more_unmoderated_sounds': num_more_unmoderated_sounds,
        'latest_packs': latest_packs,
        'packs_without_sounds': packs_without_sounds,
        'new_support': new_support,
        'new_posts': new_posts,
        'following': following,
        'followers': followers,
        'following_tags': following_tags,
        'following_count': following_count,
        'followers_count': followers_count,
        'following_tags_count': following_tags_count,
        'tags': tags,
    }
    return render(request, 'accounts/account.html', tvars)
Beispiel #3
0
def home(request):
    user = request.user

    # Tagcloud
    tags = user.profile.get_user_tags()

    # Sounds
    latest_sounds = Sound.objects.bulk_sounds_for_user(user_id=user.id, limit=5)
    unprocessed_sounds = Sound.objects.select_related().filter(user=user).exclude(processing_state="OK")
    unmoderated_sounds = TicketViews.get_pending_sounds(request.user)
    unmoderated_sounds_count = len(unmoderated_sounds)
    num_more_unmoderated_sounds = 0
    if unmoderated_sounds_count > settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE:
        num_more_unmoderated_sounds = unmoderated_sounds_count - settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE
        unmoderated_sounds = unmoderated_sounds[: settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE]

    # Packs
    latest_packs = (
        Pack.objects.select_related().filter(user=user).filter(num_sounds__gt=0).order_by("-last_updated")[0:5]
    )
    packs_without_sounds = Pack.objects.select_related().filter(user=user).filter(num_sounds=0)
    # 'packs_without_sounds' also includes packs that only contain unmoderated or unprocessed sounds

    # Moderation stats
    new_support = new_posts = 0
    if request.user.has_perm("tickets.can_moderate"):
        new_support = new_support_tickets_count()
    if request.user.has_perm("forum.can_moderate_forum"):
        new_posts = Post.objects.filter(moderation_state="NM").count()

    # Followers
    following, followers, following_tags, following_count, followers_count, following_tags_count = follow_utils.get_vars_for_home_view(
        user
    )

    tvars = {
        "home": True,
        "latest_sounds": latest_sounds,
        "unprocessed_sounds": unprocessed_sounds,
        "unmoderated_sounds": unmoderated_sounds,
        "unmoderated_sounds_count": unmoderated_sounds_count,
        "num_more_unmoderated_sounds": num_more_unmoderated_sounds,
        "latest_packs": latest_packs,
        "packs_without_sounds": packs_without_sounds,
        "new_support": new_support,
        "new_posts": new_posts,
        "following": following,
        "followers": followers,
        "following_tags": following_tags,
        "following_count": following_count,
        "followers_count": followers_count,
        "following_tags_count": following_tags_count,
        "tags": tags,
    }
    return render(request, "accounts/account.html", tvars)
Beispiel #4
0
def home(request):
    user = request.user

    # Tagcloud
    tags = user.profile.get_user_tags()

    # Sounds
    latest_sounds = Sound.objects.bulk_sounds_for_user(user_id=user.id, limit=5)
    unprocessed_sounds = Sound.objects.select_related().filter(user=user).exclude(processing_state="OK")
    unmoderated_sounds = TicketViews.get_pending_sounds(request.user)
    unmoderated_sounds_count = len(unmoderated_sounds)
    num_more_unmoderated_sounds = 0
    if unmoderated_sounds_count > settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE:
        num_more_unmoderated_sounds = unmoderated_sounds_count - settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE
        unmoderated_sounds = unmoderated_sounds[:settings.MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE]

    # Packs
    latest_packs = Pack.objects.select_related().filter(user=user, num_sounds__gt=0) \
                       .exclude(is_deleted=True).order_by("-last_updated")[0:5]
    packs_without_sounds = Pack.objects.select_related().filter(user=user, num_sounds=0).exclude(is_deleted=True)
    # 'packs_without_sounds' also includes packs that only contain unmoderated or unprocessed sounds

    # Moderation stats
    new_posts = 0
    if request.user.has_perm('forum.can_moderate_forum'):
        new_posts = Post.objects.filter(moderation_state='NM').count()

    # Followers
    following, followers, following_tags, following_count, followers_count, following_tags_count \
        = follow_utils.get_vars_for_home_view(user)

    tvars = {
        'home': True,
        'latest_sounds': latest_sounds,
        'unprocessed_sounds': unprocessed_sounds,
        'unmoderated_sounds': unmoderated_sounds,
        'unmoderated_sounds_count': unmoderated_sounds_count,
        'num_more_unmoderated_sounds': num_more_unmoderated_sounds,
        'latest_packs': latest_packs,
        'packs_without_sounds': packs_without_sounds,
        'new_posts': new_posts,
        'following': following,
        'followers': followers,
        'following_tags': following_tags,
        'following_count': following_count,
        'followers_count': followers_count,
        'following_tags_count': following_tags_count,
        'tags': tags,
    }
    return render(request, 'accounts/account.html', tvars)
Beispiel #5
0
def pending(request):
    user = request.user
    tickets_sounds = TicketViews.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 your recently uploaded sounds are still in processing" % n_unprocessed_sounds,
        )
    moderators_version = False
    tvars = {"user": user, "show_pagination": show_pagination, "moderators_version": moderators_version}
    tvars.update(paginate(request, pendings, settings.SOUNDS_PENDING_MODERATION_PER_PAGE))
    return render(request, "accounts/pending.html", tvars)
Beispiel #6
0
 def num_sounds_pending_moderation(self):
     return len(get_pending_sounds(self.user))
Beispiel #7
0
 def num_sounds_pending_moderation(self):
     return len(get_pending_sounds(self.user))
Beispiel #8
0
def pending_sounds_count(user):
    pending_sounds = TicketViews.get_pending_sounds(user)
    return len(pending_sounds)
Beispiel #9
0
def pending_sounds_count(user):
    pending_sounds = TicketViews.get_pending_sounds(user)
    return len(pending_sounds)