CI passing!
This commit is contained in:
parent
d6e7a2b635
commit
be96a61ff2
|
@ -10,7 +10,7 @@ from django.shortcuts import render
|
|||
from django.template.context_processors import csrf
|
||||
from reversion.models import Revision
|
||||
|
||||
from med.settings import PAGINATION_NUMBER as pagination_number
|
||||
from med.settings import PAGINATION_NUMBER
|
||||
from users.models import User
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ def index(request):
|
|||
revisions = Revision.objects.all().order_by(
|
||||
'date_created').reverse().select_related('user').prefetch_related(
|
||||
'version_set__object')
|
||||
paginator = Paginator(revisions, pagination_number)
|
||||
paginator = Paginator(revisions, PAGINATION_NUMBER)
|
||||
page = request.GET.get('page')
|
||||
try:
|
||||
revisions = paginator.page(page)
|
||||
|
|
|
@ -17,14 +17,14 @@ ALGO_LEN = len(ALGO_NAME + "$")
|
|||
DIGEST_LEN = 20
|
||||
|
||||
|
||||
def makeSecret(password):
|
||||
def make_secret(password):
|
||||
salt = os.urandom(4)
|
||||
h = hashlib.sha1(password.encode())
|
||||
h.update(salt)
|
||||
return ALGO_NAME + "$" + encodestring(h.digest() + salt).decode()[:-1]
|
||||
|
||||
|
||||
def checkPassword(challenge_password, password):
|
||||
def check_password(challenge_password, password):
|
||||
challenge_bytes = decodestring(challenge_password[ALGO_LEN:].encode())
|
||||
digest = challenge_bytes[:DIGEST_LEN]
|
||||
salt = challenge_bytes[DIGEST_LEN:]
|
||||
|
@ -52,14 +52,14 @@ class SSHAPasswordHasher(hashers.BasePasswordHasher):
|
|||
salt is overridden
|
||||
"""
|
||||
assert password is not None
|
||||
return makeSecret(password)
|
||||
return make_secret(password)
|
||||
|
||||
def verify(self, password, encoded):
|
||||
"""
|
||||
Check password against encoded using SSHA algorithm
|
||||
"""
|
||||
assert encoded.startswith(self.algorithm)
|
||||
return checkPassword(encoded, password)
|
||||
return check_password(encoded, password)
|
||||
|
||||
def safe_summary(self, encoded):
|
||||
"""
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
from django.contrib import admin
|
||||
from reversion.admin import VersionAdmin
|
||||
|
||||
from .models import Auteur, Emprunt, Media, Jeu
|
||||
from .models import Auteur, Emprunt, Jeu, Media
|
||||
|
||||
|
||||
class AuteurAdmin(VersionAdmin):
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.db import transaction
|
||||
from django.shortcuts import render, redirect
|
||||
from django.shortcuts import redirect, render
|
||||
from django.template.context_processors import csrf
|
||||
from django.utils import timezone
|
||||
from reversion import revisions as reversion
|
||||
|
@ -33,7 +33,8 @@ def add_emprunt(request, userid):
|
|||
user=user).count()
|
||||
if emprunts_en_cours >= user.maxemprunt:
|
||||
messages.error(request,
|
||||
"Maximum d'emprunts atteint de l'user %s" % user.maxemprunt)
|
||||
"Maximum d'emprunts atteint de "
|
||||
"l'user %s" % user.maxemprunt)
|
||||
return redirect("/")
|
||||
emprunt = EmpruntForm(request.POST or None)
|
||||
if emprunt.is_valid():
|
||||
|
|
Loading…
Reference in New Issue