Skip to content

Commit

Permalink
Merge pull request #860 from DH-IT-Portal-Development/feat/check_iden…
Browse files Browse the repository at this point in the history
…tical_comparisons

feat: Do not offer to compare files with identical urls
  • Loading branch information
miggol authored Jan 15, 2025
2 parents d07be8d + 5d5fbfc commit 47e9cb8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions reviews/templatetags/documents_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
register = template.Library()


def is_identical(new_file, old_file):
return new_file.url == old_file.url


@register.inclusion_tag("reviews/simple_compare_link.html")
def simple_compare_link(obj, file):
"""Generates a compare icon"""
Expand Down Expand Up @@ -102,6 +106,11 @@ def simple_compare_link(obj, file):
"attribute": file.field.name,
}

# Do not offer to compare identical files
old_file = getattr(parent_obj, file.field.name)
if is_identical(file, old_file):
return {}

# CompareDocumentsView expects the following args:
# - old pk
# - new pk
Expand Down

0 comments on commit 47e9cb8

Please sign in to comment.