예제 #1
0
파일: views.py 프로젝트: sacrac/django-cpm
 def form_valid(self, form):
     with reversion.create_revision():
         form.save()
         reversion.set_user(form.instance.user)
         print(form.instance.user)
         print(reversion.get_user())
     form_html = render_crispy_form(form)
     update_url = form.instance.get_update_url()
     context = {'success': True, 'form_html': form_html, 'pk': form.instance.id, 'update_url': update_url}
     return context
예제 #2
0
파일: tests.py 프로젝트: scsi110/mes-1
 def testCanAddMetaToRevision(self):
     # Create a revision with lots of meta data.
     with reversion.create_revision():
         self.test11.save()
         reversion.set_comment("Foo bar")
         self.assertEqual(reversion.get_comment(), "Foo bar")
         reversion.set_user(self.user)
         self.assertEqual(reversion.get_user(), self.user)
         reversion.add_meta(RevisionMeta, age=5)
     # Test the revision data.
     revision = reversion.get_for_object(self.test11)[0].revision
     self.assertEqual(revision.user, self.user)
     self.assertEqual(revision.comment, "Foo bar")
     self.assertEqual(revision.revisionmeta.age, 5)
예제 #3
0
 def testCanAddMetaToRevision(self):
     # Create a revision with lots of meta data.
     with reversion.create_revision():
         self.test11.save()
         reversion.set_comment("Foo bar")
         self.assertEqual(reversion.get_comment(), "Foo bar")
         reversion.set_user(self.user)
         self.assertEqual(reversion.get_user(), self.user)
         reversion.add_meta(RevisionMeta, age=5)
     # Test the revision data.
     revision = reversion.get_for_object(self.test11)[0].revision
     self.assertEqual(revision.user, self.user)
     self.assertEqual(revision.comment, "Foo bar")
     self.assertEqual(revision.revisionmeta.age, 5)
예제 #4
0
 def form_valid(self, form):
     with reversion.create_revision():
         form.save()
         reversion.set_user(form.instance.user)
         print(form.instance.user)
         print(reversion.get_user())
     form_html = render_crispy_form(form)
     update_url = form.instance.get_update_url()
     context = {
         'success': True,
         'form_html': form_html,
         'pk': form.instance.id,
         'update_url': update_url
     }
     return context
예제 #5
0
 def testGetUserNoBlock(self):
     with self.assertRaises(reversion.RevisionManagementError):
         reversion.get_user()
예제 #6
0
 def testGetUserDefault(self):
     with reversion.create_revision():
         self.assertEqual(reversion.get_user(), None)
예제 #7
0
 def testGetUser(self):
     with reversion.create_revision():
         reversion.set_user(self.user)
         self.assertEqual(reversion.get_user(), self.user)
예제 #8
0
 def testGetUserNoBlock(self):
     with self.assertRaises(reversion.RevisionManagementError):
         reversion.get_user()
예제 #9
0
 def testGetUserDefault(self):
     with reversion.create_revision():
         self.assertEqual(reversion.get_user(), None)
예제 #10
0
 def testGetUser(self):
     with reversion.create_revision():
         reversion.set_user(self.user)
         self.assertEqual(reversion.get_user(), self.user)