Ejemplo n.º 1
0
 def post(self, request, **kwargs):
     component = self.get_component(kwargs)
     if not can_add_screenshot(request.user, component.project):
         raise PermissionDenied()
     self._add_form = ScreenshotForm(request.POST, request.FILES)
     if self._add_form.is_valid():
         obj = Screenshot.objects.create(
             component=component,
             **self._add_form.cleaned_data
         )
         try_add_source(request, obj)
         messages.success(
             request,
             _(
                 'Screenshot has been uploaded, '
                 'you can now assign it to source strings.'
             )
         )
         return redirect(obj)
     else:
         messages.error(
             request,
             _('Failed to upload screenshot, please fix errors below.')
         )
         return self.get(request, **kwargs)
Ejemplo n.º 2
0
 def post(self, request, **kwargs):
     component = self.get_component(kwargs)
     if not can_add_screenshot(request.user, component.project):
         raise PermissionDenied()
     self._add_form = ScreenshotForm(request.POST, request.FILES)
     if self._add_form.is_valid():
         obj = Screenshot.objects.create(
             component=component,
             **self._add_form.cleaned_data
         )
         try_add_source(request, obj)
         messages.success(
             request,
             _(
                 'Screenshot has been uploaded, '
                 'you can now assign it to source strings.'
             )
         )
         return redirect(obj)
     else:
         messages.error(
             request,
             _('Failed to upload screenshot, please fix errors below.')
         )
         return self.get(request, **kwargs)
Ejemplo n.º 3
0
 def get_context_data(self):
     result = super(ScreenshotList, self).get_context_data()
     component = self.kwargs['component']
     result['object'] = component
     if can_add_screenshot(self.request.user, component.project):
         if self._add_form is not None:
             result['add_form'] = self._add_form
         else:
             result['add_form'] = ScreenshotForm()
     return result
Ejemplo n.º 4
0
 def get_context_data(self):
     result = super(ScreenshotList, self).get_context_data()
     component = self.kwargs['component']
     result['object'] = component
     if can_add_screenshot(self.request.user, component.project):
         if self._add_form is not None:
             result['add_form'] = self._add_form
         else:
             result['add_form'] = ScreenshotForm()
     return result