mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
One time fixes
This commit is contained in:
parent
88be3a6b1f
commit
f627632bdd
3 changed files with 12 additions and 3 deletions
|
@ -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())
|
||||
|
|
|
@ -50,7 +50,15 @@
|
|||
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">
|
||||
{% blocktrans count counter=snippet.view_count %}{{ counter }} View{% plural %}{{ counter }} Views{% endblocktrans %}
|
||||
</span>
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue