Commit b0079b94 authored by Florent Chehab's avatar Florent Chehab
Browse files

fixed syntaxed

parent f7a7f518
Pipeline #26726 passed with stages
in 3 minutes and 15 seconds
...@@ -58,7 +58,7 @@ for obj in api_config: ...@@ -58,7 +58,7 @@ for obj in api_config:
if 'requires_testing' in obj and obj['requires_testing']: if 'requires_testing' in obj and obj['requires_testing']:
continue # we don't want testing models to be register in admin continue # we don't want testing models to be register in admin
if 'ignore_in_admin' in obj and obj['ignore_in_admin']: if 'ignore_in_admin' in obj and obj['ignore_in_admin']:
continue continue
if 'versionned' not in obj: if 'versionned' not in obj:
obj['versionned'] = False obj['versionned'] = False
data.append(obj) data.append(obj)
......
...@@ -92,10 +92,10 @@ class MyModelSerializer(serializers.ModelSerializer): ...@@ -92,10 +92,10 @@ class MyModelSerializer(serializers.ModelSerializer):
def my_pre_save(self): def my_pre_save(self):
pass pass
def save(self, **kwargs): def save(self, *args, **kwargs):
return self.my_save(**kwargs) return self.my_save(*args, **kwargs)
def my_save(self, **kwargs): def my_save(self, *args, **kwargs):
user = self.get_user_in_request() user = self.get_user_in_request()
self.clean_validated_data() self.clean_validated_data()
self.my_pre_save() self.my_pre_save()
...@@ -103,7 +103,7 @@ class MyModelSerializer(serializers.ModelSerializer): ...@@ -103,7 +103,7 @@ class MyModelSerializer(serializers.ModelSerializer):
if self.moderation_required(): if self.moderation_required():
if self.instance is None: # we need to create the main model if self.instance is None: # we need to create the main model
self.instance = super( self.instance = super(
MyModelSerializer, self).save(**kwargs) MyModelSerializer, self).save(*args, **kwargs)
objs_pending_db = self.get_pending_models() objs_pending_db = self.get_pending_models()
...@@ -128,7 +128,7 @@ class MyModelSerializer(serializers.ModelSerializer): ...@@ -128,7 +128,7 @@ class MyModelSerializer(serializers.ModelSerializer):
moderated_and_updated = True moderated_and_updated = True
if self.instance is None: if self.instance is None:
self.set_model_attr_no_moder(moderated_and_updated) self.set_model_attr_no_moder(moderated_and_updated)
return super(MyModelSerializer, self).save(**kwargs) return super(MyModelSerializer, self).save(*args, **kwargs)
else: else:
# We check if we don't have any moderation pending # We check if we don't have any moderation pending
objs_pending_db = self.get_pending_models() objs_pending_db = self.get_pending_models()
...@@ -143,4 +143,4 @@ class MyModelSerializer(serializers.ModelSerializer): ...@@ -143,4 +143,4 @@ class MyModelSerializer(serializers.ModelSerializer):
objs_pending_db.delete() objs_pending_db.delete()
self.set_model_attr_no_moder(moderated_and_updated) self.set_model_attr_no_moder(moderated_and_updated)
return super(MyModelSerializer, self).save(**kwargs) return super(MyModelSerializer, self).save(*args, **kwargs)
...@@ -36,11 +36,11 @@ class MyModelVersionnedSerializer(MyModelSerializer): ...@@ -36,11 +36,11 @@ class MyModelVersionnedSerializer(MyModelSerializer):
def get_content_type_id(self, obj): def get_content_type_id(self, obj):
return ContentType.objects.get_for_model(self.Meta.model).id return ContentType.objects.get_for_model(self.Meta.model).id
def save(self, **kwargs): def save(self, *args, **kwargs):
user = self.context['request'].user user = self.context['request'].user
res = None res = None
with reversion.create_revision(): with reversion.create_revision():
res = self.my_save(**kwargs) res = self.my_save(*args, **kwargs)
reversion.set_user(user) reversion.set_user(user)
new_revision_saved.send(sender=self.__class__, obj=self.instance) new_revision_saved.send(sender=self.__class__, obj=self.instance)
return res return res
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment