cleans up code of 'website' module, replaces hardcoded 'year_of_bilan' value
This commit is contained in:
@@ -118,7 +118,7 @@ def rencontre_dans_le_mois(qs):
|
||||
|
||||
|
||||
def a_revoir_avant_bilan(qs):
|
||||
year_of_bilan = 2017
|
||||
year_of_bilan = timezone.now().date().year - 1 # Should be redacting report for last year :)
|
||||
included_set = set()
|
||||
for sujet in qs:
|
||||
most_recent_obs = Observation.objects.filter(sujet=sujet).order_by("-created_date").first()
|
||||
|
||||
16
urls.py
16
urls.py
@@ -1,23 +1,7 @@
|
||||
"""maraudes_project URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/1.10/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.conf.urls import url, include
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
from website import urls as website_urls
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^', include(website_urls)),
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
from django.urls import reverse
|
||||
from django import views
|
||||
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth import login, authenticate
|
||||
from django.contrib import messages
|
||||
from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
|
||||
|
||||
class Index(views.generic.TemplateView):
|
||||
|
||||
class Index(views.generic.TemplateView):
|
||||
template_name = "index.html"
|
||||
app_menu = None
|
||||
header = ('La Maraude ALSA', 'accueil')
|
||||
|
||||
http_method_names = ['get',]
|
||||
http_method_names = ['get', ]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
@@ -19,7 +18,6 @@ class Index(views.generic.TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
|
||||
def _get_entry_point(user):
|
||||
from utilisateurs.models import Maraudeur
|
||||
if isinstance(user, Maraudeur):
|
||||
@@ -27,6 +25,7 @@ def _get_entry_point(user):
|
||||
else:
|
||||
return reverse('index')
|
||||
|
||||
|
||||
def login_view(request):
|
||||
if request.method == 'GET':
|
||||
return HttpResponsePermanentRedirect('/')
|
||||
@@ -36,12 +35,11 @@ def login_view(request):
|
||||
user = authenticate(username=username, password=password)
|
||||
if user is not None:
|
||||
login(request, user)
|
||||
next = request.POST.get('next', None)
|
||||
if not next:
|
||||
next = _get_entry_point(user)
|
||||
_next = request.POST.get('next', None)
|
||||
if not _next:
|
||||
_next = _get_entry_point(user)
|
||||
messages.success(request, "%s, vous êtes connecté !" % user)
|
||||
return HttpResponseRedirect(next)
|
||||
return HttpResponseRedirect(_next)
|
||||
else:
|
||||
messages.error(request, "Le nom d'utilisateur et/ou le mot de passe sont incorrects !")
|
||||
return HttpResponseRedirect('/')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user