[yocto] [PATCH][rrs] rrs: Fix frontpage redirect
Aníbal Limón
anibal.limon at linux.intel.com
Tue Mar 22 11:10:21 PDT 2016
We was experimenting fixed redirects due to urls are
cached at init of rrs.
Move the redirect Release, Milestone selection to a view
called FrontPageRedirect.
Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
rrs/urls.py | 17 +++--------------
rrs/views.py | 12 ++++++++++--
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/rrs/urls.py b/rrs/urls.py
index 923d9e6..eb11a28 100644
--- a/rrs/urls.py
+++ b/rrs/urls.py
@@ -1,25 +1,14 @@
from django.views.generic import TemplateView
-from django.views.generic.simple import redirect_to
-from django.core.urlresolvers import reverse_lazy
-
from django.conf.urls import patterns, url
from layerindex.views import EditProfileFormView
from rrs.models import Release, Milestone
-from rrs.views import RecipeListView, recipes_report, RecipeDetailView, MaintainerListView
+from rrs.views import RecipeListView, recipes_report, RecipeDetailView, \
+ MaintainerListView, FrontPageRedirect
urlpatterns = patterns('',
- url(r'^$', redirect_to,
- {'url' :
- reverse_lazy('recipes',
- args = (
- Release.get_current().name,
- Milestone.get_current(Release.get_current()).name,
- )
- ),
- 'permanent' : False
- },
+ url(r'^$', FrontPageRedirect.as_view(),
name='frontpage'),
url(r'^recipes/(?P<release_name>.*)/(?P<milestone_name>.*)/$',
RecipeListView.as_view(
diff --git a/rrs/views.py b/rrs/views.py
index 957529c..3a4034a 100644
--- a/rrs/views.py
+++ b/rrs/views.py
@@ -6,14 +6,22 @@ from django.http import HttpResponse
from datetime import date, datetime
from django.http import Http404
from django.shortcuts import get_object_or_404
-from django.views.generic import ListView, DetailView
-from django.core.urlresolvers import resolve
+from django.views.generic import ListView, DetailView, RedirectView
+from django.core.urlresolvers import resolve, reverse
from layerindex.models import Recipe
from rrs.models import Release, Milestone, Maintainer, RecipeMaintainerHistory, \
RecipeMaintainer, RecipeUpstreamHistory, RecipeUpstream, \
RecipeDistro, RecipeUpgrade, Raw
+class FrontPageRedirect(RedirectView):
+ permanent = False
+
+ def get_redirect_url(self):
+ release_name = Release.get_current().name
+ milestone_name = Milestone.get_current(Release.get_current()).name
+ return reverse('recipes', args=(release_name, milestone_name))
+
def _check_url_params(upstream_status, maintainer_name):
get_object_or_404(Maintainer, name=maintainer_name)
--
2.1.4
More information about the yocto
mailing list