Commit d7c0f00d authored by Théo Labetowiez's avatar Théo Labetowiez

[COM]Tests and some corections

parent 27f687bb
Pipeline #1967 passed with stage
in 22 minutes and 41 seconds
......@@ -40,28 +40,28 @@
<div id="birthdays">
<div id="birthdays_title">{% trans %}Birthdays{% endtrans %}</div>
<div id="birthdays_content">
{% if user.is_authenticated %}
{% if user.is_subscribed %}
<ul class="birthdays_year">
{% for d in birthdays.dates('date_of_birth', 'year', 'DESC') %}
<li>
{% trans age=timezone.now().year - d.year %}{{ age }} year old{% endtrans %}
<ul>
{% for u in birthdays.filter(date_of_birth__year=d.year) %}
<li><a href="{{ u.get_absolute_url() }}">{{ u.get_short_name() }}</a></li>
{% endfor %}
{% if user.is_authenticated %}
<div id="birthdays_content">
{% if user.is_subscribed %}
<ul class="birthdays_year">
{% for d in birthdays.dates('date_of_birth', 'year', 'DESC') %}
<li>
{% trans age=timezone.now().year - d.year %}{{ age }} year old{% endtrans %}
<ul>
{% for u in birthdays.filter(date_of_birth__year=d.year) %}
<li><a href="{{ u.get_absolute_url() }}">{{ u.get_short_name() }}</a></li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
{% else %}
<p>{% trans %}You need to update your subscription to access to this content{% endtrans %}</p>
</div>
{% else %}
<p>{% trans %}You need to update your subscription to access to this content{% endtrans %}</p>
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
</div>
<div id="left_column" class="news_column">
......
......@@ -26,6 +26,9 @@ from django.test import TestCase
from django.conf import settings
from django.core.urlresolvers import reverse
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
......@@ -74,3 +77,28 @@ class ComTest(TestCase):
"""<div id="info_box">\\n <div class="markdown"><h3>INFO: <strong>Caaaataaaapuuuulte!!!!</strong></h3>"""
in str(r.content)
)
def test_birthday_non_authenticated_user(self):
self.client.logout()
response = self.client.get(reverse("core:index"))
self.assertNotContains(response, text="""<div id="birthdays_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 to update your subscription to access to this content")
),
)
def test_birthday_subscibed_user(self):
response = self.client.get(reverse("core:index"))
self.assertNotContains(
response,
text=html.escape(
_("You need to update your subscription to access to this content")
),
)
......@@ -41,6 +41,7 @@ from club.models import Club
def index(request, context=None):
from com.views import NewsListView
return NewsListView.as_view()(request)
......
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