Can now join teams from the teams pages individually. If you already have a request active, it will remove that request and replace it with a new one (with a confirmation). I left the Agenda way of joining/cancelling join of teams.

This commit is contained in:
Room5-Joey 2014-05-13 16:54:51 -07:00 committed by Luke Barratt
parent 062d00c072
commit 9adf362f6b
6 changed files with 35 additions and 3 deletions

View file

@ -13,6 +13,16 @@ class TeamersController < ApplicationController
redirect_to_back
end
def edit
logger.info params
logger.info "hello world"
teamer_id = params["teamer"]
@teamer = Teamer.find(teamer_id)
@teamer.team_id = params["id"]
@teamer.save
redirect_to_back
end
def destroy
@teamer = Teamer.find params[:id]
raise AccessError unless @teamer.can_destroy? cuser

View file

@ -6,6 +6,8 @@ class TeamsController < ApplicationController
end
def show
@teamer = Teamer.new
@teamer.user = @user
end
def new
@ -13,6 +15,12 @@ class TeamsController < ApplicationController
raise AccessError unless @team.can_create? cuser
end
def replace_teamer
logger.info params
logger.info "hello"
redirect_to_back
end
def edit
raise AccessError unless @team.can_update? cuser
end

View file

@ -53,7 +53,7 @@ class UsersController < ApplicationController
if @user.valid? and @user.save
@user.profile = Profile.new
@user.profile.user = @user
@user.profile.save
@user.profile.save!
redirect_to action: :show, id: @user.id
save_session @user
else

View file

@ -9,6 +9,20 @@
</div>
<% end %>
<% if cuser.teamers.joining.count == 0 && @team.active %>
<%= form_for @teamer do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :user_id, :value => cuser.id %>
<%= f.hidden_field :team_id, :value => @team.id %>
<div class="controls inline">
<%= f.submit "Request To Join", class: 'button' %>
</div>
<% end %>
<% elsif cuser.teamers.joining.first.team != @team %>
<%= link_to 'Request To Join', edit_teamer_path("teamer" => cuser.teamers.joining.first), method: :get,confirm: "You have already requested to join #{cuser.teamers.joining.first.team}. Do you want to request to join #{@team} instead?", class: 'button' %>
<% end %>
<div id="team" class="tabbed">
<ul id="team-nav" class="tabs">
<li><a href="#general">General</a></li>

View file

@ -57,7 +57,7 @@
<% end %>
<% else %>
<div class="flash warning">
<p>You can join only be a member of one team at a time.</p>
<p>You can only request to join one team at a time.</p>
<p>Currently you are trying to join <%= namelink @user.teamers.joining.first.team %></p>
<p>You can cancel this request by clicking "Cancel Request"</p>
</div>

View file

@ -127,7 +127,7 @@ Ensl::Application.routes.draw do
match ':controller/:action/:id'
match ':controller/:action/:id.:format'
match ':controller/:action/:id/:id2'
match 'teamers/replace' => 'teamers#replace', :as => 'teamers_replace'
namespace :api do
namespace :v1 do
resources :users