fix(core): clean_fields for created_by field belongs in model that contains field
ref: #804 #768
This commit is contained in:
@ -94,6 +94,18 @@ class CenturionModelNote(
|
||||
table_fields: list = []
|
||||
|
||||
|
||||
def clean_fields(self, exclude = None):
|
||||
|
||||
if not self.created_by:
|
||||
|
||||
raise ValidationError(
|
||||
code = 'no_user_supplied',
|
||||
message = 'No user was supplied for this model note.'
|
||||
)
|
||||
|
||||
super().clean_fields(exclude = exclude)
|
||||
|
||||
|
||||
|
||||
class NoteMetaModel(
|
||||
CenturionModelNote,
|
||||
@ -107,19 +119,6 @@ class NoteMetaModel(
|
||||
proxy = False
|
||||
|
||||
|
||||
|
||||
def clean(self):
|
||||
|
||||
if not self.created_by:
|
||||
|
||||
raise ValidationError(
|
||||
code = 'no_user_supplied',
|
||||
message = 'No user was supplied for this model note.'
|
||||
)
|
||||
|
||||
super().clean()
|
||||
|
||||
|
||||
def clean_fields(self, exclude = None):
|
||||
|
||||
if not getattr(self, 'model', None):
|
||||
@ -132,11 +131,11 @@ class NoteMetaModel(
|
||||
|
||||
self.organization = self.model.organization
|
||||
|
||||
if not self.id:
|
||||
if not self.id and self.created_by is None:
|
||||
|
||||
self.created_by = self.context['user']
|
||||
|
||||
else:
|
||||
elif self.id:
|
||||
|
||||
self.modified_by = self.context['user']
|
||||
|
||||
|
Reference in New Issue
Block a user