Repository: gratipay/gratipay.com

Issue:
Profiles generated with fake_data.py 500 when viewed
Introduced in a4b904f

This is due to `user_info` being set to an empty string instead of a dict/json, causing `escape` to be passed `None` (from `user_info.get`) instead of a string.

```
Traceback (most recent call last):
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 66, in handle_safely
    response = self.handle(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 99, in handle
    response = request.resource.respond(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/dynamic_resource.py", line 57, in respond
    response = self.get_response(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/negotiated_resource.py", line 100, in get_response
    response.body = render(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/__init__.py", line 113, in __call__
    return self.render_content(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/tornado.py", line 14, in render_content
    return self.compiled.generate(**context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/template.py", line 129, in generate
    return execute()
  File "/home/joe/git/www.gittip.com/www/%username/index.html", line 786, in _execute
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/escape.py", line 52, in xhtml_escape
    return xml.sax.saxutils.escape(value, {'"': """})
  File "/usr/lib/python2.7/xml/sax/saxutils.py", line 39, in escape
    data = data.replace("&", "&")
AttributeError: 'NoneType' object has no attribute 'replace'
```

Profiles generated with fake_data.py 500 when viewed
Introduced in a4b904f

This is due to `user_info` being set to an empty string instead of a dict/json, causing `escape` to be passed `None` (from `user_info.get`) instead of a string.

```
Traceback (most recent call last):
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 66, in handle_safely
    response = self.handle(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/website.py", line 99, in handle
    response = request.resource.respond(request)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/dynamic_resource.py", line 57, in respond
    response = self.get_response(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/resources/negotiated_resource.py", line 100, in get_response
    response.body = render(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/__init__.py", line 113, in __call__
    return self.render_content(context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/aspen/renderers/tornado.py", line 14, in render_content
    return self.compiled.generate(**context)
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/template.py", line 129, in generate
    return execute()
  File "/home/joe/git/www.gittip.com/www/%username/index.html", line 786, in _execute
  File "/home/joe/git/www.gittip.com/env/local/lib/python2.7/site-packages/tornado/escape.py", line 52, in xhtml_escape
    return xml.sax.saxutils.escape(value, {'"': """})
  File "/usr/lib/python2.7/xml/sax/saxutils.py", line 39, in escape
    data = data.replace("&", "&")
AttributeError: 'NoneType' object has no attribute 'replace'
```



Discussion:

Resolving patch:
diff --git a/gittip/fake_data.py b/gittip/fake_data.py
--- a/gittip/fake_data.py
+++ b/gittip/fake_data.py
@@ -9,7 +9,7 @@
 
 faker = Factory.create()
 
-platforms = ['github', 'twitter']
+platforms = ['github', 'twitter', 'bitbucket']
 
 
 def fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):
@@ -77,13 +77,33 @@ def fake_elsewhere(participant, platform=None):
     if platform is None:
         platform = random.choice(platforms)
 
+    info_templates = {
+        "github": {
+            "name": participant.username,
+            "html_url": "https://github.com/" + participant.username,
+            "type": "User",
+            "login": participant.username
+        },
+        "twitter": {
+            "name": participant.username,
+            "html_url": "https://twitter.com/" + participant.username,
+            "screen_name": participant.username
+        },
+        "bitbucket": {
+            "display_name": participant.username,
+            "username": participant.username,
+            "is_team": "False",
+            "html_url": "https://bitbucket.org/" + participant.username,
+        }
+    }
+
     return Elsewhere(
         id=fake_int_id(),
         platform=platform,
         user_id=fake_text_id(),
         is_locked=False,
         participant=participant.username,
-        user_info=''
+        user_info=info_templates[platform]
     )
 
 
@@ -100,8 +120,8 @@ def populate_db(session, num_participants=100, num_tips=50):
 
     #Make the "Elsewhere's"
     for p in participants:
-        #All participants get 1 or 2 elsewheres
-        num_elsewheres = random.randint(1, 2)
+        #All participants get between 1 and 3 elsewheres
+        num_elsewheres = random.randint(1, 3)
         for platform_name in platforms[:num_elsewheres]:
             e = fake_elsewhere(p, platform_name)
             session.add(e)


Test patch: