ruff rules UP008 and UP009

This commit is contained in:
thomas girod 2024-06-27 14:46:43 +02:00
parent 688871a680
commit cfc19434d0
258 changed files with 473 additions and 824 deletions

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.core.validators import django.core.validators

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import phonenumber_field.modelfields import phonenumber_field.modelfields

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr
@ -37,11 +36,11 @@ class CurrencyField(models.DecimalField):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
kwargs["max_digits"] = 12 kwargs["max_digits"] = 12
kwargs["decimal_places"] = 2 kwargs["decimal_places"] = 2
super(CurrencyField, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def to_python(self, value): def to_python(self, value):
try: try:
return super(CurrencyField, self).to_python(value).quantize(Decimal("0.01")) return super().to_python(value).quantize(Decimal("0.01"))
except AttributeError: except AttributeError:
return None return None
@ -364,7 +363,7 @@ class Operation(models.Model):
return object.__getattribute__(self, attr) return object.__getattribute__(self, attr)
def clean(self): def clean(self):
super(Operation, self).clean() super().clean()
if self.date is None: if self.date is None:
raise ValidationError(_("The date must be set.")) raise ValidationError(_("The date must be set."))
elif self.date < self.journal.start_date: elif self.date < self.journal.start_date:
@ -413,7 +412,7 @@ class Operation(models.Model):
def save(self): def save(self):
if self.number is None: if self.number is None:
self.number = self.journal.operations.count() + 1 self.number = self.journal.operations.count() + 1
super(Operation, self).save() super().save()
self.journal.update_amounts() self.journal.update_amounts()
def is_owned_by(self, user): def is_owned_by(self, user):

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr
@ -210,7 +209,7 @@ class ClubAccountCreateView(CanCreateMixin, CreateView):
template_name = "core/create.jinja" template_name = "core/create.jinja"
def get_initial(self): def get_initial(self):
ret = super(ClubAccountCreateView, self).get_initial() ret = super().get_initial()
if "parent" in self.request.GET.keys(): if "parent" in self.request.GET.keys():
obj = BankAccount.objects.filter(id=int(self.request.GET["parent"])).first() obj = BankAccount.objects.filter(id=int(self.request.GET["parent"])).first()
if obj is not None: if obj is not None:
@ -296,7 +295,7 @@ class JournalCreateView(CanCreateMixin, CreateView):
template_name = "core/create.jinja" template_name = "core/create.jinja"
def get_initial(self): def get_initial(self):
ret = super(JournalCreateView, self).get_initial() ret = super().get_initial()
if "parent" in self.request.GET.keys(): if "parent" in self.request.GET.keys():
obj = ClubAccount.objects.filter(id=int(self.request.GET["parent"])).first() obj = ClubAccount.objects.filter(id=int(self.request.GET["parent"])).first()
if obj is not None: if obj is not None:
@ -339,7 +338,7 @@ class JournalDeleteView(CanEditPropMixin, DeleteView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
if self.object.operations.count() == 0: if self.object.operations.count() == 0:
return super(JournalDeleteView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
else: else:
raise PermissionDenied raise PermissionDenied
@ -387,7 +386,7 @@ class OperationForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
club_account = kwargs.pop("club_account", None) club_account = kwargs.pop("club_account", None)
super(OperationForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if club_account: if club_account:
self.fields["label"].queryset = club_account.labels.order_by("name").all() self.fields["label"].queryset = club_account.labels.order_by("name").all()
if self.instance.target_type == "USER": if self.instance.target_type == "USER":
@ -400,7 +399,7 @@ class OperationForm(forms.ModelForm):
self.fields["company"].initial = self.instance.target_id self.fields["company"].initial = self.instance.target_id
def clean(self): def clean(self):
self.cleaned_data = super(OperationForm, self).clean() self.cleaned_data = super().clean()
if "target_type" in self.cleaned_data.keys(): if "target_type" in self.cleaned_data.keys():
if ( if (
self.cleaned_data.get("user") is None self.cleaned_data.get("user") is None
@ -430,7 +429,7 @@ class OperationForm(forms.ModelForm):
return self.cleaned_data return self.cleaned_data
def save(self): def save(self):
ret = super(OperationForm, self).save() ret = super().save()
if ( if (
self.instance.target_type == "ACCOUNT" self.instance.target_type == "ACCOUNT"
and not self.instance.linked_operation and not self.instance.linked_operation
@ -482,14 +481,14 @@ class OperationCreateView(CanCreateMixin, CreateView):
return self.form_class(club_account=ca, **self.get_form_kwargs()) return self.form_class(club_account=ca, **self.get_form_kwargs())
def get_initial(self): def get_initial(self):
ret = super(OperationCreateView, self).get_initial() ret = super().get_initial()
if self.journal is not None: if self.journal is not None:
ret["journal"] = self.journal.id ret["journal"] = self.journal.id
return ret return ret
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add journal to the context""" """Add journal to the context"""
kwargs = super(OperationCreateView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
if self.journal: if self.journal:
kwargs["object"] = self.journal kwargs["object"] = self.journal
return kwargs return kwargs
@ -507,7 +506,7 @@ class OperationEditView(CanEditMixin, UpdateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add journal to the context""" """Add journal to the context"""
kwargs = super(OperationEditView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["object"] = self.object.journal kwargs["object"] = self.object.journal
return kwargs return kwargs
@ -728,7 +727,7 @@ class JournalNatureStatementView(JournalTabsMixin, CanViewMixin, DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add infos to the context""" """Add infos to the context"""
kwargs = super(JournalNatureStatementView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["statement"] = self.big_statement() kwargs["statement"] = self.big_statement()
return kwargs return kwargs
@ -767,7 +766,7 @@ class JournalPersonStatementView(JournalTabsMixin, CanViewMixin, DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add journal to the context""" """Add journal to the context"""
kwargs = super(JournalPersonStatementView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["credit_statement"] = self.statement("CREDIT") kwargs["credit_statement"] = self.statement("CREDIT")
kwargs["debit_statement"] = self.statement("DEBIT") kwargs["debit_statement"] = self.statement("DEBIT")
kwargs["total_credit"] = self.total("CREDIT") kwargs["total_credit"] = self.total("CREDIT")
@ -797,7 +796,7 @@ class JournalAccountingStatementView(JournalTabsMixin, CanViewMixin, DetailView)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add journal to the context""" """Add journal to the context"""
kwargs = super(JournalAccountingStatementView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["statement"] = self.statement() kwargs["statement"] = self.statement()
return kwargs return kwargs
@ -852,7 +851,7 @@ class LabelCreateView(
template_name = "core/create.jinja" template_name = "core/create.jinja"
def get_initial(self): def get_initial(self):
ret = super(LabelCreateView, self).get_initial() ret = super().get_initial()
if "parent" in self.request.GET.keys(): if "parent" in self.request.GET.keys():
obj = ClubAccount.objects.filter(id=int(self.request.GET["parent"])).first() obj = ClubAccount.objects.filter(id=int(self.request.GET["parent"])).first()
if obj is not None: if obj is not None:
@ -897,19 +896,19 @@ class RefoundAccountView(FormView):
raise PermissionDenied raise PermissionDenied
def dispatch(self, request, *arg, **kwargs): def dispatch(self, request, *arg, **kwargs):
res = super(RefoundAccountView, self).dispatch(request, *arg, **kwargs) res = super().dispatch(request, *arg, **kwargs)
if self.permission(request.user): if self.permission(request.user):
return res return res
def post(self, request, *arg, **kwargs): def post(self, request, *arg, **kwargs):
self.operator = request.user self.operator = request.user
if self.permission(request.user): if self.permission(request.user):
return super(RefoundAccountView, self).post(self, request, *arg, **kwargs) return super().post(self, request, *arg, **kwargs)
def form_valid(self, form): def form_valid(self, form):
self.customer = form.cleaned_data["user"] self.customer = form.cleaned_data["user"]
self.create_selling() self.create_selling()
return super(RefoundAccountView, self).form_valid(form) return super().form_valid(form)
def get_success_url(self): def get_success_url(self):
return reverse("accounting:refound_account") return reverse("accounting:refound_account")

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr
@ -50,7 +49,7 @@ class ManageModelMixin:
class RightModelViewSet(ManageModelMixin, viewsets.ModelViewSet): class RightModelViewSet(ManageModelMixin, viewsets.ModelViewSet):
def dispatch(self, request, *arg, **kwargs): def dispatch(self, request, *arg, **kwargs):
res = super(RightModelViewSet, self).dispatch(request, *arg, **kwargs) res = super().dispatch(request, *arg, **kwargs)
obj = self.queryset obj = self.queryset
user = self.request.user user = self.request.user
try: try:

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2016,2017 # Copyright 2016,2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>
@ -40,7 +39,7 @@ class ClubEditForm(forms.ModelForm):
fields = ["address", "logo", "short_description"] fields = ["address", "logo", "short_description"]
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ClubEditForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["short_description"].widget = forms.Textarea() self.fields["short_description"].widget = forms.Textarea()
@ -61,7 +60,7 @@ class MailingForm(forms.Form):
) )
def __init__(self, club_id, user_id, mailings, *args, **kwargs): def __init__(self, club_id, user_id, mailings, *args, **kwargs):
super(MailingForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["action"] = forms.TypedChoiceField( self.fields["action"] = forms.TypedChoiceField(
choices=( choices=(
@ -116,7 +115,7 @@ class MailingForm(forms.Form):
""" """
Convert given users into real users and check their validity Convert given users into real users and check their validity
""" """
cleaned_data = super(MailingForm, self).clean() cleaned_data = super().clean()
users = [] users = []
for user in cleaned_data["subscription_users"]: for user in cleaned_data["subscription_users"]:
user = User.objects.filter(id=user).first() user = User.objects.filter(id=user).first()
@ -133,7 +132,7 @@ class MailingForm(forms.Form):
return users return users
def clean(self): def clean(self):
cleaned_data = super(MailingForm, self).clean() cleaned_data = super().clean()
if not "action" in cleaned_data: if not "action" in cleaned_data:
# If there is no action provided, we can stop here # If there is no action provided, we can stop here
@ -164,7 +163,7 @@ class SellingsForm(forms.Form):
) )
def __init__(self, club, *args, **kwargs): def __init__(self, club, *args, **kwargs):
super(SellingsForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["products"] = forms.ModelMultipleChoiceField( self.fields["products"] = forms.ModelMultipleChoiceField(
club.products.order_by("name").filter(archived=False).all(), club.products.order_by("name").filter(archived=False).all(),
label=_("Products"), label=_("Products"),
@ -201,7 +200,7 @@ class ClubMemberForm(forms.Form):
self.club.members.filter(end_date=None).order_by("-role").all() self.club.members.filter(end_date=None).order_by("-role").all()
) )
self.request_user_membership = self.club.get_membership_for(self.request_user) self.request_user_membership = self.club.get_membership_for(self.request_user)
super(ClubMemberForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Using a ModelForm binds too much the form with the model and we don't want that # Using a ModelForm binds too much the form with the model and we don't want that
# We want the view to process the model creation since they are multiple users # We want the view to process the model creation since they are multiple users
@ -241,7 +240,7 @@ class ClubMemberForm(forms.Form):
Check that the user is not trying to add an user already in the club Check that the user is not trying to add an user already in the club
Also check that the user is valid and has a valid subscription Also check that the user is valid and has a valid subscription
""" """
cleaned_data = super(ClubMemberForm, self).clean() cleaned_data = super().clean()
users = [] users = []
for user_id in cleaned_data["users"]: for user_id in cleaned_data["users"]:
user = User.objects.filter(id=user_id).first() user = User.objects.filter(id=user_id).first()
@ -264,7 +263,7 @@ class ClubMemberForm(forms.Form):
""" """
Check user rights for adding an user Check user rights for adding an user
""" """
cleaned_data = super(ClubMemberForm, self).clean() cleaned_data = super().clean()
if "start_date" in cleaned_data and not cleaned_data["start_date"]: if "start_date" in cleaned_data and not cleaned_data["start_date"]:
# Drop start_date if allowed to edition but not specified # Drop start_date if allowed to edition but not specified

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.core.validators import django.core.validators

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.utils.timezone import django.utils.timezone

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations from django.db import migrations

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import re import re

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2016,2017 # Copyright 2016,2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>
@ -190,7 +189,7 @@ class Club(models.Model):
creation = old is None creation = old is None
if not creation and old.unix_name != self.unix_name: if not creation and old.unix_name != self.unix_name:
self._change_unixname(self.unix_name) self._change_unixname(self.unix_name)
super(Club, self).save(*args, **kwargs) super().save(*args, **kwargs)
if creation: if creation:
board = MetaGroup(name=self.unix_name + settings.SITH_BOARD_SUFFIX) board = MetaGroup(name=self.unix_name + settings.SITH_BOARD_SUFFIX)
board.save() board.save()
@ -459,7 +458,7 @@ class Mailing(models.Model):
self.is_moderated = True self.is_moderated = True
else: else:
self.moderator = None self.moderator = None
super(Mailing, self).clean() super().clean()
@property @property
def email_full(self): def email_full(self):
@ -481,7 +480,7 @@ class Mailing(models.Model):
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
self.subscriptions.all().delete() self.subscriptions.all().delete()
super(Mailing, self).delete() super().delete()
def fetch_format(self): def fetch_format(self):
resp = self.email + ": " resp = self.email + ": "
@ -504,7 +503,7 @@ class Mailing(models.Model):
url=reverse("com:mailing_admin"), url=reverse("com:mailing_admin"),
type="MAILING_MODERATION", type="MAILING_MODERATION",
).save() ).save()
super(Mailing, self).save() super().save()
def __str__(self): def __str__(self):
return "%s - %s" % (self.club, self.email_full) return "%s - %s" % (self.club, self.email_full)
@ -550,7 +549,7 @@ class MailingSubscription(models.Model):
) )
except ObjectDoesNotExist: except ObjectDoesNotExist:
pass pass
super(MailingSubscription, self).clean() super().clean()
def is_owned_by(self, user): def is_owned_by(self, user):
if user.is_anonymous: if user.is_anonymous:

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2016,2017 # Copyright 2016,2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2016,2017 # Copyright 2016,2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>
@ -195,7 +194,7 @@ class ClubView(ClubTabsMixin, DetailView):
current_tab = "infos" current_tab = "infos"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(ClubView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
if self.object.page and self.object.page.revisions.exists(): if self.object.page and self.object.page.revisions.exists():
kwargs["page_revision"] = self.object.page.revisions.last().content kwargs["page_revision"] = self.object.page.revisions.last().content
return kwargs return kwargs
@ -209,10 +208,10 @@ class ClubRevView(ClubView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
obj = self.get_object() obj = self.get_object()
self.revision = get_object_or_404(PageRev, pk=kwargs["rev_id"], page__club=obj) self.revision = get_object_or_404(PageRev, pk=kwargs["rev_id"], page__club=obj)
return super(ClubRevView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(ClubRevView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["page_revision"] = self.revision.content kwargs["page_revision"] = self.revision.content
return kwargs return kwargs
@ -225,7 +224,7 @@ class ClubPageEditView(ClubTabsMixin, PageEditViewBase):
self.club = get_object_or_404(Club, pk=kwargs["club_id"]) self.club = get_object_or_404(Club, pk=kwargs["club_id"])
if not self.club.page: if not self.club.page:
raise Http404 raise Http404
return super(ClubPageEditView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_object(self): def get_object(self):
self.page = self.club.page self.page = self.club.page
@ -269,14 +268,14 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, DetailFormView):
current_tab = "members" current_tab = "members"
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super(ClubMembersView, self).get_form_kwargs() kwargs = super().get_form_kwargs()
kwargs["request_user"] = self.request.user kwargs["request_user"] = self.request.user
kwargs["club"] = self.get_object() kwargs["club"] = self.get_object()
kwargs["club_members"] = self.members kwargs["club_members"] = self.members
return kwargs return kwargs
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
kwargs = super(ClubMembersView, self).get_context_data(*args, **kwargs) kwargs = super().get_context_data(*args, **kwargs)
kwargs["members"] = self.members kwargs["members"] = self.members
return kwargs return kwargs
@ -284,7 +283,7 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, DetailFormView):
""" """
Check user rights Check user rights
""" """
resp = super(ClubMembersView, self).form_valid(form) resp = super().form_valid(form)
data = form.clean() data = form.clean()
users = data.pop("users", []) users = data.pop("users", [])
@ -299,7 +298,7 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, DetailFormView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
self.members = self.get_object().members.ongoing().order_by("-role") self.members = self.get_object().members.ongoing().order_by("-role")
return super(ClubMembersView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_success_url(self, **kwargs): def get_success_url(self, **kwargs):
return reverse_lazy( return reverse_lazy(
@ -333,12 +332,12 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
try: try:
self.asked_page = int(request.GET.get("page", 1)) self.asked_page = int(request.GET.get("page", 1))
except ValueError: except ValueError as e:
raise Http404 raise Http404 from e
return super(ClubSellingView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super(ClubSellingView, self).get_form_kwargs() kwargs = super().get_form_kwargs()
kwargs["club"] = self.object kwargs["club"] = self.object
return kwargs return kwargs
@ -346,7 +345,7 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
return self.get(request, *args, **kwargs) return self.get(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(ClubSellingView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
qs = Selling.objects.filter(club=self.object) qs = Selling.objects.filter(club=self.object)
kwargs["result"] = qs[:0] kwargs["result"] = qs[:0]
@ -390,8 +389,8 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
kwargs["paginator"] = Paginator(kwargs["result"], self.paginate_by) kwargs["paginator"] = Paginator(kwargs["result"], self.paginate_by)
try: try:
kwargs["paginated_result"] = kwargs["paginator"].page(self.asked_page) kwargs["paginated_result"] = kwargs["paginator"].page(self.asked_page)
except InvalidPage: except InvalidPage as e:
raise Http404 raise Http404 from e
return kwargs return kwargs
@ -558,7 +557,7 @@ class ClubStatView(TemplateView):
template_name = "club/stats.jinja" template_name = "club/stats.jinja"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(ClubStatView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["club_list"] = Club.objects.all() kwargs["club_list"] = Club.objects.all()
return kwargs return kwargs
@ -575,7 +574,7 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
current_tab = "mailing" current_tab = "mailing"
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super(ClubMailingView, self).get_form_kwargs() kwargs = super().get_form_kwargs()
kwargs["club_id"] = self.get_object().id kwargs["club_id"] = self.get_object().id
kwargs["user_id"] = self.request.user.id kwargs["user_id"] = self.request.user.id
kwargs["mailings"] = self.mailings kwargs["mailings"] = self.mailings
@ -583,10 +582,10 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
self.mailings = Mailing.objects.filter(club_id=self.get_object().id).all() self.mailings = Mailing.objects.filter(club_id=self.get_object().id).all()
return super(ClubMailingView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(ClubMailingView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["club"] = self.get_object() kwargs["club"] = self.get_object()
kwargs["user"] = self.request.user kwargs["user"] = self.request.user
kwargs["mailings"] = self.mailings kwargs["mailings"] = self.mailings
@ -670,7 +669,7 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
sub.delete() sub.delete()
def form_valid(self, form): def form_valid(self, form):
resp = super(ClubMailingView, self).form_valid(form) resp = super().form_valid(form)
cleaned_data = form.clean() cleaned_data = form.clean()
error = None error = None
@ -702,7 +701,7 @@ class MailingDeleteView(CanEditMixin, DeleteView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
self.club_id = self.get_object().club.id self.club_id = self.get_object().club.id
return super(MailingDeleteView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_success_url(self, **kwargs): def get_success_url(self, **kwargs):
if self.redirect_page: if self.redirect_page:
@ -718,9 +717,7 @@ class MailingSubscriptionDeleteView(CanEditMixin, DeleteView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
self.club_id = self.get_object().mailing.club.id self.club_id = self.get_object().mailing.club.id
return super(MailingSubscriptionDeleteView, self).dispatch( return super().dispatch(request, *args, **kwargs)
request, *args, **kwargs
)
def get_success_url(self, **kwargs): def get_success_url(self, **kwargs):
return reverse_lazy("club:mailing", kwargs={"club_id": self.club_id}) return reverse_lazy("club:mailing", kwargs={"club_id": self.club_id})
@ -731,7 +728,7 @@ class MailingAutoGenerationView(View):
self.mailing = get_object_or_404(Mailing, pk=kwargs["mailing_id"]) self.mailing = get_object_or_404(Mailing, pk=kwargs["mailing_id"])
if not request.user.can_edit(self.mailing): if not request.user.can_edit(self.mailing):
raise PermissionDenied raise PermissionDenied
return super(MailingAutoGenerationView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
club = self.mailing.club club = self.mailing.club
@ -751,7 +748,7 @@ class PosterListView(ClubTabsMixin, PosterListBaseView, CanViewMixin):
return self.club return self.club
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterListView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["app"] = "club" kwargs["app"] = "club"
kwargs["club"] = self.club kwargs["club"] = self.club
return kwargs return kwargs
@ -763,7 +760,7 @@ class PosterCreateView(PosterCreateBaseView, CanCreateMixin):
pk_url_kwarg = "club_id" pk_url_kwarg = "club_id"
def get_object(self): def get_object(self):
obj = super(PosterCreateView, self).get_object() obj = super().get_object()
if not obj: if not obj:
return self.club return self.club
return obj return obj
@ -779,7 +776,7 @@ class PosterEditView(ClubTabsMixin, PosterEditBaseView, CanEditMixin):
return reverse_lazy("club:poster_list", kwargs={"club_id": self.club.id}) return reverse_lazy("club:poster_list", kwargs={"club_id": self.club.id})
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterEditView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["app"] = "club" kwargs["app"] = "club"
return kwargs return kwargs

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-08-18 17:00 # Generated by Django 1.11.23 on 2019-08-18 17:00
from __future__ import unicode_literals from __future__ import unicode_literals

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2016,2017 # Copyright 2016,2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>
@ -112,7 +111,7 @@ class News(models.Model):
return "%s: %s" % (self.type, self.title) return "%s: %s" % (self.type, self.title)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
super(News, self).save(*args, **kwargs) super().save(*args, **kwargs)
for u in ( for u in (
RealGroup.objects.filter(id=settings.SITH_GROUP_COM_ADMIN_ID) RealGroup.objects.filter(id=settings.SITH_GROUP_COM_ADMIN_ID)
.first() .first()
@ -341,7 +340,7 @@ class Poster(models.Model):
url=reverse("com:poster_moderate_list"), url=reverse("com:poster_moderate_list"),
type="POSTER_MODERATION", type="POSTER_MODERATION",
).save() ).save()
return super(Poster, self).save(*args, **kwargs) return super().save(*args, **kwargs)
def clean(self, *args, **kwargs): def clean(self, *args, **kwargs):
if self.date_end and self.date_begin > self.date_end: if self.date_end and self.date_begin > self.date_end:

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2016,2017 # Copyright 2016,2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>
@ -82,7 +81,7 @@ class PosterForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user", None) self.user = kwargs.pop("user", None)
super(PosterForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if self.user: if self.user:
if not self.user.is_com_admin: if not self.user.is_com_admin:
self.fields["club"].queryset = Club.objects.filter( self.fields["club"].queryset = Club.objects.filter(
@ -145,7 +144,7 @@ class IsComAdminMixin(View):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
if not request.user.is_com_admin: if not request.user.is_com_admin:
raise PermissionDenied raise PermissionDenied
return super(IsComAdminMixin, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
class ComEditView(ComTabsMixin, CanEditPropMixin, UpdateView): class ComEditView(ComTabsMixin, CanEditPropMixin, UpdateView):
@ -199,7 +198,7 @@ class NewsForm(forms.ModelForm):
automoderation = forms.BooleanField(label=_("Automoderation"), required=False) automoderation = forms.BooleanField(label=_("Automoderation"), required=False)
def clean(self): def clean(self):
self.cleaned_data = super(NewsForm, self).clean() self.cleaned_data = super().clean()
if self.cleaned_data["type"] != "NOTICE": if self.cleaned_data["type"] != "NOTICE":
if not self.cleaned_data["start_date"]: if not self.cleaned_data["start_date"]:
self.add_error( self.add_error(
@ -225,7 +224,7 @@ class NewsForm(forms.ModelForm):
return self.cleaned_data return self.cleaned_data
def save(self): def save(self):
ret = super(NewsForm, self).save() ret = super().save()
self.instance.dates.all().delete() self.instance.dates.all().delete()
if self.instance.type == "EVENT" or self.instance.type == "CALL": if self.instance.type == "EVENT" or self.instance.type == "CALL":
NewsDate( NewsDate(
@ -252,24 +251,10 @@ class NewsEditView(CanEditMixin, UpdateView):
pk_url_kwarg = "news_id" pk_url_kwarg = "news_id"
def get_initial(self): def get_initial(self):
init = {} news_date: NewsDate = self.object.dates.order_by("id").first()
try: if news_date is None:
init["start_date"] = ( return {"start_date": None, "end_date": None}
self.object.dates.order_by("id") return {"start_date": news_date.start_date, "end_date": news_date.end_date}
.first()
.start_date.strftime("%Y-%m-%d %H:%M:%S")
)
except:
pass
try:
init["end_date"] = (
self.object.dates.order_by("id")
.first()
.end_date.strftime("%Y-%m-%d %H:%M:%S")
)
except:
pass
return init
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.get_form() form = self.get_form()
@ -302,7 +287,7 @@ class NewsEditView(CanEditMixin, UpdateView):
), ),
type="NEWS_MODERATION", type="NEWS_MODERATION",
).save() ).save()
return super(NewsEditView, self).form_valid(form) return super().form_valid(form)
class NewsCreateView(CanCreateMixin, CreateView): class NewsCreateView(CanCreateMixin, CreateView):
@ -312,10 +297,9 @@ class NewsCreateView(CanCreateMixin, CreateView):
def get_initial(self): def get_initial(self):
init = {"author": self.request.user} init = {"author": self.request.user}
try: if "club" not in self.request.GET:
init["club"] = Club.objects.filter(id=self.request.GET["club"]).first() return init
except: init["club"] = Club.objects.filter(id=self.request.GET["club"]).first()
pass
return init return init
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
@ -346,7 +330,7 @@ class NewsCreateView(CanCreateMixin, CreateView):
url=reverse("com:news_admin_list"), url=reverse("com:news_admin_list"),
type="NEWS_MODERATION", type="NEWS_MODERATION",
).save() ).save()
return super(NewsCreateView, self).form_valid(form) return super().form_valid(form)
class NewsDeleteView(CanEditMixin, DeleteView): class NewsDeleteView(CanEditMixin, DeleteView):
@ -385,7 +369,7 @@ class NewsListView(CanViewMixin, ListView):
queryset = News.objects.filter(is_moderated=True) queryset = News.objects.filter(is_moderated=True)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(NewsListView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["NewsDate"] = NewsDate kwargs["NewsDate"] = NewsDate
kwargs["timedelta"] = timedelta kwargs["timedelta"] = timedelta
kwargs["birthdays"] = ( kwargs["birthdays"] = (
@ -416,7 +400,7 @@ class WeekmailPreviewView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, Detai
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
self.bad_recipients = [] self.bad_recipients = []
return super(WeekmailPreviewView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
@ -437,14 +421,14 @@ class WeekmailPreviewView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, Detai
u.preferences.receive_weekmail = False u.preferences.receive_weekmail = False
u.preferences.save() u.preferences.save()
self.quick_notif_list += ["qn_success"] self.quick_notif_list += ["qn_success"]
return super(WeekmailPreviewView, self).get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
def get_object(self, queryset=None): def get_object(self, queryset=None):
return self.model.objects.filter(sent=False).order_by("-id").first() return self.model.objects.filter(sent=False).order_by("-id").first()
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add rendered weekmail""" """Add rendered weekmail"""
kwargs = super(WeekmailPreviewView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["weekmail_rendered"] = self.object.render_html() kwargs["weekmail_rendered"] = self.object.render_html()
kwargs["bad_recipients"] = self.bad_recipients kwargs["bad_recipients"] = self.bad_recipients
return kwargs return kwargs
@ -520,11 +504,11 @@ class WeekmailEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, UpdateVi
art.rank = -1 art.rank = -1
art.save() art.save()
self.quick_notif_list += ["qn_success"] self.quick_notif_list += ["qn_success"]
return super(WeekmailEditView, self).get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Add orphan articles""" """Add orphan articles"""
kwargs = super(WeekmailEditView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["orphans"] = WeekmailArticle.objects.filter(weekmail=None) kwargs["orphans"] = WeekmailArticle.objects.filter(weekmail=None)
return kwargs return kwargs
@ -561,22 +545,16 @@ class WeekmailArticleCreateView(QuickNotifMixin, CreateView):
quick_notif_url_arg = "qn_weekmail_new_article" quick_notif_url_arg = "qn_weekmail_new_article"
def get_initial(self): def get_initial(self):
init = {} if "club" not in self.request.GET:
try: return {}
init["club"] = Club.objects.filter(id=self.request.GET["club"]).first() return {"club": Club.objects.filter(id=self.request.GET.get("club")).first()}
except:
pass
return init
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.get_form() form = self.get_form()
self.object = form.instance self.object = form.instance
form.is_valid() #  Valid a first time to populate club field form.is_valid() # Valid a first time to populate club field
try: m = form.instance.club.get_membership_for(request.user)
m = form.instance.club.get_membership_for(request.user) if m is None or m.role <= settings.SITH_MAXIMUM_FREE_ROLE:
if m.role <= settings.SITH_MAXIMUM_FREE_ROLE:
raise
except:
form.add_error( form.add_error(
"club", "club",
ValidationError( ValidationError(
@ -592,7 +570,7 @@ class WeekmailArticleCreateView(QuickNotifMixin, CreateView):
def form_valid(self, form): def form_valid(self, form):
form.instance.author = self.request.user form.instance.author = self.request.user
return super(WeekmailArticleCreateView, self).form_valid(form) return super().form_valid(form)
class WeekmailArticleDeleteView(CanEditPropMixin, DeleteView): class WeekmailArticleDeleteView(CanEditPropMixin, DeleteView):
@ -612,10 +590,10 @@ class MailingListAdminView(ComTabsMixin, ListView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
if not (request.user.is_com_admin or request.user.is_root): if not (request.user.is_com_admin or request.user.is_root):
raise PermissionDenied raise PermissionDenied
return super(MailingListAdminView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(MailingListAdminView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["moderated"] = self.get_queryset().filter(is_moderated=True).all() kwargs["moderated"] = self.get_queryset().filter(is_moderated=True).all()
kwargs["unmoderated"] = self.get_queryset().filter(is_moderated=False).all() kwargs["unmoderated"] = self.get_queryset().filter(is_moderated=False).all()
kwargs["has_moderated"] = len(kwargs["moderated"]) > 0 kwargs["has_moderated"] = len(kwargs["moderated"]) > 0
@ -647,7 +625,7 @@ class PosterListBaseView(ListView):
self.club = None self.club = None
if club_id: if club_id:
self.club = get_object_or_404(Club, pk=club_id) self.club = get_object_or_404(Club, pk=club_id)
return super(PosterListBaseView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
if self.request.user.is_com_admin: if self.request.user.is_com_admin:
@ -656,7 +634,7 @@ class PosterListBaseView(ListView):
return Poster.objects.filter(club=self.club.id) return Poster.objects.filter(club=self.club.id)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterListBaseView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
if not self.request.user.is_com_admin: if not self.request.user.is_com_admin:
kwargs["club"] = self.club kwargs["club"] = self.club
return kwargs return kwargs
@ -675,15 +653,15 @@ class PosterCreateBaseView(CreateView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
if "club_id" in kwargs: if "club_id" in kwargs:
self.club = get_object_or_404(Club, pk=kwargs["club_id"]) self.club = get_object_or_404(Club, pk=kwargs["club_id"])
return super(PosterCreateBaseView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super(PosterCreateBaseView, self).get_form_kwargs() kwargs = super().get_form_kwargs()
kwargs.update({"user": self.request.user}) kwargs.update({"user": self.request.user})
return kwargs return kwargs
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterCreateBaseView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
if not self.request.user.is_com_admin: if not self.request.user.is_com_admin:
kwargs["club"] = self.club kwargs["club"] = self.club
return kwargs return kwargs
@ -691,7 +669,7 @@ class PosterCreateBaseView(CreateView):
def form_valid(self, form): def form_valid(self, form):
if self.request.user.is_com_admin: if self.request.user.is_com_admin:
form.instance.is_moderated = True form.instance.is_moderated = True
return super(PosterCreateBaseView, self).form_valid(form) return super().form_valid(form)
class PosterEditBaseView(UpdateView): class PosterEditBaseView(UpdateView):
@ -718,20 +696,20 @@ class PosterEditBaseView(UpdateView):
if "club_id" in kwargs and kwargs["club_id"]: if "club_id" in kwargs and kwargs["club_id"]:
try: try:
self.club = Club.objects.get(pk=kwargs["club_id"]) self.club = Club.objects.get(pk=kwargs["club_id"])
except Club.DoesNotExist: except Club.DoesNotExist as e:
raise PermissionDenied raise PermissionDenied from e
return super(PosterEditBaseView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
return Poster.objects.all() return Poster.objects.all()
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super(PosterEditBaseView, self).get_form_kwargs() kwargs = super().get_form_kwargs()
kwargs.update({"user": self.request.user}) kwargs.update({"user": self.request.user})
return kwargs return kwargs
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterEditBaseView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
if hasattr(self, "club"): if hasattr(self, "club"):
kwargs["club"] = self.club kwargs["club"] = self.club
return kwargs return kwargs
@ -739,7 +717,7 @@ class PosterEditBaseView(UpdateView):
def form_valid(self, form): def form_valid(self, form):
if self.request.user.is_com_admin: if self.request.user.is_com_admin:
form.instance.is_moderated = False form.instance.is_moderated = False
return super(PosterEditBaseView, self).form_valid(form) return super().form_valid(form)
class PosterDeleteBaseView(DeleteView): class PosterDeleteBaseView(DeleteView):
@ -754,16 +732,16 @@ class PosterDeleteBaseView(DeleteView):
if "club_id" in kwargs and kwargs["club_id"]: if "club_id" in kwargs and kwargs["club_id"]:
try: try:
self.club = Club.objects.get(pk=kwargs["club_id"]) self.club = Club.objects.get(pk=kwargs["club_id"])
except Club.DoesNotExist: except Club.DoesNotExist as e:
raise PermissionDenied raise PermissionDenied from e
return super(PosterDeleteBaseView, self).dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
class PosterListView(IsComAdminMixin, ComTabsMixin, PosterListBaseView): class PosterListView(IsComAdminMixin, ComTabsMixin, PosterListBaseView):
"""List communication posters""" """List communication posters"""
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterListView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["app"] = "com" kwargs["app"] = "com"
return kwargs return kwargs
@ -774,7 +752,7 @@ class PosterCreateView(IsComAdminMixin, ComTabsMixin, PosterCreateBaseView):
success_url = reverse_lazy("com:poster_list") success_url = reverse_lazy("com:poster_list")
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterCreateView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["app"] = "com" kwargs["app"] = "com"
return kwargs return kwargs
@ -785,7 +763,7 @@ class PosterEditView(IsComAdminMixin, ComTabsMixin, PosterEditBaseView):
success_url = reverse_lazy("com:poster_list") success_url = reverse_lazy("com:poster_list")
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterEditView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["app"] = "com" kwargs["app"] = "com"
return kwargs return kwargs
@ -805,7 +783,7 @@ class PosterModerateListView(IsComAdminMixin, ComTabsMixin, ListView):
queryset = Poster.objects.filter(is_moderated=False).all() queryset = Poster.objects.filter(is_moderated=False).all()
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(PosterModerateListView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["app"] = "com" kwargs["app"] = "com"
return kwargs return kwargs
@ -844,7 +822,7 @@ class ScreenSlideshowView(DetailView):
template_name = "com/screen_slideshow.jinja" template_name = "com/screen_slideshow.jinja"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(ScreenSlideshowView, self).get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)
kwargs["posters"] = self.object.active_posters() kwargs["posters"] = self.object.active_posters()
return kwargs return kwargs

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2017 # Copyright 2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2018 # Copyright 2018
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding:utf-8 -*
# #
# Copyright 2019 # Copyright 2019
# - Sli <antoine@bartuccio.fr> # - Sli <antoine@bartuccio.fr>
@ -41,4 +40,4 @@ class Command(compilemessages.Command):
def handle(self, *args, **options): def handle(self, *args, **options):
os.chdir("sith") os.chdir("sith")
super(Command, self).handle(*args, **options) super().handle(*args, **options)

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding:utf-8 -*
# #
# Copyright 2017 # Copyright 2017
# - Sli <antoine@bartuccio.fr> # - Sli <antoine@bartuccio.fr>

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding:utf-8 -*
# #
# Copyright 2019 # Copyright 2019
# - Sli <antoine@bartuccio.fr> # - Sli <antoine@bartuccio.fr>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2024 © AE UTBM # Copyright 2024 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2017 # Copyright 2017
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2016,2017,2023 # Copyright 2016,2017,2023
# - Skia <skia@hya.sk> # - Skia <skia@hya.sk>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2018 # Copyright 2018
# - Skia <skia@libskia.so> # - Skia <skia@libskia.so>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr
@ -51,13 +50,11 @@ class SithRenderer(Renderer):
if not width.endswith("%"): if not width.endswith("%"):
width += "px" width += "px"
style = "width: %s; " % width style = "width: %s; " % width
try: height = m.group(3)
height = m.group(3) if height is not None:
if not height.endswith("%"): if not height.endswith("%"):
height += "px" height += "px"
style += "height: %s; " % height style += "height: %s; " % height
except:
pass
else: else:
params = None params = None
src = original_src src = original_src
@ -163,7 +160,7 @@ class SithInlineLexer(InlineLexer):
link = reverse("core:file_detail", kwargs={"file_id": id}) + suffix link = reverse("core:file_detail", kwargs={"file_id": id}) + suffix
except: except:
pass pass
return super(SithInlineLexer, self)._process_link(m, link, title) return super()._process_link(m, link, title)
renderer = SithRenderer(escape=True) renderer = SithRenderer(escape=True)

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
# #
# Copyright 2023 © AE UTBM # Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr # ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.contrib.auth.models import django.contrib.auth.models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.core.validators import django.core.validators

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings from django.conf import settings

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.utils.timezone import django.utils.timezone

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.core.validators import django.core.validators

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.core.validators import django.core.validators

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import django.db.models.deletion import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-07-04 13:00 # Generated by Django 1.11.20 on 2019-07-04 13:00
from __future__ import unicode_literals from __future__ import unicode_literals

Some files were not shown because too many files have changed in this diff Show More