예제 #1
0
 def _is_staff(request, *args, **kwargs):
     if not request.user.is_authenticated():
         return login_required(view_func)(request, *args, **kwargs)
     elif is_staff(request, request.user):
         return view_func(request, *args, **kwargs)
     else:
         raise PermissionDenied
예제 #2
0
def get_staff_profile(request):
    user = request.user
    if is_staff(user):
        staff = Staff.objects.get(user=user)
        staff_profile = StaffProfile.objects.get(staff=staff)
        staff_serializer = StaffSerializer(staff)
        profile_serializer = StaffProfileSerializer(staff_profile)
        if profile_serializer.data['avatar']:
            return Response({
                "staff": staff_serializer.data,
                "avatar": profile_serializer.data['avatar']
            })
        else:
            return Response({"staff": staff_serializer.data, "avatar": None})
    else:
        return Response({"You don't have permissions for this action"})
예제 #3
0
파일: views.py 프로젝트: tetalab/PonyConf
 def get_context_data(self, **ctx):
     if self.object.is_moderable_by(self.request.user):
         vote = Vote.objects.filter(talk=self.object,
                                    user=self.request.user).first()
         ctx.update(edit_perm=True,
                    moderate_perm=True,
                    vote=vote,
                    form_url=reverse('talk-conversation',
                                     kwargs={'talk': self.object.slug}))
     else:
         ctx['edit_perm'] = self.object.is_editable_by(self.request.user)
     if is_staff(self.request, self.request.user):
         ctx.update(base_template='staff.html')
     else:
         ctx.update(base_template='base.html')
     return super().get_context_data(**ctx)
예제 #4
0
def staff(request):
    return is_staff(request, request.user)