def test_model_create(self):
        self.prepare_model_tests()
        object = TestView.objects.create(field="b")

        activity_create.send(sender=object.__class__, instance=object)

        self.assertEqual(Notification.objects.filter(watch_ct=self.ct, watch_id=object.pk).count(), 2, "Counting notification objects")
    def test_model_create(self):
        self.prepare_model_tests()
        obj = TestView.objects.create(field="b")
        activity_create.send(sender=obj.__class__, instance=obj)

        self.assertEqual(
            Notification.objects.filter(watch_ct=self.ct,
                                        watch_id=obj.pk).count(), 2,
            "Counting notification objects")
    def test_model_changed(self):
        self.prepare_model_tests()
        obj = TestView.objects.create(field="b")
        activity_create.send(sender=obj.__class__, instance=obj)  # TODO: check why we need this

        obj.field = "a"
        activity_update.send(sender=obj.__class__, instance=obj)

        data = Activity.objects.get(parent_ct=self.ct, parent_id=obj.pk, action=ACTION_UPDATED)

        self.assertEqual(
            data.text,
            '[["field", "b", "a"]]',
            "Validation Activity object",
        )
    def test_model_changed(self):
        self.prepare_model_tests()
        obj = TestView.objects.create(field="b")
        activity_create.send(sender=obj.__class__,
                             instance=obj)  # TODO: check why we need this

        obj.field = "a"
        activity_update.send(sender=obj.__class__, instance=obj)

        data = Activity.objects.get(parent_ct=self.ct,
                                    parent_id=obj.pk,
                                    action=ACTION_UPDATED)

        self.assertEqual(
            data.text,
            '[["field", "b", "a"]]',
            "Validation Activity object",
        )
Exemple #5
0
 def form_valid(self, form):
     # messages.success(self.request, 'Object cloned')
     old_object = copy.copy(self.object)
     self.clone_object(form.cleaned_data, form.instance)
     form.instance.pk = None
     if form.instance._bmfmeta.workflow:
         setattr(form.instance, form.instance._bmfmeta.workflow_field_name, form.instance._bmfmeta.workflow.default)
     form.instance.created_by = self.request.user
     form.instance.modified_by = self.request.user
     self.form_object_save(form)
     self.clone_related_objects(form.cleaned_data, old_object, self.object)
     activity_create.send(sender=self.object.__class__, instance=self.object)
     return self.render_valid_form(
         {
             "object_pk": self.object.pk,
             #   'redirect': self.object.bmfmodule_detail(),
             "message": True,
             "reload": True,
         }
     )
 def form_valid(self, form):
     # messages.success(self.request, 'Object cloned')
     old_object = copy.copy(self.object)
     self.clone_object(form.cleaned_data, form.instance)
     form.instance.pk = None
     if form.instance._bmfmeta.workflow:
         setattr(form.instance, form.instance._bmfmeta.workflow_field_name,
                 form.instance._bmfmeta.workflow.default)
     form.instance.created_by = self.request.user
     form.instance.modified_by = self.request.user
     self.form_object_save(form)
     self.clone_related_objects(form.cleaned_data, old_object, self.object)
     activity_create.send(sender=self.object.__class__,
                          instance=self.object)
     return self.render_valid_form({
         'object_pk': self.object.pk,
         # 'redirect': self.object.bmfmodule_detail(),
         'message': True,
         'reload': True,
     })
Exemple #7
0
 def form_object_save(self, form):
     self.object = form.save()
     activity_create.send(sender=self.object.__class__, instance=self.object)
Exemple #8
0
 def form_object_save(self, form):
     self.object = form.save()
     activity_create.send(sender=self.object.__class__,
                          instance=self.object)