Example #1
0
 def get_sidebar_widget(kls, request):
     top5 = TopUser.objects.exclude(user__is_superuser=True).exclude(groups__name='Others')
     top5 = top5.order_by('-points')[:10]
     is_top = request.get_full_path().startswith('/top/')
     return render_string('top/sidebar.html',
         {'topusers': top5, 'is_top': is_top, 'top': Top}
     )
Example #2
0
def sidebar_widget(context):
    user = context.get('user', None)
    gc = GrandChallengeGame
    if gc.disabled() or not user or not user.is_authenticated():
        return ''
    gc_user = user.get_profile().get_extension(GrandChallengeUser)
    return render_string('grandchallenge/sidebar.html', {'gc': gc, 'gcuser': gc_user, 'id': 'grandchallenge'})
Example #3
0
def sidebar_widget(request):
    gc = GrandChallengeGame
    if gc.disabled():
        return ''
    gc_user = request.user.get_profile().get_extension(GrandChallengeUser)
    return render_string('grandchallenge/sidebar.html', {
        'gc': gc,
        'gcuser': gc_user
    })
Example #4
0
def sidebar_widget(request):
    qotd = QotdGame.get_for_today()
    qotd_user = request.user.get_profile().get_extension(QotdUser)

    if qotd_user.has_answered:
        time_passed = datetime.now() - qotd_user.last_answered
        if time_passed > timedelta(seconds=120): # two minutes
            return ''
    return render_string('qotd/sidebar.html', {'question': qotd, 'quser': qotd_user, 'qotd': QotdGame})
Example #5
0
 def get_sidebar_widget(kls, request):
     top5 = TopUser.objects.exclude(user__is_superuser=True).exclude(
         groups__name='Others')
     top5 = top5.order_by('-points')[:10]
     is_top = request.get_full_path().startswith('/top/')
     return render_string('top/sidebar.html', {
         'topusers': top5,
         'is_top': is_top,
         'top': Top
     })
Example #6
0
def sidebar_widget(context):
    user = context.get('user', None)
    gc = GrandChallengeGame
    if gc.disabled() or not user or not user.is_authenticated():
        return ''
    gc_user = user.get_profile().get_extension(GrandChallengeUser)
    return render_string('grandchallenge/sidebar.html', {
        'gc': gc,
        'gcuser': gc_user,
        'id': 'grandchallenge'
    })
Example #7
0
def sidebar_widget(request):
    profile = request.user.get_profile()
    if not profile:
        return ''
    chall_user = profile.get_extension(ChallengeUser)
    challs = ChallengeGame.get_active(chall_user)
    challs = [c for c in challs if c.status == 'A']
    # reduce noise, thanks
    if not challs:
        return ''

    return render_string('challenge/sidebar.html', {'challenges': challs, 'chall_user': chall_user})
Example #8
0
def sidebar_widget(request):
    if SpecialQuestGame.disabled():
        return ''
    user = request.user.get_profile().get_extension(SpecialQuestUser)
    tasks = SpecialQuestTask.objects.all()
    today = date.today()
    tasks = [t for t in tasks if t not in user.done_tasks.all() and t.start_date <= today <= t.end_date]

    if not tasks:
        return ''

    return render_string('specialquest/sidebar.html', {'not_done': len(tasks)})
Example #9
0
def sidebar_widget(request):
    qotd = QotdGame.get_for_today()
    qotd_user = request.user.get_profile().get_extension(QotdUser)

    if qotd_user.has_answered:
        time_passed = datetime.now() - qotd_user.last_answered
        if time_passed > timedelta(seconds=120):  # two minutes
            return ''
    return render_string('qotd/sidebar.html', {
        'question': qotd,
        'quser': qotd_user,
        'qotd': QotdGame
    })
Example #10
0
def sidebar_widget(request):
    if SpecialQuestGame.disabled():
        return ''
    user = request.user.get_profile().get_extension(SpecialQuestUser)
    tasks = SpecialQuestTask.objects.all()
    today = date.today()
    tasks = [
        t for t in tasks if t not in user.done_tasks.all()
        and t.start_date <= today <= t.end_date
    ]

    if not tasks:
        return ''

    return render_string('specialquest/sidebar.html', {'not_done': len(tasks)})
Example #11
0
def sidebar_widget(request):
    quest = QuestGame.get_current()

    if quest is None:
        return ''

    quest_user = request.user.get_profile().get_extension(QuestUser)
    if not quest_user.started:
        quest_progress = None
    else:
        quest_progress = 1.0 * quest_user.current_level / quest.count * 100

    if quest_user.finished and (quest_user.current_quest == quest):
        time_passed = datetime.now() - quest_user.finished_time
        if time_passed > timedelta(seconds=600): # ten minutes
            return ''

    return render_string('quest/sidebar.html',
            {'quest': quest, 'quser': quest_user,
             'quest_progress': quest_progress,
             })
Example #12
0
def sidebar_widget(request):
    gc = GrandChallengeGame
    if gc.disabled():
        return ''
    gc_user = request.user.get_profile().get_extension(GrandChallengeUser)
    return render_string('grandchallenge/sidebar.html', {'gc': gc, 'gcuser': gc_user})