Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
retire the "making the world better" statement prefix
Browse files Browse the repository at this point in the history
closes #1659
  • Loading branch information
Changaco committed Dec 14, 2014
1 parent c0ddb33 commit 491d052
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 86 deletions.
17 changes: 7 additions & 10 deletions gratipay/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# encoding: utf8

from __future__ import division

from datetime import datetime, timedelta
Expand Down Expand Up @@ -434,17 +436,12 @@ def format_money(money):
return format % money


def to_statement(prepend, string, length=140, append='...'):
if prepend and string:
statement = prepend.format(string)
if len(string) > length:
return statement[:length] + append
elif len(string) > 0:
return statement
else:
return string
else:
def excerpt_intro(text, length=175, append=u'…'):
if not text:
return ''
if len(text) > length:
return text[:length] + append
return text


def is_card_expiring(expiration_year, expiration_month):
Expand Down
13 changes: 2 additions & 11 deletions templates/profile-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ <h2>{{ _("Statement") }}
</h2>

<div class="edit">
<select tabindex="201" name="number" id="statement-select">
<option value="singular"
{{ "selected" if participant.number == 'singular' else ''}}>
{{ I_AM_MAKING.format("...") }}
</option>
<option value="plural"
{{ "selected" if participant.number != 'singular' else ''}}>
{{ WE_ARE_MAKING.format("...") }}
</option>
</select>
{{ _("Tell us how you're making the world better:") }}
<textarea tabindex="202">{{ participant.statement }}</textarea>
<span class="help">{{ _("Markdown supported.") }}
<a href="https://daringfireball.net/projects/markdown/basics" target="_blank">{{ _("What is markdown?") }}</a>
Expand All @@ -27,7 +18,7 @@ <h2>{{ _("Statement") }}
</div>

<div class="view markdown-output">
{{ markdown.render(MAKING.format(participant.statement)) }}
{{ markdown.render(participant.statement) }}
</div>
</form>

Expand Down
27 changes: 27 additions & 0 deletions tests/py/test_number_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from __future__ import print_function, unicode_literals

import json

from gratipay.testing import Harness


class Tests(Harness):

def change_number(self, number, auth_as='alice', expecting_error=False):
self.make_participant('alice', claimed_time='now')

method = self.client.POST if not expecting_error else self.client.PxST
response = method( "/alice/number.json"
, {'number': number}
, auth_as=auth_as
)
return response

def test_participant_can_change_their_number(self):
response = self.change_number('plural')
actual = json.loads(response.body)['number']
assert actual == 'plural'

def test_invalid_is_400(self):
response = self.change_number('none', expecting_error=True)
assert response.code == 400, response.code
20 changes: 5 additions & 15 deletions tests/py/test_statement_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

class Tests(Harness):

def change_statement(self, statement, number='singular', auth_as='alice',
def change_statement(self, statement, auth_as='alice',
expecting_error=False):
self.make_participant('alice')
self.make_participant('alice', claimed_time='now')

method = self.client.POST if not expecting_error else self.client.PxST
response = method( "/alice/statement.json"
, {'statement': statement, 'number': number}
, {'statement': statement}
, auth_as=auth_as
)
return response
Expand All @@ -23,19 +23,9 @@ def test_participant_can_change_their_statement(self):
actual = json.loads(response.body)['statement']
assert actual == '<p>I am making the world better by being awesome.</p>\n'

def test_participant_can_change_their_number(self):
response = self.change_statement('', 'plural')
actual = json.loads(response.body)['number']
assert actual == 'plural'

def test_anonymous_gets_404(self):
def test_anonymous_gets_403(self):
response = self.change_statement( 'being awesome.'
, 'singular'
, auth_as=None
, expecting_error=True
)
assert response.code == 404, response.code

def test_invalid_is_400(self):
response = self.change_statement('', 'none', expecting_error=True)
assert response.code == 400, response.code
assert response.code == 403, response.code
11 changes: 5 additions & 6 deletions www/%username/account/close.spt
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,11 @@ if POST:
href="https://github.com/gratipay/gratipay.com/issues/397">data
retention policy</a>).</p>

<p>Things we clear immediately include your &ldquo;making the
world better&rdquo; statement, any funding goal, the tips
you're receiving, and those you're giving. You'll also be
removed from any communities and teams you were a part of. If
you're closing a team account, all team members will be removed
from the team.</p>
<p>Things we clear immediately include your profile statement,
any funding goal, the tips you're receiving, and those you're
giving. You'll also be removed from any communities and teams
you were a part of. If you're closing a team account, all team
members will be removed from the team.</p>

<p>We specifically <i>don't</i> delete your past giving and
receiving history on the site, because that information also
Expand Down
11 changes: 3 additions & 8 deletions www/%username/index.html.spt
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ accounts = participant.get_accounts_elsewhere()
long_statement = len(participant.statement) > LONG_STATEMENT
communities = community.get_list_for(website.db, participant.id)

I_AM_MAKING = _("I am making the world better by {0}")
WE_ARE_MAKING = _("We are making the world better by {0}")

if participant.number == 'singular':
MAKING = I_AM_MAKING
GRATEFUL = _("I'm grateful for gifts, but don't have a specific funding goal.")
PATRON = _("I'm here as a patron.")
PATRON_NO_GIFTS = _("I'm here as a patron, and politely decline to receive gifts.")
GOAL_RAW = _("My goal is to receive {0} per week on Gratipay.")
else:
MAKING = WE_ARE_MAKING
GRATEFUL = _("We're grateful for gifts, but don't have a specific funding goal.")
PATRON = _("We're here as a patron.")
PATRON_NO_GIFTS = _("We're here as a patron, and politely decline to receive gifts.")
Expand All @@ -62,8 +57,8 @@ def with_others(obj):
<meta name="og:url" content="https://gratipay.com/{{ username }}/" />
<meta name="og:type" content="profile" />
<meta name="og:title" content="{{ participant.get_og_title() }}" />
{% if participant.statement %}
<meta name="og:description" content="{{ _clip(MAKING.format(participant.statement), 200)|e }}" />
{% if statement %}
<meta name="og:description" content="{{ _clip(participant.statement, 200)|e }}" />
{% else %}
<meta name="og:description" content="Gratipay is a weekly gift exchange" />
{% endif %}
Expand Down Expand Up @@ -101,7 +96,7 @@ $(document).ready(function() {
<div class="{% if long_statement %}col1{% else %}col0{% endif %}">
<h2>{{ STATEMENT }}</h2>
<div class="statement markdown-output">
{{ markdown.render(MAKING.format(participant.statement)) }}
{{ markdown.render(participant.statement) }}
</div>
{% include "templates/team-listing.html" %}
{% include "templates/community-listing.html" %}
Expand Down
24 changes: 24 additions & 0 deletions www/%username/number.json.spt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import print_function, unicode_literals

from aspen import Response
from gratipay.utils import get_participant, wrap
from gratipay.exceptions import ProblemChangingNumber

[-----------------------------------------------------------------------------]

request.allow("POST")
participant = get_participant(request, restrict=True)

number = request.body["number"]

if number not in ("singular", "plural"):
raise Response(400)

if number != participant.number:
try:
participant.update_number(number)
except ProblemChangingNumber, e:
raise Response(400, unicode(e))

[---] application/json via json_dump
{"number": wrap(number)}
24 changes: 4 additions & 20 deletions www/%username/statement.json.spt
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
from __future__ import print_function, unicode_literals

from aspen import Response
from gratipay.utils import wrap, markdown
from gratipay.exceptions import ProblemChangingNumber
from gratipay.utils import get_participant, markdown

[-----------------------------------------------------------------------------]

if user.ANON:
raise Response(404)
request.allow("POST")
participant = get_participant(request, restrict=True)

statement = request.body["statement"]
number = request.body["number"]

if number not in ("singular", "plural"):
raise Response(400)

if number != user.participant.number:
try:
user.participant.update_number(number)
except ProblemChangingNumber, e:
raise Response(400, unicode(e))
user.participant.update_statement(statement)

I_AM_MAKING = _("I am making the world better by {0}")
WE_ARE_MAKING = _("We are making the world better by {0}")

MAKING = I_AM_MAKING if (number == 'singular') else WE_ARE_MAKING
participant.update_statement(statement)

[---] application/json via json_dump
{"statement": markdown.render(MAKING.format(statement)), "number": wrap(number)}
{"statement": markdown.render(statement)}
11 changes: 2 additions & 9 deletions www/about/teams/index.spt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ make use of those funds to help support them in reaching their team's goals.</p>

<h2>Creating a team</h2>

<p>Team accounts are created just like regular accounts. Just login. Once you've
setup your team account there are three steps to change it from a regular
account into a team account:</p>

<ol>
<li>On your team's Profile page, edit the "Statement" section.</li>
<li>Change "I am" into "We are".</li>
<li>Save the change.</li>
</ol>
<p>Team accounts are created just like regular accounts. Just login. Then go to
your Account page and change from "Individual" to "Team".</p>

<p>After you saved the change, the navigation section on the profile page should
include a new "Members" button. This section will list all of the team's members
Expand Down
11 changes: 4 additions & 7 deletions www/for/%slug/index.html.spt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from aspen import Response
from gratipay.models.community import name_pattern, slugize, Community
from gratipay.utils import format_money, to_statement
from gratipay.utils import excerpt_intro, format_money
from gratipay.utils.query_cache import QueryCache

LUXURY = 4
Expand All @@ -9,9 +9,6 @@ query_cache = QueryCache(website.db, threshold=20)

[---]

I_AM_MAKING = _("I am making the world better by {0}")
WE_ARE_MAKING = _("We are making the world better by {0}")

_slug = path['slug']
if name_pattern.match(_slug) is None:
raise Response(404)
Expand Down Expand Up @@ -183,7 +180,7 @@ $(document).ready(function() {
{% for i, participant in enumerate(new_participants, start=1) %}
<li{% if i > LUXURY %} class="luxury"{% endif %}>
<a href="/{{ participant.username }}/" class="mini-user tip"
data-tip="{{ to_statement((I_AM_MAKING if participant.number == 'singular' else WE_ARE_MAKING), participant.statement)|e }}">
data-tip="{{ excerpt_intro(participant.statement)|e }}">
<span class="inner">
<span class="avatar"
style="background-image: url('{{ avatar_url(participant) }}')">
Expand Down Expand Up @@ -213,7 +210,7 @@ $(document).ready(function() {
{% else %}
<a href="/{{ giver.username }}/"
class="mini-user{{ ' anonymous' if giver.anonymous else '' }} tip"
data-tip="{{ to_statement((I_AM_MAKING if giver.number == 'singular' else WE_ARE_MAKING), giver.statement) }}">
data-tip="{{ excerpt_intro(giver.statement) }}">
<span class="inner">
<span class="avatar" style="background-image: url('{{ avatar_url(giver) }}')">
</span>
Expand Down Expand Up @@ -243,7 +240,7 @@ $(document).ready(function() {
{% else %}
<a href="/{{ receiver.username }}/"
class="mini-user{{ ' anonymous' if receiver.anonymous else '' }} tip"
data-tip="{{ to_statement((I_AM_MAKING if receiver.number == 'singular' else WE_ARE_MAKING), receiver.statement) }}">
data-tip="{{ excerpt_intro(receiver.statement) }}">
<span class="inner">
<span class="avatar"
style="background-image: url('{{ avatar_url(receiver) }}')">
Expand Down

0 comments on commit 491d052

Please sign in to comment.