mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-24 18:14:22 +00:00
Club: blackify view file
This commit is contained in:
parent
88d6f8dc8a
commit
0581c667de
488
club/views.py
488
club/views.py
@ -37,13 +37,25 @@ from ajax_select.fields import AutoCompleteSelectField
|
|||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
|
|
||||||
from core.views import CanCreateMixin, CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, PageEditViewBase
|
from core.views import (
|
||||||
|
CanCreateMixin,
|
||||||
|
CanViewMixin,
|
||||||
|
CanEditMixin,
|
||||||
|
CanEditPropMixin,
|
||||||
|
TabedViewMixin,
|
||||||
|
PageEditViewBase,
|
||||||
|
)
|
||||||
from core.views.forms import SelectDate, SelectDateTime
|
from core.views.forms import SelectDate, SelectDateTime
|
||||||
from club.models import Club, Membership, Mailing, MailingSubscription
|
from club.models import Club, Membership, Mailing, MailingSubscription
|
||||||
from sith.settings import SITH_MAXIMUM_FREE_ROLE
|
from sith.settings import SITH_MAXIMUM_FREE_ROLE
|
||||||
from counter.models import Selling, Counter
|
from counter.models import Selling, Counter
|
||||||
from core.models import User, PageRev
|
from core.models import User, PageRev
|
||||||
from com.views import PosterListBaseView, PosterCreateBaseView, PosterEditBaseView, PosterDeleteBaseView
|
from com.views import (
|
||||||
|
PosterListBaseView,
|
||||||
|
PosterCreateBaseView,
|
||||||
|
PosterEditBaseView,
|
||||||
|
PosterDeleteBaseView,
|
||||||
|
)
|
||||||
from com.models import Poster
|
from com.models import Poster
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -54,7 +66,7 @@ from django.conf import settings
|
|||||||
class ClubEditForm(forms.ModelForm):
|
class ClubEditForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Club
|
model = Club
|
||||||
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(ClubEditForm, self).__init__(*args, **kwargs)
|
||||||
@ -64,36 +76,40 @@ class ClubEditForm(forms.ModelForm):
|
|||||||
class MailingForm(forms.ModelForm):
|
class MailingForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Mailing
|
model = Mailing
|
||||||
fields = ('email', 'club', 'moderator')
|
fields = ("email", "club", "moderator")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
club_id = kwargs.pop('club_id', None)
|
club_id = kwargs.pop("club_id", None)
|
||||||
user_id = kwargs.pop('user_id', -1) # Remember 0 is treated as None
|
user_id = kwargs.pop("user_id", -1) # Remember 0 is treated as None
|
||||||
super(MailingForm, self).__init__(*args, **kwargs)
|
super(MailingForm, self).__init__(*args, **kwargs)
|
||||||
if club_id:
|
if club_id:
|
||||||
self.fields['club'].queryset = Club.objects.filter(id=club_id)
|
self.fields["club"].queryset = Club.objects.filter(id=club_id)
|
||||||
self.fields['club'].initial = club_id
|
self.fields["club"].initial = club_id
|
||||||
self.fields['club'].widget = forms.HiddenInput()
|
self.fields["club"].widget = forms.HiddenInput()
|
||||||
if user_id >= 0:
|
if user_id >= 0:
|
||||||
self.fields['moderator'].queryset = User.objects.filter(id=user_id)
|
self.fields["moderator"].queryset = User.objects.filter(id=user_id)
|
||||||
self.fields['moderator'].initial = user_id
|
self.fields["moderator"].initial = user_id
|
||||||
self.fields['moderator'].widget = forms.HiddenInput()
|
self.fields["moderator"].widget = forms.HiddenInput()
|
||||||
|
|
||||||
|
|
||||||
class MailingSubscriptionForm(forms.ModelForm):
|
class MailingSubscriptionForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MailingSubscription
|
model = MailingSubscription
|
||||||
fields = ('mailing', 'user', 'email')
|
fields = ("mailing", "user", "email")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.pop('user_id', None) # For standart interface
|
kwargs.pop("user_id", None) # For standart interface
|
||||||
club_id = kwargs.pop('club_id', None)
|
club_id = kwargs.pop("club_id", None)
|
||||||
super(MailingSubscriptionForm, self).__init__(*args, **kwargs)
|
super(MailingSubscriptionForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['email'].required = False
|
self.fields["email"].required = False
|
||||||
if club_id:
|
if club_id:
|
||||||
self.fields['mailing'].queryset = Mailing.objects.filter(club__id=club_id, is_moderated=True)
|
self.fields["mailing"].queryset = Mailing.objects.filter(
|
||||||
|
club__id=club_id, is_moderated=True
|
||||||
|
)
|
||||||
|
|
||||||
user = AutoCompleteSelectField('users', label=_('User'), help_text=None, required=False)
|
user = AutoCompleteSelectField(
|
||||||
|
"users", label=_("User"), help_text=None, required=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ClubTabsMixin(TabedViewMixin):
|
class ClubTabsMixin(TabedViewMixin):
|
||||||
@ -105,66 +121,105 @@ class ClubTabsMixin(TabedViewMixin):
|
|||||||
|
|
||||||
def get_list_of_tabs(self):
|
def get_list_of_tabs(self):
|
||||||
tab_list = []
|
tab_list = []
|
||||||
tab_list.append({
|
tab_list.append(
|
||||||
'url': reverse('club:club_view', kwargs={'club_id': self.object.id}),
|
{
|
||||||
'slug': 'infos',
|
"url": reverse("club:club_view", kwargs={"club_id": self.object.id}),
|
||||||
'name': _("Infos"),
|
"slug": "infos",
|
||||||
})
|
"name": _("Infos"),
|
||||||
|
}
|
||||||
|
)
|
||||||
if self.request.user.can_view(self.object):
|
if self.request.user.can_view(self.object):
|
||||||
tab_list.append({
|
tab_list.append(
|
||||||
'url': reverse('club:club_members', kwargs={'club_id': self.object.id}),
|
{
|
||||||
'slug': 'members',
|
"url": reverse(
|
||||||
'name': _("Members"),
|
"club:club_members", kwargs={"club_id": self.object.id}
|
||||||
})
|
),
|
||||||
tab_list.append({
|
"slug": "members",
|
||||||
'url': reverse('club:club_old_members', kwargs={'club_id': self.object.id}),
|
"name": _("Members"),
|
||||||
'slug': 'elderlies',
|
}
|
||||||
'name': _("Old members"),
|
)
|
||||||
})
|
tab_list.append(
|
||||||
|
{
|
||||||
|
"url": reverse(
|
||||||
|
"club:club_old_members", kwargs={"club_id": self.object.id}
|
||||||
|
),
|
||||||
|
"slug": "elderlies",
|
||||||
|
"name": _("Old members"),
|
||||||
|
}
|
||||||
|
)
|
||||||
if self.object.page:
|
if self.object.page:
|
||||||
tab_list.append({
|
tab_list.append(
|
||||||
'url': reverse('club:club_hist', kwargs={'club_id': self.object.id}),
|
{
|
||||||
'slug': 'history',
|
"url": reverse(
|
||||||
'name': _("History"),
|
"club:club_hist", kwargs={"club_id": self.object.id}
|
||||||
})
|
),
|
||||||
|
"slug": "history",
|
||||||
|
"name": _("History"),
|
||||||
|
}
|
||||||
|
)
|
||||||
if self.request.user.can_edit(self.object):
|
if self.request.user.can_edit(self.object):
|
||||||
tab_list.append({
|
tab_list.append(
|
||||||
'url': reverse('club:tools', kwargs={'club_id': self.object.id}),
|
{
|
||||||
'slug': 'tools',
|
"url": reverse("club:tools", kwargs={"club_id": self.object.id}),
|
||||||
'name': _("Tools"),
|
"slug": "tools",
|
||||||
})
|
"name": _("Tools"),
|
||||||
tab_list.append({
|
}
|
||||||
'url': reverse('club:club_edit', kwargs={'club_id': self.object.id}),
|
)
|
||||||
'slug': 'edit',
|
tab_list.append(
|
||||||
'name': _("Edit"),
|
{
|
||||||
})
|
"url": reverse(
|
||||||
|
"club:club_edit", kwargs={"club_id": self.object.id}
|
||||||
|
),
|
||||||
|
"slug": "edit",
|
||||||
|
"name": _("Edit"),
|
||||||
|
}
|
||||||
|
)
|
||||||
if self.object.page and self.request.user.can_edit(self.object.page):
|
if self.object.page and self.request.user.can_edit(self.object.page):
|
||||||
tab_list.append({
|
tab_list.append(
|
||||||
'url': reverse('core:page_edit', kwargs={'page_name': self.object.page.get_full_name()}),
|
{
|
||||||
'slug': 'page_edit',
|
"url": reverse(
|
||||||
'name': _('Edit club page')
|
"core:page_edit",
|
||||||
})
|
kwargs={"page_name": self.object.page.get_full_name()},
|
||||||
tab_list.append({
|
),
|
||||||
'url': reverse('club:club_sellings', kwargs={'club_id': self.object.id}),
|
"slug": "page_edit",
|
||||||
'slug': 'sellings',
|
"name": _("Edit club page"),
|
||||||
'name': _("Sellings"),
|
}
|
||||||
})
|
)
|
||||||
tab_list.append({
|
tab_list.append(
|
||||||
'url': reverse('club:mailing', kwargs={'club_id': self.object.id}),
|
{
|
||||||
'slug': 'mailing',
|
"url": reverse(
|
||||||
'name': _("Mailing list"),
|
"club:club_sellings", kwargs={"club_id": self.object.id}
|
||||||
})
|
),
|
||||||
tab_list.append({
|
"slug": "sellings",
|
||||||
'url': reverse('club:poster_list', kwargs={'club_id': self.object.id}),
|
"name": _("Sellings"),
|
||||||
'slug': 'posters',
|
}
|
||||||
'name': _("Posters list"),
|
)
|
||||||
})
|
tab_list.append(
|
||||||
|
{
|
||||||
|
"url": reverse("club:mailing", kwargs={"club_id": self.object.id}),
|
||||||
|
"slug": "mailing",
|
||||||
|
"name": _("Mailing list"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
tab_list.append(
|
||||||
|
{
|
||||||
|
"url": reverse(
|
||||||
|
"club:poster_list", kwargs={"club_id": self.object.id}
|
||||||
|
),
|
||||||
|
"slug": "posters",
|
||||||
|
"name": _("Posters list"),
|
||||||
|
}
|
||||||
|
)
|
||||||
if self.request.user.is_owner(self.object):
|
if self.request.user.is_owner(self.object):
|
||||||
tab_list.append({
|
tab_list.append(
|
||||||
'url': reverse('club:club_prop', kwargs={'club_id': self.object.id}),
|
{
|
||||||
'slug': 'props',
|
"url": reverse(
|
||||||
'name': _("Props"),
|
"club:club_prop", kwargs={"club_id": self.object.id}
|
||||||
})
|
),
|
||||||
|
"slug": "props",
|
||||||
|
"name": _("Props"),
|
||||||
|
}
|
||||||
|
)
|
||||||
return tab_list
|
return tab_list
|
||||||
|
|
||||||
|
|
||||||
@ -172,23 +227,25 @@ class ClubListView(ListView):
|
|||||||
"""
|
"""
|
||||||
List the Clubs
|
List the Clubs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
template_name = 'club/club_list.jinja'
|
template_name = "club/club_list.jinja"
|
||||||
|
|
||||||
|
|
||||||
class ClubView(ClubTabsMixin, DetailView):
|
class ClubView(ClubTabsMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Front page of a Club
|
Front page of a Club
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
template_name = 'club/club_detail.jinja'
|
template_name = "club/club_detail.jinja"
|
||||||
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(ClubView, self).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
|
||||||
|
|
||||||
|
|
||||||
@ -196,23 +253,24 @@ class ClubRevView(ClubView):
|
|||||||
"""
|
"""
|
||||||
Display a specific page revision
|
Display a specific page revision
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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(ClubRevView, self).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(ClubRevView, self).get_context_data(**kwargs)
|
||||||
kwargs['page_revision'] = self.revision.content
|
kwargs["page_revision"] = self.revision.content
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
class ClubPageEditView(ClubTabsMixin, PageEditViewBase):
|
class ClubPageEditView(ClubTabsMixin, PageEditViewBase):
|
||||||
template_name = 'club/pagerev_edit.jinja'
|
template_name = "club/pagerev_edit.jinja"
|
||||||
current_tab = "page_edit"
|
current_tab = "page_edit"
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
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(ClubPageEditView, self).dispatch(request, *args, **kwargs)
|
||||||
@ -222,16 +280,17 @@ class ClubPageEditView(ClubTabsMixin, PageEditViewBase):
|
|||||||
return self._get_revision()
|
return self._get_revision()
|
||||||
|
|
||||||
def get_success_url(self, **kwargs):
|
def get_success_url(self, **kwargs):
|
||||||
return reverse_lazy('club:club_view', kwargs={'club_id': self.club.id})
|
return reverse_lazy("club:club_view", kwargs={"club_id": self.club.id})
|
||||||
|
|
||||||
|
|
||||||
class ClubPageHistView(ClubTabsMixin, CanViewMixin, DetailView):
|
class ClubPageHistView(ClubTabsMixin, CanViewMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Modification hostory of the page
|
Modification hostory of the page
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
template_name = 'club/page_history.jinja'
|
template_name = "club/page_history.jinja"
|
||||||
current_tab = "history"
|
current_tab = "history"
|
||||||
|
|
||||||
|
|
||||||
@ -239,9 +298,10 @@ class ClubToolsView(ClubTabsMixin, CanEditMixin, DetailView):
|
|||||||
"""
|
"""
|
||||||
Tools page of a Club
|
Tools page of a Club
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
template_name = 'club/club_tools.jinja'
|
template_name = "club/club_tools.jinja"
|
||||||
current_tab = "tools"
|
current_tab = "tools"
|
||||||
|
|
||||||
|
|
||||||
@ -249,16 +309,18 @@ class ClubMemberForm(forms.ModelForm):
|
|||||||
"""
|
"""
|
||||||
Form handling the members of a club
|
Form handling the members of a club
|
||||||
"""
|
"""
|
||||||
error_css_class = 'error'
|
|
||||||
required_css_class = 'required'
|
error_css_class = "error"
|
||||||
|
required_css_class = "required"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Membership
|
model = Membership
|
||||||
fields = ['user', 'role', 'start_date', 'description']
|
fields = ["user", "role", "start_date", "description"]
|
||||||
widgets = {
|
widgets = {"start_date": SelectDate}
|
||||||
'start_date': SelectDate
|
|
||||||
}
|
user = AutoCompleteSelectField(
|
||||||
user = AutoCompleteSelectField('users', required=True, label=_("Select user"), help_text=None)
|
"users", required=True, label=_("Select user"), help_text=None
|
||||||
|
)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -272,10 +334,11 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, UpdateView):
|
|||||||
"""
|
"""
|
||||||
View of a club's members
|
View of a club's members
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
form_class = ClubMemberForm
|
form_class = ClubMemberForm
|
||||||
template_name = 'club/club_members.jinja'
|
template_name = "club/club_members.jinja"
|
||||||
current_tab = "members"
|
current_tab = "members"
|
||||||
|
|
||||||
def get_form(self):
|
def get_form(self):
|
||||||
@ -284,12 +347,19 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, UpdateView):
|
|||||||
That's why the save method of ClubMemberForm is overridden.
|
That's why the save method of ClubMemberForm is overridden.
|
||||||
"""
|
"""
|
||||||
form = super(ClubMembersView, self).get_form()
|
form = super(ClubMembersView, self).get_form()
|
||||||
if 'user' in form.data and form.data.get('user') != '': # Load an existing membership if possible
|
if (
|
||||||
form.instance = Membership.objects.filter(club=self.object).filter(user=form.data.get('user')).filter(end_date=None).first()
|
"user" in form.data and form.data.get("user") != ""
|
||||||
|
): # Load an existing membership if possible
|
||||||
|
form.instance = (
|
||||||
|
Membership.objects.filter(club=self.object)
|
||||||
|
.filter(user=form.data.get("user"))
|
||||||
|
.filter(end_date=None)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
if form.instance is None: # Instanciate a new membership
|
if form.instance is None: # Instanciate a new membership
|
||||||
form.instance = Membership(club=self.object, user=self.request.user)
|
form.instance = Membership(club=self.object, user=self.request.user)
|
||||||
if not self.request.user.is_root:
|
if not self.request.user.is_root:
|
||||||
form.fields.pop('start_date', None)
|
form.fields.pop("start_date", None)
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
@ -298,9 +368,12 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, UpdateView):
|
|||||||
"""
|
"""
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
ms = self.object.get_membership_for(user)
|
ms = self.object.get_membership_for(user)
|
||||||
if (form.cleaned_data['role'] <= SITH_MAXIMUM_FREE_ROLE or
|
if (
|
||||||
(ms is not None and ms.role >= form.cleaned_data['role']) or
|
form.cleaned_data["role"] <= SITH_MAXIMUM_FREE_ROLE
|
||||||
user.is_board_member or user.is_root):
|
or (ms is not None and ms.role >= form.cleaned_data["role"])
|
||||||
|
or user.is_board_member
|
||||||
|
or user.is_root
|
||||||
|
):
|
||||||
form.save()
|
form.save()
|
||||||
form = self.form_class()
|
form = self.form_class()
|
||||||
return super(ModelFormMixin, self).form_valid(form)
|
return super(ModelFormMixin, self).form_valid(form)
|
||||||
@ -313,39 +386,57 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, UpdateView):
|
|||||||
return super(ClubMembersView, self).dispatch(request, *args, **kwargs)
|
return super(ClubMembersView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_success_url(self, **kwargs):
|
def get_success_url(self, **kwargs):
|
||||||
return reverse_lazy('club:club_members', kwargs={'club_id': self.club.id})
|
return reverse_lazy("club:club_members", kwargs={"club_id": self.club.id})
|
||||||
|
|
||||||
|
|
||||||
class ClubOldMembersView(ClubTabsMixin, CanViewMixin, DetailView):
|
class ClubOldMembersView(ClubTabsMixin, CanViewMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Old members of a club
|
Old members of a club
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
template_name = 'club/club_old_members.jinja'
|
template_name = "club/club_old_members.jinja"
|
||||||
current_tab = "elderlies"
|
current_tab = "elderlies"
|
||||||
|
|
||||||
|
|
||||||
class SellingsFormBase(forms.Form):
|
class SellingsFormBase(forms.Form):
|
||||||
begin_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("Begin date"), required=False, widget=SelectDateTime)
|
begin_date = forms.DateTimeField(
|
||||||
end_date = forms.DateTimeField(['%Y-%m-%d %H:%M:%S'], label=_("End date"), required=False, widget=SelectDateTime)
|
["%Y-%m-%d %H:%M:%S"],
|
||||||
counter = forms.ModelChoiceField(Counter.objects.order_by('name').all(), label=_("Counter"), required=False)
|
label=_("Begin date"),
|
||||||
|
required=False,
|
||||||
|
widget=SelectDateTime,
|
||||||
|
)
|
||||||
|
end_date = forms.DateTimeField(
|
||||||
|
["%Y-%m-%d %H:%M:%S"],
|
||||||
|
label=_("End date"),
|
||||||
|
required=False,
|
||||||
|
widget=SelectDateTime,
|
||||||
|
)
|
||||||
|
counter = forms.ModelChoiceField(
|
||||||
|
Counter.objects.order_by("name").all(), label=_("Counter"), required=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailView):
|
class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Sellings of a club
|
Sellings of a club
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
template_name = 'club/club_sellings.jinja'
|
template_name = "club/club_sellings.jinja"
|
||||||
current_tab = "sellings"
|
current_tab = "sellings"
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'product': forms.ModelChoiceField(self.object.products.order_by('name').all(), label=_("Product"), required=False)
|
"product": forms.ModelChoiceField(
|
||||||
|
self.object.products.order_by("name").all(),
|
||||||
|
label=_("Product"),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return type('SellingsForm', (SellingsFormBase,), kwargs)
|
return type("SellingsForm", (SellingsFormBase,), kwargs)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(ClubSellingView, self).get_context_data(**kwargs)
|
kwargs = super(ClubSellingView, self).get_context_data(**kwargs)
|
||||||
@ -354,21 +445,23 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailView):
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
if not len([v for v in form.cleaned_data.values() if v is not None]):
|
if not len([v for v in form.cleaned_data.values() if v is not None]):
|
||||||
qs = Selling.objects.filter(id=-1)
|
qs = Selling.objects.filter(id=-1)
|
||||||
if form.cleaned_data['begin_date']:
|
if form.cleaned_data["begin_date"]:
|
||||||
qs = qs.filter(date__gte=form.cleaned_data['begin_date'])
|
qs = qs.filter(date__gte=form.cleaned_data["begin_date"])
|
||||||
if form.cleaned_data['end_date']:
|
if form.cleaned_data["end_date"]:
|
||||||
qs = qs.filter(date__lte=form.cleaned_data['end_date'])
|
qs = qs.filter(date__lte=form.cleaned_data["end_date"])
|
||||||
if form.cleaned_data['counter']:
|
if form.cleaned_data["counter"]:
|
||||||
qs = qs.filter(counter=form.cleaned_data['counter'])
|
qs = qs.filter(counter=form.cleaned_data["counter"])
|
||||||
if form.cleaned_data['product']:
|
if form.cleaned_data["product"]:
|
||||||
qs = qs.filter(product__id=form.cleaned_data['product'].id)
|
qs = qs.filter(product__id=form.cleaned_data["product"].id)
|
||||||
kwargs['result'] = qs.all().order_by('-id')
|
kwargs["result"] = qs.all().order_by("-id")
|
||||||
kwargs['total'] = sum([s.quantity * s.unit_price for s in qs.all()])
|
kwargs["total"] = sum([s.quantity * s.unit_price for s in qs.all()])
|
||||||
kwargs['total_quantity'] = sum([s.quantity for s in qs.all()])
|
kwargs["total_quantity"] = sum([s.quantity for s in qs.all()])
|
||||||
kwargs['benefit'] = kwargs['total'] - sum([s.product.purchase_price for s in qs.exclude(product=None)])
|
kwargs["benefit"] = kwargs["total"] - sum(
|
||||||
|
[s.product.purchase_price for s in qs.exclude(product=None)]
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
kwargs['result'] = qs[:0]
|
kwargs["result"] = qs[:0]
|
||||||
kwargs['form'] = form
|
kwargs["form"] = form
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
@ -379,36 +472,56 @@ class ClubSellingCSVView(ClubSellingView):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
import csv
|
import csv
|
||||||
response = HttpResponse(content_type='text/csv')
|
|
||||||
|
response = HttpResponse(content_type="text/csv")
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
name = _("Sellings") + "_" + self.object.name + ".csv"
|
name = _("Sellings") + "_" + self.object.name + ".csv"
|
||||||
response['Content-Disposition'] = 'filename=' + name
|
response["Content-Disposition"] = "filename=" + name
|
||||||
kwargs = self.get_context_data(**kwargs)
|
kwargs = self.get_context_data(**kwargs)
|
||||||
writer = csv.writer(response, delimiter=";", lineterminator='\n', quoting=csv.QUOTE_ALL)
|
writer = csv.writer(
|
||||||
|
response, delimiter=";", lineterminator="\n", quoting=csv.QUOTE_ALL
|
||||||
|
)
|
||||||
|
|
||||||
writer.writerow([_t('Quantity'), kwargs['total_quantity']])
|
writer.writerow([_t("Quantity"), kwargs["total_quantity"]])
|
||||||
writer.writerow([_t('Total'), kwargs['total']])
|
writer.writerow([_t("Total"), kwargs["total"]])
|
||||||
writer.writerow([_t('Benefit'), kwargs['benefit']])
|
writer.writerow([_t("Benefit"), kwargs["benefit"]])
|
||||||
writer.writerow([_t('Date'), _t('Counter'), _t('Barman'), _t('Customer'), _t('Label'),
|
writer.writerow(
|
||||||
_t('Quantity'), _t('Total'), _t('Payment method'), _t('Selling price'), _t('Purchase price'), _t('Benefit')])
|
[
|
||||||
for o in kwargs['result']:
|
_t("Date"),
|
||||||
|
_t("Counter"),
|
||||||
|
_t("Barman"),
|
||||||
|
_t("Customer"),
|
||||||
|
_t("Label"),
|
||||||
|
_t("Quantity"),
|
||||||
|
_t("Total"),
|
||||||
|
_t("Payment method"),
|
||||||
|
_t("Selling price"),
|
||||||
|
_t("Purchase price"),
|
||||||
|
_t("Benefit"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
for o in kwargs["result"]:
|
||||||
row = [o.date, o.counter]
|
row = [o.date, o.counter]
|
||||||
if o.seller:
|
if o.seller:
|
||||||
row.append(o.seller.get_display_name())
|
row.append(o.seller.get_display_name())
|
||||||
else:
|
else:
|
||||||
row.append('')
|
row.append("")
|
||||||
if o.customer:
|
if o.customer:
|
||||||
row.append(o.customer.user.get_display_name())
|
row.append(o.customer.user.get_display_name())
|
||||||
else:
|
else:
|
||||||
row.append('')
|
row.append("")
|
||||||
row = row + [o.label, o.quantity, o.quantity * o.unit_price,
|
row = row + [
|
||||||
o.get_payment_method_display()]
|
o.label,
|
||||||
|
o.quantity,
|
||||||
|
o.quantity * o.unit_price,
|
||||||
|
o.get_payment_method_display(),
|
||||||
|
]
|
||||||
if o.product:
|
if o.product:
|
||||||
row.append(o.product.selling_price)
|
row.append(o.product.selling_price)
|
||||||
row.append(o.product.purchase_price)
|
row.append(o.product.purchase_price)
|
||||||
row.append(o.product.selling_price - o.product.purchase_price)
|
row.append(o.product.selling_price - o.product.purchase_price)
|
||||||
else:
|
else:
|
||||||
row = row + ['', '', '']
|
row = row + ["", "", ""]
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@ -418,10 +531,11 @@ class ClubEditView(ClubTabsMixin, CanEditMixin, UpdateView):
|
|||||||
"""
|
"""
|
||||||
Edit a Club's main informations (for the club's members)
|
Edit a Club's main informations (for the club's members)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
form_class = ClubEditForm
|
form_class = ClubEditForm
|
||||||
template_name = 'core/edit.jinja'
|
template_name = "core/edit.jinja"
|
||||||
current_tab = "edit"
|
current_tab = "edit"
|
||||||
|
|
||||||
|
|
||||||
@ -429,10 +543,11 @@ class ClubEditPropView(ClubTabsMixin, CanEditPropMixin, UpdateView):
|
|||||||
"""
|
"""
|
||||||
Edit the properties of a Club object (for the Sith admins)
|
Edit the properties of a Club object (for the Sith admins)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
fields = ['name', 'unix_name', 'parent', 'is_active']
|
fields = ["name", "unix_name", "parent", "is_active"]
|
||||||
template_name = 'core/edit.jinja'
|
template_name = "core/edit.jinja"
|
||||||
current_tab = "props"
|
current_tab = "props"
|
||||||
|
|
||||||
|
|
||||||
@ -440,16 +555,18 @@ class ClubCreateView(CanEditPropMixin, CreateView):
|
|||||||
"""
|
"""
|
||||||
Create a club (for the Sith admin)
|
Create a club (for the Sith admin)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Club
|
model = Club
|
||||||
pk_url_kwarg = "club_id"
|
pk_url_kwarg = "club_id"
|
||||||
fields = ['name', 'unix_name', 'parent']
|
fields = ["name", "unix_name", "parent"]
|
||||||
template_name = 'core/edit.jinja'
|
template_name = "core/edit.jinja"
|
||||||
|
|
||||||
|
|
||||||
class MembershipSetOldView(CanEditMixin, DetailView):
|
class MembershipSetOldView(CanEditMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Set a membership as beeing old
|
Set a membership as beeing old
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Membership
|
model = Membership
|
||||||
pk_url_kwarg = "membership_id"
|
pk_url_kwarg = "membership_id"
|
||||||
|
|
||||||
@ -457,11 +574,23 @@ class MembershipSetOldView(CanEditMixin, DetailView):
|
|||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
self.object.end_date = timezone.now()
|
self.object.end_date = timezone.now()
|
||||||
self.object.save()
|
self.object.save()
|
||||||
return HttpResponseRedirect(reverse('club:club_members', args=self.args, kwargs={'club_id': self.object.club.id}))
|
return HttpResponseRedirect(
|
||||||
|
reverse(
|
||||||
|
"club:club_members",
|
||||||
|
args=self.args,
|
||||||
|
kwargs={"club_id": self.object.club.id},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
return HttpResponseRedirect(reverse('club:club_members', args=self.args, kwargs={'club_id': self.object.club.id}))
|
return HttpResponseRedirect(
|
||||||
|
reverse(
|
||||||
|
"club:club_members",
|
||||||
|
args=self.args,
|
||||||
|
kwargs={"club_id": self.object.club.id},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ClubStatView(TemplateView):
|
class ClubStatView(TemplateView):
|
||||||
@ -469,7 +598,7 @@ class ClubStatView(TemplateView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(ClubStatView, self).get_context_data(**kwargs)
|
kwargs = super(ClubStatView, self).get_context_data(**kwargs)
|
||||||
kwargs['club_list'] = Club.objects.all()
|
kwargs["club_list"] = Club.objects.all()
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
@ -477,16 +606,21 @@ class ClubMailingView(ClubTabsMixin, ListView):
|
|||||||
"""
|
"""
|
||||||
A list of mailing for a given club
|
A list of mailing for a given club
|
||||||
"""
|
"""
|
||||||
|
|
||||||
action = None
|
action = None
|
||||||
model = Mailing
|
model = Mailing
|
||||||
template_name = "club/mailing.jinja"
|
template_name = "club/mailing.jinja"
|
||||||
current_tab = 'mailing'
|
current_tab = "mailing"
|
||||||
|
|
||||||
def authorized(self):
|
def authorized(self):
|
||||||
return self.club.has_rights_in_club(self.user) or self.user.is_root or self.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
return (
|
||||||
|
self.club.has_rights_in_club(self.user)
|
||||||
|
or self.user.is_root
|
||||||
|
or self.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||||
|
)
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
self.club = get_object_or_404(Club, pk=kwargs['club_id'])
|
self.club = get_object_or_404(Club, pk=kwargs["club_id"])
|
||||||
self.user = request.user
|
self.user = request.user
|
||||||
self.object = self.club
|
self.object = self.club
|
||||||
if not self.authorized():
|
if not self.authorized():
|
||||||
@ -504,7 +638,9 @@ class ClubMailingView(ClubTabsMixin, ListView):
|
|||||||
elif self.action == "add_member":
|
elif self.action == "add_member":
|
||||||
form = MailingSubscriptionForm
|
form = MailingSubscriptionForm
|
||||||
model = MailingSubscription
|
model = MailingSubscription
|
||||||
return MailingGenericCreateView.as_view(model=model, list_view=self, form_class=form)(request, *args, **kwargs)
|
return MailingGenericCreateView.as_view(
|
||||||
|
model=model, list_view=self, form_class=form
|
||||||
|
)(request, *args, **kwargs)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@ -512,11 +648,11 @@ class ClubMailingView(ClubTabsMixin, ListView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(ClubMailingView, self).get_context_data(**kwargs)
|
kwargs = super(ClubMailingView, self).get_context_data(**kwargs)
|
||||||
kwargs['add_member'] = self.member_form
|
kwargs["add_member"] = self.member_form
|
||||||
kwargs['add_mailing'] = self.mailing_form
|
kwargs["add_mailing"] = self.mailing_form
|
||||||
kwargs['club'] = self.club
|
kwargs["club"] = self.club
|
||||||
kwargs['user'] = self.user
|
kwargs["user"] = self.user
|
||||||
kwargs['has_objects'] = len(kwargs['object_list']) > 0
|
kwargs["has_objects"] = len(kwargs["object_list"]) > 0
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
@ -527,20 +663,23 @@ class MailingGenericCreateView(CreateView, SingleObjectMixin):
|
|||||||
"""
|
"""
|
||||||
Create a new mailing list
|
Create a new mailing list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_view = None
|
list_view = None
|
||||||
form_class = None
|
form_class = None
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
view_kwargs = self.list_view.get_context_data(**kwargs)
|
view_kwargs = self.list_view.get_context_data(**kwargs)
|
||||||
for key, data in super(MailingGenericCreateView, self).get_context_data(**kwargs).items():
|
for key, data in (
|
||||||
|
super(MailingGenericCreateView, self).get_context_data(**kwargs).items()
|
||||||
|
):
|
||||||
view_kwargs[key] = data
|
view_kwargs[key] = data
|
||||||
view_kwargs[self.list_view.action] = view_kwargs['form']
|
view_kwargs[self.list_view.action] = view_kwargs["form"]
|
||||||
return view_kwargs
|
return view_kwargs
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super(MailingGenericCreateView, self).get_form_kwargs()
|
kwargs = super(MailingGenericCreateView, self).get_form_kwargs()
|
||||||
kwargs['club_id'] = self.list_view.club.id
|
kwargs["club_id"] = self.list_view.club.id
|
||||||
kwargs['user_id'] = self.list_view.user.id
|
kwargs["user_id"] = self.list_view.user.id
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
@ -550,13 +689,13 @@ class MailingGenericCreateView(CreateView, SingleObjectMixin):
|
|||||||
return super(MailingGenericCreateView, self).dispatch(request, *args, **kwargs)
|
return super(MailingGenericCreateView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_success_url(self, **kwargs):
|
def get_success_url(self, **kwargs):
|
||||||
return reverse_lazy('club:mailing', kwargs={'club_id': self.list_view.club.id})
|
return reverse_lazy("club:mailing", kwargs={"club_id": self.list_view.club.id})
|
||||||
|
|
||||||
|
|
||||||
class MailingDeleteView(CanEditMixin, DeleteView):
|
class MailingDeleteView(CanEditMixin, DeleteView):
|
||||||
|
|
||||||
model = Mailing
|
model = Mailing
|
||||||
template_name = 'core/delete_confirm.jinja'
|
template_name = "core/delete_confirm.jinja"
|
||||||
pk_url_kwarg = "mailing_id"
|
pk_url_kwarg = "mailing_id"
|
||||||
redirect_page = None
|
redirect_page = None
|
||||||
|
|
||||||
@ -568,27 +707,28 @@ class MailingDeleteView(CanEditMixin, DeleteView):
|
|||||||
if self.redirect_page:
|
if self.redirect_page:
|
||||||
return reverse_lazy(self.redirect_page)
|
return reverse_lazy(self.redirect_page)
|
||||||
else:
|
else:
|
||||||
return reverse_lazy('club:mailing', kwargs={'club_id': self.club_id})
|
return reverse_lazy("club:mailing", kwargs={"club_id": self.club_id})
|
||||||
|
|
||||||
|
|
||||||
class MailingSubscriptionDeleteView(CanEditMixin, DeleteView):
|
class MailingSubscriptionDeleteView(CanEditMixin, DeleteView):
|
||||||
|
|
||||||
model = MailingSubscription
|
model = MailingSubscription
|
||||||
template_name = 'core/delete_confirm.jinja'
|
template_name = "core/delete_confirm.jinja"
|
||||||
pk_url_kwarg = "mailing_subscription_id"
|
pk_url_kwarg = "mailing_subscription_id"
|
||||||
|
|
||||||
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(request, *args, **kwargs)
|
return super(MailingSubscriptionDeleteView, self).dispatch(
|
||||||
|
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})
|
||||||
|
|
||||||
|
|
||||||
class MailingAutoGenerationView(View):
|
class MailingAutoGenerationView(View):
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
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(MailingAutoGenerationView, self).dispatch(request, *args, **kwargs)
|
||||||
@ -596,23 +736,24 @@ class MailingAutoGenerationView(View):
|
|||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
club = self.mailing.club
|
club = self.mailing.club
|
||||||
self.mailing.subscriptions.all().delete()
|
self.mailing.subscriptions.all().delete()
|
||||||
members = club.members.filter(role__gte=settings.SITH_CLUB_ROLES_ID['Board member']).exclude(end_date__lte=timezone.now())
|
members = club.members.filter(
|
||||||
|
role__gte=settings.SITH_CLUB_ROLES_ID["Board member"]
|
||||||
|
).exclude(end_date__lte=timezone.now())
|
||||||
for member in members.all():
|
for member in members.all():
|
||||||
MailingSubscription(user=member.user, mailing=self.mailing).save()
|
MailingSubscription(user=member.user, mailing=self.mailing).save()
|
||||||
return redirect('club:mailing', club_id=club.id)
|
return redirect("club:mailing", club_id=club.id)
|
||||||
|
|
||||||
|
|
||||||
class MailingAutoCleanView(View):
|
class MailingAutoCleanView(View):
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
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(MailingAutoCleanView, self).dispatch(request, *args, **kwargs)
|
return super(MailingAutoCleanView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.mailing.subscriptions.all().delete()
|
self.mailing.subscriptions.all().delete()
|
||||||
return redirect('club:mailing', club_id=self.mailing.club.id)
|
return redirect("club:mailing", club_id=self.mailing.club.id)
|
||||||
|
|
||||||
|
|
||||||
class PosterListView(ClubTabsMixin, PosterListBaseView, CanViewMixin):
|
class PosterListView(ClubTabsMixin, PosterListBaseView, CanViewMixin):
|
||||||
@ -623,8 +764,8 @@ class PosterListView(ClubTabsMixin, PosterListBaseView, CanViewMixin):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(PosterListView, self).get_context_data(**kwargs)
|
kwargs = super(PosterListView, self).get_context_data(**kwargs)
|
||||||
kwargs['app'] = "club"
|
kwargs["app"] = "club"
|
||||||
kwargs['club'] = self.club
|
kwargs["club"] = self.club
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
@ -640,18 +781,18 @@ class PosterCreateView(PosterCreateBaseView, CanCreateMixin):
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
def get_success_url(self, **kwargs):
|
def get_success_url(self, **kwargs):
|
||||||
return reverse_lazy('club:poster_list', kwargs={'club_id': self.club.id})
|
return reverse_lazy("club:poster_list", kwargs={"club_id": self.club.id})
|
||||||
|
|
||||||
|
|
||||||
class PosterEditView(ClubTabsMixin, PosterEditBaseView, CanEditMixin):
|
class PosterEditView(ClubTabsMixin, PosterEditBaseView, CanEditMixin):
|
||||||
"""Edit communication poster"""
|
"""Edit communication poster"""
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
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(PosterEditView, self).get_context_data(**kwargs)
|
||||||
kwargs['app'] = "club"
|
kwargs["app"] = "club"
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
@ -659,5 +800,4 @@ class PosterDeleteView(PosterDeleteBaseView, ClubTabsMixin, CanEditMixin):
|
|||||||
"""Delete communication poster"""
|
"""Delete communication poster"""
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('club:poster_list', kwargs={'club_id': self.club.id})
|
return reverse_lazy("club:poster_list", kwargs={"club_id": self.club.id})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user