예제 #1
0
def view_with_ladder(request, ladder, template, context=None):
    if not context:
        context = {}
    context.update({'ladder': ladder, 'watcher': get_watcher(request.user, ladder)})
    try:
        return render(request, template, context)
    except TemplateDoesNotExist:
        raise Http404("Template does not exist: %s" % template)
예제 #2
0
 def decorated(request, ladder_id, *args, **kwargs):
     if request.user.is_authenticated() and (get_watcher(request.user, ladder_id, 'ADMIN') or request.user.player_set.filter(ladder=ladder_id).count() != 0):
         return f(request, ladder_id, *args, **kwargs)
     return HttpResponseForbidden()
예제 #3
0
 def decorated(request, ladder_id, *args, **kwargs):
     if not (request.user.is_authenticated() and get_watcher(request.user, ladder_id, 'ADMIN')):
         return HttpResponseForbidden()
     return f(request, ladder_id, *args, **kwargs)
예제 #4
0
 def decorated(request, ladder_id, *args, **kwargs):
     ladder = get_ladder_or_404(pk=ladder_id)
     if ladder.is_private and not (request.user.is_authenticated() and get_watcher(request.user, ladder)):
         return redirect('/home/')
     return f(request, ladder_id, *args, **kwargs)