diff --git a/rrs/fixtures/initial_data.json b/rrs/fixtures/initial_data.json index 0d9eb94..a063993 100644 --- a/rrs/fixtures/initial_data.json +++ b/rrs/fixtures/initial_data.json @@ -8,6 +8,15 @@ } }, + { + "pk": 1, + "model": "rrs.maintainer", + "fields": { + "name": "All", + "email": "" + } + }, + { "pk": 1, "model": "rrs.milestone", diff --git a/rrs/models.py b/rrs/models.py index c23a397..31577bb 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -101,6 +101,7 @@ class RecipeUpstreamHistory(models.Model): class RecipeUpstream(models.Model): RECIPE_UPSTREAM_STATUS_CHOICES = ( + ('A', 'All'), ('N', 'Not updated'), ('Y', 'Up-to-date'), ('D', 'Downgrade'), diff --git a/rrs/views.py b/rrs/views.py index aa8d0d0..4177601 100644 --- a/rrs/views.py +++ b/rrs/views.py @@ -1,13 +1,26 @@ import urllib +from django.http import Http404 from django.shortcuts import get_object_or_404 -from django.views.generic import ListView +from django.views.generic import ListView, DetailView from django.core.urlresolvers import resolve from layerindex.models import Recipe from rrs.models import Milestone, Maintainer, RecipeMaintainer, RecipeUpstream, \ RecipeUpstreamHistory +def _check_url_params(upstream_status, maintainer_name): + get_object_or_404(Maintainer, name=maintainer_name) + + found = 0 + for us in RecipeUpstream.RECIPE_UPSTREAM_STATUS_CHOICES_DICT.keys(): + if RecipeUpstream.RECIPE_UPSTREAM_STATUS_CHOICES_DICT[us] == upstream_status: + found = 1 + break + + if found == 0: + raise Http404 + class RecipeList(): name = None version = None @@ -42,6 +55,8 @@ class RecipeListView(ListView): else: self.maintainer_name = 'All' + _check_url_params(self.upstream_status, self.maintainer_name) + recipe_upstream_history = RecipeUpstreamHistory.get_last_by_date_range( milestone.start_date, milestone.end_date @@ -107,7 +122,7 @@ class RecipeListView(ListView): context['recipe_list_count'] = self.recipe_list_count context['upstream_status'] = self.upstream_status - all_upstream_status = ['All'] + all_upstream_status = [] for us in RecipeUpstream.RECIPE_UPSTREAM_STATUS_CHOICES: all_upstream_status.append(us[1]) context['all_upstream_status'] = all_upstream_status