prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  When I am logged in, everyone else's communities are the same
  They have the same communities. For example, cookiecutter has 3 people in it, (me, audreyr, and sloria), but if I visit kennethreitz or mitsuhiko they also claim to be in it. So do the gittip project maintainers.
  
  
  </issue>
  <code>
  [start of gittip/models/community.py]
  1 import re
  2 
  3 import gittip
  4 from postgres.orm import Model
  5 
  6 
  7 name_pattern = re.compile(r'^[A-Za-z0-9,._ -]+$')
  8 
  9 def slugize(slug):
  10     """Convert a string to a string for an URL.
  11     """
  12     assert name_pattern.match(slug) is not None
  13     slug = slug.lower()
  14     for c in (' ', ',', '.', '_'):
  15         slug = slug.replace(c, '-')
  16     while '--' in slug:
  17         slug = slug.replace('--', '-')
  18     slug = slug.strip('-')
  19     return slug
  20 
  21 
  22 def slug_to_name(slug):
  23     """Given a slug like ``python``, return a name like ``Python``.
  24 
  25     :database: One SELECT, one row
  26 
  27     """
  28     SQL = "SELECT name FROM community_summary WHERE slug=%s"
  29     return gittip.db.one(SQL, (slug,))
  30 
  31 
  32 def get_list_for(user):
  33     """Return a listing of communities.
  34 
  35     :database: One SELECT, multiple rows
  36 
  37     """
  38     if user is None or user.ANON:
  39         member_test = "false"
  40         sort_order = 'DESC'
  41         params = ()
  42     else:
  43         member_test = "bool_or(participant = %s)"
  44         sort_order = 'ASC'
  45         params = (user.participant.username,)
  46 
  47     return gittip.db.all("""
  48 
  49         SELECT max(name) AS name
  50              , slug
  51              , count(*) AS nmembers
  52              , {} AS is_member
  53           FROM current_communities
  54       GROUP BY slug
  55       ORDER BY nmembers {}, slug
  56 
  57     """.format(member_test, sort_order), params)
  58 
  59 
  60 class Community(Model):
  61     """Model a community on Gittip.
  62     """
  63 
  64     typname = "community_summary"
  65 
  66     def check_membership(self, participant):
  67         return self.db.one("""
  68 
  69         SELECT * FROM current_communities WHERE slug=%s AND participant=%s
  70 
  71         """, (self.slug, participant.username)) is not None
  72 
  73 
  74 def typecast(request):
  75     pass
  76
  [end of gittip/models/community.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/gittip/models/community.py b/gittip/models/community.py
  --- a/gittip/models/community.py
  +++ b/gittip/models/community.py
  @@ -29,20 +29,20 @@
       return gittip.db.one(SQL, (slug,))
   
   
  -def get_list_for(user):
  +def get_list_for(username):
       """Return a listing of communities.
   
       :database: One SELECT, multiple rows
   
       """
  -    if user is None or user.ANON:
  +    if username is None:
           member_test = "false"
           sort_order = 'DESC'
           params = ()
       else:
           member_test = "bool_or(participant = %s)"
           sort_order = 'ASC'
  -        params = (user.participant.username,)
  +        params = (username,)
   
       return gittip.db.all("""
  
verification_info: {"golden_diff": "diff --git a/gittip/models/community.py b/gittip/models/community.py\n--- a/gittip/models/community.py\n+++ b/gittip/models/community.py\n@@ -29,20 +29,20 @@\n     return gittip.db.one(SQL, (slug,))\n \n \n-def get_list_for(user):\n+def get_list_for(username):\n     \"\"\"Return a listing of communities.\n \n     :database: One SELECT, multiple rows\n \n     \"\"\"\n-    if user is None or user.ANON:\n+    if username is None:\n         member_test = \"false\"\n         sort_order = 'DESC'\n         params = ()\n     else:\n         member_test = \"bool_or(participant = %s)\"\n         sort_order = 'ASC'\n-        params = (user.participant.username,)\n+        params = (username,)\n \n     return gittip.db.all(\"\"\"\n", "issue": "When I am logged in, everyone else's communities are the same\nThey have the same communities. For example, cookiecutter has 3 people in it, (me, audreyr, and sloria), but if I visit kennethreitz or mitsuhiko they also claim to be in it. So do the gittip project maintainers.\n\n", "before_files": [{"content": "import re\n\nimport gittip\nfrom postgres.orm import Model\n\n\nname_pattern = re.compile(r'^[A-Za-z0-9,._ -]+$')\n\ndef slugize(slug):\n    \"\"\"Convert a string to a string for an URL.\n    \"\"\"\n    assert name_pattern.match(slug) is not None\n    slug = slug.lower()\n    for c in (' ', ',', '.', '_'):\n        slug = slug.replace(c, '-')\n    while '--' in slug:\n        slug = slug.replace('--', '-')\n    slug = slug.strip('-')\n    return slug\n\n\ndef slug_to_name(slug):\n    \"\"\"Given a slug like ``python``, return a name like ``Python``.\n\n    :database: One SELECT, one row\n\n    \"\"\"\n    SQL = \"SELECT name FROM community_summary WHERE slug=%s\"\n    return gittip.db.one(SQL, (slug,))\n\n\ndef get_list_for(user):\n    \"\"\"Return a listing of communities.\n\n    :database: One SELECT, multiple rows\n\n    \"\"\"\n    if user is None or user.ANON:\n        member_test = \"false\"\n        sort_order = 'DESC'\n        params = ()\n    else:\n        member_test = \"bool_or(participant = %s)\"\n        sort_order = 'ASC'\n        params = (user.participant.username,)\n\n    return gittip.db.all(\"\"\"\n\n        SELECT max(name) AS name\n             , slug\n             , count(*) AS nmembers\n             , {} AS is_member\n          FROM current_communities\n      GROUP BY slug\n      ORDER BY nmembers {}, slug\n\n    \"\"\".format(member_test, sort_order), params)\n\n\nclass Community(Model):\n    \"\"\"Model a community on Gittip.\n    \"\"\"\n\n    typname = \"community_summary\"\n\n    def check_membership(self, participant):\n        return self.db.one(\"\"\"\n\n        SELECT * FROM current_communities WHERE slug=%s AND participant=%s\n\n        \"\"\", (self.slug, participant.username)) is not None\n\n\ndef typecast(request):\n    pass\n", "path": "gittip/models/community.py"}]}