Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Prevent tipping to organizations
Browse files Browse the repository at this point in the history
I want to emphasize natural persons over corporate persons. There should
be some support for "batch tipping" where everyone in an org gets a
slice of tip. But for now just link out to individual members.
  • Loading branch information
chadwhitacre committed Jun 6, 2012
1 parent 8f86cba commit a367c19
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 22 deletions.
4 changes: 2 additions & 2 deletions templates/participant.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{% block their_voice %}{% end %}
</div>

{% if user.ANON %}
{% if can_tip and user.ANON %}
<h2>Sign in
<a href="{{ github_oauth_url(username) }}">with
Github</a> to tip {{ username }}.</h2>
{% else %}
{% elif can_tip %}
{% if user.id != username %}
<h2>Your weekly tip to {{ username }} is:</h2>

Expand Down
1 change: 1 addition & 0 deletions www/%participant_id/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

name = participant['user_info'].get('name', username)
github = participant['user_info']
can_tip = True

# ========================================================================== ^L
{% extends templates/participant.html %}
Expand Down
16 changes: 16 additions & 0 deletions www/assets/%version/gittip.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ B {
margin-right: 10pt;
}

#members {
list-style: none;
margin-bottom: 12pt;
margin: 0 auto;
}
#members TD {
padding: 0 0 0.5em 0;
text-align: left;
}
#members IMG {
width: 18pt;
height: 18pt;
margin-right: 6pt;
float: left;
}

.clear {
clear: both;
}
Expand Down
86 changes: 68 additions & 18 deletions www/github/%login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,96 @@

# Try to load from Gittip.
# ==========================

participant_id, claimed_time, balance = github.upsert(userinfo)
if claimed_time:
request.redirect('/%s/' % participant_id)
# We can only tip Users, not Organizations (or whatever else type can be).

participant = False
username = userinfo['login']
name = userinfo.get('name')
if not name:
name = username

if not user.ANON:
my_tip = get_tip(user.id, participant_id)
usertype = userinfo.get("type", "unknown type of account").lower()
if usertype == "user":
can_tip = True
participant_id, claimed_time, balance = github.upsert(userinfo)
if claimed_time:
request.redirect('/%s/' % participant_id)

if not user.ANON:
my_tip = get_tip(user.id, participant_id)
elif usertype == "organization":
members = []
resp = requests.get("https://api.github.com/orgs/%s/members" % username)
if resp.status_code == 200:
members = json.loads(resp.text)
can_tip = False
else:
can_tip = False


# ========================================================================== ^L
{% extends templates/participant.html %}

{% block their_voice %}
<script>
$(document).ready(Gittip.initTipButtons);
</script>

<h2 class="first"><b>{{ name }}</b> has {{ get_tipjar(username) }}</h2>
{% if usertype == "user" %}
<script>
$(document).ready(Gittip.initTipButtons);
</script>

<h2 class="first"><b>{{ name }}</b> has {{ get_tipjar(username) }}</h2>

{% if user.ANON %}
{% if user.ANON %}
<ul id="accounts">
<li>
<img src="{{ userinfo.get('avatar_url', '/assets/%s/no-avatar.png' % __version__) }}" />
Are you <a href="{{ userinfo['html_url'] }}">{{ userinfo['login'] }}</a> from Github?<br />
<a href="{{ github_oauth_url(username) }}">Click here</a> to claim this tipjar.
</li>
</ul>
{% else %}
<ul id="accounts">
<li>
<img src="{{ userinfo.get('avatar_url', '/assets/%s/no-avatar.png' % __version__) }}" />
Are you <a href="{{ userinfo['html_url'] }}">{{ userinfo['login'] }}</a> from Github?<br />
You&rsquo;ll have to <a href="/sign-out.html">sign out</a> and sign back in to claim this tipjar.
</li>
</ul>
{% end %}
{% elif usertype == "organization" %}

<h2 class="first"><b>{{ name }}</b> is an {{ usertype }} on Github.</h2>
<ul id="accounts">
<li>
<img src="{{ userinfo.get('avatar_url', '/assets/%s/no-avatar.png' % __version__) }}" />
Are you <a href="{{ userinfo['html_url'] }}">{{ userinfo['login'] }}</a> from Github?<br />
<a href="{{ github_oauth_url(username) }}">Click here</a> to claim this tipjar.
Gittip is designed for people, not corporations.<br />
{% if len(members) == 0 %}
{{ name }} does not have any public members.
{% elif len(members) == 1 %}
{{ name }} has one public member.
{% else %}
Here are the {{ len(members) }} public members of <a href="https://github.com/{{ username }}">{{ name }}</a>.
{% end %}
</li>
</ul>
<table id="members">
{% for member in members %}
<tr><td>
<a href="/github/{{ member['login'] }}/"><img src="{{ member.get('avatar_url', '/assets/%s/no-avatar.png' % __version__) }}" />
{{ member['login'] }}</a>
</td></tr>
{% end %}
</table>

{% else %}

<h2 class="first">Not sure what to do with <b>{{ name }}</b>.</h2>
<ul id="accounts">
<li>
<img src="{{ userinfo.get('avatar_url', '/assets/%s/no-avatar.png' % __version__) }}" />
Are you <a href="{{ userinfo['html_url'] }}">{{ userinfo['login'] }}</a> from Github?<br />
You&rsquo;ll have to <a href="/sign-out.html">sign out</a> and sign back in to claim this tipjar.
I don&rsquo;t recognize the &ldquo;{{ usertype }}&rdquo; type of user on Github.<br />
Sorry. :-(
</li>
</ul>
{% end %}
</ul>

{% end %}
{% end %}
4 changes: 2 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ <h2><b>Gittip</b> is a gift economy.</h2>
{% end %}
{% block body %}
{% if user.ANON %}
<h2 class="first">Step 1. Sign in with your <a
href="https://github.com/login/oauth/authorize?client_id={{ website.github_client_id }}">Github</a> account.</h2>
<h2 class="first">Step 1. Sign in with <a
href="https://github.com/login/oauth/authorize?client_id={{ website.github_client_id }}">Github</a>.</h2>

<h2>Step 2. Tip someone!</h2>

Expand Down

0 comments on commit a367c19

Please sign in to comment.