euscanwww: misc fixes

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
Corentin Chary 2012-08-03 21:58:24 +02:00
parent d0aceaeec4
commit 94f6b7541c
3 changed files with 16 additions and 13 deletions

View File

@ -145,13 +145,13 @@ class Version(models.Model):
def cpv(self): def cpv(self):
return '%s/%s-%s%s' % ( return '%s/%s-%s%s' % (
self.package.category, self.package.name, self.version, self.package.category, self.package.name, self.version,
self.revision if self.revision != '-r0' else '' '-' + self.revision if self.revision != '-r0' else ''
) )
def __unicode__(self): def __unicode__(self):
return '%s/%s-%s%s:%s [%s]' % ( return '%s/%s-%s%s:%s [%s]' % (
self.package.category, self.package.name, self.version, self.package.category, self.package.name, self.version,
self.revision if self.revision != '-r0' else '', '-' + self.revision if self.revision != '-r0' else '',
self.slot, self.overlay or "<upstream>" self.slot, self.overlay or "<upstream>"
) )

View File

@ -24,7 +24,7 @@
Hot categories: Hot categories:
<ul> <ul>
{% for c in categories|slice:":3" %} {% for c in categories|slice:":3" %}
<li><a href="{% url "category" c.category %}">{{ c.category }}</a> ({{ c.n_versions|sub:c.n_packaged }})</li> <li><a href="{% url "category" c.category %}">{{ c.category }}</a> ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
</li> </li>
@ -43,7 +43,7 @@
Hot herds: Hot herds:
<ul> <ul>
{% for c in herds|slice:":3" %} {% for c in herds|slice:":3" %}
<li><a href="{% url "herd" c.herds__herd %}">{{ c.herds__herd }}</a> ({{ c.n_versions|sub:c.n_packaged }})</li> <li><a href="{% url "herd" c.herds__herd %}">{{ c.herds__herd }}</a> ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
</li> </li>
@ -65,7 +65,7 @@
Hot maintainers: Hot maintainers:
<ul> <ul>
{% for c in maintainers|slice:":3" %} {% for c in maintainers|slice:":3" %}
<li><a href="{% url "maintainer" c.maintainers__id %}">{{ c.maintainers__name }}</a> ({{ c.n_versions|sub:c.n_packaged }})</li> <li><a href="{% url "maintainer" c.maintainers__id %}">{{ c.maintainers__name }}</a> ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
</li> </li>
@ -84,7 +84,7 @@
Hot packages: Hot packages:
<ul> <ul>
{% for c in packages|slice:":3" %} {% for c in packages|slice:":3" %}
<li><a href="{% url "package" c.category c.name %}">{{ c }}</a> ({{ c.n_versions|sub:c.n_packaged }})</li> <li><a href="{% url "package" c.category c.name %}">{{ c }}</a> ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
</li> </li>

View File

@ -377,28 +377,31 @@ def refresh_package(request, category, package):
if not created: if not created:
obj.priority += 1 obj.priority += 1
obj.save() obj.save()
if created:
from djeuscan.tasks import consume_refresh_queue
consume_refresh_queue.delay()
return {"result": "success", "position": obj.position} return {"result": "success", "position": obj.position}
@login_required @login_required
@render_to('euscan/accounts/index.html') @render_to('euscan/accounts/index.html')
def accounts_index(request): def accounts_index(request):
user = request.user user = request.user
upstream_k = lambda c: c["n_versions"] - c["n_packaged"] upstream_k = lambda c: c["n_versions"] - c["n_packaged"] - c["n_overlay"]
categories = sorted(get_account_categories(user), categories = sorted(get_account_categories(user),
key=upstream_k, reverse=True) key=upstream_k, reverse=True)
c_upstream = sum([c["n_versions"] - c["n_packaged"] for c in categories]) c_upstream = sum([upstream_k(c) for c in categories])
herds = sorted(get_account_herds(request.user), herds = sorted(get_account_herds(request.user),
key=upstream_k, reverse=True) key=upstream_k, reverse=True)
h_upstream = sum([c["n_versions"] - c["n_packaged"] for c in herds]) h_upstream = sum([upstream_k(c) for c in herds])
maintainers = sorted(get_account_maintainers(request.user), maintainers = sorted(get_account_maintainers(request.user),
key=upstream_k, reverse=True) key=upstream_k, reverse=True)
m_upstream = sum([c["n_versions"] - c["n_packaged"] for c in maintainers]) m_upstream = sum([upstream_k(c) for c in maintainers])
packages = sorted(get_profile(user).packages.all(), packages = sorted(get_profile(user).packages.all(),
key=lambda p: p.n_versions - p.n_packaged, reverse=True) key=lambda p: p.n_versions - p.n_packaged - p.n_overlay, reverse=True)
p_upstream = sum([c.n_versions - c.n_packaged for c in packages]) p_upstream = sum([c.n_versions - c.n_packaged - c.n_overlay for c in packages])
return { return {
"categories": categories, "categories_upstream": c_upstream, "categories": categories, "categories_upstream": c_upstream,
"herds": herds, "herds_upstream": h_upstream, "herds": herds, "herds_upstream": h_upstream,