コード例 #1
0
    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")
コード例 #2
0
    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")
コード例 #3
0
    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",
        )
コード例 #4
0
    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",
        )
コード例 #5
0
ファイル: module.py プロジェクト: seethersan/django-bmf
 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,
         }
     )
コード例 #6
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,
     })
コード例 #7
0
ファイル: module.py プロジェクト: kamilnazar1/django-bmf
 def form_object_save(self, form):
     self.object = form.save()
     activity_create.send(sender=self.object.__class__, instance=self.object)
コード例 #8
0
 def form_object_save(self, form):
     self.object = form.save()
     activity_create.send(sender=self.object.__class__,
                          instance=self.object)