Skip to content

Commit 0e76285

Browse files
committed
refactor: Refactor contact info block into a component
- Remove DjangoSnippetsEmailVerificationSentView (no longer needed for overriding) - Use the contact info component on the Email Verification page as well
1 parent 82c3a62 commit 0e76285

File tree

8 files changed

+85
-48
lines changed

8 files changed

+85
-48
lines changed

base/components/components.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Literal
22

33
from django_components import Component, register
4-
from pydantic import BaseModel
4+
from pydantic import BaseModel, EmailStr
55

66
from base.main import TAB_VAR, ObjectList
77
from base.pagination import PAGE_VAR, Pagination
@@ -107,3 +107,25 @@ def get_template_data(self, args, kwargs, slots, context):
107107
"tabs": self.create_all_tabs(object_list),
108108
"object_list": object_list,
109109
}
110+
111+
112+
@register("contact_information_button")
113+
class ContactInformationButton(Component):
114+
MAINTAINER_EMAILS = [
115+
"antoliny0919@gmail.com",
116+
"wedgemail@gmail.com",
117+
]
118+
template_file = "contact_information_button.html"
119+
120+
class Kwargs(BaseModel):
121+
button_text: str
122+
description: str
123+
contact_emails: list[EmailStr] | None = None
124+
125+
def get_template_data(self, args, kwargs, slots, context):
126+
contact_emails = kwargs.contact_emails or self.MAINTAINER_EMAILS
127+
return {
128+
"button_text": kwargs.button_text,
129+
"description": kwargs.description,
130+
"contact_emails": contact_emails,
131+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{% if contact_emails %}
2+
<div class="flex flex-col justify-center items-center" x-data="{ show: false }">
3+
<button
4+
class="p-0 m-0 text-base-white border-2 px-4 py-2 rounded-lg font-text"
5+
:class="show ? 'bg-base-green-400' : 'bg-base-green-600 hover:bg-base-green-400'"
6+
@click="show = !show"
7+
:aria-expanded="show"
8+
>
9+
{{ button_text }}
10+
</button>
11+
<div x-show="show" class="text-center my-4 text-base" x-transition>
12+
<span>{{ description }}</span>
13+
<div class="flex justify-center gap-4 mt-2">
14+
{% for email in contact_emails %}
15+
<a class="underline" href="mailto:{{ email }}">{{ email }}</a>
16+
{% endfor %}
17+
</div>
18+
</div>
19+
</div>
20+
{% endif %}

base/views.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{% extends "account/base.html" %}
22

3-
{% load i18n %}
4-
{% load account %}
3+
{% load static widget_tweaks %}
54

6-
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
5+
{% block head_title %}Verify Your E-mail Address{% endblock %}
76

8-
{% block content_header %}{% trans "Password Reset" %}{% endblock %}
7+
{% block header%}{% endblock %}
98

109
{% block content %}
11-
{% if user.is_authenticated %}
12-
{% include "account/snippets/already_logged_in.html" %}
13-
{% endif %}
14-
15-
<p>{% blocktrans %}We have sent you an e-mail. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}</p>
10+
<div class="w-[40rem] flex flex-col items-center justify-center mx-auto p-8 font-common shadow-sign-content rounded-lg">
11+
<h3>Password Reset</h3>
12+
<img src="{% static 'img/verification_sent.png' %}">
13+
<p class="my-4 text-xl font-common">We have sent an e-mail to you for verification 🚀</p>
14+
<p class="text-center">Follow the link provided to finalize the password reset process. If you do not see the verification email in your main inbox, check your spam folder.</p>
15+
{% component 'contact_information_button' button_text="Didn't receive the email ?" description="If you didn't receive the verification email, please contact us at:" / %}
16+
</div>
1617
{% endblock %}
18+
{% block footer %}{% endblock %}

djangosnippets/templates/account/verification_sent.html

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,7 @@ <h3>Email Verification</h3>
1212
<img src="{% static 'img/verification_sent.png' %}">
1313
<p class="my-4 text-xl font-common">We have sent an e-mail to you for verification 🚀</p>
1414
<p class="text-center">Follow the link provided to finalize the signup process. If you do not see the verification email in your main inbox, check your spam folder.</p>
15-
{% if maintainer_emails %}
16-
<div class="flex flex-col justify-center items-center" x-data="{ show: false }">
17-
<button
18-
class="p-0 m-0 text-base-white border-2 px-4 py-2 rounded-lg font-text"
19-
:class="show ? 'bg-base-green-400' : 'bg-base-green-600 hover:bg-base-green-400'"
20-
@click="show = !show"
21-
>
22-
Didn't receive the email ?
23-
</button>
24-
<div x-show="show" class="text-center my-4 text-base" x-transition>
25-
<span>If you didn't receive the verification email, please contact us at:</span>
26-
<div class="flex justify-center gap-4 mt-2">
27-
{% for email in maintainer_emails %}
28-
<a class="underline" href="mailto:{{ email }}">{{ email }}</a>
29-
{% endfor %}
30-
</div>
31-
</div>
32-
</div>
33-
{% endif %}
15+
{% component 'contact_information_button' button_text="Didn't receive the email ?" description="If you didn't receive the verification email, please contact us at:" / %}
3416
</div>
3517
{% endblock %}
3618
{% block footer %}{% endblock %}

djangosnippets/urls.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from django.shortcuts import render
33
from django.urls import include, path
44

5-
from base.views import DjangoSnippetsEmailVerificationSentView
6-
75
admin.autodiscover()
86

97

@@ -13,7 +11,6 @@ def trigger_sentry_error(request):
1311

1412
urlpatterns = [
1513
path("sentry-debug/", trigger_sentry_error),
16-
path("accounts/confirm-email/", DjangoSnippetsEmailVerificationSentView.as_view(), name="account_email_verification_sent"),
1714
path("accounts/", include("allauth.urls")),
1815
path("manage/", admin.site.urls),
1916
path("components/", include("django_components.urls")),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies = [
2020
"markdown",
2121
"pillow",
2222
"psycopg2-binary",
23-
"pydantic",
23+
"pydantic[email]",
2424
"pygments",
2525
"python-akismet",
2626
"python-dotenv",

uv.lock

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)