From d42a2d3c79279fb9745a159cf9d04397c5386b11 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Wed, 20 Mar 2013 12:57:23 +0100 Subject: [PATCH] Don't display the compare button if the snippet has no replies. Fixes issue #6. --- dpaste/models.py | 4 ++++ dpaste/templates/dpaste/snippet_details.html | 2 ++ 2 files changed, 6 insertions(+) diff --git a/dpaste/models.py b/dpaste/models.py index b060cca..a055101 100644 --- a/dpaste/models.py +++ b/dpaste/models.py @@ -29,6 +29,10 @@ class Snippet(models.Model): def content_splitted(self): return self.content_highlighted.splitlines() + @property + def is_single(self): + return self.is_root_node() and not self.get_children() + def save(self, *args, **kwargs): if not self.pk: self.published = datetime.datetime.now() diff --git a/dpaste/templates/dpaste/snippet_details.html b/dpaste/templates/dpaste/snippet_details.html index 2426587..5433647 100644 --- a/dpaste/templates/dpaste/snippet_details.html +++ b/dpaste/templates/dpaste/snippet_details.html @@ -52,7 +52,9 @@ {% if snippet.pk|in_list:request.session.snippet_list %} {% trans "Delete Now" %} {% endif %} + {% if not snippet.is_single %} {% trans "Compare Snippets" %} + {% endif %} {% trans "View Raw" %}