Skip to content

Commit

Permalink
EventMonthArchiveView UI update
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Dec 3, 2024
1 parent c0fea8e commit 59f22bd
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 8 deletions.
56 changes: 56 additions & 0 deletions lacommunaute/event/tests/__snapshots__/tests_views.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# serializer version: 1
# name: TestEventMonthArchiveView.test_action_box[False-anonymous][anonymous]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">
Je suis l'organisateur d'un évènement à destination des CIP pour les aider à améliorer leur pratique professionnelle ?
<br/>
Je me connecte pour ajouter un évènement public dans le calendrier de la communauté
</div>
<div class="col-lg-auto col-12">


<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=%2Fcalendar%2Fcreate%2F">Se connecter | S'inscrire</a>

</div>
</div>
</div>
</div>
</div>

</div>
</section>
'''
# ---
# name: TestEventMonthArchiveView.test_action_box[True-authenticated][authenticated]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">
Je suis l'organisateur d'un évènement à destination des CIP pour les aider à améliorer leur pratique professionnelle ?
<br/>
J'ajoute un évènement public dans le calendrier de la communauté
</div>
<div class="col-lg-auto col-12">
<a class="btn btn-primary" href="/calendar/create/">Ajouter un évènement public</a>
</div>
</div>
</div>
</div>
</div>

</div>
</section>
'''
# ---
23 changes: 20 additions & 3 deletions lacommunaute/event/tests/tests_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime, timedelta

import pytest
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.test import TestCase
Expand All @@ -12,6 +13,7 @@
from lacommunaute.event.forms import EventModelForm
from lacommunaute.event.models import Event
from lacommunaute.users.factories import UserFactory
from lacommunaute.utils.testing import parse_response_to_soup


faker = Faker()
Expand Down Expand Up @@ -75,7 +77,7 @@ def setUpTestData(cls):
def test_login_is_required(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("openid_connect:authorize") + "?next=" + self.url)
self.assertEqual(response.url, reverse("users:login") + "?next=" + self.url)

def test_event_is_created(self):
self.client.force_login(self.user)
Expand Down Expand Up @@ -191,7 +193,7 @@ def setUpTestData(cls):
def test_login_is_required(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("openid_connect:authorize") + "?next=" + self.url)
self.assertEqual(response.url, reverse("users:login") + "?next=" + self.url)

self.client.force_login(self.user)
response = self.client.get(self.url)
Expand Down Expand Up @@ -221,7 +223,6 @@ def test_view_wo_args(self):
response = self.client.get(reverse("event:current"))
self.assertContains(response, event.name, status_code=200)
self.assertContains(response, reverse("event:detail", kwargs={"pk": event.pk}))
self.assertContains(response, reverse("event:create"))

def test_view_with_args(self):
event = EventFactory(date=timezone.now())
Expand Down Expand Up @@ -272,3 +273,19 @@ def test_navbar(self):
),
status_code=200,
)


class TestEventMonthArchiveView:
@pytest.mark.parametrize(
"authenticated,snapshot_name",
[
(False, "anonymous"),
(True, "authenticated"),
],
)
def test_action_box(self, client, db, authenticated, snapshot_name, snapshot):
if authenticated:
client.force_login(UserFactory())
response = client.get(reverse("event:current"))
content = parse_response_to_soup(response, selector="#action-box")
assert str(content) == snapshot(name=snapshot_name)
39 changes: 34 additions & 5 deletions lacommunaute/templates/event/event_archive_month.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{% trans "Events" %} {{ month }}
{% endblock sub_title %}
{% block content %}
{% url 'event:create' as create_url %}
<section class="s-title-01 mt-lg-5">
<div class="s-title-01__container container">
<div class="s-title-01__row row">
Expand Down Expand Up @@ -55,13 +56,41 @@ <h1 class="s-title-01__title h1">
</div>
</div>
</section>
<section class="s-section">
<section id="action-box" class="s-section">
<div class="s-section__container container">
<div class="s-section__row row">
<div class="s-section__col col-12">
<a href="{% url 'event:create' %}" role="button" class="btn btn-primary">{% trans "Post a new Public Event" %}</a>
{% if user.is_authenticated %}
<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">
Je suis l'organisateur d'un évènement à destination des CIP pour les aider à améliorer leur pratique professionnelle ?
<br>
J'ajoute un évènement public dans le calendrier de la communauté
</div>
<div class="col-lg-auto col-12 ">
<a href="{{ create_url }}" class="btn btn-primary">{% trans "Post a new Public Event" %}</a>
</div>
</div>
</div>
</div>
</div>
</div>
{% else %}
<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">
Je suis l'organisateur d'un évènement à destination des CIP pour les aider à améliorer leur pratique professionnelle ?
<br>
Je me connecte pour ajouter un évènement public dans le calendrier de la communauté
</div>
<div class="col-lg-auto col-12">{% include "registration/includes/login_link.html" with next=create_url %}</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
</section>
{% endblock content %}

0 comments on commit 59f22bd

Please sign in to comment.