diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index ec15f69..90b4af7 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -92,7 +92,7 @@ class TournamentsController < ApplicationController def school_delegate if params[:search] - @users = User.limit(200).search(params[:search]) + @user = User.where('email = ?', params[:search]).first elsif params[:school_delegate] @delegate = SchoolDelegate.new @delegate.user_id = params[:school_delegate]["user_id"] @@ -104,19 +104,18 @@ class TournamentsController < ApplicationController format.html { redirect_to "/tournaments/#{@tournament.id}/school_delegate", notice: 'There was an issue delegating permissions please try again' } end end - else - @users_delegates = [] - @tournament.schools.each do |s| - s.delegates.each do |d| - @users_delegates << d - end + end + @users_delegates = [] + @tournament.schools.each do |s| + s.delegates.each do |d| + @users_delegates << d end end end def delegate if params[:search] - @users = User.limit(200).search(params[:search]) + @user = User.where('email = ?', params[:search]).first elsif params[:tournament_delegate] @delegate = TournamentDelegate.new @delegate.user_id = params[:tournament_delegate]["user_id"] @@ -128,9 +127,8 @@ class TournamentsController < ApplicationController format.html { redirect_to "/tournaments/#{@tournament.id}/delegate", notice: 'There was an issue delegating permissions please try again' } end end - else - @users_delegates = @tournament.delegates end + @users_delegates = @tournament.delegates end def matches @@ -230,9 +228,9 @@ class TournamentsController < ApplicationController end def show - @schools = @tournament.schools.includes(:delegates) + @schools = @tournament.schools.includes(:delegates).sort_by{|school|school.name} @weights = @tournament.weights.sort_by{|x|[x.max]} - @mats = @tournament.mats + @mats = @tournament.mats.sort_by{|mat|mat.name} end def new diff --git a/app/views/tournaments/delegate.html.erb b/app/views/tournaments/delegate.html.erb index 2685c7e..75fcd09 100644 --- a/app/views/tournaments/delegate.html.erb +++ b/app/views/tournaments/delegate.html.erb @@ -1,11 +1,11 @@ -<% if @users %>
Search by email address
+Search by email address to delegate tournament permissions
+<% if @user %>| <%= user.email %> | +<%= @user.email %> | <%= form_for TournamentDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'delegate', :method => "post") do |f| %> - <%= f.hidden_field :user_id, :value => user.id %> + <%= f.hidden_field :user_id, :value => @user.id %> <% if can? :manage, @tournament %> <%= submit_tag "Give permissions", :class=>"btn btn-success"%> <% end %> <% end %> |
Search by email address
- - +| <%= user.email %> | +<%= @user.email %> | <%= form_for SchoolDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'school_delegate', :method => "post") do |f| %><%= f.collection_select :school_id, @tournament.schools, :id, :name %> | - <%= f.hidden_field :user_id, :value => user.id %> + <%= f.hidden_field :user_id, :value => @user.id %> <% if can? :manage, @tournament %> <%= submit_tag "Give permissions", :class=>"btn btn-success"%> <% end %> <% end %> |
Search by email address
- - +