Skip to content

Commit

Permalink
render members:login FormView POST call
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Nov 7, 2024
1 parent 952226c commit 14393f8
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lacommunaute/forum_member/tests/__snapshots__/tests_view.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,38 @@
</section>


</main>
'''
# ---
# name: TestLoginView.test_post[login_view_content]
'''
<main class="s-main" id="main" role="main">






<section class="s-title-01 mt-lg-5">
<div class="s-title-01__container container">
<div class="s-title-01__row row">
<div class="s-title-01__col col-lg-8 col-12">
<h1 class="s-title-01__title h1">Se connecter | S'inscrire</h1>
</div>
</div>
</div>
</section>
<section class="s-section">
<div class="s-section__container container">
<div class="s-section__row row">
<div class="s-section__col col-12 col-lg-7">
Un lien de connexion vous a été envoyé par à l'adresse [email protected]. Veuillez vérifier votre boîte de réception et cliquer sur le lien pour vous connecter.
</div>
</div>
</div>
</section>


</main>
'''
# ---
7 changes: 7 additions & 0 deletions lacommunaute/forum_member/tests/tests_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ def test_content(self, client, db, next, snapshot):
assert response.status_code == 200
content = parse_response_to_soup(response, selector="main")
assert str(content) == snapshot(name="login_view_content")

def test_post(self, client, db, snapshot):
email = "[email protected]"
response = client.post(reverse("members:login"), data={"email": email})
assert response.status_code == 200
content = parse_response_to_soup(response, selector="main")
assert str(content) == snapshot(name="login_view_content")
6 changes: 6 additions & 0 deletions lacommunaute/forum_member/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from django.shortcuts import render
from django.urls import reverse
from django.views.generic import FormView, ListView
from machina.apps.forum_member.views import (
Expand Down Expand Up @@ -53,3 +54,8 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["next"] = self.request.GET.get("next", "/")
return context

def form_valid(self, form):
email = form.cleaned_data["email"]
next = self.request.GET.get("next", "/")
return render(self.request, "registration/login_link_sent.html", {"email": email, "next": next})
28 changes: 28 additions & 0 deletions lacommunaute/templates/registration/login_link_sent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends "layouts/base.html" %}
{% load static %}
{% load i18n %}
{% load theme_inclusion %}
{% block title %}Connexion {{ block.super }}{% endblock %}
{% block meta_description %}
{% trans "Login | Sign in" %}
{% endblock meta_description %}
{% block content %}
<section class="s-title-01 mt-lg-5">
<div class="s-title-01__container container">
<div class="s-title-01__row row">
<div class="s-title-01__col col-lg-8 col-12">
<h1 class="s-title-01__title h1">{% trans "Login | Sign in" %}</h1>
</div>
</div>
</div>
</section>
<section class="s-section">
<div class="s-section__container container">
<div class="s-section__row row">
<div class="s-section__col col-12 col-lg-7">
Un lien de connexion vous a été envoyé par à l'adresse {{ email }}. Veuillez vérifier votre boîte de réception et cliquer sur le lien pour vous connecter.
</div>
</div>
</div>
</section>
{% endblock content %}

0 comments on commit 14393f8

Please sign in to comment.