@require_POST
@login_required
def upload_screenshot(request, pk):
 source = get_object_or_404(Source, pk=pk)
 if (not can_upload_screenshot(request.user, source.subproject.project)):
  raise PermissionDenied()
 form = ScreenshotUploadForm(request.POST, request.FILES, instance=source)
 if form.is_valid():
  form.save()
 else:
  for error in form.errors:
   for message in form.errors[error]:
    messages.error(request, message)
 return redirect(request.POST.get('next', source.get_absolute_url()))

@ require_POST @ login_required def upload_screenshot ( request , pk ) : source = get_object_or_404 ( Source , pk = pk ) if ( not can_upload_screenshot ( request . user , source . subproject . project ) ) : raise PermissionDenied ( ) form = ScreenshotUploadForm ( request . POST , request . FILES , instance = source ) if form . is_valid ( ) : form . save ( ) else : for error in form . errors : for message in form . errors [ error ] : messages . error ( request , message ) return redirect ( request . POST . get ( 'next' , source . get_absolute_url ( ) ) )
upload screenshot handler .