Example #1
0
 def get_context_data(self, **kwargs):
     access = MarkAccess(self.request.user, mark=self.object)
     if not access.can_edit:
         raise BridgeException(
             _("You don't have an access to edit this mark"))
     context = super().get_context_data(**kwargs)
     mark_version = self.version_model.objects.select_related('mark')\
         .get(mark=self.object, version=int(self.request.GET.get('version', self.object.version)))
     context.update({
         'access':
         access,
         'versions':
         self.versions_serializer_class(mark=self.object).data,
         'cancel_url':
         reverse('marks:{}'.format(self.mark_type), args=[self.object.id]),
         'save_url':
         reverse('marks:api-{mtype}-detail'.format(mtype=self.mark_type),
                 args=[self.object.id]),
         'save_method':
         'PUT',
         'data':
         MarkVersionFormData(self.mark_type, mark_version=mark_version),
         'attrs':
         mark_version.attrs.all()
     })
     return context
Example #2
0
 def get_context_data(self, instance, **kwargs):
     context = super().get_context_data(instance, **kwargs)
     context.update({
         'action':
         'create',
         'attrs':
         instance.attrs.all(),
         'data':
         MarkVersionFormData(self.mtype),
         'save_url':
         reverse('marks:api-{mtype}-list'.format(mtype=self.mtype)),
         'save_method':
         'POST'
     })
     return context
Example #3
0
 def get_context_data(self, instance, **kwargs):
     context = super().get_context_data(instance, **kwargs)
     context.update({
         'action':
         'edit',
         'attrs':
         instance.attrs.all(),
         'data':
         MarkVersionFormData(self.mtype, mark_version=instance),
         'save_url':
         reverse('marks:api-{mtype}-detail'.format(mtype=self.mtype),
                 args=[instance.mark_id]),
         'save_method':
         'PUT'
     })
     return context
Example #4
0
 def get_context_data(self, **kwargs):
     access = MarkAccess(self.request.user, report=self.object)
     if not access.can_create:
         raise BridgeException(
             _("You don't have an access to create new mark"))
     context = super().get_context_data(**kwargs)
     context.update({
         'access':
         access,
         'cancel_url':
         reverse('reports:{}'.format(self.mark_type),
                 args=[self.object.id]),
         'save_url':
         reverse('marks:api-{mtype}-list'.format(mtype=self.mark_type)),
         'save_method':
         'POST',
         'data':
         MarkVersionFormData(self.mark_type),
         'attrs':
         self.object.attrs.all()
     })
     return context