From 34e966f5de1e51c8a8d8b1c6e4472693ab8c76da Mon Sep 17 00:00:00 2001 From: volpino Date: Fri, 27 Jul 2012 12:21:48 +0200 Subject: [PATCH] euscanwww: Adding queue position in refresh package alert message Signed-off-by: volpino --- euscanwww/djeuscan/models.py | 7 +++++++ euscanwww/djeuscan/templates/euscan/package.html | 12 +++++++----- euscanwww/djeuscan/views.py | 15 ++++++++++----- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index 86f79bc..c2b2d17 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -324,6 +324,13 @@ class RefreshPackageQuery(models.Model): priority = models.IntegerField(default=0) users = models.ManyToManyField(User) + @property + def position(self): + ordered = RefreshPackageQuery.objects.all().order_by("-priority") + for pos, obj in enumerate(ordered, start=1): + if obj == self: + return pos + def __unicode__(self): return u'[%d] %s' % (self.priority, self.package) diff --git a/euscanwww/djeuscan/templates/euscan/package.html b/euscanwww/djeuscan/templates/euscan/package.html index 8c90efe..d0381a9 100644 --- a/euscanwww/djeuscan/templates/euscan/package.html +++ b/euscanwww/djeuscan/templates/euscan/package.html @@ -25,8 +25,9 @@ {% block content %} -
- A refresh request is in progress, please wait... +
+

A refresh request is in progress, please wait...

+

Queue position: {{ refresh_pos }}

@@ -34,10 +35,10 @@ {% if user.is_authenticated %} - -