Bases: UserPassesTestMixin, View
  
class-attribute
      instance-attribute
  
    
    
 
post(request, type, submission_pk)
            
              Source code in hypha/apply/flags/views.py
              |  | def post(self, request, type, submission_pk):
    # Only staff can create staff flags.
    if type == self.model.STAFF and not self.request.user.is_apply_staff:
        return HttpResponseNotAllowed()
    submission = ApplicationSubmission.objects.get(pk=submission_pk)
    submission_type = ContentType.objects.get_for_model(ApplicationSubmission)
    # Trying to get a flag from the table, or create a new one
    flag, created = self.model.objects.get_or_create(
        user=request.user,
        target_object_id=submission_pk,
        target_content_type=submission_type,
        type=type,
    )
    # If no new flag has been created,
    # Then we believe that the request was to delete the flag.
    if not created:
        flag.delete()
    return render(
        request, "flags/flags.html", {"flag": flag, "submission": submission}
    )
 | 
 
     
 
    
            
              Source code in hypha/apply/flags/views.py
              |  | def test_func(self):
    return self.request.user.is_apply_staff or self.request.user.is_reviewer
 |