]> git.ipfire.org Git - ipfire.org.git/commitdiff
users: Move Subscribe/Unsubscribe handlers from People
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Jul 2023 15:17:02 +0000 (15:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Jul 2023 15:17:02 +0000 (15:17 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/people/subscribed.html [deleted file]
src/templates/people/unsubscribed.html [deleted file]
src/templates/users/subscribe.html [new file with mode: 0644]
src/templates/users/subscribed.html [new file with mode: 0644]
src/templates/users/unsubscribe.html [moved from src/templates/people/unsubscribe.html with 51% similarity]
src/templates/users/unsubscribed.html [new file with mode: 0644]
src/web/__init__.py
src/web/people.py
src/web/users.py

index 8b2766322302637f425aaad6b2517e3850f268a2..3268135c2d5d57eedc933add57ab9d19c19ed776 100644 (file)
@@ -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 (file)
index 5a26825..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "../base.html" %}
-
-{% block title %}{{ _("Thank You") }}{% end block %}
-
-{% block content %}
-       <div class="row justify-content-center my-5">
-               <div class="col-12 col-md-6">
-                       <div class="card bg-success text-white p-md-5 mb-3">
-                               <div class="card-body text-center">
-                                       <span class="fas fa-check fa-5x my-4"></span>
-
-                                       <p class="lead">
-                                               {{ _("You have been subscribed and will now receive updates from the IPFire Project.") }}
-                                       </p>
-                               </div>
-                       </div>
-
-                       <div class="d-grid">
-                               <a class="btn btn-light" href="/">
-                                       {{ _("Back") }}
-                               </a>
-                       </div>
-               </div>
-       </div>
-{% end block %}
diff --git a/src/templates/people/unsubscribed.html b/src/templates/people/unsubscribed.html
deleted file mode 100644 (file)
index 164f442..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-{% extends "../base.html" %}
-
-{% block title %}{{ _("Thank You") }}{% end block %}
-
-{% block content %}
-       <div class="row justify-content-center my-5">
-               <div class="col-12 col-md-6">
-                       <div class="card bg-danger text-white p-md-5 mb-3">
-                               <div class="card-body text-center">
-                                       <span class="fas fa-check fa-5x my-4"></span>
-
-                                       <p class="lead">
-                                               {{ _("You have been unsubscribed and will no longer receive important updates from the IPFire Project.") }}
-                                       </p>
-                               </div>
-                       </div>
-
-                       <form action="/subscribe" method="POST">
-                               {% raw xsrf_form_html() %}
-
-                               <div class="d-grid">
-                                       <button type="submit" class="btn btn-success">
-                                               {{ _("Continue Receiving Important Updates") }}
-                                       </button>
-                               </div>
-                       </form>
-               </div>
-       </div>
-{% end block %}
diff --git a/src/templates/users/subscribe.html b/src/templates/users/subscribe.html
new file mode 100644 (file)
index 0000000..06a5420
--- /dev/null
@@ -0,0 +1,35 @@
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Subscribe") }}{% end block %}
+
+{% block container %}
+       <div class="columns is-centered">
+               <div class="column is-one-third-desktop">
+                       <div class="notification my-auto">
+                               <h5 class="title is-5">{{ _("Subscribe Now To Stay Up To Date") }}</h5>
+
+                               <div class="content">
+                                       <p>
+                                               {{ _("Subscribe and you will receive important emails from the IPFire Project:") }}
+                                       </p>
+
+                                       <ul>
+                                               <li>{{ _("Important release announcements including notificiations about security updates") }}</li>
+                                               <li>{{ _("News from our blog and inside the project") }}</li>
+                                               <li>{{ _("Information about our fundraising efforts") }}</li>
+                                       </ul>
+                               </div>
+
+                               <div class="block">
+                                       <form method="POST" action="/subscribe">
+                                               {% raw xsrf_form_html() %}
+
+                                               <button type="submit" class="button is-success is-large is-fullwidth">
+                                                       {{ _("Subscribe") }}
+                                               </button>
+                                       </form>
+                               </div>
+                       </div>
+               </div>
+       </div>
+{% end block %}
diff --git a/src/templates/users/subscribed.html b/src/templates/users/subscribed.html
new file mode 100644 (file)
index 0000000..a58f02d
--- /dev/null
@@ -0,0 +1,19 @@
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Thank You") }}{% end block %}
+
+{% block container %}
+       <div class="columns is-centered">
+               <div class="column is-one-third-desktop">
+                       <div class="notification is-success my-auto has-text-centered">
+                               <div class="block">
+                                       <span class="fa-solid fa-check fa-5x my-4"></span>
+                               </div>
+
+                               <p>
+                                       {{ _("You have been subscribed and will now receive updates from the IPFire Project") }}
+                               </p>
+                       </div>
+               </div>
+       </div>
+{% end block %}
similarity index 51%
rename from src/templates/people/unsubscribe.html
rename to src/templates/users/unsubscribe.html
index 04a264b1508b749729c6e0511befdf6224b254de..631239a1615f069b65ace7cc1c0678a17d12421e 100644 (file)
@@ -2,13 +2,13 @@
 
 {% block title %}{{ _("Unsubscribe") }}{% end block %}
 
-{% block content %}
-       <div class="row justify-content-center my-5">
-               <div class="col col-md-8 col-lg-6">
-                       <div class="card border-danger">
-                               <div class="card-body">
-                                       <h5>{{ _("We'd Be Sorry To See You Go") }}</h5>
+{% block container %}
+       <div class="columns is-centered">
+               <div class="column is-one-third-desktop">
+                       <div class="notification my-auto">
+                               <h5 class="title is-5">{{ _("We'd Be Sorry To See You Go") }}</h5>
 
+                               <div class="content">
                                        <p>
                                                {{ _("If you unsubscribe, you will no longer receive important emails from the IPFire Project.") }}
                                                {{ _("There are plenty of benefits to remain subscribed:") }}
                                                <li>{{ _("News from our blog and inside the project") }}</li>
                                                <li>{{ _("Information about our fundraising efforts") }}</li>
                                        </ul>
+                               </div>
 
-                                       <form action="/subscribe" method="POST">
+                               <div class="block">
+                                       <form method="POST" action="/subscribe">
                                                {% raw xsrf_form_html() %}
 
-                                               <div class="d-grid">
-                                                       <button type="submit" class="btn btn-success mb-3">
-                                                               {{ _("Continue Receiving Important Updates") }}
-                                                       </button>
-                                               </div>
+                                               <button type="submit" class="button is-success is-large is-fullwidth">
+                                                       {{ _("Continue Receiving Important Updates") }}
+                                               </button>
                                        </form>
+                               </div>
 
-                                       <form action="/unsubscribe" method="POST">
+                               <div class="block">
+                                       <form method="POST" action="/unsubscribe">
                                                {% raw xsrf_form_html() %}
 
-                                               <div class="d-grid">
-                                                       <button type="submit" class="btn btn-danger">
-                                                               {{ _("Unsubscribe") }}
-                                                       </button>
-                                               </div>
+                                               <button type="submit" class="button is-danger is-fullwidth">
+                                                       {{ _("Unsubscribe") }}
+                                               </button>
                                        </form>
                                </div>
                        </div>
diff --git a/src/templates/users/unsubscribed.html b/src/templates/users/unsubscribed.html
new file mode 100644 (file)
index 0000000..bf1c0aa
--- /dev/null
@@ -0,0 +1,31 @@
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Thank You") }}{% end block %}
+
+{% block container %}
+       <div class="columns is-centered">
+               <div class="column is-one-third-desktop my-auto">
+                       <div class="block">
+                               <div class="notification is-danger has-text-centered">
+                                       <div class="block">
+                                               <span class="fa-solid fa-check fa-5x my-4"></span>
+                                       </div>
+
+                                       <p>
+                                               {{ _("You have been unsubscribed and will no longer receive important updates from the IPFire Project") }}
+                                       </p>
+                               </div>
+                       </div>
+
+                       <div class="block">
+                               <form action="/subscribe" method="POST">
+                                       {% raw xsrf_form_html() %}
+
+                                       <button type="submit" class="button is-success is-fullwidth">
+                                               {{ _("Continue Receiving Important Updates") }}
+                                       </button>
+                               </form>
+                       </div>
+               </div>
+       </div>
+{% end block %}
index 9041b861953d9ab87dca8f35175efd68d9a4f823..848abae6a37eddede8ad173c71ed58f193db160e 100644 (file)
@@ -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)
index 83ab51a748c5649a694f57ef924ff09532f94d18..2d4c2e42ab1e2e64bf1556637e22bb135dd5bd39 100644 (file)
@@ -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")
index 7435a552c1ae224051689246db2d6ec7397e3950..53b3434122901cf48418afc424558ccbf6f6c2c9 100644 (file)
@@ -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,