From af26948adf5b9256b22d139d557107839677f3a3 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 14 Oct 2017 04:48:43 +0200 Subject: [PATCH] Pylintage again --- re2o/context_processors.py | 14 +++++++++----- re2o/urls.py | 10 ++++++++-- re2o/views.py | 11 +++++++---- re2o/wsgi.py | 5 +++-- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/re2o/context_processors.py b/re2o/context_processors.py index ed4769b5..e562a347 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -19,15 +19,19 @@ # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +"""Fonction de context, variables renvoyées à toutes les vues""" + from __future__ import unicode_literals -from machines.models import Interface, Machine from preferences.models import GeneralOption, OptionalMachine + def context_user(request): - general_options, created = GeneralOption.objects.get_or_create() - machine_options, created = OptionalMachine.objects.get_or_create() + """Fonction de context lorsqu'un user est logué (ou non), + renvoie les infos sur l'user, la liste de ses droits, ses machines""" + general_options, _created = GeneralOption.objects.get_or_create() + machine_options, _created = OptionalMachine.objects.get_or_create() user = request.user if user.is_authenticated(): interfaces = user.user_interfaces() @@ -52,8 +56,8 @@ def context_user(request): 'is_bofh': is_bofh, 'is_trez': is_trez, 'is_infra': is_infra, - 'is_admin' : is_admin, + 'is_admin': is_admin, 'interfaces': interfaces, 'site_name': general_options.site_name, - 'ipv6_enabled' : machine_options.ipv6, + 'ipv6_enabled': machine_options.ipv6, } diff --git a/re2o/urls.py b/re2o/urls.py index 5fd45f85..775b87ec 100644 --- a/re2o/urls.py +++ b/re2o/urls.py @@ -49,10 +49,16 @@ urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^users/', include('users.urls', namespace='users')), url(r'^search/', include('search.urls', namespace='search')), - url(r'^cotisations/', include('cotisations.urls', namespace='cotisations')), + url( + r'^cotisations/', + include('cotisations.urls', namespace='cotisations') + ), url(r'^machines/', include('machines.urls', namespace='machines')), url(r'^topologie/', include('topologie.urls', namespace='topologie')), url(r'^logs/', include('logs.urls', namespace='logs')), - url(r'^preferences/', include('preferences.urls', namespace='preferences')), + url( + r'^preferences/', + include('preferences.urls', namespace='preferences') + ), ] diff --git a/re2o/views.py b/re2o/views.py index 77a36418..9cab6273 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -19,25 +19,28 @@ # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" +Fonctions de la page d'accueil et diverses fonctions utiles pour tous +les views +""" from __future__ import unicode_literals from django.shortcuts import render -from django.shortcuts import get_object_or_404 from django.template.context_processors import csrf -from django.template import Context, RequestContext, loader from preferences.models import Service + def form(ctx, template, request): + """Form générique, raccourci importé par les fonctions views du site""" context = ctx context.update(csrf(request)) return render(request, template, context) def index(request): - i = 0 + """Affiche la liste des services sur la page d'accueil de re2o""" services = [[], [], []] for indice, serv in enumerate(Service.objects.all()): services[indice % 3].append(serv) - return form({'services_urls': services}, 're2o/index.html', request) diff --git a/re2o/wsgi.py b/re2o/wsgi.py index 70108566..deb6b330 100644 --- a/re2o/wsgi.py +++ b/re2o/wsgi.py @@ -32,9 +32,10 @@ https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ from __future__ import unicode_literals import os -from django.core.wsgi import get_wsgi_application -from os.path import dirname import sys +from os.path import dirname +from django.core.wsgi import get_wsgi_application + sys.path.append(dirname(dirname(__file__))) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "re2o.settings")