euscanwww: Adding support for GET options in feed

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-08-08 15:19:31 +02:00
parent 78bc2520a7
commit 8b39853b5f

View File

@ -148,16 +148,19 @@ class CategoryFeed(BaseFeed):
class UserFeed(BaseFeed): class UserFeed(BaseFeed):
link = "/" link = "/"
def description(self, user): def description(self, data):
return "%s - last euscan changes" return "%s - last euscan changes"
def title(self, user): def title(self, data):
return "%s - watched packages" % user return "%s - watched packages" % data[0]
def get_object(self, request): def get_object(self, request):
return request.user options = request.GET
return request.user, options
def items(self, data):
user, options = data
def items(self, user):
profile = get_profile(user) profile = get_profile(user)
packages = get_account_packages(user) packages = get_account_packages(user)
overlays = [o.name for o in profile.overlays.all()] overlays = [o.name for o in profile.overlays.all()]
@ -165,9 +168,18 @@ class UserFeed(BaseFeed):
ret = VersionLog.objects.filter( ret = VersionLog.objects.filter(
Q(package__in=packages) | Q(overlay__in=overlays) Q(package__in=packages) | Q(overlay__in=overlays)
) )
if not profile.upstream_info:
# first of all consider options, then user preferences
if options:
upstream_info = "upstream_info" in options
portage_info = "portage_info" in options
else:
upstream_info = profile.upstream_info
portage_info = profile.portage_info
if not upstream_info:
ret = ret.exclude(overlay="") ret = ret.exclude(overlay="")
if not profile.portage_info: if not portage_info:
ret = ret.exclude(~Q(overlay="")) ret = ret.exclude(~Q(overlay=""))
return ret.order_by("-datetime")[:100] return ret.order_by("-datetime")[:100]