mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
rrs: Recipes add url validation
Add url validation for Milestone and Upstream status and maintainer name params if isn't valid raise HTTP 404. Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
This commit is contained in:
parent
a7ede0d126
commit
a021f8d441
|
@ -8,6 +8,15 @@
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "rrs.maintainer",
|
||||
"fields": {
|
||||
"name": "All",
|
||||
"email": ""
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "rrs.milestone",
|
||||
|
|
|
@ -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'),
|
||||
|
|
19
rrs/views.py
19
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user