One time fixes

This commit is contained in:
Martin Mahner 2014-01-21 12:30:06 +01:00
parent 88be3a6b1f
commit f627632bdd
3 changed files with 12 additions and 3 deletions

View file

@ -14,7 +14,7 @@ class Command(LabelCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
deleteable_snippets = Snippet.objects.filter( deleteable_snippets = Snippet.objects.filter(
expires__isnull=False, expires__isnull=False,
expire_type__in=[Snippet.EXPIRE_TIME, Snippet.EXPIRE_ONETIME], expire_type=Snippet.EXPIRE_TIME,
expires__lte=datetime.datetime.now() expires__lte=datetime.datetime.now()
) )
sys.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count()) sys.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count())

View file

@ -50,7 +50,15 @@
Snippet Options Snippet Options
======================================================================= --> ======================================================================= -->
<div class="btn-group snippet-options"> <div class="btn-group snippet-options">
<button disabled class="btn">Expires in: {{ snippet.expires|timeuntil }}</button> <span class="btn disabled">
{% 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 %}
</span>
<span class="btn disabled"> <span class="btn disabled">
{% blocktrans count counter=snippet.view_count %}{{ counter }} View{% plural %}{{ counter }} Views{% endblocktrans %} {% blocktrans count counter=snippet.view_count %}{{ counter }} View{% plural %}{{ counter }} Views{% endblocktrans %}
</span> </span>

View file

@ -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) snippet = get_object_or_404(Snippet, secret_id=snippet_id)
# One time snippet get deleted if the view count matches our limit # 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() snippet.delete()
raise Http404() raise Http404()