mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Posters now working + notifications for com admin
This commit is contained in:
parent
cc99cecaa0
commit
72d2862e3e
@ -88,8 +88,9 @@ class MailingSubscriptionForm(forms.ModelForm):
|
|||||||
|
|
||||||
class ClubTabsMixin(TabedViewMixin):
|
class ClubTabsMixin(TabedViewMixin):
|
||||||
def get_tabs_title(self):
|
def get_tabs_title(self):
|
||||||
if isinstance(self.object, PageRev):
|
obj = self.get_object()
|
||||||
self.object = self.object.page.club
|
if isinstance(obj, PageRev):
|
||||||
|
self.object = obj.page.club
|
||||||
return self.object.get_display_name()
|
return self.object.get_display_name()
|
||||||
|
|
||||||
def get_list_of_tabs(self):
|
def get_list_of_tabs(self):
|
||||||
@ -601,7 +602,7 @@ class MailingAutoCleanView(View):
|
|||||||
return redirect('club:mailing', club_id=self.mailing.club.id)
|
return redirect('club:mailing', club_id=self.mailing.club.id)
|
||||||
|
|
||||||
|
|
||||||
class PosterListView(PosterListBaseView, ClubTabsMixin, CanViewMixin):
|
class PosterListView(PosterListBaseView, CanViewMixin, ClubTabsMixin):
|
||||||
"""List communication posters"""
|
"""List communication posters"""
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
@ -610,6 +611,7 @@ class PosterListView(PosterListBaseView, ClubTabsMixin, 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['current_tab'] = self.current_tab
|
||||||
kwargs['tabs_title'] = self.get_tabs_title()
|
kwargs['tabs_title'] = self.get_tabs_title()
|
||||||
kwargs['list_of_tabs'] = self.get_list_of_tabs()
|
kwargs['list_of_tabs'] = self.get_list_of_tabs()
|
||||||
return kwargs
|
return kwargs
|
||||||
@ -618,20 +620,24 @@ class PosterListView(PosterListBaseView, ClubTabsMixin, CanViewMixin):
|
|||||||
class PosterCreateView(PosterCreateBaseView, CanCreateMixin):
|
class PosterCreateView(PosterCreateBaseView, CanCreateMixin):
|
||||||
"""Create communication poster"""
|
"""Create communication poster"""
|
||||||
|
|
||||||
def get_success_url(self, **kwargs):
|
pk_url_kwarg = "club_id"
|
||||||
return reverse_lazy('club:poster_list', kwargs={'club_id': self.club.id});
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_object(self):
|
||||||
kwargs = super(PosterCreateView, self).get_context_data(**kwargs)
|
print(self.club)
|
||||||
kwargs['app'] = "club"
|
obj = super(PosterCreateView, self).get_object()
|
||||||
return kwargs
|
if not obj:
|
||||||
|
return self.club
|
||||||
|
return obj
|
||||||
|
|
||||||
|
def get_success_url(self, **kwargs):
|
||||||
|
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)
|
||||||
@ -643,5 +649,5 @@ 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})
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2016,2017
|
# Copyright 2016,2017
|
||||||
# - Skia <skia@libskia.so>
|
# - Skia <skia@libskia.so>
|
||||||
|
# - Sli <antoine@bartuccio.fr>
|
||||||
#
|
#
|
||||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||||
# http://ae.utbm.fr.
|
# http://ae.utbm.fr.
|
||||||
@ -31,6 +32,7 @@ from django.core.urlresolvers import reverse
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||||
from django.core.mail import EmailMultiAlternatives
|
from django.core.mail import EmailMultiAlternatives
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
@ -202,6 +204,7 @@ class Screen(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s" % (self.name)
|
return "%s" % (self.name)
|
||||||
|
|
||||||
|
|
||||||
class Poster(models.Model):
|
class Poster(models.Model):
|
||||||
name = models.CharField(_("name"), blank=False, null=False, max_length=128, default="")
|
name = models.CharField(_("name"), blank=False, null=False, max_length=128, default="")
|
||||||
file = models.ImageField(_("file"), null=False, upload_to="com/posters")
|
file = models.ImageField(_("file"), null=False, upload_to="com/posters")
|
||||||
@ -215,7 +218,11 @@ class Poster(models.Model):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.date_end and self.date_begin > self.date_end:
|
if self.date_end and self.date_begin > self.date_end:
|
||||||
raise ValidationError
|
raise ValidationError(_("Begin date should be before end date"))
|
||||||
|
if not self.is_moderated:
|
||||||
|
for u in RealGroup.objects.filter(id=settings.SITH_GROUP_COM_ADMIN_ID).first().users.all():
|
||||||
|
Notification(user=u, url=reverse("com:poster_moderate_list"),
|
||||||
|
type="POSTER_MODERATION").save()
|
||||||
return super(Poster, self).save(*args, **kwargs)
|
return super(Poster, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def is_owned_by(self, user):
|
def is_owned_by(self, user):
|
||||||
@ -224,5 +231,12 @@ class Poster(models.Model):
|
|||||||
def can_be_moderated_by(self, user):
|
def can_be_moderated_by(self, user):
|
||||||
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||||
|
|
||||||
|
def get_display_name(self):
|
||||||
|
return self.club.get_display_name()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def page(self):
|
||||||
|
return self.club.page
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -538,11 +538,9 @@ class PosterCreateBaseView(CreateView):
|
|||||||
return Poster.objects.all()
|
return Poster.objects.all()
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
if 'club_id' in kwargs and kwargs['club_id']:
|
if 'club_id' in kwargs:
|
||||||
try:
|
self.club = get_object_or_404(Club, pk=kwargs['club_id'])
|
||||||
self.club = Club.objects.get(pk=kwargs['club_id'])
|
print(self.club)
|
||||||
except Club.DoesNotExist:
|
|
||||||
raise PermissionDenied
|
|
||||||
return super(PosterCreateBaseView, self).dispatch(request, *args, **kwargs)
|
return super(PosterCreateBaseView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
|
19
core/migrations/0028_auto_20171216_2044.py
Normal file
19
core/migrations/0028_auto_20171216_2044.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0027_gift'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='notification',
|
||||||
|
name='type',
|
||||||
|
field=models.CharField(default='GENERIC', verbose_name='type', max_length=32, choices=[('POSTER_MODERATION', 'A new poster needs to be moderated'), ('MAILING_MODERATION', 'A new mailing list needs to be moderated'), ('NEWS_MODERATION', 'There are %s fresh news to be moderated'), ('FILE_MODERATION', 'New files to be moderated'), ('SAS_MODERATION', 'There are %s pictures to be moderated in the SAS'), ('NEW_PICTURES', "You've been identified on some pictures"), ('REFILLING', 'You just refilled of %s €'), ('SELLING', 'You just bought %s'), ('GENERIC', 'You have a notification')]),
|
||||||
|
),
|
||||||
|
]
|
@ -562,6 +562,7 @@ SITH_LAUNDERETTE_PRICES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SITH_NOTIFICATIONS = [
|
SITH_NOTIFICATIONS = [
|
||||||
|
('POSTER_MODERATION', _("A new poster needs to be moderated")),
|
||||||
('MAILING_MODERATION', _("A new mailing list needs to be moderated")),
|
('MAILING_MODERATION', _("A new mailing list needs to be moderated")),
|
||||||
('NEWS_MODERATION', _("There are %s fresh news to be moderated")),
|
('NEWS_MODERATION', _("There are %s fresh news to be moderated")),
|
||||||
('FILE_MODERATION', _("New files to be moderated")),
|
('FILE_MODERATION', _("New files to be moderated")),
|
||||||
|
Loading…
Reference in New Issue
Block a user