mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Use id instead of pk or checking for anonymous user
This commit is contained in:
parent
1a7a4bad49
commit
78e208dcdb
@ -14,7 +14,6 @@ from django.db import models
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
|
||||
# Django-JSONField
|
||||
from jsonfield import JSONField
|
||||
@ -291,7 +290,7 @@ class PrimordialModel(CreatedModifiedModel):
|
||||
def save(self, *args, **kwargs):
|
||||
update_fields = kwargs.get('update_fields', [])
|
||||
user = get_current_user()
|
||||
if user and (user == AnonymousUser or not user.pk):
|
||||
if user and not user.id:
|
||||
user = None
|
||||
if not self.pk and not self.created_by:
|
||||
self.created_by = user
|
||||
|
Loading…
Reference in New Issue
Block a user