mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-21 21:53:30 +00:00
ruff rules UP008 and UP009
This commit is contained in:
parent
688871a680
commit
cfc19434d0
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.core.validators
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import phonenumber_field.modelfields
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
@ -37,11 +36,11 @@ class CurrencyField(models.DecimalField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs["max_digits"] = 12
|
||||
kwargs["decimal_places"] = 2
|
||||
super(CurrencyField, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def to_python(self, value):
|
||||
try:
|
||||
return super(CurrencyField, self).to_python(value).quantize(Decimal("0.01"))
|
||||
return super().to_python(value).quantize(Decimal("0.01"))
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
@ -364,7 +363,7 @@ class Operation(models.Model):
|
||||
return object.__getattribute__(self, attr)
|
||||
|
||||
def clean(self):
|
||||
super(Operation, self).clean()
|
||||
super().clean()
|
||||
if self.date is None:
|
||||
raise ValidationError(_("The date must be set."))
|
||||
elif self.date < self.journal.start_date:
|
||||
@ -413,7 +412,7 @@ class Operation(models.Model):
|
||||
def save(self):
|
||||
if self.number is None:
|
||||
self.number = self.journal.operations.count() + 1
|
||||
super(Operation, self).save()
|
||||
super().save()
|
||||
self.journal.update_amounts()
|
||||
|
||||
def is_owned_by(self, user):
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
@ -210,7 +209,7 @@ class ClubAccountCreateView(CanCreateMixin, CreateView):
|
||||
template_name = "core/create.jinja"
|
||||
|
||||
def get_initial(self):
|
||||
ret = super(ClubAccountCreateView, self).get_initial()
|
||||
ret = super().get_initial()
|
||||
if "parent" in self.request.GET.keys():
|
||||
obj = BankAccount.objects.filter(id=int(self.request.GET["parent"])).first()
|
||||
if obj is not None:
|
||||
@ -296,7 +295,7 @@ class JournalCreateView(CanCreateMixin, CreateView):
|
||||
template_name = "core/create.jinja"
|
||||
|
||||
def get_initial(self):
|
||||
ret = super(JournalCreateView, self).get_initial()
|
||||
ret = super().get_initial()
|
||||
if "parent" in self.request.GET.keys():
|
||||
obj = ClubAccount.objects.filter(id=int(self.request.GET["parent"])).first()
|
||||
if obj is not None:
|
||||
@ -339,7 +338,7 @@ class JournalDeleteView(CanEditPropMixin, DeleteView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
if self.object.operations.count() == 0:
|
||||
return super(JournalDeleteView, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
else:
|
||||
raise PermissionDenied
|
||||
|
||||
@ -387,7 +386,7 @@ class OperationForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
club_account = kwargs.pop("club_account", None)
|
||||
super(OperationForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
if club_account:
|
||||
self.fields["label"].queryset = club_account.labels.order_by("name").all()
|
||||
if self.instance.target_type == "USER":
|
||||
@ -400,7 +399,7 @@ class OperationForm(forms.ModelForm):
|
||||
self.fields["company"].initial = self.instance.target_id
|
||||
|
||||
def clean(self):
|
||||
self.cleaned_data = super(OperationForm, self).clean()
|
||||
self.cleaned_data = super().clean()
|
||||
if "target_type" in self.cleaned_data.keys():
|
||||
if (
|
||||
self.cleaned_data.get("user") is None
|
||||
@ -430,7 +429,7 @@ class OperationForm(forms.ModelForm):
|
||||
return self.cleaned_data
|
||||
|
||||
def save(self):
|
||||
ret = super(OperationForm, self).save()
|
||||
ret = super().save()
|
||||
if (
|
||||
self.instance.target_type == "ACCOUNT"
|
||||
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())
|
||||
|
||||
def get_initial(self):
|
||||
ret = super(OperationCreateView, self).get_initial()
|
||||
ret = super().get_initial()
|
||||
if self.journal is not None:
|
||||
ret["journal"] = self.journal.id
|
||||
return ret
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add journal to the context"""
|
||||
kwargs = super(OperationCreateView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
if self.journal:
|
||||
kwargs["object"] = self.journal
|
||||
return kwargs
|
||||
@ -507,7 +506,7 @@ class OperationEditView(CanEditMixin, UpdateView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add journal to the context"""
|
||||
kwargs = super(OperationEditView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["object"] = self.object.journal
|
||||
return kwargs
|
||||
|
||||
@ -728,7 +727,7 @@ class JournalNatureStatementView(JournalTabsMixin, CanViewMixin, DetailView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add infos to the context"""
|
||||
kwargs = super(JournalNatureStatementView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["statement"] = self.big_statement()
|
||||
return kwargs
|
||||
|
||||
@ -767,7 +766,7 @@ class JournalPersonStatementView(JournalTabsMixin, CanViewMixin, DetailView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""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["debit_statement"] = self.statement("DEBIT")
|
||||
kwargs["total_credit"] = self.total("CREDIT")
|
||||
@ -797,7 +796,7 @@ class JournalAccountingStatementView(JournalTabsMixin, CanViewMixin, DetailView)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add journal to the context"""
|
||||
kwargs = super(JournalAccountingStatementView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["statement"] = self.statement()
|
||||
return kwargs
|
||||
|
||||
@ -852,7 +851,7 @@ class LabelCreateView(
|
||||
template_name = "core/create.jinja"
|
||||
|
||||
def get_initial(self):
|
||||
ret = super(LabelCreateView, self).get_initial()
|
||||
ret = super().get_initial()
|
||||
if "parent" in self.request.GET.keys():
|
||||
obj = ClubAccount.objects.filter(id=int(self.request.GET["parent"])).first()
|
||||
if obj is not None:
|
||||
@ -897,19 +896,19 @@ class RefoundAccountView(FormView):
|
||||
raise PermissionDenied
|
||||
|
||||
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):
|
||||
return res
|
||||
|
||||
def post(self, request, *arg, **kwargs):
|
||||
self.operator = 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):
|
||||
self.customer = form.cleaned_data["user"]
|
||||
self.create_selling()
|
||||
return super(RefoundAccountView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("accounting:refound_account")
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
@ -50,7 +49,7 @@ class ManageModelMixin:
|
||||
|
||||
class RightModelViewSet(ManageModelMixin, viewsets.ModelViewSet):
|
||||
def dispatch(self, request, *arg, **kwargs):
|
||||
res = super(RightModelViewSet, self).dispatch(request, *arg, **kwargs)
|
||||
res = super().dispatch(request, *arg, **kwargs)
|
||||
obj = self.queryset
|
||||
user = self.request.user
|
||||
try:
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
@ -40,7 +39,7 @@ class ClubEditForm(forms.ModelForm):
|
||||
fields = ["address", "logo", "short_description"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ClubEditForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
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):
|
||||
super(MailingForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.fields["action"] = forms.TypedChoiceField(
|
||||
choices=(
|
||||
@ -116,7 +115,7 @@ class MailingForm(forms.Form):
|
||||
"""
|
||||
Convert given users into real users and check their validity
|
||||
"""
|
||||
cleaned_data = super(MailingForm, self).clean()
|
||||
cleaned_data = super().clean()
|
||||
users = []
|
||||
for user in cleaned_data["subscription_users"]:
|
||||
user = User.objects.filter(id=user).first()
|
||||
@ -133,7 +132,7 @@ class MailingForm(forms.Form):
|
||||
return users
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(MailingForm, self).clean()
|
||||
cleaned_data = super().clean()
|
||||
|
||||
if not "action" in cleaned_data:
|
||||
# If there is no action provided, we can stop here
|
||||
@ -164,7 +163,7 @@ class SellingsForm(forms.Form):
|
||||
)
|
||||
|
||||
def __init__(self, club, *args, **kwargs):
|
||||
super(SellingsForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["products"] = forms.ModelMultipleChoiceField(
|
||||
club.products.order_by("name").filter(archived=False).all(),
|
||||
label=_("Products"),
|
||||
@ -201,7 +200,7 @@ class ClubMemberForm(forms.Form):
|
||||
self.club.members.filter(end_date=None).order_by("-role").all()
|
||||
)
|
||||
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
|
||||
# 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
|
||||
Also check that the user is valid and has a valid subscription
|
||||
"""
|
||||
cleaned_data = super(ClubMemberForm, self).clean()
|
||||
cleaned_data = super().clean()
|
||||
users = []
|
||||
for user_id in cleaned_data["users"]:
|
||||
user = User.objects.filter(id=user_id).first()
|
||||
@ -264,7 +263,7 @@ class ClubMemberForm(forms.Form):
|
||||
"""
|
||||
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"]:
|
||||
# Drop start_date if allowed to edition but not specified
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.core.validators
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.utils.timezone
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
@ -190,7 +189,7 @@ class Club(models.Model):
|
||||
creation = old is None
|
||||
if not creation and old.unix_name != self.unix_name:
|
||||
self._change_unixname(self.unix_name)
|
||||
super(Club, self).save(*args, **kwargs)
|
||||
super().save(*args, **kwargs)
|
||||
if creation:
|
||||
board = MetaGroup(name=self.unix_name + settings.SITH_BOARD_SUFFIX)
|
||||
board.save()
|
||||
@ -459,7 +458,7 @@ class Mailing(models.Model):
|
||||
self.is_moderated = True
|
||||
else:
|
||||
self.moderator = None
|
||||
super(Mailing, self).clean()
|
||||
super().clean()
|
||||
|
||||
@property
|
||||
def email_full(self):
|
||||
@ -481,7 +480,7 @@ class Mailing(models.Model):
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
self.subscriptions.all().delete()
|
||||
super(Mailing, self).delete()
|
||||
super().delete()
|
||||
|
||||
def fetch_format(self):
|
||||
resp = self.email + ": "
|
||||
@ -504,7 +503,7 @@ class Mailing(models.Model):
|
||||
url=reverse("com:mailing_admin"),
|
||||
type="MAILING_MODERATION",
|
||||
).save()
|
||||
super(Mailing, self).save()
|
||||
super().save()
|
||||
|
||||
def __str__(self):
|
||||
return "%s - %s" % (self.club, self.email_full)
|
||||
@ -550,7 +549,7 @@ class MailingSubscription(models.Model):
|
||||
)
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
super(MailingSubscription, self).clean()
|
||||
super().clean()
|
||||
|
||||
def is_owned_by(self, user):
|
||||
if user.is_anonymous:
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
@ -195,7 +194,7 @@ class ClubView(ClubTabsMixin, DetailView):
|
||||
current_tab = "infos"
|
||||
|
||||
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():
|
||||
kwargs["page_revision"] = self.object.page.revisions.last().content
|
||||
return kwargs
|
||||
@ -209,10 +208,10 @@ class ClubRevView(ClubView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
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):
|
||||
kwargs = super(ClubRevView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["page_revision"] = self.revision.content
|
||||
return kwargs
|
||||
|
||||
@ -225,7 +224,7 @@ class ClubPageEditView(ClubTabsMixin, PageEditViewBase):
|
||||
self.club = get_object_or_404(Club, pk=kwargs["club_id"])
|
||||
if not self.club.page:
|
||||
raise Http404
|
||||
return super(ClubPageEditView, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_object(self):
|
||||
self.page = self.club.page
|
||||
@ -269,14 +268,14 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, DetailFormView):
|
||||
current_tab = "members"
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(ClubMembersView, self).get_form_kwargs()
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["request_user"] = self.request.user
|
||||
kwargs["club"] = self.get_object()
|
||||
kwargs["club_members"] = self.members
|
||||
return 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
|
||||
return kwargs
|
||||
|
||||
@ -284,7 +283,7 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, DetailFormView):
|
||||
"""
|
||||
Check user rights
|
||||
"""
|
||||
resp = super(ClubMembersView, self).form_valid(form)
|
||||
resp = super().form_valid(form)
|
||||
|
||||
data = form.clean()
|
||||
users = data.pop("users", [])
|
||||
@ -299,7 +298,7 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, DetailFormView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
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):
|
||||
return reverse_lazy(
|
||||
@ -333,12 +332,12 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
try:
|
||||
self.asked_page = int(request.GET.get("page", 1))
|
||||
except ValueError:
|
||||
raise Http404
|
||||
return super(ClubSellingView, self).dispatch(request, *args, **kwargs)
|
||||
except ValueError as e:
|
||||
raise Http404 from e
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(ClubSellingView, self).get_form_kwargs()
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["club"] = self.object
|
||||
return kwargs
|
||||
|
||||
@ -346,7 +345,7 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
return self.get(request, *args, **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)
|
||||
|
||||
kwargs["result"] = qs[:0]
|
||||
@ -390,8 +389,8 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
kwargs["paginator"] = Paginator(kwargs["result"], self.paginate_by)
|
||||
try:
|
||||
kwargs["paginated_result"] = kwargs["paginator"].page(self.asked_page)
|
||||
except InvalidPage:
|
||||
raise Http404
|
||||
except InvalidPage as e:
|
||||
raise Http404 from e
|
||||
|
||||
return kwargs
|
||||
|
||||
@ -558,7 +557,7 @@ class ClubStatView(TemplateView):
|
||||
template_name = "club/stats.jinja"
|
||||
|
||||
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()
|
||||
return kwargs
|
||||
|
||||
@ -575,7 +574,7 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
current_tab = "mailing"
|
||||
|
||||
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["user_id"] = self.request.user.id
|
||||
kwargs["mailings"] = self.mailings
|
||||
@ -583,10 +582,10 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
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):
|
||||
kwargs = super(ClubMailingView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["club"] = self.get_object()
|
||||
kwargs["user"] = self.request.user
|
||||
kwargs["mailings"] = self.mailings
|
||||
@ -670,7 +669,7 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
sub.delete()
|
||||
|
||||
def form_valid(self, form):
|
||||
resp = super(ClubMailingView, self).form_valid(form)
|
||||
resp = super().form_valid(form)
|
||||
|
||||
cleaned_data = form.clean()
|
||||
error = None
|
||||
@ -702,7 +701,7 @@ class MailingDeleteView(CanEditMixin, DeleteView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
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):
|
||||
if self.redirect_page:
|
||||
@ -718,9 +717,7 @@ class MailingSubscriptionDeleteView(CanEditMixin, DeleteView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.club_id = self.get_object().mailing.club.id
|
||||
return super(MailingSubscriptionDeleteView, self).dispatch(
|
||||
request, *args, **kwargs
|
||||
)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_success_url(self, **kwargs):
|
||||
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"])
|
||||
if not request.user.can_edit(self.mailing):
|
||||
raise PermissionDenied
|
||||
return super(MailingAutoGenerationView, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
club = self.mailing.club
|
||||
@ -751,7 +748,7 @@ class PosterListView(ClubTabsMixin, PosterListBaseView, CanViewMixin):
|
||||
return self.club
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(PosterListView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["app"] = "club"
|
||||
kwargs["club"] = self.club
|
||||
return kwargs
|
||||
@ -763,7 +760,7 @@ class PosterCreateView(PosterCreateBaseView, CanCreateMixin):
|
||||
pk_url_kwarg = "club_id"
|
||||
|
||||
def get_object(self):
|
||||
obj = super(PosterCreateView, self).get_object()
|
||||
obj = super().get_object()
|
||||
if not obj:
|
||||
return self.club
|
||||
return obj
|
||||
@ -779,7 +776,7 @@ class PosterEditView(ClubTabsMixin, PosterEditBaseView, CanEditMixin):
|
||||
return reverse_lazy("club:poster_list", kwargs={"club_id": self.club.id})
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(PosterEditView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["app"] = "club"
|
||||
return kwargs
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.23 on 2019-08-18 17:00
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
@ -112,7 +111,7 @@ class News(models.Model):
|
||||
return "%s: %s" % (self.type, self.title)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(News, self).save(*args, **kwargs)
|
||||
super().save(*args, **kwargs)
|
||||
for u in (
|
||||
RealGroup.objects.filter(id=settings.SITH_GROUP_COM_ADMIN_ID)
|
||||
.first()
|
||||
@ -341,7 +340,7 @@ class Poster(models.Model):
|
||||
url=reverse("com:poster_moderate_list"),
|
||||
type="POSTER_MODERATION",
|
||||
).save()
|
||||
return super(Poster, self).save(*args, **kwargs)
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
def clean(self, *args, **kwargs):
|
||||
if self.date_end and self.date_begin > self.date_end:
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
118
com/views.py
118
com/views.py
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
@ -82,7 +81,7 @@ class PosterForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop("user", None)
|
||||
super(PosterForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
if self.user:
|
||||
if not self.user.is_com_admin:
|
||||
self.fields["club"].queryset = Club.objects.filter(
|
||||
@ -145,7 +144,7 @@ class IsComAdminMixin(View):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not request.user.is_com_admin:
|
||||
raise PermissionDenied
|
||||
return super(IsComAdminMixin, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class ComEditView(ComTabsMixin, CanEditPropMixin, UpdateView):
|
||||
@ -199,7 +198,7 @@ class NewsForm(forms.ModelForm):
|
||||
automoderation = forms.BooleanField(label=_("Automoderation"), required=False)
|
||||
|
||||
def clean(self):
|
||||
self.cleaned_data = super(NewsForm, self).clean()
|
||||
self.cleaned_data = super().clean()
|
||||
if self.cleaned_data["type"] != "NOTICE":
|
||||
if not self.cleaned_data["start_date"]:
|
||||
self.add_error(
|
||||
@ -225,7 +224,7 @@ class NewsForm(forms.ModelForm):
|
||||
return self.cleaned_data
|
||||
|
||||
def save(self):
|
||||
ret = super(NewsForm, self).save()
|
||||
ret = super().save()
|
||||
self.instance.dates.all().delete()
|
||||
if self.instance.type == "EVENT" or self.instance.type == "CALL":
|
||||
NewsDate(
|
||||
@ -252,24 +251,10 @@ class NewsEditView(CanEditMixin, UpdateView):
|
||||
pk_url_kwarg = "news_id"
|
||||
|
||||
def get_initial(self):
|
||||
init = {}
|
||||
try:
|
||||
init["start_date"] = (
|
||||
self.object.dates.order_by("id")
|
||||
.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
|
||||
news_date: NewsDate = self.object.dates.order_by("id").first()
|
||||
if news_date is None:
|
||||
return {"start_date": None, "end_date": None}
|
||||
return {"start_date": news_date.start_date, "end_date": news_date.end_date}
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
form = self.get_form()
|
||||
@ -302,7 +287,7 @@ class NewsEditView(CanEditMixin, UpdateView):
|
||||
),
|
||||
type="NEWS_MODERATION",
|
||||
).save()
|
||||
return super(NewsEditView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class NewsCreateView(CanCreateMixin, CreateView):
|
||||
@ -312,10 +297,9 @@ class NewsCreateView(CanCreateMixin, CreateView):
|
||||
|
||||
def get_initial(self):
|
||||
init = {"author": self.request.user}
|
||||
try:
|
||||
init["club"] = Club.objects.filter(id=self.request.GET["club"]).first()
|
||||
except:
|
||||
pass
|
||||
if "club" not in self.request.GET:
|
||||
return init
|
||||
init["club"] = Club.objects.filter(id=self.request.GET["club"]).first()
|
||||
return init
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
@ -346,7 +330,7 @@ class NewsCreateView(CanCreateMixin, CreateView):
|
||||
url=reverse("com:news_admin_list"),
|
||||
type="NEWS_MODERATION",
|
||||
).save()
|
||||
return super(NewsCreateView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class NewsDeleteView(CanEditMixin, DeleteView):
|
||||
@ -385,7 +369,7 @@ class NewsListView(CanViewMixin, ListView):
|
||||
queryset = News.objects.filter(is_moderated=True)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(NewsListView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["NewsDate"] = NewsDate
|
||||
kwargs["timedelta"] = timedelta
|
||||
kwargs["birthdays"] = (
|
||||
@ -416,7 +400,7 @@ class WeekmailPreviewView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, Detai
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.bad_recipients = []
|
||||
return super(WeekmailPreviewView, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
@ -437,14 +421,14 @@ class WeekmailPreviewView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, Detai
|
||||
u.preferences.receive_weekmail = False
|
||||
u.preferences.save()
|
||||
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):
|
||||
return self.model.objects.filter(sent=False).order_by("-id").first()
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""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["bad_recipients"] = self.bad_recipients
|
||||
return kwargs
|
||||
@ -520,11 +504,11 @@ class WeekmailEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, UpdateVi
|
||||
art.rank = -1
|
||||
art.save()
|
||||
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):
|
||||
"""Add orphan articles"""
|
||||
kwargs = super(WeekmailEditView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["orphans"] = WeekmailArticle.objects.filter(weekmail=None)
|
||||
return kwargs
|
||||
|
||||
@ -561,22 +545,16 @@ class WeekmailArticleCreateView(QuickNotifMixin, CreateView):
|
||||
quick_notif_url_arg = "qn_weekmail_new_article"
|
||||
|
||||
def get_initial(self):
|
||||
init = {}
|
||||
try:
|
||||
init["club"] = Club.objects.filter(id=self.request.GET["club"]).first()
|
||||
except:
|
||||
pass
|
||||
return init
|
||||
if "club" not in self.request.GET:
|
||||
return {}
|
||||
return {"club": Club.objects.filter(id=self.request.GET.get("club")).first()}
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
form = self.get_form()
|
||||
self.object = form.instance
|
||||
form.is_valid() # Valid a first time to populate club field
|
||||
try:
|
||||
m = form.instance.club.get_membership_for(request.user)
|
||||
if m.role <= settings.SITH_MAXIMUM_FREE_ROLE:
|
||||
raise
|
||||
except:
|
||||
form.is_valid() # Valid a first time to populate club field
|
||||
m = form.instance.club.get_membership_for(request.user)
|
||||
if m is None or m.role <= settings.SITH_MAXIMUM_FREE_ROLE:
|
||||
form.add_error(
|
||||
"club",
|
||||
ValidationError(
|
||||
@ -592,7 +570,7 @@ class WeekmailArticleCreateView(QuickNotifMixin, CreateView):
|
||||
|
||||
def form_valid(self, form):
|
||||
form.instance.author = self.request.user
|
||||
return super(WeekmailArticleCreateView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class WeekmailArticleDeleteView(CanEditPropMixin, DeleteView):
|
||||
@ -612,10 +590,10 @@ class MailingListAdminView(ComTabsMixin, ListView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not (request.user.is_com_admin or request.user.is_root):
|
||||
raise PermissionDenied
|
||||
return super(MailingListAdminView, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **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["unmoderated"] = self.get_queryset().filter(is_moderated=False).all()
|
||||
kwargs["has_moderated"] = len(kwargs["moderated"]) > 0
|
||||
@ -647,7 +625,7 @@ class PosterListBaseView(ListView):
|
||||
self.club = None
|
||||
if 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):
|
||||
if self.request.user.is_com_admin:
|
||||
@ -656,7 +634,7 @@ class PosterListBaseView(ListView):
|
||||
return Poster.objects.filter(club=self.club.id)
|
||||
|
||||
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:
|
||||
kwargs["club"] = self.club
|
||||
return kwargs
|
||||
@ -675,15 +653,15 @@ class PosterCreateBaseView(CreateView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if "club_id" in kwargs:
|
||||
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):
|
||||
kwargs = super(PosterCreateBaseView, self).get_form_kwargs()
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs.update({"user": self.request.user})
|
||||
return 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:
|
||||
kwargs["club"] = self.club
|
||||
return kwargs
|
||||
@ -691,7 +669,7 @@ class PosterCreateBaseView(CreateView):
|
||||
def form_valid(self, form):
|
||||
if self.request.user.is_com_admin:
|
||||
form.instance.is_moderated = True
|
||||
return super(PosterCreateBaseView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class PosterEditBaseView(UpdateView):
|
||||
@ -718,20 +696,20 @@ class PosterEditBaseView(UpdateView):
|
||||
if "club_id" in kwargs and kwargs["club_id"]:
|
||||
try:
|
||||
self.club = Club.objects.get(pk=kwargs["club_id"])
|
||||
except Club.DoesNotExist:
|
||||
raise PermissionDenied
|
||||
return super(PosterEditBaseView, self).dispatch(request, *args, **kwargs)
|
||||
except Club.DoesNotExist as e:
|
||||
raise PermissionDenied from e
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return Poster.objects.all()
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(PosterEditBaseView, self).get_form_kwargs()
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs.update({"user": self.request.user})
|
||||
return 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"):
|
||||
kwargs["club"] = self.club
|
||||
return kwargs
|
||||
@ -739,7 +717,7 @@ class PosterEditBaseView(UpdateView):
|
||||
def form_valid(self, form):
|
||||
if self.request.user.is_com_admin:
|
||||
form.instance.is_moderated = False
|
||||
return super(PosterEditBaseView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class PosterDeleteBaseView(DeleteView):
|
||||
@ -754,16 +732,16 @@ class PosterDeleteBaseView(DeleteView):
|
||||
if "club_id" in kwargs and kwargs["club_id"]:
|
||||
try:
|
||||
self.club = Club.objects.get(pk=kwargs["club_id"])
|
||||
except Club.DoesNotExist:
|
||||
raise PermissionDenied
|
||||
return super(PosterDeleteBaseView, self).dispatch(request, *args, **kwargs)
|
||||
except Club.DoesNotExist as e:
|
||||
raise PermissionDenied from e
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class PosterListView(IsComAdminMixin, ComTabsMixin, PosterListBaseView):
|
||||
"""List communication posters"""
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(PosterListView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["app"] = "com"
|
||||
return kwargs
|
||||
|
||||
@ -774,7 +752,7 @@ class PosterCreateView(IsComAdminMixin, ComTabsMixin, PosterCreateBaseView):
|
||||
success_url = reverse_lazy("com:poster_list")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(PosterCreateView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["app"] = "com"
|
||||
return kwargs
|
||||
|
||||
@ -785,7 +763,7 @@ class PosterEditView(IsComAdminMixin, ComTabsMixin, PosterEditBaseView):
|
||||
success_url = reverse_lazy("com:poster_list")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(PosterEditView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["app"] = "com"
|
||||
return kwargs
|
||||
|
||||
@ -805,7 +783,7 @@ class PosterModerateListView(IsComAdminMixin, ComTabsMixin, ListView):
|
||||
queryset = Poster.objects.filter(is_moderated=False).all()
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(PosterModerateListView, self).get_context_data(**kwargs)
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["app"] = "com"
|
||||
return kwargs
|
||||
|
||||
@ -844,7 +822,7 @@ class ScreenSlideshowView(DetailView):
|
||||
template_name = "com/screen_slideshow.jinja"
|
||||
|
||||
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()
|
||||
return kwargs
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Skia <skia@libskia.so>
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2018
|
||||
# - Skia <skia@libskia.so>
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2019
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
@ -41,4 +40,4 @@ class Command(compilemessages.Command):
|
||||
|
||||
def handle(self, *args, **options):
|
||||
os.chdir("sith")
|
||||
super(Command, self).handle(*args, **options)
|
||||
super().handle(*args, **options)
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2019
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2024 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Skia <skia@libskia.so>
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2016,2017,2023
|
||||
# - Skia <skia@hya.sk>
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2018
|
||||
# - Skia <skia@libskia.so>
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
@ -51,13 +50,11 @@ class SithRenderer(Renderer):
|
||||
if not width.endswith("%"):
|
||||
width += "px"
|
||||
style = "width: %s; " % width
|
||||
try:
|
||||
height = m.group(3)
|
||||
height = m.group(3)
|
||||
if height is not None:
|
||||
if not height.endswith("%"):
|
||||
height += "px"
|
||||
style += "height: %s; " % height
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
params = None
|
||||
src = original_src
|
||||
@ -163,7 +160,7 @@ class SithInlineLexer(InlineLexer):
|
||||
link = reverse("core:file_detail", kwargs={"file_id": id}) + suffix
|
||||
except:
|
||||
pass
|
||||
return super(SithInlineLexer, self)._process_link(m, link, title)
|
||||
return super()._process_link(m, link, title)
|
||||
|
||||
|
||||
renderer = SithRenderer(escape=True)
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.contrib.auth.models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.core.validators
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.utils.timezone
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.core.validators
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.core.validators
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.20 on 2019-07-04 13:00
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user