-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from liberapay/team-avatars
Team avatars
- Loading branch information
Showing
15 changed files
with
179 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
BEGIN; | ||
|
||
UPDATE elsewhere | ||
SET avatar_url = regexp_replace(avatar_url, | ||
'^https://secure\.gravatar\.com/', | ||
'https://seccdn.libravatar.org/' | ||
) | ||
WHERE avatar_url LIKE '%//secure.gravatar.com/%'; | ||
|
||
UPDATE participants | ||
SET avatar_url = regexp_replace(avatar_url, | ||
'^https://secure\.gravatar\.com/', | ||
'https://seccdn.libravatar.org/' | ||
) | ||
WHERE avatar_url LIKE '%//secure.gravatar.com/%'; | ||
|
||
ALTER TABLE participants ADD COLUMN avatar_src text; | ||
|
||
ALTER TABLE participants ADD COLUMN avatar_email text; | ||
|
||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
<form action="/about/teams" method="POST"> | ||
<form class="form-inline" action="/about/teams" method="POST"> | ||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}" /> | ||
<div class="input-group"> | ||
<input class="form-control" name="name" size=30 | ||
placeholder="{{ _('Name of the team') }}" /> | ||
<div class="input-group-btn"> | ||
<button class="btn btn-success">{{ _("Create") }}</button> | ||
</div> | ||
</div> | ||
|
||
<input class="form-control" name="name" size=30 | ||
placeholder="{{ _('Name of the team') }}" /> | ||
<input class="form-control" name="email" type="email" size=30 | ||
placeholder="{{ _('Email of the team (optional)') }}" /> | ||
<button class="btn btn-success">{{ _("Create") }}</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from aspen import Response | ||
|
||
from liberapay.utils import b64encode_s, get_participant | ||
|
||
[---] | ||
|
||
participant = get_participant(state, restrict=True, allow_member=True) | ||
|
||
msg = None | ||
|
||
if request.method == 'POST': | ||
src, email = request.body['src'], request.body.get('email') or None | ||
|
||
if src not in constants.AVATAR_SOURCES: | ||
raise Response(400, 'bad src') | ||
|
||
website.db.run(""" | ||
UPDATE participants SET avatar_email = %s WHERE id = %s | ||
""", (email, participant.id)) | ||
participant.set_attributes(avatar_email=email) | ||
|
||
r = participant.update_avatar(src+':') | ||
if not r: | ||
raise Response(400, _("We were unable to get an avatar for you from {0}.", src)) | ||
|
||
msg = _("Your new avatar URL is: {0}", participant.avatar_url) | ||
if request.headers.get('X-Requested-With') != 'XMLHttpRequest': | ||
response.redirect(participant.path('edit')+'?success='+b64encode_s(msg)+'#avatar') | ||
|
||
[---] application/json | ||
{"url": participant.avatar_url, "msg": msg} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters