mail subscription confirm functions;
confirmation code & mail template still missing
This commit is contained in:
parent
9beb864a2f
commit
d002969377
9
db.py
9
db.py
|
@ -196,6 +196,15 @@ u\d\d?
|
||||||
return None
|
return None
|
||||||
return User(uid)
|
return User(uid)
|
||||||
|
|
||||||
|
def by_city(self, city):
|
||||||
|
from user import User
|
||||||
|
self.execute("SELECT user_id FROM cities WHERE city=?", (city, ))
|
||||||
|
try:
|
||||||
|
uid, = self.cur.fetchone()
|
||||||
|
except TypeError:
|
||||||
|
return None
|
||||||
|
return User(uid)
|
||||||
|
|
||||||
def user_facing_properties(self, city):
|
def user_facing_properties(self, city):
|
||||||
self.execute("""SELECT city, markdown, masto_link, twit_link
|
self.execute("""SELECT city, markdown, masto_link, twit_link
|
||||||
FROM cities
|
FROM cities
|
||||||
|
|
15
frontend.py
15
frontend.py
|
@ -89,14 +89,23 @@ def city_page(city):
|
||||||
|
|
||||||
@get('/city/mail/<city>')
|
@get('/city/mail/<city>')
|
||||||
@view('template/mail.tpl')
|
@view('template/mail.tpl')
|
||||||
def display_mail_page(city, user):
|
def display_mail_page(city):
|
||||||
|
user = db.by_city(city)
|
||||||
return user.state()
|
return user.state()
|
||||||
|
|
||||||
|
|
||||||
@post('/city/mail/submit/<city>')
|
@post('/city/mail/submit/<city>')
|
||||||
def subscribe_mail(user, city):
|
def subscribe_mail(city):
|
||||||
email = request.forms['mailaddress']
|
email = request.forms['mailaddress']
|
||||||
# add confirmation mail workflow
|
code = generate_code(email, city)
|
||||||
|
# send mail with code to email
|
||||||
|
|
||||||
|
|
||||||
|
@get('/city/mail/confirm/<code>')
|
||||||
|
@view('template/city.tpl')
|
||||||
|
def confirm_subscribe(code):
|
||||||
|
email, city = parse_code(code)
|
||||||
|
user = db.by_city(city)
|
||||||
user.add_subscriber(email)
|
user.add_subscriber(email)
|
||||||
redirect('/city/' + city)
|
redirect('/city/' + city)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue