diff options
-rw-r--r-- | public/utils.py | 15 | ||||
-rw-r--r-- | templates/public/index.html | 10 |
2 files changed, 18 insertions, 7 deletions
diff --git a/public/utils.py b/public/utils.py index f4418d13..88f073d0 100644 --- a/public/utils.py +++ b/public/utils.py @@ -8,12 +8,19 @@ def get_recent_updates(): for a in Arch.objects.all(): # grab a few extra so we can hopefully catch everything we need pkgs += list(Package.objects.select_related('arch', 'repo').filter(arch=a).order_by('-last_update')[:50]) - pkgs.sort(reverse=True, key=lambda q: q.last_update) - for p in pkgs: + pkgs.sort(key=lambda q: q.last_update) + updates = [] + ctr = 0 + while ctr < 15 and len(pkgs) > 0: + # not particularly happy with this logic, but it works. + p = pkgs.pop() samepkgs = filter(lambda q: p.is_same_version(q) and p.repo == q.repo, pkgs) - p.allarches = '/'.join(sorted([q.arch.name for q in samepkgs])) + samepkgs.append(p) + samepkgs.sort(key=lambda q: q.arch.name) + updates.append(samepkgs) for q in samepkgs: if p != q: pkgs.remove(q) - return pkgs[:15] + ctr += 1 + return updates # vim: set ts=4 sw=4 et: diff --git a/templates/public/index.html b/templates/public/index.html index 9d05d139..cd2b6b2a 100644 --- a/templates/public/index.html +++ b/templates/public/index.html @@ -57,11 +57,15 @@ <td><h3>Recent Updates</h3></td> <td style="vertical-align:top;text-align:right"><a href="/feeds/packages/"><img src="/media/rss.png" alt="RSS Feed" /></a></td> </tr> - {% for pkg in pkg_updates %} + {% for update in pkg_updates %} + {% with update|first as fpkg %} <tr> - <td><a href="{{ pkg.get_absolute_url }}" class="{{ pkg.repo.name|lower }}">{{ pkg.pkgname }} {{ pkg.pkgver }}-{{ pkg.pkgrel }}</a></td> - <td style="text-align:right">{{ pkg.allarches }}</td> + <td><span class="{{ fpkg.repo.name|lower }}">{{ fpkg.pkgname }} {{ fpkg.pkgver }}-{{ fpkg.pkgrel }}</span></td> + <td style="text-align:right"> + {% for pkg in update %}<a href="{{ pkg.get_absolute_url }}">{{ pkg.arch }}</a>{% if not forloop.last %}/{% endif %}{% endfor %} + </td> </tr> + {% endwith %} {% endfor %} <tr> <td style="font-size:x-small;white-space:nowrap;"><br /><a href="{% url feeds-list %}">More Feeds...</a></td> |