From 984cc80eec51808a589417a35d0f47956edcd616 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 18 Oct 2013 10:09:35 +0200 Subject: [PATCH] Fix handling mil home page Defining flat pages in urlpatterns breaks language_switcher behavior --- edumed/milurls.py | 8 ++------ edumed/templates/base_mil.html | 2 +- edumed/views.py | 5 +++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/edumed/milurls.py b/edumed/milurls.py index 0b3ea6c..9178dfa 100644 --- a/edumed/milurls.py +++ b/edumed/milurls.py @@ -1,19 +1,15 @@ from django.conf.urls import include, url, patterns from fnpdjango.utils.urls import i18n_patterns -from .views import MILHomeView +from .views import mil_home_view urlpatterns = i18n_patterns('', + url(r'^$', mil_home_view, name="mil_home"), url(r'^kompetencje/', include('curriculum.urls')), url(r'^wez-udzial/', include('comment.urls')) ) -urlpatterns += patterns('', - url(r'^$', 'django.contrib.flatpages.views.flatpage', {'url': '/'}, name="mil_home_pl"), - url(r'^en/$', 'django.contrib.flatpages.views.flatpage', {'url': '/en/'}, name="mil_home_en") -) - handler404 = 'edumed.views.mil_404_view' diff --git a/edumed/templates/base_mil.html b/edumed/templates/base_mil.html index dec800b..e5300e6 100644 --- a/edumed/templates/base_mil.html +++ b/edumed/templates/base_mil.html @@ -5,7 +5,7 @@ {% load i18n %} {% block top_navigation %} -
  • {% trans 'Consultations' %}
  • +
  • {% trans 'Consultations' %}
  • {% trans 'Competencies' %}
  • {% trans 'Take Part' %}
  • {% if request.LANGUAGE_CODE == 'pl' %} diff --git a/edumed/views.py b/edumed/views.py index f2fa91f..009f6a0 100755 --- a/edumed/views.py +++ b/edumed/views.py @@ -2,6 +2,7 @@ import os.path from django.conf import settings from django.views.generic import TemplateView from django.views.defaults import page_not_found +from django.contrib.flatpages.views import flatpage from pybb.views import ProfileEditView from .forms import AvatarlessEditProfileForm @@ -16,8 +17,8 @@ class HomeView(TemplateView): return context -class MILHomeView(TemplateView): - template_name = 'home_mil.html' +def mil_home_view(request): + return flatpage(request, url = '/' if request.LANGUAGE_CODE == 'pl' else '/en/') def mil_404_view(request): return page_not_found(request, '404_mil.html') -- 2.20.1