From df1cc6aae5eb7e762cba88835308070234a91b86 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Tue, 12 Feb 2013 07:14:55 -0500 Subject: [PATCH] Make initial signin friendlier; #634 This varies the message for people with no giving or receiving based on how long they've been on the site. For the first minute, we say "just joined Gittip!" then for a week we say "joined recently," then after that we go with "is lurking." It was too abrasive to say "is lurking" as the first thing people see when they join the site. --- gittip/models/participant.py | 7 +++++++ templates/participant.html | 5 +++++ tests/test_participant_model.py | 13 +++++++++++++ 3 files changed, 25 insertions(+) diff --git a/gittip/models/participant.py b/gittip/models/participant.py index e3a9dc5586..ba203809a6 100644 --- a/gittip/models/participant.py +++ b/gittip/models/participant.py @@ -236,6 +236,13 @@ def get_og_title(self): out += " is" return out + " on Gittip" + def get_age_in_seconds(self): + out = -1 + if self.claimed_time is not None: + now = datetime.datetime.now(self.claimed_time.tzinfo) + out = (now - self.claimed_time).total_seconds() + return out + # TODO: Move these queries into this class. diff --git a/templates/participant.html b/templates/participant.html index 4a1bae3e07..922b4dc2e7 100644 --- a/templates/participant.html +++ b/templates/participant.html @@ -30,9 +30,14 @@

{{ participant.id }} receives

{% end %} {% else %} + {% set age = participant.get_age_in_seconds() %}

{{ participant.id }} {% if g > 0 %} gives anonymously + {% elif age < 60 %} + just joined Gittip! :D + {% elif age < (60 * 60 * 24 * 7) %} + joined recently {% else %} is lurking {% end %} diff --git a/tests/test_participant_model.py b/tests/test_participant_model.py index dde4046264..2eeb9e6fd5 100644 --- a/tests/test_participant_model.py +++ b/tests/test_participant_model.py @@ -308,6 +308,19 @@ def test_gnob_looks_at_latest_tip_only(self): assert actual == 0, actual + # get_age_in_seconds - gais + + def test_gais_gets_age_in_seconds(self): + now = datetime.datetime.now(pytz.utc) + alice = self.make_participant('alice', claimed_time=now) + actual = alice.get_age_in_seconds() + assert 0 < actual < 1, actual + + def test_gais_returns_negative_one_if_None(self): + alice = self.make_participant('alice', claimed_time=None) + actual = alice.get_age_in_seconds() + assert actual == -1, actual + # def get_details(self): # def resolve_unclaimed(self): # def set_as_claimed(self):