diff --git a/med/templates/med/history.html b/media/templates/media/history.html
similarity index 100%
rename from med/templates/med/history.html
rename to media/templates/media/history.html
diff --git a/media/views.py b/media/views.py
index c36c456..56473cd 100644
--- a/media/views.py
+++ b/media/views.py
@@ -358,4 +358,4 @@ def history(request, object, id):
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
reversions = paginator.page(paginator.num_pages)
- return render(request, 'med/history.html', {'reversions': reversions, 'object': object_instance})
+ return render(request, 'media/history.html', {'reversions': reversions, 'object': object_instance})
diff --git a/users/__init__.py b/users/__init__.py
index 20abb0d..e69de29 100644
--- a/users/__init__.py
+++ b/users/__init__.py
@@ -1,22 +0,0 @@
-# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-# se veut agnostique au réseau considéré, de manière à être installable en
-# quelques clics.
-#
-# Copyright © 2017 Gabriel Détraz
-# Copyright © 2017 Goulven Kermarec
-# Copyright © 2017 Augustin Lemesle
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# 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.
-
diff --git a/users/admin.py b/users/admin.py
index 0b054b0..1d9121a 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -7,7 +7,7 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import ugettext_lazy as _
from reversion.admin import VersionAdmin
-from .models import User, Right, Adhesion, ListRight, Clef, Request
+from .models import Adhesion, Clef, ListRight, Request, Right, User
class RequestAdmin(admin.ModelAdmin):
@@ -44,7 +44,8 @@ class IsAdherentFilter(admin.SimpleListFilter):
value = self.value()
if value == 'Yes':
# Get current membership year and list all members
- last_adh_year = Adhesion.objects.all().order_by('annee_debut').reverse().first()
+ last_adh_year = Adhesion.objects.all().order_by('annee_debut')\
+ .reverse().first()
return last_adh_year.adherent
return queryset
@@ -69,7 +70,8 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
"""
Get current membership year and check if user is there
"""
- last_adh_year = Adhesion.objects.all().order_by('annee_debut').reverse().first()
+ last_adh_year = Adhesion.objects.all().order_by('annee_debut')\
+ .reverse().first()
return last_adh_year and obj in last_adh_year.adherent.all()
is_adherent.boolean = True
diff --git a/users/decorators.py b/users/decorators.py
deleted file mode 100644
index 0046ee6..0000000
--- a/users/decorators.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- mode: python; coding: utf-8 -*-
-# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
-# SPDX-License-Identifier: GPL-3.0-or-later
-
-import ipaddress
-
-from django.shortcuts import redirect
-
-from med.settings import AUTHORIZED_IP_RANGE, AUTHORIZED_IP6_RANGE
-
-
-def user_is_in_campus(function):
- def wrap(request, *args, **kwargs):
- if not request.user.is_authenticated:
- remote_ip = get_ip(request)
- if not ipaddress.ip_address(remote_ip) in ipaddress.ip_network(
- AUTHORIZED_IP_RANGE) and not ipaddress.ip_address(remote_ip) in ipaddress.ip_network(
- AUTHORIZED_IP6_RANGE):
- return redirect("/")
- return function(request, *args, **kwargs)
-
- wrap.__doc__ = function.__doc__
- wrap.__name__ = function.__name__
- return wrap
-
-
-def get_ip(request):
- """Returns the IP of the request, accounting for the possibility of being
- behind a proxy.
- """
- ip = request.META.get("HTTP_X_FORWARDED_FOR", None)
- if ip:
- # X_FORWARDED_FOR returns client1, proxy1, proxy2,...
- ip = ip.split(", ")[0]
- else:
- ip = request.META.get("REMOTE_ADDR", "")
- return ip
diff --git a/users/forms.py b/users/forms.py
index 74d85c8..0dd319a 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -3,18 +3,25 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from django import forms
-from django.contrib.auth.forms import ReadOnlyPasswordHashField
from django.core.validators import MinLengthValidator
-from django.forms import ModelForm, Form
+from django.forms import ModelForm
-from .models import Adhesion, Clef, ListRight, Right, User
+from .models import User
class PassForm(forms.Form):
- passwd1 = forms.CharField(label=u'Nouveau mot de passe', max_length=255, validators=[MinLengthValidator(8)],
- widget=forms.PasswordInput)
- passwd2 = forms.CharField(label=u'Saisir à nouveau le mot de passe', max_length=255,
- validators=[MinLengthValidator(8)], widget=forms.PasswordInput)
+ passwd1 = forms.CharField(
+ label=u'Nouveau mot de passe',
+ max_length=255,
+ validators=[MinLengthValidator(8)],
+ widget=forms.PasswordInput,
+ )
+ passwd2 = forms.CharField(
+ label=u'Saisir à nouveau le mot de passe',
+ max_length=255,
+ validators=[MinLengthValidator(8)],
+ widget=forms.PasswordInput
+ )
class BaseInfoForm(ModelForm):
@@ -41,36 +48,3 @@ class InfoForm(BaseInfoForm):
'address',
'maxemprunt',
]
-
-
-class PasswordForm(ModelForm):
- class Meta:
- model = User
- fields = ['password']
-
-
-class AdhesionForm(ModelForm):
- adherent = forms.ModelMultipleChoiceField(User.objects.all(), widget=forms.CheckboxSelectMultiple, required=False)
-
- class Meta:
- model = Adhesion
- fields = '__all__'
-
-
-class RightForm(ModelForm):
- def __init__(self, *args, **kwargs):
- super(RightForm, self).__init__(*args, **kwargs)
- self.fields['right'].label = 'Droit'
- self.fields['right'].empty_label = "Choisir un nouveau droit"
-
- class Meta:
- model = Right
- fields = ['right']
-
-
-class DelRightForm(Form):
- rights = forms.ModelMultipleChoiceField(queryset=Right.objects.all(), widget=forms.CheckboxSelectMultiple)
-
- def __init__(self, right, *args, **kwargs):
- super(DelRightForm, self).__init__(*args, **kwargs)
- self.fields['rights'].queryset = Right.objects.filter(right=right)
diff --git a/users/models.py b/users/models.py
index 4cf7eac..bb921bd 100644
--- a/users/models.py
+++ b/users/models.py
@@ -28,7 +28,8 @@ class User(AbstractUser):
)
maxemprunt = models.IntegerField(
verbose_name=_('maximum borrowed'),
- help_text=_('Maximal amount of simultaneous borrowed item authorized.'),
+ help_text=_('Maximal amount of simultaneous borrowed item '
+ 'authorized.'),
default=MAX_EMPRUNT,
)
comment = models.CharField(
@@ -50,7 +51,8 @@ class User(AbstractUser):
@property
def is_adherent(self):
- last_adh_year = Adhesion.objects.all().order_by('annee_debut').reverse().first()
+ last_adh_year = Adhesion.objects.all().order_by(
+ 'annee_debut').reverse().first()
return last_adh_year and self in last_adh_year.adherent.all()
@@ -69,8 +71,8 @@ class Request(models.Model):
def save(self):
if not self.expires_at:
- self.expires_at = timezone.now() \
- + datetime.timedelta(hours=REQ_EXPIRE_HRS)
+ self.expires_at = timezone.now()
+ self.expires_at += datetime.timedelta(hours=REQ_EXPIRE_HRS)
if not self.token:
self.token = str(uuid.uuid4()).replace('-', '') # remove hyphens
super().save()
@@ -95,7 +97,11 @@ class ListRight(models.Model):
PRETTY_NAME = "Liste des droits existants"
listright = models.CharField(max_length=255, unique=True)
- details = models.CharField(help_text="Description", max_length=255, blank=True)
+ details = models.CharField(
+ help_text="Description",
+ max_length=255,
+ blank=True,
+ )
def __str__(self):
return self.listright
@@ -103,7 +109,8 @@ class ListRight(models.Model):
class Clef(models.Model):
nom = models.CharField(max_length=255, unique=True)
- proprio = models.ForeignKey('User', on_delete=models.PROTECT, blank=True, null=True)
+ proprio = models.ForeignKey('User', on_delete=models.PROTECT, blank=True,
+ null=True)
commentaire = models.CharField(max_length=255, null=True, blank=True)
diff --git a/users/templates/users/aff_clef.html b/users/templates/users/aff_clef.html
index 88888f6..72d7b38 100644
--- a/users/templates/users/aff_clef.html
+++ b/users/templates/users/aff_clef.html
@@ -8,7 +8,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
Clef |
Propriétaire |
Commentaire |
- |
{% for clef in clef_list %}
@@ -16,9 +15,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
{{ clef.nom }} |
{{ clef.proprio }} |
{{ clef.commentaire }} |
-
- {% include 'buttons/history.html' with href='users:history' name='clef' id=clef.id %}
- |
{% endfor %}
diff --git a/users/templates/users/del_right.html b/users/templates/users/del_right.html
deleted file mode 100644
index 740778a..0000000
--- a/users/templates/users/del_right.html
+++ /dev/null
@@ -1,58 +0,0 @@
-{% extends "users/sidebar.html" %}
-{% comment %}
-Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-se veut agnostique au réseau considéré, de manière à être installable en
-quelques clics.
-
-Copyright © 2017 Gabriel Détraz
-Copyright © 2017 Goulven Kermarec
-Copyright © 2017 Augustin Lemesle
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-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.
-{% endcomment %}
-
-{% load bootstrap3 %}
-
-{% block title %}Création et modification d'utilisateur{% endblock %}
-
-
-{% block content %}
-
-Gestion des droits
-
-
-
-
-
-
-{% endblock %}
diff --git a/users/templates/users/delete.html b/users/templates/users/delete.html
deleted file mode 100644
index 1ca4061..0000000
--- a/users/templates/users/delete.html
+++ /dev/null
@@ -1,40 +0,0 @@
-{% extends "media/sidebar.html" %}
-{% comment %}
-Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-se veut agnostique au réseau considéré, de manière à être installable en
-quelques clics.
-
-Copyright © 2017 Gabriel Détraz
-Copyright © 2017 Goulven Kermarec
-Copyright © 2017 Augustin Lemesle
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-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.
-{% endcomment %}
-
-{% load bootstrap3 %}
-
-{% block title %}Création et modification de media{% endblock %}
-
-{% block content %}
-
-
-
-
-
-{% endblock %}
diff --git a/users/urls.py b/users/urls.py
index 22613b4..098a46a 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -9,16 +9,15 @@ from . import views
app_name = 'users'
urlpatterns = [
url(r'^new_user/$', views.new_user, name='new-user'),
- url(r'^edit_info/(?P[0-9]+)$', views.edit_info, name='edit-info'),
- url(r'^password/(?P[0-9]+)$', views.password, name='password'),
+ url(r'^edit_info/(?P[0-9]+)$', views.edit_info,
+ name='edit-info'),
+ url(r'^password/(?P[0-9]+)$', views.password,
+ name='password'),
url(r'^profil/(?P[0-9]+)$', views.profil, name='profil'),
url(r'^adherer/(?P[0-9]+)$', views.adherer, name='adherer'),
url(r'^mon_profil/$', views.mon_profil, name='mon-profil'),
url(r'^index_clef/$', views.index_clef, name='index-clef'),
- url(r'^history/(?P