mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Moved club field + migrations
This commit is contained in:
parent
17d3860ec5
commit
693c3ed27e
43
com/migrations/0004_auto_20171023_0929.py
Normal file
43
com/migrations/0004_auto_20171023_0929.py
Normal file
@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('club', '0010_auto_20170912_2028'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('com', '0003_auto_20170115_2300'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Poster',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('name', models.CharField(verbose_name='name', max_length=128, default='')),
|
||||
('file', models.ImageField(verbose_name='file', upload_to='com/posters')),
|
||||
('date_begin', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('date_end', models.DateTimeField(blank=True, null=True)),
|
||||
('is_moderated', models.BooleanField(verbose_name='is moderated', default=False)),
|
||||
('club', models.ForeignKey(verbose_name='club', related_name='posters', to='club.Club')),
|
||||
('moderator', models.ForeignKey(verbose_name='moderator', blank=True, null=True, related_name='moderated_posters', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Screen',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('name', models.CharField(verbose_name='name', max_length=128)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='poster',
|
||||
name='screens',
|
||||
field=models.ManyToManyField(related_name='posters', to='com.Screen'),
|
||||
),
|
||||
]
|
@ -191,7 +191,6 @@ class WeekmailArticle(models.Model):
|
||||
|
||||
class Screen(models.Model):
|
||||
name = models.CharField(_("name"), max_length=128)
|
||||
club = models.ForeignKey(Club, related_name="screens", verbose_name=_("club"), null=False)
|
||||
|
||||
def active_posters(self):
|
||||
now = timezone.now()
|
||||
@ -206,6 +205,7 @@ class Screen(models.Model):
|
||||
class Poster(models.Model):
|
||||
name = models.CharField(_("name"), blank=False, null=False, max_length=128, default="")
|
||||
file = models.ImageField(_("file"), null=False, upload_to="com/posters")
|
||||
club = models.ForeignKey(Club, related_name="posters", verbose_name=_("club"), null=False)
|
||||
screens = models.ManyToManyField(Screen, related_name="posters")
|
||||
date_begin = models.DateTimeField(blank=False, null=False, default=timezone.now)
|
||||
date_end = models.DateTimeField(blank=True, null=True)
|
||||
@ -220,7 +220,7 @@ class Poster(models.Model):
|
||||
def is_owned_by(self, user):
|
||||
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||
|
||||
def can_moderate(self, user):
|
||||
def can_be_moderated_by(self, user):
|
||||
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -549,7 +549,7 @@ class PosterModerateView(IsComAdminMixin, ComTabsMixin, ModerateView):
|
||||
"""Moderate communication poster"""
|
||||
def get(self, request, *args, **kwargs):
|
||||
obj = get_object_or_404(Poster, pk=kwargs['object_id'])
|
||||
if obj.can_moderate(request.user):
|
||||
if obj.can_be_moderated_by(request.user):
|
||||
obj.is_moderated = True
|
||||
obj.moderator = request.user
|
||||
obj.save()
|
||||
|
Loading…
Reference in New Issue
Block a user