From: Michael Tremer Date: Wed, 26 Jul 2023 15:17:02 +0000 (+0000) Subject: users: Move Subscribe/Unsubscribe handlers from People X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb440bad6f16f8921140d67bf5843fdd9089d7b0;p=ipfire.org.git users: Move Subscribe/Unsubscribe handlers from People Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 8b276632..3268135c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,10 +293,7 @@ templates_nopaste_modules_DATA = \ templates_nopaste_modulesdir = $(templates_nopastedir)/modules templates_people_DATA = \ - src/templates/people/index.html \ - src/templates/people/subscribed.html \ - src/templates/people/unsubscribe.html \ - src/templates/people/unsubscribed.html + src/templates/people/index.html templates_peopledir = $(templatesdir)/people @@ -318,7 +315,11 @@ templates_users_DATA = \ src/templates/users/edit.html \ src/templates/users/index.html \ src/templates/users/passwd.html \ - src/templates/users/show.html + src/templates/users/show.html \ + src/templates/users/subscribe.html \ + src/templates/users/subscribed.html \ + src/templates/users/unsubscribe.html \ + src/templates/users/unsubscribed.html templates_usersdir = $(templatesdir)/users diff --git a/src/templates/people/subscribed.html b/src/templates/people/subscribed.html deleted file mode 100644 index 5a26825f..00000000 --- a/src/templates/people/subscribed.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Thank You") }}{% end block %} - -{% block content %} -
-
-
-
- - -

- {{ _("You have been subscribed and will now receive updates from the IPFire Project.") }} -

-
-
- - -
-
-{% end block %} diff --git a/src/templates/people/unsubscribed.html b/src/templates/people/unsubscribed.html deleted file mode 100644 index 164f4426..00000000 --- a/src/templates/people/unsubscribed.html +++ /dev/null @@ -1,29 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Thank You") }}{% end block %} - -{% block content %} -
-
-
-
- - -

- {{ _("You have been unsubscribed and will no longer receive important updates from the IPFire Project.") }} -

-
-
- -
- {% raw xsrf_form_html() %} - -
- -
-
-
-
-{% end block %} diff --git a/src/templates/users/subscribe.html b/src/templates/users/subscribe.html new file mode 100644 index 00000000..06a5420a --- /dev/null +++ b/src/templates/users/subscribe.html @@ -0,0 +1,35 @@ +{% extends "../base.html" %} + +{% block title %}{{ _("Subscribe") }}{% end block %} + +{% block container %} +
+
+
+
{{ _("Subscribe Now To Stay Up To Date") }}
+ +
+

+ {{ _("Subscribe and you will receive important emails from the IPFire Project:") }} +

+ +
    +
  • {{ _("Important release announcements including notificiations about security updates") }}
  • +
  • {{ _("News from our blog and inside the project") }}
  • +
  • {{ _("Information about our fundraising efforts") }}
  • +
+
+ +
+
+ {% raw xsrf_form_html() %} + + +
+
+
+
+
+{% end block %} diff --git a/src/templates/users/subscribed.html b/src/templates/users/subscribed.html new file mode 100644 index 00000000..a58f02d0 --- /dev/null +++ b/src/templates/users/subscribed.html @@ -0,0 +1,19 @@ +{% extends "../base.html" %} + +{% block title %}{{ _("Thank You") }}{% end block %} + +{% block container %} +
+
+
+
+ +
+ +

+ {{ _("You have been subscribed and will now receive updates from the IPFire Project") }} +

+
+
+
+{% end block %} diff --git a/src/templates/people/unsubscribe.html b/src/templates/users/unsubscribe.html similarity index 51% rename from src/templates/people/unsubscribe.html rename to src/templates/users/unsubscribe.html index 04a264b1..631239a1 100644 --- a/src/templates/people/unsubscribe.html +++ b/src/templates/users/unsubscribe.html @@ -2,13 +2,13 @@ {% block title %}{{ _("Unsubscribe") }}{% end block %} -{% block content %} -
-
-
-
-
{{ _("We'd Be Sorry To See You Go") }}
+{% block container %} +
+
+
+
{{ _("We'd Be Sorry To See You Go") }}
+

{{ _("If you unsubscribe, you will no longer receive important emails from the IPFire Project.") }} {{ _("There are plenty of benefits to remain subscribed:") }} @@ -19,25 +19,25 @@

  • {{ _("News from our blog and inside the project") }}
  • {{ _("Information about our fundraising efforts") }}
  • +
    -
    +
    + {% raw xsrf_form_html() %} -
    - -
    + +
    -
    +
    + {% raw xsrf_form_html() %} -
    - -
    +
    diff --git a/src/templates/users/unsubscribed.html b/src/templates/users/unsubscribed.html new file mode 100644 index 00000000..bf1c0aae --- /dev/null +++ b/src/templates/users/unsubscribed.html @@ -0,0 +1,31 @@ +{% extends "../base.html" %} + +{% block title %}{{ _("Thank You") }}{% end block %} + +{% block container %} +
    +
    +
    +
    +
    + +
    + +

    + {{ _("You have been unsubscribed and will no longer receive important updates from the IPFire Project") }} +

    +
    +
    + +
    +
    + {% raw xsrf_form_html() %} + + +
    +
    +
    +
    +{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 9041b861..848abae6 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -181,6 +181,10 @@ class Application(tornado.web.Application): (r"/users/([a-z_][a-z0-9_-]{0,31})/edit", users.EditHandler), (r"/users/([a-z_][a-z0-9_-]{0,31})/passwd", users.PasswdHandler), + # Promotional Consent Stuff + (r"/subscribe", users.SubscribeHandler), + (r"/unsubscribe", users.UnsubscribeHandler), + # VoIP (r"/voip", voip.IndexHandler), @@ -336,10 +340,6 @@ class Application(tornado.web.Application): (r"/activate/([a-z_][a-z0-9_-]{0,31})/(\w+)", auth.ActivateHandler), (r"/register", auth.RegisterHandler), - # Promotional Consent Stuff - (r"/subscribe", people.SubscribeHandler), - (r"/unsubscribe", people.UnsubscribeHandler), - # Serve any static files (r"/static/(.*)", tornado.web.StaticFileHandler, { "path" : self.settings.get("static_path") }), ] + authentication_handlers) diff --git a/src/web/people.py b/src/web/people.py index 83ab51a7..2d4c2e42 100644 --- a/src/web/people.py +++ b/src/web/people.py @@ -9,28 +9,3 @@ class IndexHandler(base.BaseHandler): @tornado.web.authenticated def get(self): self.render("people/index.html") - - -class SubscribeHandler(base.BaseHandler): - @tornado.web.authenticated - def post(self): - # Give consent - self.current_user.consents_to_promotional_emails = True - - self.render("people/subscribed.html") - - -class UnsubscribeHandler(base.BaseHandler): - @tornado.web.authenticated - def get(self): - if self.current_user.consents_to_promotional_emails: - return self.render("people/unsubscribe.html") - - self.render("people/unsubscribed.html") - - @tornado.web.authenticated - def post(self): - # Withdraw consent - self.current_user.consents_to_promotional_emails = False - - self.render("people/unsubscribed.html") diff --git a/src/web/users.py b/src/web/users.py index 7435a552..53b34341 100644 --- a/src/web/users.py +++ b/src/web/users.py @@ -308,6 +308,37 @@ class GroupShowHandler(base.BaseHandler): self.render("users/groups/show.html", group=group) +class SubscribeHandler(base.BaseHandler): + @tornado.web.authenticated + def get(self): + self.render("users/subscribe.html") + + @tornado.web.authenticated + def post(self): + # Give consent + with self.db.transaction(): + self.current_user.consents_to_promotional_emails = True + + self.render("users/subscribed.html") + + +class UnsubscribeHandler(base.BaseHandler): + @tornado.web.authenticated + def get(self): + if self.current_user.consents_to_promotional_emails: + return self.render("users/unsubscribe.html") + + self.render("users/unsubscribed.html") + + @tornado.web.authenticated + def post(self): + # Withdraw consent + with self.db.transaction(): + self.current_user.consents_to_promotional_emails = False + + self.render("users/unsubscribed.html") + + class ListModule(ui_modules.UIModule): def render(self, accounts, show_created_at=False): return self.render_string("users/modules/list.html", accounts=accounts,