This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an implementation of communication between people on the site.
- Loading branch information
1 parent
89223bf
commit dd9e271
Showing
8 changed files
with
305 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from aspen import Response | ||
from gittip.utils import get_participant | ||
from gittip import AMOUNTS | ||
# ========================================================================== ^L | ||
|
||
participant = get_participant(request, restrict=False) | ||
hero = "Horn" | ||
title = "%s - %s" % (participant.username, hero) | ||
locked = False | ||
|
||
# ========================================================================== ^L | ||
{% extends templates/profile.html %} | ||
{% block page %} | ||
<script>$(document).ready(Gittip.horn.init);</script> | ||
<div class="col0" id="horn"> | ||
{% if not user.ANON %} | ||
{% if user == participant %} | ||
<h2>Toot your own horn!</h2> | ||
{% else %} | ||
<h2>Toot their horn!</h2> | ||
{% end %} | ||
<form id="toot-form"> | ||
<textarea id="toot"></textarea> | ||
<p class="help"> | ||
<span> | ||
{% if user == participant %} | ||
What have you done today that's awesome? Don't be shy!<br /> | ||
Anyone who gave you money last week will see this on their Horn. | ||
{% else %} | ||
Why do you appreciate {{ participant.username }}? | ||
{% end %} | ||
</span> | ||
<button id="toot-button" type="submit">Toot</button> | ||
</p> | ||
<div class="clear"></div> | ||
</form> | ||
{% end %} | ||
<h2>Toots</h2> | ||
<ul id="toots"></ul> | ||
</div> | ||
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from aspen import Response | ||
from gittip import db | ||
|
||
# ============================= ^L | ||
|
||
if user.ANON: | ||
raise Response(400) | ||
tooter = user.username | ||
tootee = path['username'] | ||
toot= body['toot'] | ||
if len(toot) > 140: | ||
raise Response(400) | ||
db.execute( "INSERT INTO toots (tooter, tootee, toot) VALUES (%s, %s, %s)" | ||
, (tooter, tootee, toot) | ||
) | ||
response.code = 204 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""Return an array of toots for this participant. | ||
|
||
If the user is the participant, then the toot stream will include toots | ||
referring to people they gave money to last week. | ||
|
||
""" | ||
from gittip import db | ||
from gittip.utils import get_participant | ||
|
||
SQL_SELF = """ | ||
|
||
SELECT id, ctime, %s as horn, tootee, tooter = tootee AS own, toot | ||
FROM toots | ||
WHERE ( tootee = %s | ||
OR tootee IN ( SELECT tippee | ||
FROM transfers | ||
WHERE tipper=%s | ||
AND "timestamp" < (now() - interval '8 days') | ||
) | ||
) | ||
AND id > %s | ||
AND id <= %s | ||
ORDER BY id DESC | ||
LIMIT %s | ||
|
||
""" | ||
|
||
SQL_OTHER = """ | ||
|
||
SELECT id, ctime, %s as horn, tootee, tooter = tootee AS own, toot | ||
FROM toots | ||
WHERE tootee = %s | ||
AND id > %s | ||
AND id <= %s | ||
ORDER BY id DESC | ||
LIMIT %s | ||
|
||
""" | ||
|
||
DEFAULT_LIMIT = 200 | ||
# =========================== ^L | ||
participant = get_participant(request, restrict=False) | ||
username = participant.username | ||
try: | ||
limit = min(int(qs.get('limit', DEFAULT_LIMIT)), DEFAULT_LIMIT) | ||
since_id = long(qs.get('since_id', 0)) | ||
if user == participant: | ||
SQL = SQL_SELF | ||
args = [username, username, username, since_id, limit] | ||
else: | ||
SQL = SQL_OTHER | ||
args = [username, username, since_id, limit] | ||
|
||
max_id = qs.get('max_id') | ||
if max_id is None: | ||
SQL = SQL.replace("AND id <= %s", "") | ||
else: | ||
args.insert(-1, long(max_id)) | ||
except ValueError: # cast to int/long failed | ||
raise Response(400) | ||
response.body = list(db.fetchall(SQL, tuple(args))) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters