From 50d2ba440458b9b947ac79178fe3ada5b091cad2 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 6 May 2024 07:12:51 +0000 Subject: [PATCH] Updated documentation --- _modules/apis_core/history/models.html | 21 ++++++++++++++++++++ _modules/apis_core/history/serializers.html | 12 +---------- genindex.html | 10 +++++++--- modules/apis_core.history.html | 5 +++++ modules/apis_core.html | 1 + objects.inv | Bin 7760 -> 7766 bytes searchindex.js | 2 +- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/_modules/apis_core/history/models.html b/_modules/apis_core/history/models.html index e1123bbfa..935e4c70d 100644 --- a/_modules/apis_core/history/models.html +++ b/_modules/apis_core/history/models.html @@ -213,6 +213,27 @@

Source code for apis_core.history.models

     def get_absolute_url(self):
         ct = ContentType.objects.get_for_model(self)
         return reverse("apis_core:generic:detail", args=[ct, self.history_id])
+ + +
+[docs] + def get_diff(self, other_version=None): + if self.history_type == "-": + return None + version = other_version or self.prev_record + if version: + delta = self.diff_against(version) + else: + delta = self.diff_against(self.__class__()) + changes = list( + filter( + lambda x: (x.new != "" or x.old is not None) + and x.field != "id" + and not x.field.endswith("_ptr"), + delta.changes, + ) + ) + return sorted(changes, key=lambda change: change.field)
diff --git a/_modules/apis_core/history/serializers.html b/_modules/apis_core/history/serializers.html index 3a7dbf5fc..c6f1fbd30 100644 --- a/_modules/apis_core/history/serializers.html +++ b/_modules/apis_core/history/serializers.html @@ -170,19 +170,9 @@

Source code for apis_core.history.serializers

def get_diff(self, obj): if obj.history_type == "-": return None - if obj.prev_record is None: - diff = obj.diff_against(obj.__class__()) - else: - diff = obj.diff_against(obj.prev_record) changed_fields = [] changes = [] - for change in diff.changes: - if ( - (change.new == "" and change.old is None) - or change.field == "id" - or change.field.endswith("_ptr") - ): - continue + for change in obj.get_diff(): changed_fields.append(change.field) changes.append(ModelChangeSerializer(change, obj).data) return {"changed_fields": changed_fields, "changes": changes}
diff --git a/genindex.html b/genindex.html index c7ef44f67..58af75428 100644 --- a/genindex.html +++ b/genindex.html @@ -1608,8 +1608,12 @@

G

  • get_delete_url() (apis_core.generic.abc.GenericModel method)
  • -
  • get_diff() (apis_core.history.serializers.HistoryLogSerializer method) +
  • get_diff() (apis_core.history.models.APISHistoryTableBase method) + +
  • get_duplicate_url() (apis_core.apis_entities.models.AbstractEntity method)
  • get_edit_url() (apis_core.apis_entities.models.AbstractEntity method) @@ -1618,10 +1622,10 @@

    G

  • (apis_core.generic.abc.GenericModel method)
  • -
  • get_entity_class_of_name() (in module apis_core.utils.caching) -