general: do not attach users to migration snapshots (#62073)
This commit is contained in:
parent
909f16eff3
commit
bad495bff9
|
@ -62,7 +62,7 @@ class Category(XmlStorableObject):
|
|||
if not self.url_name:
|
||||
changed = True # trigger new slug in .store()
|
||||
if changed:
|
||||
self.store()
|
||||
self.store(comment=_('Automatic update'), snapshot_store_user=False)
|
||||
|
||||
@classmethod
|
||||
def get_object_class(cls):
|
||||
|
@ -92,7 +92,7 @@ class Category(XmlStorableObject):
|
|||
return True
|
||||
return False
|
||||
|
||||
def store(self, *args, comment=None, **kwargs):
|
||||
def store(self, *args, comment=None, snapshot_store_user=True, **kwargs):
|
||||
if not self.url_name:
|
||||
existing_slugs = {
|
||||
x.url_name: True for x in self.select(ignore_migration=True, ignore_errors=True)
|
||||
|
@ -105,7 +105,9 @@ class Category(XmlStorableObject):
|
|||
i += 1
|
||||
super().store(*args, **kwargs)
|
||||
if get_publisher().snapshot_class:
|
||||
get_publisher().snapshot_class.snap(instance=self, comment=comment)
|
||||
get_publisher().snapshot_class.snap(
|
||||
instance=self, comment=comment, store_user=snapshot_store_user
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def sort_by_position(cls, categories):
|
||||
|
|
|
@ -578,16 +578,18 @@ class NamedDataSource(XmlStorableObject):
|
|||
# .store() will take care of setting the slug
|
||||
changed = True
|
||||
if changed:
|
||||
self.store()
|
||||
self.store(comment=_('Automatic update'), snapshot_store_user=False)
|
||||
|
||||
def store(self, comment=None, *args, **kwargs):
|
||||
def store(self, comment=None, snapshot_store_user=True, *args, **kwargs):
|
||||
assert not self.is_readonly()
|
||||
if self.slug is None:
|
||||
# set slug if it's not yet there
|
||||
self.slug = self.get_new_slug()
|
||||
super().store(*args, **kwargs)
|
||||
if get_publisher().snapshot_class:
|
||||
get_publisher().snapshot_class.snap(instance=self, comment=comment)
|
||||
get_publisher().snapshot_class.snap(
|
||||
instance=self, comment=comment, store_user=snapshot_store_user
|
||||
)
|
||||
|
||||
def get_admin_url(self):
|
||||
base_url = get_publisher().get_backoffice_url()
|
||||
|
|
|
@ -324,7 +324,7 @@ class FormDef(StorableObject):
|
|||
changed |= f.migrate()
|
||||
|
||||
if changed:
|
||||
self.store()
|
||||
self.store(comment=_('Automatic update'), snapshot_store_user=False)
|
||||
|
||||
@classmethod
|
||||
def remove_object(cls, id):
|
||||
|
@ -452,7 +452,7 @@ class FormDef(StorableObject):
|
|||
|
||||
sql.formdef_wipe()
|
||||
|
||||
def store(self, comment=None, *args, **kwargs):
|
||||
def store(self, comment=None, snapshot_store_user=True, *args, **kwargs):
|
||||
assert not self.is_readonly()
|
||||
if self.url_name is None:
|
||||
# set url name if it's not yet there
|
||||
|
@ -478,7 +478,9 @@ class FormDef(StorableObject):
|
|||
if object_only:
|
||||
return
|
||||
if get_publisher().snapshot_class:
|
||||
get_publisher().snapshot_class.snap(instance=self, comment=comment)
|
||||
get_publisher().snapshot_class.snap(
|
||||
instance=self, comment=comment, store_user=snapshot_store_user
|
||||
)
|
||||
|
||||
self.update_storage()
|
||||
self.store_related_custom_views()
|
||||
|
|
|
@ -136,12 +136,12 @@ class Snapshot:
|
|||
_user = None
|
||||
|
||||
@classmethod
|
||||
def snap(cls, instance, comment=None, label=None):
|
||||
def snap(cls, instance, comment=None, label=None, store_user=True):
|
||||
obj = cls()
|
||||
obj.object_type = instance.xml_root_node
|
||||
obj.object_id = instance.id
|
||||
obj.timestamp = now()
|
||||
if get_session():
|
||||
if get_session() and store_user:
|
||||
obj.user_id = get_session().user
|
||||
tree = instance.export_to_xml(include_id=True)
|
||||
obj.serialization = ET.tostring(tree).decode('utf-8')
|
||||
|
|
|
@ -548,7 +548,7 @@ class Workflow(StorableObject):
|
|||
self.global_actions = []
|
||||
|
||||
if changed:
|
||||
self.store(migration_update=True)
|
||||
self.store(migration_update=True, comment=_('Automatic update'), snapshot_store_user=False)
|
||||
|
||||
@property
|
||||
def category(self):
|
||||
|
@ -566,7 +566,7 @@ class Workflow(StorableObject):
|
|||
workflow_roles.sort(key=lambda x: '' if x[0] == '_receiver' else misc.simplify(x[1]))
|
||||
return workflow_roles
|
||||
|
||||
def store(self, comment=None, *args, migration_update=False, **kwargs):
|
||||
def store(self, comment=None, *args, migration_update=False, snapshot_store_user=True, **kwargs):
|
||||
assert not self.is_readonly()
|
||||
must_update = False
|
||||
has_geolocation = False
|
||||
|
@ -604,7 +604,9 @@ class Workflow(StorableObject):
|
|||
|
||||
StorableObject.store(self, *args, **kwargs)
|
||||
if get_publisher().snapshot_class:
|
||||
get_publisher().snapshot_class.snap(instance=self, comment=comment)
|
||||
get_publisher().snapshot_class.snap(
|
||||
instance=self, comment=comment, store_user=snapshot_store_user
|
||||
)
|
||||
|
||||
def update(job=None):
|
||||
# instruct all related carddefs/formdefs to update.
|
||||
|
|
Loading…
Reference in New Issue