Commit d7b351a1 authored by Sli's avatar Sli

Merge branch 'cyl' into 'master'

[COM] Make the news visible for non-authenticated user and birthday visible for subriber only

See merge request !225
parents 2232c495 9e0c4e70
Pipeline #1995 passed with stage
in 23 minutes and 56 seconds
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-08-18 17:00
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("com", "0005_auto_20180318_2227")]
operations = [migrations.RemoveField(model_name="sith", name="index_page")]
...@@ -45,7 +45,6 @@ class Sith(models.Model): ...@@ -45,7 +45,6 @@ class Sith(models.Model):
alert_msg = models.TextField(_("alert message"), default="", blank=True) alert_msg = models.TextField(_("alert message"), default="", blank=True)
info_msg = models.TextField(_("info 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="") weekmail_destinations = models.TextField(_("weekmail destinations"), default="")
def is_owned_by(self, user): def is_owned_by(self, user):
......
...@@ -40,22 +40,26 @@ ...@@ -40,22 +40,26 @@
<div id="birthdays"> <div id="birthdays">
<div id="birthdays_title">{% trans %}Birthdays{% endtrans %}</div> <div id="birthdays_title">{% trans %}Birthdays{% endtrans %}</div>
<div id="birthdays_content"> <div id="birthdays_content">
<ul class="birthdays_year"> {% if user.is_subscribed %}
{% for d in birthdays.dates('date_of_birth', 'year', 'DESC') %} <ul class="birthdays_year">
<li> {% for d in birthdays.dates('date_of_birth', 'year', 'DESC') %}
{% trans age=timezone.now().year - d.year %}{{ age }} year old{% endtrans %} <li>
<ul> {% trans age=timezone.now().year - d.year %}{{ age }} year old{% endtrans %}
{% for u in birthdays.filter(date_of_birth__year=d.year) %} <ul>
<li><a href="{{ u.get_absolute_url() }}">{{ u.get_short_name() }}</a></li> {% for u in birthdays.filter(date_of_birth__year=d.year) %}
{% endfor %} <li><a href="{{ u.get_absolute_url() }}">{{ u.get_short_name() }}</a></li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul> </ul>
</li> {% else %}
{% endfor %} <p>{% trans %}You need an up to date subscription to access this content{% endtrans %}</p>
</ul> {% endif %}
</div>
</div> </div>
</div> </div>
</div>
<div id="left_column" class="news_column"> <div id="left_column" class="news_column">
......
...@@ -26,6 +26,9 @@ from django.test import TestCase ...@@ -26,6 +26,9 @@ from django.test import TestCase
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.management import call_command from django.core.management import call_command
from django.utils import html
from django.utils.translation import ugettext as _
from core.models import User, RealGroup from core.models import User, RealGroup
...@@ -74,3 +77,23 @@ class ComTest(TestCase): ...@@ -74,3 +77,23 @@ class ComTest(TestCase):
"""<div id="info_box">\\n <div class="markdown"><h3>INFO: <strong>Caaaataaaapuuuulte!!!!</strong></h3>""" """<div id="info_box">\\n <div class="markdown"><h3>INFO: <strong>Caaaataaaapuuuulte!!!!</strong></h3>"""
in str(r.content) in str(r.content)
) )
def test_birthday_non_subscribed_user(self):
self.client.login(username="guy", password="plop")
response = self.client.get(reverse("core:index"))
self.assertContains(
response,
text=html.escape(
_("You need an up to date subscription to access this content")
),
)
def test_birthday_subscibed_user(self):
response = self.client.get(reverse("core:index"))
self.assertNotContains(
response,
text=html.escape(
_("You need an up to date subscription to access this content")
),
)
...@@ -30,7 +30,6 @@ from club.views import MailingDeleteView ...@@ -30,7 +30,6 @@ from club.views import MailingDeleteView
urlpatterns = [ urlpatterns = [
url(r"^sith/edit/alert$", AlertMsgEditView.as_view(), name="alert_edit"), url(r"^sith/edit/alert$", AlertMsgEditView.as_view(), name="alert_edit"),
url(r"^sith/edit/info$", InfoMsgEditView.as_view(), name="info_edit"), url(r"^sith/edit/info$", InfoMsgEditView.as_view(), name="info_edit"),
url(r"^sith/edit/index$", IndexEditView.as_view(), name="index_edit"),
url( url(
r"^sith/edit/weekmail_destinations$", r"^sith/edit/weekmail_destinations$",
WeekmailDestinationEditView.as_view(), WeekmailDestinationEditView.as_view(),
......
...@@ -182,14 +182,6 @@ class InfoMsgEditView(ComEditView): ...@@ -182,14 +182,6 @@ class InfoMsgEditView(ComEditView):
success_url = reverse_lazy("com:info_edit") success_url = reverse_lazy("com:info_edit")
class IndexEditView(ComEditView):
form_class = modelform_factory(
Sith, fields=["index_page"], widgets={"index_page": MarkdownInput}
)
current_tab = "index"
success_url = reverse_lazy("com:index_edit")
class WeekmailDestinationEditView(ComEditView): class WeekmailDestinationEditView(ComEditView):
fields = ["weekmail_destinations"] fields = ["weekmail_destinations"]
current_tab = "weekmail_destinations" current_tab = "weekmail_destinations"
......
{% extends "core/base.jinja" %}
{% block title %}
{% trans %}Welcome!{% endtrans %}
{% endblock %}
{% block content %}
{{ get_sith().index_page|markdown }}
{% endblock %}
...@@ -40,11 +40,9 @@ from club.models import Club ...@@ -40,11 +40,9 @@ from club.models import Club
def index(request, context=None): def index(request, context=None):
if request.user.is_authenticated(): from com.views import NewsListView
from com.views import NewsListView
return NewsListView.as_view()(request) return NewsListView.as_view()(request)
return render(request, "core/index.jinja")
class NotificationList(ListView): class NotificationList(ListView):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment