euscanwww: Created a feed for scan world with packages in GET

Note: Check if passing parameters in GET is good, there's the risk of
looong urls

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-09-14 15:25:08 +02:00
parent 58381f9808
commit 16f8d0c355
4 changed files with 38 additions and 3 deletions

1
TODO
View File

@ -52,7 +52,6 @@ euscanwww
---------
- Add an /about/config page that describe the current config (overlays, stuff in make.conf, euscan default settings, etc..)
- Create a rss for "scan world" + packages in GET
- Always keep in db all found versions (when using an API only?). But don't display them if older than current packaged version, except maybe in the "upstream_version" column.
### packages

View File

@ -229,9 +229,32 @@ class UserFeed(BaseFeed):
}
def _items(self, data):
user, options = data["user"], data["options"]
user = data["user"]
profile = get_profile(user)
vlogs = get_account_versionlogs(profile)
return vlogs, 100
class WorldScanFeed(BaseFeed):
link = "/"
def get_object(self, request):
return {
"options": request.GET,
}
def _items(self, data):
packages = []
for pkg_name in data["options"].getlist("package", []):
if "/" in pkg_name:
cat, name = pkg_name.split("/", 1)
pkg = Package.objects.filter(name=name, category=cat)
else:
pkg = Package.objects.filter(name=pkg_name)
packages.extend(pkg)
vlogs = VersionLog.objects.filter(package__in=packages)
return vlogs, 100

View File

@ -7,6 +7,18 @@
{{ block.super }} - World Scan
{% endblock %}
{% block menu_feed %}
{{ block.super }}
<li>
<img src="{{ STATIC_URL }}/img/feed.png" alt="feed" />
<a title="World scan Feed"
href="{% url "world_scan_feed" %}?package={{ packages|join:"&package=" }}">
World scan feed
</a>
</li>
{% endblock %}
{% block content %}
<h2>
World scan:

View File

@ -8,7 +8,7 @@ from djcelery.views import apply as apply_task
from djeuscan.views import registered_tasks
from djeuscan.feeds import PackageFeed, CategoryFeed, HerdFeed, \
MaintainerFeed, GlobalFeed, UserFeed
MaintainerFeed, GlobalFeed, UserFeed, WorldScanFeed
admin_required = user_passes_test(lambda u: u.is_superuser)
@ -117,6 +117,7 @@ urlpatterns = patterns('djeuscan.views',
url(r'^statistics/charts/(?P<chart>[\w\-]+).png$', 'chart', name="chart"),
url(r'^world/$', 'world', name="world"),
url(r'^world/scan/$', 'world_scan', name="world_scan"),
url(r'^world/scan/feed$', WorldScanFeed(), name="world_scan_feed"),
url(r'^world/favourite/$', 'favourite_world', name="favourite_world"),
url(r'^world/unfavourite/$', 'unfavourite_world',
name="unfavourite_world"),