mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 21:10:54 +00:00
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:
parent
062d00c072
commit
9adf362f6b
6 changed files with 35 additions and 3 deletions
|
@ -13,6 +13,16 @@ class TeamersController < ApplicationController
|
||||||
redirect_to_back
|
redirect_to_back
|
||||||
end
|
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
|
def destroy
|
||||||
@teamer = Teamer.find params[:id]
|
@teamer = Teamer.find params[:id]
|
||||||
raise AccessError unless @teamer.can_destroy? cuser
|
raise AccessError unless @teamer.can_destroy? cuser
|
||||||
|
|
|
@ -6,6 +6,8 @@ class TeamsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@teamer = Teamer.new
|
||||||
|
@teamer.user = @user
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -13,6 +15,12 @@ class TeamsController < ApplicationController
|
||||||
raise AccessError unless @team.can_create? cuser
|
raise AccessError unless @team.can_create? cuser
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def replace_teamer
|
||||||
|
logger.info params
|
||||||
|
logger.info "hello"
|
||||||
|
redirect_to_back
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
raise AccessError unless @team.can_update? cuser
|
raise AccessError unless @team.can_update? cuser
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,7 +53,7 @@ class UsersController < ApplicationController
|
||||||
if @user.valid? and @user.save
|
if @user.valid? and @user.save
|
||||||
@user.profile = Profile.new
|
@user.profile = Profile.new
|
||||||
@user.profile.user = @user
|
@user.profile.user = @user
|
||||||
@user.profile.save
|
@user.profile.save!
|
||||||
redirect_to action: :show, id: @user.id
|
redirect_to action: :show, id: @user.id
|
||||||
save_session @user
|
save_session @user
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,6 +9,20 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% 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">
|
<div id="team" class="tabbed">
|
||||||
<ul id="team-nav" class="tabs">
|
<ul id="team-nav" class="tabs">
|
||||||
<li><a href="#general">General</a></li>
|
<li><a href="#general">General</a></li>
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="flash warning">
|
<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>Currently you are trying to join <%= namelink @user.teamers.joining.first.team %></p>
|
||||||
<p>You can cancel this request by clicking "Cancel Request"</p>
|
<p>You can cancel this request by clicking "Cancel Request"</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -127,7 +127,7 @@ Ensl::Application.routes.draw do
|
||||||
match ':controller/:action/:id'
|
match ':controller/:action/:id'
|
||||||
match ':controller/:action/:id.:format'
|
match ':controller/:action/:id.:format'
|
||||||
match ':controller/:action/:id/:id2'
|
match ':controller/:action/:id/:id2'
|
||||||
|
match 'teamers/replace' => 'teamers#replace', :as => 'teamers_replace'
|
||||||
namespace :api do
|
namespace :api do
|
||||||
namespace :v1 do
|
namespace :v1 do
|
||||||
resources :users
|
resources :users
|
||||||
|
|
Loading…
Reference in a new issue