From 7d9ed0b881bd05878e7a54f785c2551bc6e336d6 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 7 Aug 2012 01:16:51 -0500 Subject: Add reverse conflicts to package details This is a place where calling vercmp could come in really handy. Signed-off-by: Dan McGee --- main/models.py | 10 ++++++++++ templates/packages/details.html | 13 ++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/main/models.py b/main/models.py index 7d8ea755..b49edde3 100644 --- a/main/models.py +++ b/main/models.py @@ -258,6 +258,16 @@ def sort_key(val): return (sort_order.get(dep.deptype, 1000), dep.name) return sorted(deps, key=sort_key) + @cache_function(123) + def reverse_conflicts(self): + """ + Returns a list of packages with conflicts against this package. + """ + # TODO: fix this; right now we cheat since we can't do proper version + # number checking without using alpm or vercmp directly. + return Package.objects.filter(conflicts__name=self.pkgname, + conflicts__comparison='').distinct() + @cache_function(125) def base_package(self): """ diff --git a/templates/packages/details.html b/templates/packages/details.html index 201e3074..9e898b7f 100644 --- a/templates/packages/details.html +++ b/templates/packages/details.html @@ -126,16 +126,23 @@

Versions Elsewhere

{% include "packages/details_relatedto.html" %} {% endif %}{% endwith %} + {% with pkg.replaces.all as all_related %}{% if all_related %} + + Replaces: + {% include "packages/details_relatedto.html" %} + + {% endif %}{% endwith %} {% with pkg.conflicts.all as all_related %}{% if all_related %} Conflicts: {% include "packages/details_relatedto.html" %} {% endif %}{% endwith %} - {% with pkg.replaces.all as all_related %}{% if all_related %} + {% with pkg.reverse_conflicts as rev_conflicts %}{% if rev_conflicts %} - Replaces: - {% include "packages/details_relatedto.html" %} + Reverse Conflicts: + {% for conflict in rev_conflicts %} + {% pkg_details_link conflict %}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}{% endwith %} -- cgit v1.2.3-54-g00ecf