diff --git a/liberapay/models/participant.py b/liberapay/models/participant.py index 4b423b79db..b0fa76a8f2 100644 --- a/liberapay/models/participant.py +++ b/liberapay/models/participant.py @@ -119,7 +119,7 @@ def make_active(cls, username, kind, password, cursor=None): p.change_username(username, c) return p - def make_team(self, name): + def make_team(self, name, email=None): with self.db.get_cursor() as c: t = c.one(""" INSERT INTO participants @@ -129,6 +129,8 @@ def make_team(self, name): """) t.change_username(name, c) t.add_member(self, c) + if email: + t.add_email(email) return t @classmethod @@ -1638,6 +1640,10 @@ def to_dict(self, details=False, inquirer=None): def path(self, path): return '/%s/%s' % (self.username, path) + @property + def is_person(self): + return self.kind in ('individual', 'organization') + class NeedConfirmation(Exception): """Represent the case where we need user confirmation during a merge. diff --git a/templates/create-team.html b/templates/create-team.html index ef23dd603d..bd71f24b99 100644 --- a/templates/create-team.html +++ b/templates/create-team.html @@ -1,10 +1,9 @@ -
diff --git a/templates/settings.html b/templates/settings.html index 70482d97f0..fc319e2e4c 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -1,12 +1,13 @@ % extends "templates/base.html" % block subnav - {% set pages = [ + {% set pages = ([ ('/giving/', _('Giving')), ('/receiving/', _('Receiving')), ('/wallet/', _('Wallet')), ('/settings/', _('Settings')), ('/identity', _('Identity')), + ] if participant.is_person else []) + [ ('/emails/', _('Emails')), ('/widgets/', _('Widgets')), ] + ([ diff --git a/www/%username/emails/index.spt b/www/%username/emails/index.spt index 5aaee76c10..488f9ed1b6 100644 --- a/www/%username/emails/index.spt +++ b/www/%username/emails/index.spt @@ -3,7 +3,7 @@ from liberapay.utils import get_participant [---] -participant = get_participant(state, restrict=True) +participant = get_participant(state, restrict=True, allow_member=True) title = participant.username subhead = _("Email settings") emails = participant.get_emails() diff --git a/www/%username/emails/modify.json.spt b/www/%username/emails/modify.json.spt index 05b75de5d3..906c004c1c 100644 --- a/www/%username/emails/modify.json.spt +++ b/www/%username/emails/modify.json.spt @@ -4,7 +4,7 @@ from liberapay.utils import get_participant [-----------------------------------------] request.allow("POST") -participant = get_participant(state, restrict=True) +participant = get_participant(state, restrict=True, allow_member=True) if not participant.email_lang: participant.set_email_lang(request.headers.get("Accept-Language")) diff --git a/www/%username/emails/verify.html.spt b/www/%username/emails/verify.html.spt index 1e1c4ae778..7c57b646d4 100644 --- a/www/%username/emails/verify.html.spt +++ b/www/%username/emails/verify.html.spt @@ -9,7 +9,8 @@ from liberapay.utils import emails, get_participant [-----------------------------------------------------------------------------] participant = get_participant(state, restrict=False) -if participant == user: +ok = participant == user or participant.kind == 'group' and user.member_of(participant) +if ok: email = request.qs.get('email', '') nonce = request.qs.get('nonce', '') result = participant.verify_email(email, nonce) @@ -27,7 +28,7 @@ if participant == user:{{ _("Sign in to finish connecting your email.") }}
{% include "templates/sign-in-link.html" %}
- % elif user != participant + % elif not ok{{ _("You're signed into the wrong Liberapay account to complete this email " diff --git a/www/about/teams.spt b/www/about/teams.spt index 0394d11603..b117ed4004 100644 --- a/www/about/teams.spt +++ b/www/about/teams.spt @@ -20,7 +20,7 @@ if request.method == 'POST': else: raise UsernameAlreadyTaken(name) else: - t = user.make_team(name) + t = user.make_team(name, request.body.get('email')) response.redirect('/'+t.username+'/edit') title = _("Teams")