diff --git a/com/templates/com/news_list.jinja b/com/templates/com/news_list.jinja index 4240ac1c..e077ca3d 100644 --- a/com/templates/com/news_list.jinja +++ b/com/templates/com/news_list.jinja @@ -6,85 +6,121 @@ {% block content %}
-

{% trans %}News{% endtrans %}

{% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %} - {% trans %}Administrate news{% endtrans %} +
+ {% trans %}Administrate news{% endtrans %} +
{% endif %} -
-
{% trans %}Agenda{% endtrans %}
-
- {% for d in NewsDate.objects.filter(end_date__gte=timezone.now(), - news__is_moderated=True, news__type__in=["WEEKLY", - "EVENT"]).order_by('start_date', 'end_date') %} -
-
- {{ d.start_date|localtime|date('D d M Y') }} -
-
- {{ d.start_date|localtime|time(DATETIME_FORMAT) }} - - {{ d.end_date|localtime|time(DATETIME_FORMAT) }} -
-
- {{ d.news.title }} - {{ d.news.club }} -
-
{{ d.news.summary|markdown }}
-
- {% endfor %} -
+
+
+
{% trans %}Agenda{% endtrans %}
+
+ {% for d in NewsDate.objects.filter(end_date__gte=timezone.now(), + news__is_moderated=True, news__type__in=["WEEKLY", + "EVENT"]).order_by('start_date', 'end_date') %} +
+
+ {{ d.start_date|localtime|date('D d M Y') }} +
+
+ {{ d.start_date|localtime|time(DATETIME_FORMAT) }} - + {{ d.end_date|localtime|time(DATETIME_FORMAT) }} +
+ +
{{ d.news.summary|markdown }}
+
+ {% endfor %} +
+
- {% for news in object_list.filter(type="NOTICE") %} -
-

{{ news.title }}

-

{{ news.summary|markdown }}

-
- {% endfor %} - {% for news in object_list.filter(dates__start_date__lte=timezone.now(), dates__end_date__gte=timezone.now(), type="CALL") %} -
-

{{ news.title }}

-

- {{ news.dates.first().start_date|localtime|date(DATETIME_FORMAT) }} - {{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }} - - {{ news.dates.first().end_date|localtime|date(DATETIME_FORMAT) }} - {{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }} -

-

{{ news.summary|markdown }}

-
- {% endfor %} -
-

{% trans %}Events today and the next few days{% endtrans %}

- {% for d in NewsDate.objects.filter(end_date__gte=timezone.now(), start_date__lte=timezone.now()+timedelta(days=5), - news__type="EVENT", news__is_moderated=True).datetimes('start_date', 'day') %} -
{{ d|localtime|date(DATETIME_FORMAT) }}
- {% for news in object_list.filter(dates__start_date__gte=d, dates__start_date__lte=d+timedelta(days=1), - type="EVENT").exclude(dates__end_date__lt=timezone.now()) %} -
-

{{ news.title }}

-

- {{ news.dates.first().start_date|localtime|date(DATETIME_FORMAT) }} - {{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }} - - {{ news.dates.first().end_date|localtime|date(DATETIME_FORMAT) }} - {{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }} -

-

{{ news.club }}

-

{{ news.summary|markdown }}

-
- {% endfor %} -
- {% endfor %} -

{% trans %}Coming soon... don't miss!{% endtrans %}

- {% for news in object_list.filter(dates__start_date__gte=timezone.now()+timedelta(days=5), type="EVENT", is_moderated=True) %} -
-

{{ news.title }} - {{ news.dates.first().start_date|localtime|date(DATETIME_FORMAT) }} - {{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }} - - {{ news.dates.first().end_date|localtime|date(DATETIME_FORMAT) }} - {{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }} -

-
- {% endfor %} + +
+ + {% for news in object_list.filter(type="NOTICE") %} +
+

{{ news.title }}

+
{{ news.summary|markdown }}
+
+ {% endfor %} + + {% for news in object_list.filter(dates__start_date__lte=timezone.now(), + dates__end_date__gte=timezone.now(), type="CALL") %} +
+

{{ news.title }}

+
+ {{ news.dates.first().start_date|localtime|date(DATETIME_FORMAT) }} + {{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }} - + {{ news.dates.first().end_date|localtime|date(DATETIME_FORMAT) }} + {{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }} +
+
{{ news.summary|markdown }}
+
+ {% endfor %} + + {% set events_dates = NewsDate.objects.filter(end_date__gte=timezone.now(), start_date__lte=timezone.now()+timedelta(days=5), + news__type="EVENT", news__is_moderated=True).datetimes('start_date', 'day') %} +

{% trans %}Events today and the next few days{% endtrans %}

+ {% if events_dates %} + {% for d in events_dates %} +
+
+
+
{{ d|localtime|date('D') }}
+
{{ d|localtime|date('d') }}
+
{{ d|localtime|date('b') }}
+
+
+
+ {% for news in object_list.filter(dates__start_date__gte=d, + dates__start_date__lte=d+timedelta(days=1), + type="EVENT").exclude(dates__end_date__lt=timezone.now()) + .order_by('dates__start_date') %} +
+ +

{{ news.title }}

+ +
+ {{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }} - + {{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }} +
+
{{ news.summary|markdown }}
+
+ {% endfor %} +
+
+ {% endfor %} + {% else %} +
+ {% trans %}Nothing to come...{% endtrans %} +
+ {% endif %} + + {% set coming_soon = object_list.filter(dates__start_date__gte=timezone.now()+timedelta(days=5), + type="EVENT").order_by('dates__start_date') %} + {% if coming_soon %} +

{% trans %}Coming soon... don't miss!{% endtrans %}

+ {% for news in coming_soon %} +
+ {{ news.title }} + {{ news.dates.first().start_date|localtime|date(DATETIME_FORMAT) }} + {{ news.dates.first().start_date|localtime|time(DATETIME_FORMAT) }} - + {{ news.dates.first().end_date|localtime|date(DATETIME_FORMAT) }} + {{ news.dates.first().end_date|localtime|time(DATETIME_FORMAT) }} +
+ {% endfor %} + {% endif %} +
{% endblock %} diff --git a/com/views.py b/com/views.py index bf6485a3..77dea73e 100644 --- a/com/views.py +++ b/com/views.py @@ -43,7 +43,7 @@ from datetime import timedelta from com.models import Sith, News, NewsDate, Weekmail, WeekmailArticle from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin, QuickNotifMixin from core.views.forms import SelectDateTime -from core.models import Notification, RealGroup +from core.models import Notification, RealGroup, User from club.models import Club, Mailing @@ -277,6 +277,7 @@ class NewsAdminListView(CanEditMixin, ListView): class NewsListView(CanViewMixin, ListView): model = News template_name = 'com/news_list.jinja' + queryset = News.objects.filter(is_moderated=True) def get_context_data(self, **kwargs): kwargs = super(NewsListView, self).get_context_data(**kwargs) diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index d17e73e6..108a1fb5 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -542,6 +542,12 @@ Welcome to the wiki page! friday += timedelta(hours=6) friday.replace(hour=20, minute=0, second=0) # Event + n = News(title="Apero barman", summary="Viens boire un coup avec les barmans", + content="Glou glou glou glou glou glou glou" , type="EVENT", + club=bar_club, author=subscriber, is_moderated=True, moderator=skia) + n.save() + NewsDate(news=n, start_date=timezone.now()+timedelta(hours=70), + end_date=timezone.now()+timedelta(hours=72)).save() n = News(title="Repas barman", summary="Enjoy la fin du semestre!", content="Viens donc t'enjailler avec les autres barmans aux " "frais du BdF! \o/", type="EVENT", club=bar_club, @@ -549,6 +555,13 @@ Welcome to the wiki page! n.save() NewsDate(news=n, start_date=timezone.now()+timedelta(hours=72), end_date=timezone.now()+timedelta(hours=84)).save() + n = News(title="Repas fromager", summary="Wien manger du l'bon fromeug'", + content="Fô viendre mangey d'la bonne fondue!", + type="EVENT", club=bar_club, author=subscriber, + is_moderated=True, moderator=skia) + n.save() + NewsDate(news=n, start_date=timezone.now()+timedelta(hours=96), + end_date=timezone.now()+timedelta(hours=100)).save() n = News(title="SdF", summary="Enjoy la fin des finaux!", content="Viens faire la fête avec tout plein de gens!", type="EVENT", club=bar_club, author=subscriber, diff --git a/core/static/com/img/news.png b/core/static/com/img/news.png new file mode 100755 index 00000000..072b15b9 Binary files /dev/null and b/core/static/com/img/news.png differ diff --git a/core/static/core/style.scss b/core/static/core/style.scss index 154e32f7..2c145458 100644 --- a/core/static/core/style.scss +++ b/core/static/core/style.scss @@ -339,23 +339,42 @@ header { } } } + /*---------------------------------NEWS--------------------------------*/ #news { - section { - padding: 5px; + .news_column { + display: inline-block; + margin: 0px; + vertical-align: top; } - section.news_call, section.news_notice { - background: lightgrey; - margin: 2px; + #news_admin { + margin-bottom: 1em; } - section.news_event:nth-of-type(even) { - background: lightblue; - } - #agenda { - box-shadow: $black-color 2px 2px 2px; - display: block; + #right_column { width: 20%; float: right; + } + #left_column { + width: 79%; + h3 { + background: $second-color; + box-shadow: grey 2px 2px 2px; + padding: 0.4em; + margin: 0em 0em 0.5em 0em; + text-transform: uppercase; + font-size: 1.1em; + border: solid 1px black; + &:last-of-type { + margin: 2em 0em 1em 0em; + } + } + } + +/* AGENDA */ + #agenda { + box-shadow: grey 2px 2px 2px; + display: block; + width: 100%; background: white; font-size: 70%; border: solid 1px $black-color; @@ -368,7 +387,6 @@ header { text-transform: uppercase; border-bottom: solid 1px $black-color; background: $second-color; - } #agenda_content { overflow: auto; @@ -391,11 +409,136 @@ header { } } } - .news_weekly p { - margin: 0.2em; +/* END AGENDA */ + +/* EVENTS TODAY AND NEXT FEW DAYS */ + .news_events_group { + border: solid 1px black; + box-shadow: grey 2px 2px 2px; + margin-left: 1em; + margin-bottom: 0.5em; + .news_events_group_date { + display: table-cell; + padding: 0.6em; + vertical-align: middle; + background: $primary-dark-color; + color: $white-color; + text-transform: uppercase; + text-align: center; + font-weight: bold; + font-family: monospace; + font-size: 1.4em; + div { + margin: 0px auto; + .day { + font-size: 1.5em; + } + } + } + .news_events_group_items { + display: table-cell; + width: 100%; + border-left: solid 1px black; + .news_event:nth-of-type(odd) { + background: white; + } + .news_event:nth-of-type(even) { + background: $primary-neutral-light-color; + } + .news_event { + display: block; + padding: 0.4em; + &:not(:last-child) { + border-bottom: 1px solid grey; + } + div { + margin: 0.2em; + } + h4 { + margin-top: 1em; + text-transform: uppercase; + } + .club_logo { + float: left; + width: 7em; + margin: 0em; + margin-right: 1em; + margin-bottom: 0.8em; + img { + max-height: 6em; + display: block; + margin: 0em auto; + } + } + .news_date { + font-size: 100%; + } + .news_content { + clear: left; + } + } + } + } +/* END EVENTS TODAY AND NEXT FEW DAYS */ + +/* COMING SOON */ + .news_coming_soon { + display: list-item; + list-style-type: square; + list-style-position: inside; + margin-left: 1em; + padding-left: 0em; + a { + font-weight: bold; + text-transform: uppercase; + } + .news_date { + font-size: 0.9em; + } + } +/* END COMING SOON */ + +/* NOTICES */ + .news_notice { + margin: 0em 0em 1em 1em; + padding: 0.4em; + padding-left: 1em; + background: lightgrey; + border: 1px solid grey; + box-shadow: grey 2px 2px 2px; + h4 { + margin: 0em; + } + .news_content { + margin-left: 1em; + } + } +/* END NOTICES */ + +/* CALLS */ + .news_call { + margin: 0em 0em 1em 1em; + padding: 0.4em; + padding-left: 1em; + background: $secondary-neutral-light-color; + border: 1px solid grey; + box-shadow: grey 2px 2px 2px; + h4 { + margin: 0em; + } + .news_date { + font-size: 0.9em; + } + .news_content { + margin-left: 1em; + } + } +/* END CALLS */ + + .news_empty { + margin-left: 1em; } .news_date { - font-size: small; color: grey; } } @@ -473,7 +616,7 @@ h6 { } p, pre { - margin-top: 1em; + margin-top: 0.8em; margin-left: 0px; }