Skip to content

Commit

Permalink
homepage for invitees
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyril Fluck authored and Cyril Fluck committed Jan 28, 2012
1 parent 9fb65b1 commit ec71838
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
8 changes: 7 additions & 1 deletion app/controllers/canvas_controller.rb
@@ -1,8 +1,14 @@
class CanvasController < ApplicationController
def index
@new_invitee = false

if @signed_request && @signed_request["user_id"]
user = User.where(:facebook_id => @signed_request["user_id"]).first
sign_in( user ) if user
if user
sign_in( user )
elsif Invitation.where( :invitee_id => @signed_request['user_id'] ).count > 0
@new_invitee = true
end
end
end

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/invitations_controller.rb
Expand Up @@ -5,7 +5,6 @@ class InvitationsController < ApplicationController
# GET /invitations
# GET /invitations.json
def index
debugger
@invitations = Invitation.all

respond_to do |format|
Expand Down Expand Up @@ -89,5 +88,7 @@ def callback
params[:to].each_value do | facebook_id |
Invitation.create( user: current_user, invitee_id: facebook_id )
end

redirect_to invitations_path, :notice => "#{params[:to].length} friend(s) invited."
end
end
8 changes: 3 additions & 5 deletions app/views/canvas/index.html.haml
@@ -1,9 +1,7 @@
- if current_user
- elsif @new_invitee
%h1 Welcome to TennisYourWorld
= link_to 'Join Us!', user_omniauth_callback_path
- else
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
%script
FB.init({appId: '185797408106593', xfbml: true, cookie: true, oauth: true});
FB.login({scope: 'email});
%h1 We're sorry, but TennisYourWorld is a private group.
%p You need to be invited by a member in order to access this content.
2 changes: 1 addition & 1 deletion app/views/invitations/index.html.erb
Expand Up @@ -12,7 +12,7 @@
<% @invitations.each do |invitation| %>
<tr>
<td><%= invitation.user %></td>
<td><%= invitation.invitee %></td>
<td><%= invitation.invitee_id %></td>
<td><%= link_to 'Show', invitation %></td>
<td><%= link_to 'Edit', edit_invitation_path(invitation) %></td>
<td><%= link_to 'Destroy', invitation, confirm: 'Are you sure?', method: :delete %></td>
Expand Down

0 comments on commit ec71838

Please sign in to comment.