Correctifs

This commit is contained in:
Aurélien Delobelle 2016-08-15 01:48:22 +02:00
parent 55fd10f9d4
commit 70eab07b8b

View file

@ -44,7 +44,7 @@ def account(request):
@login_required @login_required
@permission_required('kfet.is_team') @permission_required('kfet.is_team')
def account_is_validandfree_ajax(request): def account_is_validandfree_ajax(request):
if not request.GET.get("trigramme"): if not request.GET.get("trigramme", ''):
raise Http404 raise Http404
trigramme = request.GET.get("trigramme") trigramme = request.GET.get("trigramme")
data = Account.is_validandfree(trigramme) data = Account.is_validandfree(trigramme)
@ -118,7 +118,7 @@ def account_create_ajax(request, username=None, login_clipper=None):
user = None user = None
if login_clipper: if login_clipper:
# à partir d'un clipper # à partir d'un clipper
# le user associé à ce clipper ne devrait pas encore existé # le user associé à ce clipper ne devrait pas encore exister
clipper = get_object_or_404(Clipper, username = login_clipper) clipper = get_object_or_404(Clipper, username = login_clipper)
try: try:
# Vérification que clipper ne soit pas déjà dans User # Vérification que clipper ne soit pas déjà dans User
@ -132,7 +132,7 @@ def account_create_ajax(request, username=None, login_clipper=None):
# UserForm - Prefill + Création # UserForm - Prefill + Création
user_initial_data = { user_initial_data = {
'username' : login_clipper, 'username' : login_clipper,
'email' : login_clipper + "@clipper.ens.fr"} 'email' : "%s@clipper.ens.fr" % login_clipper}
if clipper.fullname: if clipper.fullname:
# Prefill du nom et prénom # Prefill du nom et prénom
names = clipper.fullname.split() names = clipper.fullname.split()
@ -180,10 +180,7 @@ def account_create_ajax(request, username=None, login_clipper=None):
@login_required @login_required
def account_read(request, trigramme): def account_read(request, trigramme):
try: account = get_object_or_404(Account, trigramme=trigramme)
account = Account.objects.get(trigramme=trigramme)
except Account.DoesNotExist:
raise Http404
# Checking permissions # Checking permissions
if not request.user.has_perm('kfet.is_team') \ if not request.user.has_perm('kfet.is_team') \
@ -196,10 +193,7 @@ def account_read(request, trigramme):
@login_required @login_required
def account_update(request, trigramme): def account_update(request, trigramme):
try: account = get_object_or_404(Account, trigramme=trigramme)
account = Account.objects.get(trigramme=trigramme)
except Account.DoesNotExist:
raise Http404
# Checking permissions # Checking permissions
if not request.user.has_perm('kfet.is_team') \ if not request.user.has_perm('kfet.is_team') \
@ -278,7 +272,7 @@ class CheckoutCreate(SuccessMessageMixin, CreateView):
# Surcharge de la validation # Surcharge de la validation
def form_valid(self, form): def form_valid(self, form):
# Checking permission # Checking permission
if not self.request.user.has_perm('add_checkout'): if not self.request.user.has_perm('kfet.add_checkout'):
raise PermissionDenied raise PermissionDenied
# Creating # Creating
form.instance.created_by = self.request.user.profile.account_kfet form.instance.created_by = self.request.user.profile.account_kfet
@ -302,7 +296,7 @@ class CheckoutUpdate(SuccessMessageMixin, UpdateView):
# Surcharge de la validation # Surcharge de la validation
def form_valid(self, form): def form_valid(self, form):
# Checking permission # Checking permission
if not self.request.user.has_perm('change_checkout'): if not self.request.user.has_perm('kfet.change_checkout'):
raise PermissionDenied raise PermissionDenied
# Updating # Updating
return super(CheckoutUpdate, self).form_valid(form) return super(CheckoutUpdate, self).form_valid(form)