Exemplo n.º 1
0
 def testCanAddMetaToRevision(self):
     # Create a revision with lots of meta data.
     with create_revision():
         self.test11.save()
         set_comment("Foo bar")
         self.assertEqual(get_comment(), "Foo bar")
         set_user(self.user)
         self.assertEqual(get_user(), self.user)
         add_meta(RevisionMeta, age=5)
     # Test the revision data.
     revision = 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)
Exemplo n.º 2
0
 def testCanAddMetaToRevision(self):
     # Create a revision with lots of meta data.
     with create_revision():
         self.test11.save()
         set_comment("Foo bar")
         self.assertEqual(get_comment(), "Foo bar")
         set_user(self.user)
         self.assertEqual(get_user(), self.user)
         add_meta(RevisionMeta, age=5)
     # Test the revision data.
     revision = 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)
Exemplo n.º 3
0
def post_revision_commit(sender, instance, **kwargs):
    if reversion.is_active() and (instance.status == 2 or instance.status == 4) and not instance.imported:

        authorized_user = instance.user
        authorizer = reversion.get_user()

        authorization = Authorization()

        if instance.specific_stream:
            authorization.stream = instance.specific_stream

        authorization.authorized_user = authorized_user
        authorization.authorizer = authorizer
        authorization.partner = instance.partner
        authorization.save()
Exemplo n.º 4
0
def _set_user_from_request(request):
    if getattr(request, "user",
               None) and request.user.is_authenticated and get_user() is None:
        set_user(request.user)
Exemplo n.º 5
0
def _set_user_from_request(request):
    if hasattr(request, "user") and is_authenticated(request.user) and get_user() is None:
        set_user(request.user)
Exemplo n.º 6
0
def _set_user_from_request(request):
    if getattr(request, "user", None) and request.user.is_authenticated and get_user() is None:
        set_user(request.user)
Exemplo n.º 7
0
def _set_user_from_request(request):
    if getattr(request, "jwt_user",
               None) and request.jwt_user.uuid and get_user() is None:
        set_user(request.jwt_user.uuid)