Browse Source

Add index view and redirections from root

Jocelyn Delande 9 years ago
parent
commit
10d688f032
3 changed files with 17 additions and 1 deletions
  1. 8 0
      costs/templates/costs/index.html
  2. 5 1
      costs/views.py
  3. 4 0
      transparency/urls.py

+ 8 - 0
costs/templates/costs/index.html

@@ -0,0 +1,8 @@
+<h1>Transparency !</h1>
+
+<nav>
+  <ul>
+    <li><a href="services">Services</a> (proposés par l'association)</li>
+    <li><a href="resources">Ressources</a> (biens & coûts récurents)</li>
+  </ul>
+</nav>

+ 5 - 1
costs/views.py

@@ -2,7 +2,11 @@ from itertools import chain
 
 from django.shortcuts import render
 
-from .models import Service, Cost, Good
+from .models import Service, Cost, Good, CostUse, GoodUse
+
+
+def index(request):
+    return render(request, 'costs/index.html')
 
 
 def list_services(request):

+ 4 - 0
transparency/urls.py

@@ -16,8 +16,12 @@ Including another URLconf
 from django.conf.urls import include, url
 from django.contrib import admin
 import costs.urls
+from django.views.generic import RedirectView
+
 
 urlpatterns = [
     url(r'^admin/', include(admin.site.urls)),
     url(r'^transparency/', include(costs.urls)),
+    url(r'^/?$', RedirectView.as_view(
+        pattern_name='index', permanent=False)),
 ]