feat: setup cookies
CI / test (push) Successful in 1m8s
CI / build (push) Successful in 27s

This commit is contained in:
2026-07-21 14:14:40 +02:00
parent d43bbbb5f2
commit 1ecca9362f
10 changed files with 351 additions and 45 deletions
+113 -23
View File
@@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: crochet\n" "Project-Id-Version: crochet\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-07-21 11:59+0000\n" "POT-Creation-Date: 2026-07-21 12:09+0000\n"
"Language: en\n" "Language: en\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@@ -31,6 +31,23 @@ msgstr "Password updated."
msgid "Cambiar contraseña" msgid "Cambiar contraseña"
msgstr "Change password" msgstr "Change password"
#: crochet/templates/crochet/_cookie_banner.html:8
msgid ""
"Usamos únicamente las cookies necesarias para que la web funcione (mantener "
"tu sesión iniciada y proteger los formularios). No usamos cookies de "
"analítica ni de publicidad."
msgstr ""
"We only use the cookies necessary for the site to work (keeping you logged "
"in and protecting forms). We don't use analytics or advertising cookies."
#: crochet/templates/crochet/_cookie_banner.html:9
msgid "Más información"
msgstr "More information"
#: crochet/templates/crochet/_cookie_banner.html:11
msgid "Entendido"
msgstr "Got it"
#: crochet/templates/crochet/account_home.html:4 #: crochet/templates/crochet/account_home.html:4
msgid "Mis patrones" msgid "Mis patrones"
msgstr "My patterns" msgstr "My patterns"
@@ -98,6 +115,75 @@ msgstr "Log out"
msgid "Iniciar sesión" msgid "Iniciar sesión"
msgstr "Log in" msgstr "Log in"
#: crochet/templates/crochet/cookie_policy.html:4
#: crochet/templates/crochet/cookie_policy.html:12
msgid "Política de cookies"
msgstr "Cookie policy"
#: crochet/templates/crochet/cookie_policy.html:15
msgid ""
"Una cookie es un pequeño archivo que una web guarda en tu navegador. Aquí "
"usamos únicamente las que hacen falta para que la página funcione; no usamos "
"cookies de analítica ni de publicidad, ni de terceros."
msgstr ""
"A cookie is a small file that a website stores in your browser. Here we only "
"use the ones needed for the page to work; we don't use analytics, "
"advertising, or third-party cookies."
#: crochet/templates/crochet/cookie_policy.html:20
msgid "Cookies que usamos"
msgstr "Cookies we use"
#: crochet/templates/crochet/cookie_policy.html:25
msgid "Nombre"
msgstr "Name"
#: crochet/templates/crochet/cookie_policy.html:26
msgid "Finalidad"
msgstr "Purpose"
#: crochet/templates/crochet/cookie_policy.html:27
msgid "Duración"
msgstr "Duration"
#: crochet/templates/crochet/cookie_policy.html:33
msgid "Mantiene tu sesión iniciada."
msgstr "Keeps you logged in."
#: crochet/templates/crochet/cookie_policy.html:34
msgid "Hasta que cierras sesión o caduca."
msgstr "Until you log out or it expires."
#: crochet/templates/crochet/cookie_policy.html:38
msgid ""
"Protege los formularios frente a ataques de falsificación de petición (CSRF)."
msgstr "Protects forms against cross-site request forgery (CSRF) attacks."
#: crochet/templates/crochet/cookie_policy.html:39
msgid "1 año."
msgstr "1 year."
#: crochet/templates/crochet/cookie_policy.html:45
msgid ""
"Además, tu navegador guarda localmente (no como cookie) que ya has visto el "
"aviso de cookies, para no volver a mostrártelo."
msgstr ""
"Your browser also stores locally (not as a cookie) that you've already seen "
"the cookie notice, so it isn't shown again."
#: crochet/templates/crochet/cookie_policy.html:51
msgid ""
"Ambas son cookies técnicas necesarias para el funcionamiento del sitio "
"(iniciar sesión y proteger los formularios), así que no requieren tu "
"consentimiento previo."
msgstr ""
"Both are technical cookies necessary for the site to work (logging in and "
"protecting forms), so they don't require your prior consent."
#: crochet/templates/crochet/cookie_policy.html:54
msgid "Volver al inicio"
msgstr "Back to home"
#: crochet/templates/crochet/email/base.html:43 #: crochet/templates/crochet/email/base.html:43
msgid "" msgid ""
"Este email se ha enviado automáticamente, no respondas a esta dirección." "Este email se ha enviado automáticamente, no respondas a esta dirección."
@@ -548,7 +634,7 @@ msgstr ""
msgid "Añade una sección para ver aquí el resultado." msgid "Añade una sección para ver aquí el resultado."
msgstr "Add a section to see the result here." msgstr "Add a section to see the result here."
#: crochet/templates/crochet/pattern_detail.html:24 #: crochet/templates/crochet/pattern_detail.html:26
msgid "Descargar PDF" msgid "Descargar PDF"
msgstr "Download PDF" msgstr "Download PDF"
@@ -581,79 +667,83 @@ msgstr "Sign up"
msgid "¿Ya tienes cuenta? Inicia sesión" msgid "¿Ya tienes cuenta? Inicia sesión"
msgstr "Already have an account? Log in" msgstr "Already have an account? Log in"
#: crochet/urls.py:36
msgid "pattern/<uuid:uuid>/"
msgstr ""
#: crochet/urls.py:37 #: crochet/urls.py:37
msgid "pattern/<uuid:uuid>/edit/" msgid "cookies/"
msgstr "" msgstr ""
#: crochet/urls.py:38 #: crochet/urls.py:38
msgid "pattern/<uuid:uuid>/save/" msgid "pattern/<uuid:uuid>/"
msgstr "" msgstr ""
#: crochet/urls.py:39 #: crochet/urls.py:39
msgid "pattern/<uuid:uuid>/images/" msgid "pattern/<uuid:uuid>/edit/"
msgstr "" msgstr ""
#: crochet/urls.py:40 #: crochet/urls.py:40
msgid "pattern/<uuid:uuid>/cover/" msgid "pattern/<uuid:uuid>/save/"
msgstr "" msgstr ""
#: crochet/urls.py:41 #: crochet/urls.py:41
msgid "pattern/<uuid:uuid>/pdf/" msgid "pattern/<uuid:uuid>/images/"
msgstr "" msgstr ""
#: crochet/urls.py:42 #: crochet/urls.py:42
msgid "pattern/<uuid:uuid>/delete/" msgid "pattern/<uuid:uuid>/cover/"
msgstr "" msgstr ""
#: crochet/urls.py:43 #: crochet/urls.py:43
msgid "pattern/new/" msgid "pattern/<uuid:uuid>/pdf/"
msgstr "" msgstr ""
#: crochet/urls.py:44 #: crochet/urls.py:44
msgid "account/" msgid "pattern/<uuid:uuid>/delete/"
msgstr "" msgstr ""
#: crochet/urls.py:45 #: crochet/urls.py:45
msgid "account/settings/" msgid "pattern/new/"
msgstr "" msgstr ""
#: crochet/urls.py:46 #: crochet/urls.py:46
msgid "account/settings/email/" msgid "account/"
msgstr ""
#: crochet/urls.py:47
msgid "account/settings/"
msgstr "" msgstr ""
#: crochet/urls.py:48 #: crochet/urls.py:48
msgid "account/settings/email/"
msgstr ""
#: crochet/urls.py:50
msgid "account/settings/password/" msgid "account/settings/password/"
msgstr "" msgstr ""
#: crochet/urls.py:51 #: crochet/urls.py:53
msgid "account/register/" msgid "account/register/"
msgstr "" msgstr ""
#: crochet/urls.py:53 #: crochet/urls.py:55
msgid "account/login/" msgid "account/login/"
msgstr "" msgstr ""
#: crochet/urls.py:58 #: crochet/urls.py:60
msgid "account/logout/" msgid "account/logout/"
msgstr "" msgstr ""
#: crochet/urls.py:60 #: crochet/urls.py:62
msgid "account/password-reset/" msgid "account/password-reset/"
msgstr "" msgstr ""
#: crochet/urls.py:79 #: crochet/urls.py:81
msgid "account/password-reset/done/" msgid "account/password-reset/done/"
msgstr "" msgstr ""
#: crochet/urls.py:83 #: crochet/urls.py:85
msgid "account/reset/<uidb64>/<token>/" msgid "account/reset/<uidb64>/<token>/"
msgstr "" msgstr ""
#: crochet/urls.py:91 #: crochet/urls.py:93
msgid "account/reset/done/" msgid "account/reset/done/"
msgstr "" msgstr ""
+102 -21
View File
@@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: crochet\n" "Project-Id-Version: crochet\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-07-21 11:59+0000\n" "POT-Creation-Date: 2026-07-21 12:09+0000\n"
"Language: es\n" "Language: es\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@@ -31,6 +31,21 @@ msgstr ""
msgid "Cambiar contraseña" msgid "Cambiar contraseña"
msgstr "" msgstr ""
#: crochet/templates/crochet/_cookie_banner.html:8
msgid ""
"Usamos únicamente las cookies necesarias para que la web funcione (mantener "
"tu sesión iniciada y proteger los formularios). No usamos cookies de "
"analítica ni de publicidad."
msgstr ""
#: crochet/templates/crochet/_cookie_banner.html:9
msgid "Más información"
msgstr ""
#: crochet/templates/crochet/_cookie_banner.html:11
msgid "Entendido"
msgstr ""
#: crochet/templates/crochet/account_home.html:4 #: crochet/templates/crochet/account_home.html:4
msgid "Mis patrones" msgid "Mis patrones"
msgstr "" msgstr ""
@@ -98,6 +113,68 @@ msgstr ""
msgid "Iniciar sesión" msgid "Iniciar sesión"
msgstr "" msgstr ""
#: crochet/templates/crochet/cookie_policy.html:4
#: crochet/templates/crochet/cookie_policy.html:12
msgid "Política de cookies"
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:15
msgid ""
"Una cookie es un pequeño archivo que una web guarda en tu navegador. Aquí "
"usamos únicamente las que hacen falta para que la página funcione; no usamos "
"cookies de analítica ni de publicidad, ni de terceros."
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:20
msgid "Cookies que usamos"
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:25
msgid "Nombre"
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:26
msgid "Finalidad"
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:27
msgid "Duración"
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:33
msgid "Mantiene tu sesión iniciada."
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:34
msgid "Hasta que cierras sesión o caduca."
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:38
msgid ""
"Protege los formularios frente a ataques de falsificación de petición (CSRF)."
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:39
msgid "1 año."
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:45
msgid ""
"Además, tu navegador guarda localmente (no como cookie) que ya has visto el "
"aviso de cookies, para no volver a mostrártelo."
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:51
msgid ""
"Ambas son cookies técnicas necesarias para el funcionamiento del sitio "
"(iniciar sesión y proteger los formularios), así que no requieren tu "
"consentimiento previo."
msgstr ""
#: crochet/templates/crochet/cookie_policy.html:54
msgid "Volver al inicio"
msgstr ""
#: crochet/templates/crochet/email/base.html:43 #: crochet/templates/crochet/email/base.html:43
msgid "" msgid ""
"Este email se ha enviado automáticamente, no respondas a esta dirección." "Este email se ha enviado automáticamente, no respondas a esta dirección."
@@ -527,7 +604,7 @@ msgstr ""
msgid "Añade una sección para ver aquí el resultado." msgid "Añade una sección para ver aquí el resultado."
msgstr "" msgstr ""
#: crochet/templates/crochet/pattern_detail.html:24 #: crochet/templates/crochet/pattern_detail.html:26
msgid "Descargar PDF" msgid "Descargar PDF"
msgstr "" msgstr ""
@@ -560,82 +637,86 @@ msgstr ""
msgid "¿Ya tienes cuenta? Inicia sesión" msgid "¿Ya tienes cuenta? Inicia sesión"
msgstr "" msgstr ""
#: crochet/urls.py:37
msgid "cookies/"
msgstr ""
# Rutas traducibles de crochet/urls.py: la base "pattern/" se traduce como # Rutas traducibles de crochet/urls.py: la base "pattern/" se traduce como
# "patron/" (sin tilde, para no meter caracteres acentuados en la URL). # "patron/" (sin tilde, para no meter caracteres acentuados en la URL).
#: crochet/urls.py:36 #: crochet/urls.py:38
msgid "pattern/<uuid:uuid>/" msgid "pattern/<uuid:uuid>/"
msgstr "patron/<uuid:uuid>/" msgstr "patron/<uuid:uuid>/"
#: crochet/urls.py:37 #: crochet/urls.py:39
msgid "pattern/<uuid:uuid>/edit/" msgid "pattern/<uuid:uuid>/edit/"
msgstr "patron/<uuid:uuid>/editar/" msgstr "patron/<uuid:uuid>/editar/"
#: crochet/urls.py:38 #: crochet/urls.py:40
msgid "pattern/<uuid:uuid>/save/" msgid "pattern/<uuid:uuid>/save/"
msgstr "patron/<uuid:uuid>/guardar/" msgstr "patron/<uuid:uuid>/guardar/"
#: crochet/urls.py:39 #: crochet/urls.py:41
msgid "pattern/<uuid:uuid>/images/" msgid "pattern/<uuid:uuid>/images/"
msgstr "patron/<uuid:uuid>/imagenes/" msgstr "patron/<uuid:uuid>/imagenes/"
#: crochet/urls.py:40 #: crochet/urls.py:42
msgid "pattern/<uuid:uuid>/cover/" msgid "pattern/<uuid:uuid>/cover/"
msgstr "patron/<uuid:uuid>/portada/" msgstr "patron/<uuid:uuid>/portada/"
#: crochet/urls.py:41 #: crochet/urls.py:43
msgid "pattern/<uuid:uuid>/pdf/" msgid "pattern/<uuid:uuid>/pdf/"
msgstr "patron/<uuid:uuid>/pdf/" msgstr "patron/<uuid:uuid>/pdf/"
#: crochet/urls.py:42 #: crochet/urls.py:44
msgid "pattern/<uuid:uuid>/delete/" msgid "pattern/<uuid:uuid>/delete/"
msgstr "patron/<uuid:uuid>/eliminar/" msgstr "patron/<uuid:uuid>/eliminar/"
#: crochet/urls.py:43 #: crochet/urls.py:45
msgid "pattern/new/" msgid "pattern/new/"
msgstr "patron/nuevo/" msgstr "patron/nuevo/"
# Igual que "pattern/" arriba: "account/" se traduce como "cuenta/". # Igual que "pattern/" arriba: "account/" se traduce como "cuenta/".
#: crochet/urls.py:44 #: crochet/urls.py:46
msgid "account/" msgid "account/"
msgstr "cuenta/" msgstr "cuenta/"
#: crochet/urls.py:45 #: crochet/urls.py:47
msgid "account/settings/" msgid "account/settings/"
msgstr "cuenta/ajustes/" msgstr "cuenta/ajustes/"
#: crochet/urls.py:46 #: crochet/urls.py:48
msgid "account/settings/email/" msgid "account/settings/email/"
msgstr "cuenta/ajustes/email/" msgstr "cuenta/ajustes/email/"
#: crochet/urls.py:48 #: crochet/urls.py:50
msgid "account/settings/password/" msgid "account/settings/password/"
msgstr "cuenta/ajustes/contrasena/" msgstr "cuenta/ajustes/contrasena/"
#: crochet/urls.py:51 #: crochet/urls.py:53
msgid "account/register/" msgid "account/register/"
msgstr "cuenta/registro/" msgstr "cuenta/registro/"
#: crochet/urls.py:53 #: crochet/urls.py:55
msgid "account/login/" msgid "account/login/"
msgstr "cuenta/entrar/" msgstr "cuenta/entrar/"
#: crochet/urls.py:58 #: crochet/urls.py:60
msgid "account/logout/" msgid "account/logout/"
msgstr "cuenta/salir/" msgstr "cuenta/salir/"
#: crochet/urls.py:60 #: crochet/urls.py:62
msgid "account/password-reset/" msgid "account/password-reset/"
msgstr "cuenta/recuperar-contrasena/" msgstr "cuenta/recuperar-contrasena/"
#: crochet/urls.py:79 #: crochet/urls.py:81
msgid "account/password-reset/done/" msgid "account/password-reset/done/"
msgstr "cuenta/recuperar-contrasena/enviado/" msgstr "cuenta/recuperar-contrasena/enviado/"
#: crochet/urls.py:83 #: crochet/urls.py:85
msgid "account/reset/<uidb64>/<token>/" msgid "account/reset/<uidb64>/<token>/"
msgstr "cuenta/restablecer/<uidb64>/<token>/" msgstr "cuenta/restablecer/<uidb64>/<token>/"
#: crochet/urls.py:91 #: crochet/urls.py:93
msgid "account/reset/done/" msgid "account/reset/done/"
msgstr "cuenta/restablecer/hecho/" msgstr "cuenta/restablecer/hecho/"
+18
View File
@@ -0,0 +1,18 @@
// Aviso de cookies (ver crochet/_cookie_banner.html): la preferencia se
// guarda en localStorage, no en una cookie propia, para no tener que crear
// una cookie solo para recordar que se ha descartado el aviso de cookies.
const STORAGE_KEY = 'cookieConsentAccepted';
const banner = document.getElementById('cookie-banner');
const acceptButton = document.getElementById('cookie-banner-accept');
if (banner && acceptButton) {
if (!localStorage.getItem(STORAGE_KEY)) {
banner.classList.remove('hidden');
}
acceptButton.addEventListener('click', () => {
localStorage.setItem(STORAGE_KEY, '1');
banner.classList.add('hidden');
});
}
@@ -0,0 +1,13 @@
{% load i18n %}
<!-- Oculto por defecto (clase "hidden" de Tailwind): cookie-consent.js lo
muestra solo si el navegador no tiene ya guardado que se aceptó, para
que no parpadee visible un instante en cada carga de página. -->
<div id="cookie-banner" class="hidden fixed inset-x-0 bottom-0 z-50 p-4 no-print">
<div class="alert bg-base-100 border border-base-300 shadow-lg max-w-2xl mx-auto flex-col sm:flex-row items-center gap-4">
<span class="text-sm">
{% blocktrans %}Usamos únicamente las cookies necesarias para que la web funcione (mantener tu sesión iniciada y proteger los formularios). No usamos cookies de analítica ni de publicidad.{% endblocktrans %}
<a href="{% url 'crochet:cookie_policy' %}" class="link link-primary">{% trans 'Más información' %}</a>
</span>
<button type="button" id="cookie-banner-accept" class="btn btn-sm btn-primary shrink-0">{% trans 'Entendido' %}</button>
</div>
</div>
+7
View File
@@ -65,6 +65,13 @@
</nav> </nav>
{% endblock %} {% endblock %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
<!-- pattern_detail.html (vista de solo lectura/PDF) sobreescribe este
bloque dejándolo vacío, igual que el navbar: no carga daisyUI y no
debe llevar JS de más (WeasyPrint no lo ejecuta de todos modos). -->
{% block cookie_banner %}
{% include 'crochet/_cookie_banner.html' %}
<script defer src="{% static 'js/cookie-consent.js' %}"></script>
{% endblock %}
{% block extra_js %}{% endblock %} {% block extra_js %}{% endblock %}
</body> </body>
@@ -0,0 +1,56 @@
{% extends 'crochet/base.html' %}
{% load i18n %}
{% block title %}{% trans 'Política de cookies' %}{% endblock %}
{% block extra_css %}
{% include 'crochet/_platform_assets.html' %}
{% endblock %}
{% block content %}
<main class="max-w-2xl mx-auto px-4 py-8 flex flex-col gap-6">
<h1 class="text-2xl font-semibold">{% trans 'Política de cookies' %}</h1>
<p>
{% blocktrans %}Una cookie es un pequeño archivo que una web guarda en tu navegador. Aquí usamos únicamente las que hacen falta para que la página funcione; no usamos cookies de analítica ni de publicidad, ni de terceros.{% endblocktrans %}
</p>
<section class="card bg-base-100 shadow border border-base-300">
<div class="card-body">
<h2 class="card-title text-lg">{% trans 'Cookies que usamos' %}</h2>
<div class="overflow-x-auto">
<table class="table">
<thead>
<tr>
<th>{% trans 'Nombre' %}</th>
<th>{% trans 'Finalidad' %}</th>
<th>{% trans 'Duración' %}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>sessionid</code></td>
<td>{% trans 'Mantiene tu sesión iniciada.' %}</td>
<td>{% trans 'Hasta que cierras sesión o caduca.' %}</td>
</tr>
<tr>
<td><code>csrftoken</code></td>
<td>{% trans 'Protege los formularios frente a ataques de falsificación de petición (CSRF).' %}</td>
<td>{% trans '1 año.' %}</td>
</tr>
</tbody>
</table>
</div>
<p class="text-sm text-base-content/70">
{% blocktrans %}Además, tu navegador guarda localmente (no como cookie) que ya has visto el aviso de cookies, para no volver a mostrártelo.{% endblocktrans %}
</p>
</div>
</section>
<p>
{% blocktrans %}Ambas son cookies técnicas necesarias para el funcionamiento del sitio (iniciar sesión y proteger los formularios), así que no requieren tu consentimiento previo.{% endblocktrans %}
</p>
<a href="{% url 'crochet:home' %}" class="link link-primary">{% trans 'Volver al inicio' %}</a>
</main>
{% endblock %}
@@ -15,8 +15,10 @@
{% endblock %} {% endblock %}
<!-- Sin daisyUI aquí (ver arriba), así que el navbar de base.html no tiene <!-- Sin daisyUI aquí (ver arriba), así que el navbar de base.html no tiene
ningún estilo que aplicarle: se deja vacío a propósito. --> ningún estilo que aplicarle: se deja vacío a propósito. Lo mismo con
el aviso de cookies: es una vista de solo lectura sin JS propio. -->
{% block navbar %}{% endblock %} {% block navbar %}{% endblock %}
{% block cookie_banner %}{% endblock %}
{% block content %} {% block content %}
<main class="p-4"> <main class="p-4">
+33
View File
@@ -53,6 +53,39 @@ class HomeViewTests(TestCase):
self.assertEqual(response_en.status_code, 200) self.assertEqual(response_en.status_code, 200)
class CookiePolicyViewTests(TestCase):
def test_get_renders_the_policy_page(self):
with translation.override('es'):
url = reverse('crochet:cookie_policy')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'crochet/cookie_policy.html')
self.assertContains(response, 'sessionid')
self.assertContains(response, 'csrftoken')
class CookieBannerTests(TestCase):
def test_regular_pages_include_the_cookie_banner(self):
with translation.override('es'):
url = reverse('crochet:home')
policy_url = reverse('crochet:cookie_policy')
response = self.client.get(url)
self.assertContains(response, 'id="cookie-banner"')
self.assertContains(response, f'href="{policy_url}"')
self.assertContains(response, 'cookie-consent.js')
def test_pattern_detail_does_not_include_the_cookie_banner(self):
pattern = Pattern.objects.create()
with translation.override('es'):
url = reverse('crochet:pattern_detail', args=[pattern.uuid])
response = self.client.get(url)
self.assertNotContains(response, 'id="cookie-banner"')
self.assertNotContains(response, 'cookie-consent.js')
class LanguageSwitcherTests(TestCase): class LanguageSwitcherTests(TestCase):
def test_home_page_switcher_offers_the_same_page_in_english(self): def test_home_page_switcher_offers_the_same_page_in_english(self):
response = self.client.get('/es/') response = self.client.get('/es/')
+2
View File
@@ -8,6 +8,7 @@ from crochet.views import (
AccountHomeView, AccountHomeView,
AccountPasswordChangeView, AccountPasswordChangeView,
AccountSettingsView, AccountSettingsView,
CookiePolicyView,
HomeView, HomeView,
PatternCoverImageUploadView, PatternCoverImageUploadView,
PatternCreateView, PatternCreateView,
@@ -33,6 +34,7 @@ app_name = 'crochet'
# /es/patron/<uuid>/editar/. # /es/patron/<uuid>/editar/.
urlpatterns = [ urlpatterns = [
path('', name='home', view=HomeView.as_view()), path('', name='home', view=HomeView.as_view()),
path(_('cookies/'), name='cookie_policy', view=CookiePolicyView.as_view()),
path(_('pattern/<uuid:uuid>/'), name='pattern_detail', view=PatternDetailView.as_view()), path(_('pattern/<uuid:uuid>/'), name='pattern_detail', view=PatternDetailView.as_view()),
path(_('pattern/<uuid:uuid>/edit/'), name='pattern_edit', view=PatternEditView.as_view()), path(_('pattern/<uuid:uuid>/edit/'), name='pattern_edit', view=PatternEditView.as_view()),
path(_('pattern/<uuid:uuid>/save/'), name='pattern_save', view=PatternSaveView.as_view()), path(_('pattern/<uuid:uuid>/save/'), name='pattern_save', view=PatternSaveView.as_view()),
+4
View File
@@ -67,6 +67,10 @@ class HomeView(TemplateView):
template_name = 'crochet/home.html' template_name = 'crochet/home.html'
class CookiePolicyView(TemplateView):
template_name = 'crochet/cookie_policy.html'
class PatternEditView(LoginRequiredMixin, DetailView): class PatternEditView(LoginRequiredMixin, DetailView):
model = Pattern model = Pattern
template_name = 'crochet/pattern.html' template_name = 'crochet/pattern.html'