Skip to content

Commit

Permalink
add mailman template view
Browse files Browse the repository at this point in the history
  • Loading branch information
jeriox committed Sep 13, 2024
1 parent a99d08d commit c63637e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
6 changes: 2 additions & 4 deletions myhpi/tenca_django/mailinglist.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def toggle_membership(self, email):
This is useful from interfaces where you don't want to hint attackers
the current membership status of others.
Returns a tuple of (status, token), where token is True if the user was newly
Returns a tuple of (status, token), where status is True if the user was newly
added and False if it was removed.
"""
if self.is_member(email):
Expand All @@ -121,9 +121,7 @@ def configure_single_template(self, mailman_template_name, tenca_template_name):
invite_link=self.build_invite_link(),
web_ui=urllib.parse.urljoin(settings.GET_SITE_URL(), reverse("tenca_dashboard"))
)
self.list.set_template(mailman_template_name, templates.http_substitute_url(
tenca_template_name, **template_args
))
self.list.set_template(mailman_template_name, urllib.parse.urljoin(settings.SITE_URL, reverse("tenca_django:mailman_template", kwargs={'template_name': tenca_template_name})))

def pending_subscriptions(self, request_type='subscription'):
"""As of mailman<3.3.3 no unsubscriptions are delivered via REST.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
{{action_link}}

If you did not request this, please report abuse by visiting the following link:
$action_abuse_link
{{action_abuse_link}}

Thanks for using {{web_ui}}! We hope to serve you again soon.
1 change: 1 addition & 0 deletions myhpi/tenca_django/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
app_name = "tenca_django"

urlpatterns = [
path("templates/<str:template_name>/", views.MailmanTemplateView.as_view(), name="mailman_template"),
path("dashboard/", views.TencaDashboard.as_view(), name="tenca_dashboard"),
path(
"confirm/<str:list_id>/<str:token>/", views.TencaActionConfirmView.as_view(), name="confirm"
Expand Down
15 changes: 15 additions & 0 deletions myhpi/tenca_django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
from myhpi.tenca_django.mixins import TencaListAdminMixin, TencaSingleListMixin


class MailmanTemplateView(TemplateView):
content_type = "text/plain"

def get_template_names(self):
if (template_name := self.kwargs.get("template_name", None)) and template_name in ["creation_message", "subscription_message", "unsubscription_message", "rejected_message", "mail_footer"]:
return [f"mailman/{template_name}.html"]
raise Http404

def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
for key, value in self.request.GET.items():
ctx[key] = value
return ctx


class TencaDashboard(LoginRequiredMixin, FormView):
template_name = "tenca_django/dashboard.html"
form_class = TencaNewListForm
Expand Down

0 comments on commit c63637e

Please sign in to comment.