src/templates/people/passwd.html \
src/templates/people/search.html \
src/templates/people/sip.html \
+ src/templates/people/subscribe.html \
+ src/templates/people/subscribed.html \
+ src/templates/people/unsubscribe.html \
+ src/templates/people/unsubscribed.html \
src/templates/people/user.html \
src/templates/people/user-edit.html \
src/templates/people/users.html
first_name=res.first_name, last_name=res.last_name,
country_code=res.country_code)
+ # Non-EU users do not need to consent to promo emails
+ if account.country_code and not account.country_code in countries.EU_COUNTRIES:
+ account.consents_to_promotional_emails = True
+
# Invite newly registered users to newsletter
self.backend.messages.send_template(
"newsletter/subscribe", address="%s <%s>" % (account, account.email))
# Delete avatar hash
self.memcache.delete("accounts:%s:avatar-hash" % self.dn)
+ # Consent to promotional emails
+
+ def get_consents_to_promotional_emails(self):
+ return self.is_member_of_group("promotional-consent")
+
+ def set_contents_to_promotional_emails(self, value):
+ group = self.backend.groups.get_by_gid("promotional-consent")
+ assert group, "Could not find group: promotional-consent"
+
+ if value is True:
+ group.add_member(self)
+ else:
+ group.del_member(self)
+
+ consents_to_promotional_emails = property(
+ get_consents_to_promotional_emails,
+ set_contents_to_promotional_emails,
+ )
+
class StopForumSpam(Object):
def init(self, uid, email, address):
"""
Adds a member to this group
"""
+ # Do nothing if this user is already in the group
+ if account.is_member_of_group(self.gid):
+ return
+
if "posixGroup" in self.objectclasses:
self._add_string("memberUid", account.uid)
else:
self.members.append(account)
self.members.sort()
+ def del_member(self, account):
+ """
+ Removes a member from a group
+ """
+ # Do nothing if this user is not in the group
+ if not account.is_member_of_group(self.gid):
+ return
+
+ if "posixGroup" in self.objectclasses:
+ self._delete_string("memberUid", account.uid)
+ else:
+ self._delete_string("member", account.dn)
+
+
if __name__ == "__main__":
a = Accounts()
"PF", "PG", "PN", "PW", "SB", "TK", "TO", "TV", "UM", "VU", "WF", "WS"],
}
+EU_COUNTRIES = (
+ "BE",
+ "BG",
+ "CZ",
+ "DK",
+ "DE",
+ "EE",
+ "IE",
+ "EL",
+ "ES",
+ "FR",
+ "FR",
+ "GB",
+ "HR",
+ "IT",
+ "CY",
+ "LV",
+ "LT",
+ "LU",
+ "HU",
+ "MT",
+ "NL",
+ "AT",
+ "PL",
+ "PT",
+ "RO",
+ "SI",
+ "SK",
+ "FI",
+ "SE",
+)
+
def get_name(code):
try:
return iso3166.countries_by_alpha2[code].name
{% block footer %}
{{ _("Don't like these emails?") }}
- <a href="https://people.ipfire.org/">{{ _("Unsubscribe") }}</a>.
+ <a href="https://people.ipfire.org/unsubscribe">{{ _("Unsubscribe") }}</a>.
{% end block %}
</div>
</div>
+ {% if not current_user.consents_to_promotional_emails %}
+ <div class="card glow-primary border-primary">
+ <div class="card-body">
+ <h6>{{ _("You are currently not subscribed to important updates from the IPFire Project") }}</h6>
+
+ <div class="row">
+ <div class="col-2 d-flex align-items-center justify-content-center">
+ <i class="fas fa-envelope-open-text fa-3x text-primary"></i>
+ </div>
+
+ <div class="col-10 col-lg-6 mb-3 mb-lg-0">
+ <p class="card-text">
+ {{ _("Subscribe to receive notifications about important security updates of IPFire and other news from inside the project") }}
+ </p>
+ </div>
+
+ <div class="col-12 col-lg-4">
+ <a class="btn btn-success btn-block" href="/subscribe">
+ {{ _("Subscribe Now") }}
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+ {% end %}
+
{% if hints %}
<div class="card my-5">
<div class="card-body">
--- /dev/null
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Subscribe") }}{% 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-success">
+ <div class="card-body">
+ <h5>{{ _("Subscribe to Receive Import Updates from the IPFire Project") }}</h5>
+
+ <p>
+ {{ _("Subscribe to receive updates after releases and other important news from the IPFire Project.") }}
+ </p>
+
+ <form action="" method="POST">
+ {% raw xsrf_form_html() %}
+
+ <button type="submit" class="btn btn-success btn-block">
+ {{ _("Subscribe") }}
+ </button>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+{% end block %}
--- /dev/null
+{% 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">
+ <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>
+ </div>
+{% end block %}
--- /dev/null
+{% extends "../base.html" %}
+
+{% 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>{{ _("Unsubscribe From Updates From The IPFire Project") }}</h5>
+
+ <p>
+ {{ _("If you unsubscribe, you will no longer receive important emails from the IPFire Project.") }}
+ </p>
+
+ <form action="/subscribe" method="POST">
+ {% raw xsrf_form_html() %}
+
+ <button type="submit" class="btn btn-success btn-lg btn-block mb-3">
+ {{ _("I want to continue receiving important updates") }}
+ </button>
+ </form>
+
+ <form action="/unsubscribe" method="POST">
+ {% raw xsrf_form_html() %}
+
+ <button type="submit" class="btn btn-danger btn-block">
+ {{ _("Unsubscribe") }}
+ </button>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+{% end block %}
--- /dev/null
+{% 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="" method="POST">
+ {% raw xsrf_form_html() %}
+
+ <button type="submit" class="btn btn-success btn-block">
+ {{ _("I want to continue receiving important updates") }}
+ </button>
+ </form>
+ </div>
+ </div>
+{% end block %}
(r"/users/([a-z_][a-z0-9_-]{0,31})/passwd", people.UserPasswdHandler),
(r"/users/([a-z_][a-z0-9_-]{0,31})/sip", people.SIPHandler),
+ # Promotional Consent Stuff
+ (r"/subscribe", people.SubscribeHandler),
+ (r"/unsubscribe", people.UnsubscribeHandler),
+
# Single-Sign-On for Discourse
(r"/sso/discourse", people.SSODiscourse),
self.render("people/search.html", q=q, accounts=accounts)
+class SubscribeHandler(auth.CacheMixin, base.BaseHandler):
+ @tornado.web.authenticated
+ def get(self):
+ if self.current_user.consents_to_promotional_emails:
+ return self.render("people/subscribed.html")
+
+ self.render("people/subscribe.html")
+
+ @tornado.web.authenticated
+ def post(self):
+ # Give consent
+ self.current_user.consents_to_promotional_emails = True
+
+ self.render("people/subscribed.html")
+
+
+class UnsubscribeHandler(auth.CacheMixin, 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")
+
+
class SIPHandler(auth.CacheMixin, base.BaseHandler):
@tornado.web.authenticated
def get(self, uid):