From f627632bdd06068ec0f44f30d995f087aa287b77 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Tue, 21 Jan 2014 12:30:06 +0100 Subject: [PATCH] One time fixes --- dpaste/management/commands/cleanup_snippets.py | 2 +- dpaste/templates/dpaste/snippet_details.html | 10 +++++++++- dpaste/views.py | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dpaste/management/commands/cleanup_snippets.py b/dpaste/management/commands/cleanup_snippets.py index 59993f8..a9feea5 100644 --- a/dpaste/management/commands/cleanup_snippets.py +++ b/dpaste/management/commands/cleanup_snippets.py @@ -14,7 +14,7 @@ class Command(LabelCommand): def handle(self, *args, **options): deleteable_snippets = Snippet.objects.filter( expires__isnull=False, - expire_type__in=[Snippet.EXPIRE_TIME, Snippet.EXPIRE_ONETIME], + expire_type=Snippet.EXPIRE_TIME, expires__lte=datetime.datetime.now() ) sys.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count()) diff --git a/dpaste/templates/dpaste/snippet_details.html b/dpaste/templates/dpaste/snippet_details.html index 1393f3b..135e862 100644 --- a/dpaste/templates/dpaste/snippet_details.html +++ b/dpaste/templates/dpaste/snippet_details.html @@ -50,7 +50,15 @@ Snippet Options ======================================================================= -->
- + + {% if snippet.expire_type == 1 %} + {% blocktrans with date=snippet.expires|timeuntil %}Expires in: {{ date }}{% endblocktrans %} + {% elif snippet.expire_type == 2 %} + {% trans "Snippet never expires" %} + {% elif snippet.expire_type == 3 %} + {% trans "One-time snippet" %} + {% endif %} + {% blocktrans count counter=snippet.view_count %}{{ counter }} View{% plural %}{{ counter }} Views{% endblocktrans %} diff --git a/dpaste/views.py b/dpaste/views.py index 8377578..6e039bf 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -59,7 +59,8 @@ def snippet_details(request, snippet_id, template_name='dpaste/snippet_details.h snippet = get_object_or_404(Snippet, secret_id=snippet_id) # One time snippet get deleted if the view count matches our limit - if snippet.view_count >= ONETIME_LIMIT: + if snippet.expire_type == Snippet.EXPIRE_ONETIME \ + and snippet.view_count >= ONETIME_LIMIT: snippet.delete() raise Http404()