From 5e7a3cabe7435f9713b7977d8f708e8718d94226 Mon Sep 17 00:00:00 2001 From: Changaco Date: Wed, 5 Nov 2014 22:47:15 +0100 Subject: [PATCH] retire the "making the world better" statement prefix closes #1659 --- gratipay/utils/__init__.py | 17 +++++++---------- templates/profile-edit.html | 13 ++----------- tests/py/test_number_json.py | 27 +++++++++++++++++++++++++++ tests/py/test_statement_json.py | 20 +++++--------------- www/%username/account/close.spt | 11 +++++------ www/%username/index.html.spt | 11 +++-------- www/%username/number.json.spt | 24 ++++++++++++++++++++++++ www/%username/statement.json.spt | 24 ++++-------------------- www/about/teams/index.spt | 11 ++--------- www/for/%slug/index.html.spt | 11 ++++------- 10 files changed, 83 insertions(+), 86 deletions(-) create mode 100644 tests/py/test_number_json.py create mode 100644 www/%username/number.json.spt diff --git a/gratipay/utils/__init__.py b/gratipay/utils/__init__.py index 5486849c93..933c2e79ed 100644 --- a/gratipay/utils/__init__.py +++ b/gratipay/utils/__init__.py @@ -1,3 +1,5 @@ +# encoding: utf8 + from __future__ import division from datetime import datetime, timedelta @@ -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): diff --git a/templates/profile-edit.html b/templates/profile-edit.html index 1517e601de..fc0e620dfe 100644 --- a/templates/profile-edit.html +++ b/templates/profile-edit.html @@ -9,16 +9,7 @@

{{ _("Statement") }}

- + {{ _("Tell us how you're making the world better:") }} {{ _("Markdown supported.") }} {{ _("What is markdown?") }} @@ -27,7 +18,7 @@

{{ _("Statement") }}

- {{ markdown.render(MAKING.format(participant.statement)) }} + {{ markdown.render(participant.statement) }}
diff --git a/tests/py/test_number_json.py b/tests/py/test_number_json.py new file mode 100644 index 0000000000..49a58671df --- /dev/null +++ b/tests/py/test_number_json.py @@ -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 diff --git a/tests/py/test_statement_json.py b/tests/py/test_statement_json.py index ef370d36c8..418643122e 100644 --- a/tests/py/test_statement_json.py +++ b/tests/py/test_statement_json.py @@ -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 @@ -23,19 +23,9 @@ def test_participant_can_change_their_statement(self): actual = json.loads(response.body)['statement'] assert actual == '

I am making the world better by being awesome.

\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 diff --git a/www/%username/account/close.spt b/www/%username/account/close.spt index ff3aece7d0..206af451ba 100644 --- a/www/%username/account/close.spt +++ b/www/%username/account/close.spt @@ -106,12 +106,11 @@ if POST: href="https://github.com/gratipay/gratipay.com/issues/397">data retention policy).

-

Things we clear immediately include your “making the - world better” 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.

+

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.

We specifically don't delete your past giving and receiving history on the site, because that information also diff --git a/www/%username/index.html.spt b/www/%username/index.html.spt index 2fa84f5282..751b1be172 100644 --- a/www/%username/index.html.spt +++ b/www/%username/index.html.spt @@ -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.") @@ -62,8 +57,8 @@ def with_others(obj): - {% if participant.statement %} - + {% if statement %} + {% else %} {% endif %} @@ -101,7 +96,7 @@ $(document).ready(function() {

{{ STATEMENT }}

- {{ markdown.render(MAKING.format(participant.statement)) }} + {{ markdown.render(participant.statement) }}
{% include "templates/team-listing.html" %} {% include "templates/community-listing.html" %} diff --git a/www/%username/number.json.spt b/www/%username/number.json.spt new file mode 100644 index 0000000000..3ab9547ec9 --- /dev/null +++ b/www/%username/number.json.spt @@ -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)} diff --git a/www/%username/statement.json.spt b/www/%username/statement.json.spt index 187e44ec73..f1b47cdf96 100644 --- a/www/%username/statement.json.spt +++ b/www/%username/statement.json.spt @@ -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)} diff --git a/www/about/teams/index.spt b/www/about/teams/index.spt index 612ff69b9e..ef71562e55 100644 --- a/www/about/teams/index.spt +++ b/www/about/teams/index.spt @@ -19,15 +19,8 @@ make use of those funds to help support them in reaching their team's goals.

Creating a team

-

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:

- -
    -
  1. On your team's Profile page, edit the "Statement" section.
  2. -
  3. Change "I am" into "We are".
  4. -
  5. Save the change.
  6. -
+

Team accounts are created just like regular accounts. Just login. Then go to +your Account page and change from "Individual" to "Team".

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 diff --git a/www/for/%slug/index.html.spt b/www/for/%slug/index.html.spt index f2841aa5d2..90c65f06c9 100644 --- a/www/for/%slug/index.html.spt +++ b/www/for/%slug/index.html.spt @@ -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 @@ -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) @@ -183,7 +180,7 @@ $(document).ready(function() { {% for i, participant in enumerate(new_participants, start=1) %} LUXURY %} class="luxury"{% endif %}> + data-tip="{{ excerpt_intro(participant.statement)|e }}"> @@ -213,7 +210,7 @@ $(document).ready(function() { {% else %} + data-tip="{{ excerpt_intro(giver.statement) }}"> @@ -243,7 +240,7 @@ $(document).ready(function() { {% else %} + data-tip="{{ excerpt_intro(receiver.statement) }}">