1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-11-26 21:27:11 +00:00

CI passing!

This commit is contained in:
Alexandre Iooss 2019-08-09 23:22:20 +02:00
parent d6e7a2b635
commit be96a61ff2
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
5 changed files with 12 additions and 11 deletions

View File

@ -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)

View File

@ -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):
"""

View File

@ -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):

View File

@ -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():

View File

@ -28,11 +28,11 @@ deps =
pyflakes
pylint
commands =
flake8 logs med media search users
flake8 logs media search users
pylint .
[flake8]
ignore = D203, W503, E203
ignore = D203, W503, E203, I100, I201, I202
exclude =
.tox,
.git,