Don't display the compare button if the snippet has no replies. Fixes issue #6.

This commit is contained in:
Martin Mahner 2013-03-20 12:57:23 +01:00
parent ca1e12596c
commit d42a2d3c79
2 changed files with 6 additions and 0 deletions

View file

@ -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()

View file

@ -52,7 +52,9 @@
{% if snippet.pk|in_list:request.session.snippet_list %}
<a class="btn" href="{% url "snippet_delete" snippet.secret_id %}" onclick="return confirm('{% trans "Really delete this snippet?" %}');"><i class="icon-trash"></i> {% trans "Delete Now" %}</a>
{% endif %}
{% if not snippet.is_single %}
<a class="btn snippet-diff-trigger" href="#snippet-diff"><i class="icon-search"></i> {% trans "Compare Snippets" %}</a>
{% endif %}
<a class="btn" href="{% url "snippet_details_raw" snippet.secret_id %}"><i class="icon-align-left"></i> {% trans "View Raw" %}</a>
</div>