Example #1
0
 def denunciar(self, request, motivo):
     if not es_perfil_denunciante(request.user):
         raise ImmediateHttpResponse(HttpUnauthorized())
     try:
         modelo = self._meta.object_class.objects.get(pk=request.api['pk'])
         denunciante = Perfil.objects.get_subclass(usuario=request.user)
         Denuncia.objects.create(modelo=modelo, denunciante=denunciante, motivo=motivo)
         return self.create_response(request, {}, HttpOK)
     except Exception:
         raise ImmediateHttpResponse(HttpBadRequest())
Example #2
0
 def create_detail(self, object_list, bundle):
     return es_perfil_denunciante(bundle.request.user)
Example #3
0
 def create_list(self, object_list, bundle):
     # Solo los perfiles denunciantes pueden crear denuncias
     if es_perfil_denunciante(bundle.request.user):
         return object_list
     else:
         raise Unauthorized()