diff --git a/com/migrations/0003_auto_20170103_1341.py b/com/migrations/0003_auto_20170103_1341.py new file mode 100644 index 00000000..ebcddb20 --- /dev/null +++ b/com/migrations/0003_auto_20170103_1341.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('club', '0006_auto_20161229_0040'), + ('com', '0002_news_newsdate'), + ] + + operations = [ + migrations.CreateModel( + name='Weekmail', + fields=[ + ('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), + ('title', models.CharField(verbose_name='title', max_length=64)), + ('intro', models.TextField(verbose_name='intro', blank=True)), + ('joke', models.TextField(verbose_name='joke', blank=True)), + ('protip', models.TextField(verbose_name='protip', blank=True)), + ('conclusion', models.TextField(verbose_name='conclusion', blank=True)), + ('sent', models.BooleanField(verbose_name='sent', default=False)), + ], + options={ + 'ordering': ['-id'], + }, + ), + migrations.CreateModel( + name='WeekmailArticle', + fields=[ + ('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), + ('title', models.CharField(verbose_name='title', max_length=64)), + ('content', models.TextField(verbose_name='content')), + ('rank', models.IntegerField(verbose_name='rank', default=-1)), + ('author', models.ForeignKey(related_name='owned_weekmail_articles', to=settings.AUTH_USER_MODEL, verbose_name='author')), + ('club', models.ForeignKey(related_name='weekmail_articles', to='club.Club', verbose_name='club')), + ('weekmail', models.ForeignKey(related_name='articles', to='com.Weekmail', verbose_name='weekmail')), + ], + ), + migrations.AddField( + model_name='sith', + name='weekmail_destinations', + field=models.TextField(verbose_name='weekmail destinations', default=''), + ), + ] diff --git a/com/models.py b/com/models.py index 6c48e332..65f8558e 100644 --- a/com/models.py +++ b/com/models.py @@ -11,6 +11,7 @@ class Sith(models.Model): alert_msg = models.TextField(_("alert message"), default="", blank=True) info_msg = models.TextField(_("info message"), default="", blank=True) index_page = models.TextField(_("index page"), default="", blank=True) + weekmail_destinations = models.TextField(_("weekmail destinations"), default="") def is_owned_by(self, user): return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) @@ -64,3 +65,35 @@ class NewsDate(models.Model): def __str__(self): return "%s: %s - %s" % (self.news.title, self.start_date, self.end_date) + +class Weekmail(models.Model): + """ + The weekmail class + """ + title = models.CharField(_("title"), max_length=64) + intro = models.TextField(_("intro"), blank=True) + joke = models.TextField(_("joke"), blank=True) + protip = models.TextField(_("protip"), blank=True) + conclusion = models.TextField(_("conclusion"), blank=True) + sent = models.BooleanField(_("sent"), default=False) + + class Meta: + ordering = ['-id'] + + def send(self): + print("Sending weekmail n°" + str(self.id)) + self.sent = True + self.save() + +class WeekmailArticle(models.Model): + weekmail = models.ForeignKey(Weekmail, related_name="articles", verbose_name=_("weekmail")) + title = models.CharField(_("title"), max_length=64) + content = models.TextField(_("content")) + author = models.ForeignKey(User, related_name="owned_weekmail_articles", verbose_name=_("author")) + club = models.ForeignKey(Club, related_name="weekmail_articles", verbose_name=_("club")) + rank = models.IntegerField(_('rank'), default=-1) + + def clean(self): + super(WeekmailArticle, self).clean() + if not self.weekmail: + self.weekmail = Weekmail.objects.order_by('-id').first() diff --git a/com/templates/com/weekmail.jinja b/com/templates/com/weekmail.jinja new file mode 100644 index 00000000..dfe2b57c --- /dev/null +++ b/com/templates/com/weekmail.jinja @@ -0,0 +1,13 @@ +{% extends "core/base.jinja" %} + +{% block title %} +{% trans %}Weekmail{% endtrans %} +{% endblock %} + +{% block content %} +