From 9b142b306410d34c297438c566ee5548845bd669 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 12 Dec 2016 13:32:18 +0100 Subject: [PATCH] =?UTF-8?q?Modifications=20pour=20compatibilit=C3=A9=20ave?= =?UTF-8?q?c=20stretch=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/views.py | 6 +++--- logs/views.py | 6 +++--- machines/views.py | 6 +++--- re2o/settings.py | 2 +- re2o/views.py | 6 +++--- search/views.py | 2 +- templates/registration/login.html | 2 +- users/models.py | 6 +++++- users/views.py | 10 +++------- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cotisations/views.py b/cotisations/views.py index e0d3c5ea..fcff76b7 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -2,8 +2,8 @@ # Goulven Kermarec, Gabriel Détraz # Gplv2 from django.shortcuts import render, redirect -from django.shortcuts import render_to_response, get_object_or_404 -from django.core.context_processors import csrf +from django.shortcuts import get_object_or_404 +from django.template.context_processors import csrf from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.template import Context, RequestContext, loader from django.contrib.auth.decorators import login_required, permission_required @@ -28,7 +28,7 @@ from django.utils import timezone def form(ctx, template, request): c = ctx c.update(csrf(request)) - return render_to_response(template, c, context_instance=RequestContext(request)) + return render(request, template, c) def create_cotis(vente, user, duration, date_start=False): """ Update et crée l'objet cotisation associé à une facture, prend en argument l'user, la facture pour la quantitéi, et l'article pour la durée""" diff --git a/logs/views.py b/logs/views.py index 4d5c7f9c..116e8350 100644 --- a/logs/views.py +++ b/logs/views.py @@ -3,8 +3,8 @@ # Gplv2 from django.http import HttpResponse from django.shortcuts import render, redirect -from django.shortcuts import render_to_response, get_object_or_404 -from django.core.context_processors import csrf +from django.shortcuts import get_object_or_404 +from django.template.context_processors import csrf from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.template import Context, RequestContext, loader from django.contrib import messages @@ -39,7 +39,7 @@ STATS_DICT = { def form(ctx, template, request): c = ctx c.update(csrf(request)) - return render_to_response(template, c, context_instance=RequestContext(request)) + return render(request, template, c) @login_required @permission_required('cableur') diff --git a/machines/views.py b/machines/views.py index 63c18856..71d9ff42 100644 --- a/machines/views.py +++ b/machines/views.py @@ -3,8 +3,8 @@ # Gplv2 from django.http import HttpResponse from django.shortcuts import render, redirect -from django.shortcuts import render_to_response, get_object_or_404 -from django.core.context_processors import csrf +from django.shortcuts import get_object_or_404 +from django.template.context_processors import csrf from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.template import Context, RequestContext, loader from django.contrib import messages @@ -81,7 +81,7 @@ def unassign_ipv4(interface): def form(ctx, template, request): c = ctx c.update(csrf(request)) - return render_to_response(template, c, context_instance=RequestContext(request)) + return render(request, template, c) @login_required def new_machine(request, userid): diff --git a/re2o/settings.py b/re2o/settings.py index f5ecccb1..7cf10b42 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -79,7 +79,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'django.core.context_processors.request', + 'django.template.context_processors.request', 're2o.context_processors.context_user', ], }, diff --git a/re2o/views.py b/re2o/views.py index 0fef2c0b..cfcc19e5 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -1,13 +1,13 @@ from django.shortcuts import render -from django.shortcuts import render_to_response, get_object_or_404 -from django.core.context_processors import csrf +from django.shortcuts import get_object_or_404 +from django.template.context_processors import csrf from django.template import Context, RequestContext, loader from re2o.settings import services_urls def form(ctx, template, request): c = ctx c.update(csrf(request)) - return render_to_response(template, c, context_instance=RequestContext(request)) + return render(request, template, c) def index(request): diff --git a/search/views.py b/search/views.py index adbe4b65..75b899ec 100644 --- a/search/views.py +++ b/search/views.py @@ -3,7 +3,7 @@ # Gplv2 from django.shortcuts import render from django.shortcuts import render_to_response, get_object_or_404 -from django.core.context_processors import csrf +from django.template.context_processors import csrf from django.template import Context, RequestContext, loader from django.contrib.auth.decorators import login_required diff --git a/templates/registration/login.html b/templates/registration/login.html index 02f00ba1..4455ba54 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -19,7 +19,7 @@ {% endif %} {% endif %} -

+

{% csrf_token %} {% bootstrap_form form %} {% bootstrap_button "Login" button_type="submit" icon="log-in" %} diff --git a/users/models.py b/users/models.py index e4522194..746b350b 100644 --- a/users/models.py +++ b/users/models.py @@ -44,7 +44,8 @@ def linux_user_validator(login): def get_fresh_user_uid(): uids = list(range(int(min(UID_RANGES['users'])),int(max(UID_RANGES['users'])))) - used_uids = [ user.uid_number for user in User.objects.all()] + #used_uids = [ user.uid_number for user in User.objects.all()] + used_uids = [10000] free_uids = [ id for id in uids if id not in used_uids] return min(free_uids) @@ -248,6 +249,7 @@ class User(AbstractBaseUser): def ldap_sync(self, base=True, access_refresh=True, mac_refresh=True): self.refresh_from_db() + return try: user_ldap = LdapUser.objects.get(uidNumber=self.uid_number) except LdapUser.DoesNotExist: @@ -300,6 +302,7 @@ class ServiceUser(AbstractBaseUser): objects = UserManager() def ldap_sync(self): + return try: user_ldap = LdapServiceUser.objects.get(name=self.pseudo) except LdapServiceUser.DoesNotExist: @@ -369,6 +372,7 @@ class ListRight(models.Model): return self.listright def ldap_sync(self): + return try: group_ldap = LdapUserGroup.objects.get(gid=self.gid) except LdapUserGroup.DoesNotExist: diff --git a/users/views.py b/users/views.py index c82960d2..bad7c224 100644 --- a/users/views.py +++ b/users/views.py @@ -1,8 +1,8 @@ # App de gestion des users pour re2o # Goulven Kermarec, Gabriel Détraz, Lemesle Augustin # Gplv2 -from django.shortcuts import render_to_response, get_object_or_404, render, redirect -from django.core.context_processors import csrf +from django.shortcuts import get_object_or_404, render, redirect +from django.template.context_processors import csrf from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.template import Context, RequestContext, loader from django.contrib import messages @@ -41,11 +41,7 @@ def unarchive(user): def form(ctx, template, request): c = ctx c.update(csrf(request)) - return render_to_response( - template, - c, - context_instance=RequestContext(request) - ) + return render(request, template, c) def password_change_action(u_form, user, request, req=False): """ Fonction qui effectue le changeemnt de mdp bdd"""