From 612902aa915e8d2a65bdf37c2d3c564e2d88110c Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 7 Jan 2016 16:08:46 +0000 Subject: [PATCH 01/25] School delegates permissions are working --- app/controllers/schools_controller.rb | 11 +++++-- app/controllers/wrestlers_controller.rb | 11 ++++--- app/models/ability.rb | 2 +- app/views/schools/show.html.erb | 6 ++-- app/views/tournaments/show.html.erb | 4 ++- app/views/wrestlers/show.html.erb | 2 +- test/controllers/schools_controller_test.rb | 30 +++++++++++++++++++ test/controllers/wrestlers_controller_test.rb | 30 +++++++++++++++++++ test/fixtures/school_delegates.yml | 4 +++ test/fixtures/users.yml | 4 +++ 10 files changed, 92 insertions(+), 12 deletions(-) diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index b47a693..54697a3 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -1,6 +1,7 @@ class SchoolsController < ApplicationController before_action :set_school, only: [:show, :edit, :update, :destroy] - before_filter :check_access, only: [:new,:create,:update,:destroy,:edit] + before_filter :check_access_director, only: [:new,:create,:destroy] + before_filter :check_access_delegate, only: [:update,:edit] # GET /schools/1 @@ -76,15 +77,21 @@ class SchoolsController < ApplicationController params.require(:school).permit(:name, :score, :tournament_id) end - def check_access + def check_access_director if params[:tournament] @tournament = Tournament.find(params[:tournament]) elsif params[:school] @tournament = Tournament.find(params[:school]["tournament_id"]) elsif @school @tournament = @school.tournament + elsif school_params + @tournament = Tournament.find(school_params[:tournament_id]) end authorize! :manage, @tournament end + + def check_access_delegate + authorize! :manage, @school + end end diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb index a76783f..ae055f5 100644 --- a/app/controllers/wrestlers_controller.rb +++ b/app/controllers/wrestlers_controller.rb @@ -92,13 +92,16 @@ class WrestlersController < ApplicationController def check_access if params[:school] @school = School.find(params[:school]) - @tournament = Tournament.find(@school.tournament.id) + #@tournament = Tournament.find(@school.tournament.id) elsif params[:wrestler] @school = School.find(params[:wrestler]["school_id"]) - @tournament = Tournament.find(@school.tournament.id) + #@tournament = Tournament.find(@school.tournament.id) elsif @wrestler - @tournament = @wrestler.tournament + @school = @wrestler.school + #@tournament = @wrestler.tournament + elsif wrestler_params + @school = School.find(wrestler_params[:school_id]) end - authorize! :manage, @tournament + authorize! :manage, @school end end diff --git a/app/models/ability.rb b/app/models/ability.rb index a6a5983..57e7a74 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -40,7 +40,7 @@ class Ability end #Can manage school if tournament owner can :manage, School do |school| - school.tournament.map(&:user_id).include? user.id + school.tournament.user.id == user.id end #Can manage school if tournament delegate can :manage, School do |school| diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb index a1fc7c3..5fff49f 100644 --- a/app/views/schools/show.html.erb +++ b/app/views/schools/show.html.erb @@ -1,7 +1,7 @@

<%= notice %>

<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %> - <% if can? :manage, @tournament %> + <% if can? :manage, @school %> | <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %> <% end %> @@ -27,7 +27,7 @@
- <% if can? :manage, @tournament %> + <% if can? :manage, @school %> <%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%> <% end %>
@@ -66,7 +66,7 @@ <%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %> <%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %> - <% if can? :manage, @tournament %> + <% if can? :manage, wrestler.school %> <%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary btn-sm" %> <%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %> <% end %> diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index aee4fe4..9ca40a7 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -53,8 +53,10 @@ <%= school.name %> <%= link_to 'Show', school, :class=>"btn btn-default btn-sm" %> - <% if can? :manage, @tournament %> + <% if can? :manage, school %> <%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary btn-sm" %> + <% end %> + <% if can? :manage, @tournament %> <%= link_to 'Destroy', school, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %> <% end %> diff --git a/app/views/wrestlers/show.html.erb b/app/views/wrestlers/show.html.erb index cb47a00..d59b429 100644 --- a/app/views/wrestlers/show.html.erb +++ b/app/views/wrestlers/show.html.erb @@ -2,7 +2,7 @@

<%= notice %>

<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %> - <% if can? :manage, @tournament %> + <% if can? :manage, @school %> | <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %> <% end %> <% cache ["wrestlers", @wrestler] do %> diff --git a/test/controllers/schools_controller_test.rb b/test/controllers/schools_controller_test.rb index 8421c6a..f788822 100644 --- a/test/controllers/schools_controller_test.rb +++ b/test/controllers/schools_controller_test.rb @@ -40,6 +40,10 @@ class SchoolsControllerTest < ActionController::TestCase def sign_in_tournament_delegate sign_in users(:three) end + + def sign_in_school_delegate + sign_in users(:four) + end def success assert_response :success @@ -60,6 +64,12 @@ class SchoolsControllerTest < ActionController::TestCase get_edit success end + + test "logged in school delegate should get edit school page" do + sign_in_school_delegate + get_edit + success + end test "logged in user should not get edit school page if not owner" do sign_in_non_owner @@ -94,6 +104,12 @@ class SchoolsControllerTest < ActionController::TestCase post_update assert_redirected_to tournament_path(@school.tournament_id) end + + test "logged in school delegate should post update school" do + sign_in_school_delegate + post_update + assert_redirected_to tournament_path(@school.tournament_id) + end test "logged in tournament owner can create a new school" do sign_in_owner @@ -110,6 +126,14 @@ class SchoolsControllerTest < ActionController::TestCase create assert_redirected_to tournament_path(@school.tournament_id) end + + test "logged in school delegate cannot create a new school" do + sign_in_school_delegate + new + redirect + create + redirect + end test "logged in user not tournament owner cannot create a school" do sign_in_non_owner @@ -130,6 +154,12 @@ class SchoolsControllerTest < ActionController::TestCase destroy assert_redirected_to tournament_path(@tournament.id) end + + test "logged in school delegate can destroy a school" do + sign_in_school_delegate + destroy + redirect + end test "logged in user not tournament owner cannot destroy school" do sign_in_non_owner diff --git a/test/controllers/wrestlers_controller_test.rb b/test/controllers/wrestlers_controller_test.rb index c3c3fa9..9ef496f 100644 --- a/test/controllers/wrestlers_controller_test.rb +++ b/test/controllers/wrestlers_controller_test.rb @@ -41,6 +41,10 @@ class WrestlersControllerTest < ActionController::TestCase def sign_in_tournament_delegate sign_in users(:three) end + + def sign_in_school_delegate + sign_in users(:four) + end def success assert_response :success @@ -61,6 +65,12 @@ class WrestlersControllerTest < ActionController::TestCase get_edit success end + + test "logged in school delegate should get edit wrestler page" do + sign_in_school_delegate + get_edit + success + end test "logged in user should not get edit wrestler page if not owner" do sign_in_non_owner @@ -95,6 +105,12 @@ class WrestlersControllerTest < ActionController::TestCase post_update assert_redirected_to school_path(@school.id) end + + test "logged in school delegate should post update wrestler" do + sign_in_school_delegate + post_update + assert_redirected_to school_path(@school.id) + end test "logged in tournament owner can create a new wrestler" do sign_in_owner @@ -111,6 +127,14 @@ class WrestlersControllerTest < ActionController::TestCase create assert_redirected_to school_path(@school.id) end + + test "logged in school delegate can create a new wrestler" do + sign_in_school_delegate + new + success + create + assert_redirected_to school_path(@school.id) + end test "logged in user not tournament owner cannot create a wrestler" do sign_in_non_owner @@ -131,6 +155,12 @@ class WrestlersControllerTest < ActionController::TestCase destroy assert_redirected_to school_path(@school.id) end + + test "logged in school delegate can destroy a wrestler" do + sign_in_school_delegate + destroy + assert_redirected_to school_path(@school.id) + end test "logged in user not tournament owner cannot destroy wrestler" do sign_in_non_owner diff --git a/test/fixtures/school_delegates.yml b/test/fixtures/school_delegates.yml index 143b056..9b2dc94 100644 --- a/test/fixtures/school_delegates.yml +++ b/test/fixtures/school_delegates.yml @@ -7,3 +7,7 @@ # two: # user_id: 1 # school_id: 1 + +one: + user_id: 4 + school_id: 1 \ No newline at end of file diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 6d8325a..da16999 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -19,3 +19,7 @@ two: three: email: test3@test.com id: 3 + +four: + email: test4@test.com + id: 4 From 1e9ca0d3b12af857bb28d2921265ed411ee3193f Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 7 Jan 2016 16:30:30 +0000 Subject: [PATCH 02/25] Test all controllers for school delegate access --- test/controllers/matches_controller_test.rb | 16 ++++++ test/controllers/mats_controller_test.rb | 38 +++++++++++++- .../tournaments_controller_test.rb | 52 +++++++++++++++++++ test/controllers/weights_controller_test.rb | 30 +++++++++++ 4 files changed, 135 insertions(+), 1 deletion(-) diff --git a/test/controllers/matches_controller_test.rb b/test/controllers/matches_controller_test.rb index 52a58f0..d9bd562 100644 --- a/test/controllers/matches_controller_test.rb +++ b/test/controllers/matches_controller_test.rb @@ -28,6 +28,10 @@ class MatchesControllerTest < ActionController::TestCase def sign_in_tournament_delegate sign_in users(:three) end + + def sign_in_school_delegate + sign_in users(:four) + end def success assert_response :success @@ -52,6 +56,12 @@ class MatchesControllerTest < ActionController::TestCase get_edit redirect end + + test "logged school delegate should not get edit match page if not owner" do + sign_in_school_delegate + get_edit + redirect + end test "non logged in user should not get edit match page" do get_edit @@ -68,6 +78,12 @@ class MatchesControllerTest < ActionController::TestCase post_update assert_redirected_to '/static_pages/not_allowed' end + + test "logged school delegate should not post update match if not owner" do + sign_in_school_delegate + post_update + assert_redirected_to '/static_pages/not_allowed' + end test "logged in tournament delegate should get edit match page" do sign_in_tournament_delegate diff --git a/test/controllers/mats_controller_test.rb b/test/controllers/mats_controller_test.rb index 4f2f788..7ebf6c4 100644 --- a/test/controllers/mats_controller_test.rb +++ b/test/controllers/mats_controller_test.rb @@ -44,7 +44,11 @@ class MatsControllerTest < ActionController::TestCase def sign_in_tournament_delegate sign_in users(:three) end - + + def sign_in_school_delegate + sign_in users(:four) + end + def success assert_response :success end @@ -78,6 +82,12 @@ class MatsControllerTest < ActionController::TestCase get_edit redirect end + + test "logged school delegate should not get edit mat page if not owner" do + sign_in_school_delegate + get_edit + redirect + end test "non logged in user should not get edit mat page" do get_edit @@ -94,6 +104,12 @@ class MatsControllerTest < ActionController::TestCase post_update redirect end + + test "logged school delegate should not post update mat if not owner" do + sign_in_school_delegate + post_update + redirect + end test "logged in tournament owner should post update mat" do sign_in_owner @@ -130,6 +146,14 @@ class MatsControllerTest < ActionController::TestCase create redirect end + + test "logged school delegate not tournament owner cannot create a mat" do + sign_in_school_delegate + new + redirect + create + redirect + end test "logged in tournament owner can destroy a mat" do sign_in_owner @@ -149,11 +173,23 @@ class MatsControllerTest < ActionController::TestCase redirect end + test "logged school delegate not tournament owner cannot destroy mat" do + sign_in_school_delegate + destroy + redirect + end + test "logged in user should not get show mat" do sign_in_non_owner show redirect end + + test "logged school delegate should not get show mat" do + sign_in_school_delegate + show + redirect + end test "logged in tournament owner should get show mat" do sign_in_owner diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb index 4fc0e6d..74f497c 100644 --- a/test/controllers/tournaments_controller_test.rb +++ b/test/controllers/tournaments_controller_test.rb @@ -29,6 +29,10 @@ include Devise::TestHelpers def sign_in_delegate sign_in users(:three) end + + def sign_in_school_delegate + sign_in users(:four) + end def success assert_response :success @@ -61,6 +65,12 @@ include Devise::TestHelpers get :generate_matches, id: 1 redirect end + + test "logged in school delegate cannot generate matches" do + sign_in_school_delegate + get :generate_matches, id: 1 + redirect + end test "logged in tournament owner can create custom weights" do sign_in_owner @@ -73,6 +83,12 @@ include Devise::TestHelpers get :create_custom_weights, id: 1, customValue: 'hs' redirect end + + test "logged in school delegate cannot create custom weights" do + sign_in_school_delegate + get :create_custom_weights, id: 1, customValue: 'hs' + redirect + end test "logged in tournament owner can access weigh_ins" do @@ -86,6 +102,12 @@ include Devise::TestHelpers get :weigh_in, id: 1 redirect end + + test "logged in school delegate cannot access weigh_ins" do + sign_in_school_delegate + get :weigh_in, id: 1 + redirect + end test "logged in tournament owner can access weigh_in_weight" do sign_in_owner @@ -99,6 +121,12 @@ include Devise::TestHelpers redirect end + test "logged in school delegate cannot access weigh_in_weight" do + sign_in_school_delegate + get :weigh_in_weight, id: 1, weight: 1 + redirect + end + test "logged in tournament owner can access post weigh_in_weight" do sign_in_owner post :weigh_in, id: 1, weight: 1, wrestler: @wrestlers @@ -109,6 +137,12 @@ include Devise::TestHelpers post :weigh_in_weight, id: 1, weight: 1, wrestler: @wrestlers redirect end + + test "logged in school delegate cannot access post weigh_in_weight" do + sign_in_school_delegate + post :weigh_in_weight, id: 1, weight: 1, wrestler: @wrestlers + redirect + end test "logged in tournament owner should get edit tournament page" do @@ -122,6 +156,12 @@ include Devise::TestHelpers get_edit redirect end + + test "logged in school delegate should not get edit tournament page if not owner" do + sign_in_school_delegate + get_edit + redirect + end test "non logged in user should not get edit tournament page" do get_edit @@ -138,6 +178,12 @@ include Devise::TestHelpers post_update assert_redirected_to '/static_pages/not_allowed' end + + test "logged in school delegate should not post update tournament if not owner" do + sign_in_school_delegate + post_update + assert_redirected_to '/static_pages/not_allowed' + end test "logged in tournament owner should post update tournament" do sign_in_owner @@ -158,6 +204,12 @@ include Devise::TestHelpers redirect end + test "logged in school delegate not tournament owner cannot destroy tournament" do + sign_in_school_delegate + destroy + redirect + end + #TESTS THAT NEED MATCHES PUT ABOVE THIS test "redirect up_matches if no matches" do diff --git a/test/controllers/weights_controller_test.rb b/test/controllers/weights_controller_test.rb index dd7ea4a..ba2a152 100644 --- a/test/controllers/weights_controller_test.rb +++ b/test/controllers/weights_controller_test.rb @@ -40,6 +40,10 @@ class WeightsControllerTest < ActionController::TestCase def sign_in_tournament_delegate sign_in users(:three) end + + def sign_in_school_delegate + sign_in users(:four) + end def success assert_response :success @@ -66,6 +70,12 @@ class WeightsControllerTest < ActionController::TestCase get_edit redirect end + + test "logged school delegate should not get edit weight page if not owner" do + sign_in_school_delegate + get_edit + redirect + end test "non logged in user should not get edit weight page" do get_edit @@ -82,6 +92,12 @@ class WeightsControllerTest < ActionController::TestCase post_update redirect end + + test "logged school delegate should not post update weight if not owner" do + sign_in_school_delegate + post_update + redirect + end test "logged in tournament owner should post update weight" do sign_in_owner @@ -118,6 +134,14 @@ class WeightsControllerTest < ActionController::TestCase create redirect end + + test "logged school delegate not tournament owner cannot create a weight" do + sign_in_school_delegate + new + redirect + create + redirect + end test "logged in tournament owner can destroy a weight" do sign_in_owner @@ -136,6 +160,12 @@ class WeightsControllerTest < ActionController::TestCase destroy redirect end + + test "logged school delegate not tournament owner cannot destroy weight" do + sign_in_school_delegate + destroy + redirect + end test "view wegiht" do get :show, id: 1 From 216e60d2b8319f5d100ec2592649590734e369d9 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 7 Jan 2016 16:35:24 +0000 Subject: [PATCH 03/25] Remove back button from printable brackets page --- app/views/tournaments/all_brackets.html.erb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/tournaments/all_brackets.html.erb b/app/views/tournaments/all_brackets.html.erb index 3d1107a..9182666 100644 --- a/app/views/tournaments/all_brackets.html.erb +++ b/app/views/tournaments/all_brackets.html.erb @@ -18,9 +18,6 @@ - <%= link_to "Back to #{@tournament.name} weights", "/tournaments/#{@tournament.id}/brackets" %> -
-
<% @tournament.weights.sort_by{|w| w.max}.each do |w| %> From dd9e19b43f3ba6b507ff8f91dac2f947076b718c Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 7 Jan 2016 19:55:15 +0000 Subject: [PATCH 04/25] Added views to delegate tournament permissions --- app/controllers/static_pages_controller.rb | 1 + app/controllers/tournaments_controller.rb | 26 +++++++- app/models/ability.rb | 2 +- app/models/school_delegate.rb | 2 + app/models/tournament_delegate.rb | 4 +- app/models/user.rb | 25 ++++++- .../static_pages/my_tournaments.html.erb | 35 +++++++++- app/views/tournaments/delegate.html.erb | 65 +++++++++++++++++++ app/views/tournaments/index.html.erb | 2 + config/routes.rb | 5 ++ 10 files changed, 157 insertions(+), 10 deletions(-) create mode 100644 app/views/tournaments/delegate.html.erb diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 489a4c4..b350998 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -5,6 +5,7 @@ class StaticPagesController < ApplicationController tournaments_delegated = current_user.delegated_tournaments all_tournaments = tournaments_created + tournaments_delegated @tournaments = all_tournaments.sort_by{|t| t.daysUntil} + @schools = current_user.delegated_schools end def not_allowed diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 7fa29bd..5604143 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -1,10 +1,30 @@ class TournamentsController < ApplicationController - before_action :set_tournament, only: [:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] + before_action :set_tournament, only: [:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] before_filter :check_access_manage, only: [:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches] - before_filter :check_access_destroy, only: [:destroy] + before_filter :check_access_destroy, only: [:destroy,:delegate] before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets] - + + def delegate + if params[:search] + @users = User.search(params[:search]) + elsif params[:user] + @user = User.find(params[:user]["id"]) + @delegate = TournamentDelegate.new + @delegate.user_id = @user.id + @delegate.tournament_id = @tournament.id + respond_to do |format| + if @delegate.save + format.html { redirect_to "/tournaments/#{@tournament.id}/delegate", notice: 'Delegated permissions added successfully' } + else + 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 + end + def matches @matches = @tournament.matches.sort_by{|m| m.bout_number} if @match diff --git a/app/models/ability.rb b/app/models/ability.rb index 57e7a74..10b7574 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -40,7 +40,7 @@ class Ability end #Can manage school if tournament owner can :manage, School do |school| - school.tournament.user.id == user.id + school.tournament.user_id == user.id end #Can manage school if tournament delegate can :manage, School do |school| diff --git a/app/models/school_delegate.rb b/app/models/school_delegate.rb index 382079c..d85f2f6 100644 --- a/app/models/school_delegate.rb +++ b/app/models/school_delegate.rb @@ -1,2 +1,4 @@ class SchoolDelegate < ActiveRecord::Base + belongs_to :school + belongs_to :user end diff --git a/app/models/tournament_delegate.rb b/app/models/tournament_delegate.rb index c0e197b..310998a 100644 --- a/app/models/tournament_delegate.rb +++ b/app/models/tournament_delegate.rb @@ -1,4 +1,4 @@ class TournamentDelegate < ActiveRecord::Base - # belongs_to :tournament - # has_one :user + belongs_to :tournament + belongs_to :user end diff --git a/app/models/user.rb b/app/models/user.rb index e9279e6..ea5745c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,10 +2,29 @@ class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable has_many :tournaments - has_many :delegated_tournaments, class_name: "TournamentDelegate" - has_many :delegated_schools, class_name: "SchoolDelegate" + has_many :delegated_tournament_permissions, class_name: "TournamentDelegate" + has_many :delegated_school_permissions, class_name: "SchoolDelegate" devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - + + def delegated_tournaments + tournaments_delegated = [] + delegated_tournament_permissions.each do |t| + tournaments_delegated << t.tournament + end + tournaments_delegated + end + + def delegated_schools + schools_delegated = [] + delegated_school_permissions.each do |t| + schools_delegated << t.school + end + schools_delegated + end + + def self.search(search) + where("email LIKE ?", "%#{search}%") + end end diff --git a/app/views/static_pages/my_tournaments.html.erb b/app/views/static_pages/my_tournaments.html.erb index 40a1be6..265ea0e 100644 --- a/app/views/static_pages/my_tournaments.html.erb +++ b/app/views/static_pages/my_tournaments.html.erb @@ -27,6 +27,8 @@ @@ -34,7 +36,38 @@ <% end %>
<%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %> <% if can? :manage, tournament %> <%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %> + <% end %> + <% if can? :destroy, tournament %> <%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %> <% end %>
- +
+
+<% if @schools.size > 0 %> +

My Schools

+
+
+ + + + + + + + + + + + <% @schools.each do |school| %> + + + + + + + <% end %> + +
NameTournament NameTournament Date
<%= school.name %><%= tournament.school.name %><%= tournament.school.date %><%= link_to 'Show', school, :class=>"btn btn-default btn-sm" %> + <% if can? :manage, school %> + <%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary btn-sm" %> + <% end %> +
+<% end %>
diff --git a/app/views/tournaments/delegate.html.erb b/app/views/tournaments/delegate.html.erb new file mode 100644 index 0000000..fac3b58 --- /dev/null +++ b/app/views/tournaments/delegate.html.erb @@ -0,0 +1,65 @@ +<%= link_to "Back to #{@tournament_name}", "/tournaments/#{@tournament_id}", :class=>"btn btn-default" %> +
+
+ + + +<% if @users %> +

Search results

<%= form_tag(tournament_delegate_path, :method => "get", id: "search-form") do %> + <%= text_field_tag :search, params[:search], placeholder: "Search users" %> + <%= submit_tag "Search" %> + <% end %> +

Search by email address

+
+
+ + + + + + + + + <% @users.each do |user| %> + + + + + + <% end %> + +
User Email
<%= user.email %> + <%= form_for user, :url => url_for(:controller => 'tournaments', :action => 'delegate', :method => "patch") do |f| %> + <%= f.hidden_field :id, :value => user.id %> + <% if can? :manage, @tournament %> + <%= submit_tag "Give permissions", :class=>"btn btn-success"%> + <% end %> + <% end %> +
+<% end %> + +<% if @users_delegates %> +

Delegated users

<%= form_tag(tournament_delegate_path, :method => "get", id: "search-form") do %> + <%= text_field_tag :search, params[:search], placeholder: "Search users" %> + <%= submit_tag "Search" %> + <% end %> +

Search by email address

+
+
+ + + + + + + + <% @users_delegates.each do |delegate| %> + + + + + + <% end %> + +
User Email
<%= delegate.user.email %>
+<% end %> \ No newline at end of file diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index 85d0313..f250520 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -31,6 +31,8 @@ <%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %> <% if can? :manage, tournament %> <%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %> + <% end %> + <% if can? :destroy, tournament %> <%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index d98061e..6b77d97 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,6 +40,11 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/up_matches' => 'tournaments#up_matches' get 'tournaments/:id/no_matches' => 'tournaments#no_matches' get 'tournaments/:id/matches' => 'tournaments#matches' + get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate + patch 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate + + get 'schools/:id/delegate' => 'schools#delegate' + post 'schools/:id/delegate' => 'schools#delegate' # Example of regular route: # get 'products/:id' => 'catalog#view' From bd5768b037ed1e88022c8b85fb2cce80672ad73a Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 7 Jan 2016 20:18:36 +0000 Subject: [PATCH 05/25] Views for school and tournament delegates --- app/controllers/tournaments_controller.rb | 33 +++++++-- app/views/tournaments/delegate.html.erb | 4 +- .../tournaments/school_delegate.html.erb | 70 +++++++++++++++++++ config/routes.rb | 7 +- 4 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 app/views/tournaments/school_delegate.html.erb diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 5604143..0c45605 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -1,17 +1,40 @@ class TournamentsController < ApplicationController - before_action :set_tournament, only: [:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] - before_filter :check_access_manage, only: [:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches] + before_action :set_tournament, only: [:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] + before_filter :check_access_manage, only: [:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches] before_filter :check_access_destroy, only: [:destroy,:delegate] before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets] + def school_delegate + if params[:search] + @users = User.search(params[:search]) + elsif params[:school_delegate] + @delegate = SchoolDelegate.new + @delegate.user_id = params[:school_delegate]["user_id"] + @delegate.school_id = params[:school_delegate]["school_id"] + respond_to do |format| + if @delegate.save + format.html { redirect_to "/tournaments/#{@tournament.id}/school_delegate", notice: 'Delegated permissions added successfully' } + else + 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 + end + end + def delegate if params[:search] @users = User.search(params[:search]) - elsif params[:user] - @user = User.find(params[:user]["id"]) + elsif params[:tournament_delegate] @delegate = TournamentDelegate.new - @delegate.user_id = @user.id + @delegate.user_id = params[:tournament_delegate]["user_id"] @delegate.tournament_id = @tournament.id respond_to do |format| if @delegate.save diff --git a/app/views/tournaments/delegate.html.erb b/app/views/tournaments/delegate.html.erb index fac3b58..f8bfa90 100644 --- a/app/views/tournaments/delegate.html.erb +++ b/app/views/tournaments/delegate.html.erb @@ -24,8 +24,8 @@ <%= user.email %> - <%= form_for user, :url => url_for(:controller => 'tournaments', :action => 'delegate', :method => "patch") do |f| %> - <%= f.hidden_field :id, :value => user.id %> + <%= form_for TournamentDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'delegate', :method => "post") do |f| %> + <%= f.hidden_field :user_id, :value => user.id %> <% if can? :manage, @tournament %> <%= submit_tag "Give permissions", :class=>"btn btn-success"%> <% end %> diff --git a/app/views/tournaments/school_delegate.html.erb b/app/views/tournaments/school_delegate.html.erb new file mode 100644 index 0000000..e5803ca --- /dev/null +++ b/app/views/tournaments/school_delegate.html.erb @@ -0,0 +1,70 @@ +<%= link_to "Back to #{@tournament_name}", "/tournaments/#{@tournament_id}", :class=>"btn btn-default" %> +
+
+ + + +<% if @users %> +

Search results

<%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %> + <%= text_field_tag :search, params[:search], placeholder: "Search users" %> + <%= submit_tag "Search" %> + <% end %> +

Search by email address

+
+
+ + + + + + + + + + <% @users.each do |user| %> + + + <%= form_for SchoolDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'school_delegate', :method => "post") do |f| %> + + + + + <% end %> + +
User EmailSchool to delegate
<%= user.email %><%= f.collection_select :school_id, @tournament.schools, :id, :name %> + + <%= f.hidden_field :user_id, :value => user.id %> + <% if can? :manage, @tournament %> + <%= submit_tag "Give permissions", :class=>"btn btn-success"%> + <% end %> + <% end %> +
+<% end %> + +<% if @users_delegates %> +

Delegated users schools

<%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %> + <%= text_field_tag :search, params[:search], placeholder: "Search users" %> + <%= submit_tag "Search" %> + <% end %> +

Search by email address

+
+
+ + + + + + + + + <% @users_delegates.each do |delegate| %> + + + + + + + <% end %> + +
User EmailSchool
<%= delegate.user.email %><%= delegate.school.name %>
+<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6b77d97..175c963 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -41,10 +41,9 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/no_matches' => 'tournaments#no_matches' get 'tournaments/:id/matches' => 'tournaments#matches' get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate - patch 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate - - get 'schools/:id/delegate' => 'schools#delegate' - post 'schools/:id/delegate' => 'schools#delegate' + post 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate + get 'tournaments/:id/school_delegate' => 'tournaments#school_delegate', :as => :school_delegate + post 'tournaments/:id/school_delegate' => 'tournaments#school_delegate', :as => :set_school_delegate # Example of regular route: # get 'products/:id' => 'catalog#view' From 838ab738bdf0a7beefdfbac75b587022e7ef2070 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 7 Jan 2016 20:20:18 +0000 Subject: [PATCH 06/25] Navigation for delegations --- app/views/layouts/_lsidebar.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/layouts/_lsidebar.html.erb b/app/views/layouts/_lsidebar.html.erb index 2aa0c9f..ff69005 100644 --- a/app/views/layouts/_lsidebar.html.erb +++ b/app/views/layouts/_lsidebar.html.erb @@ -21,6 +21,8 @@
<%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %>
<%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %>
<%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" %> +
<%= link_to "Tournament Delegation" , "/tournaments/#{@tournament.id}/delegate" %> +
<%= link_to "School Delegation" , "/tournaments/#{@tournament.id}/school_delegate"%>

Time Savers

<%= link_to "Create High School Weights" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' } %> From 613af2337dc27ca816f6b18a51575bdbddec7bdc Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 7 Jan 2016 20:22:10 +0000 Subject: [PATCH 07/25] Fixed typo on my tournaments page --- app/views/static_pages/my_tournaments.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/static_pages/my_tournaments.html.erb b/app/views/static_pages/my_tournaments.html.erb index 265ea0e..ca5e33f 100644 --- a/app/views/static_pages/my_tournaments.html.erb +++ b/app/views/static_pages/my_tournaments.html.erb @@ -56,8 +56,8 @@ <% @schools.each do |school| %> <%= school.name %> - <%= tournament.school.name %> - <%= tournament.school.date %> + <%= school.tournament.name %> + <%= school.tournament.date %> <%= link_to 'Show', school, :class=>"btn btn-default btn-sm" %> <% if can? :manage, school %> <%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary btn-sm" %> From fb157887a6e0ac725d04910bd64278dfa5d609de Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 13:14:29 +0000 Subject: [PATCH 08/25] Added ability to remove permissions --- app/controllers/tournaments_controller.rb | 26 ++++++++++++++++--- app/views/tournaments/delegate.html.erb | 3 ++- .../tournaments/school_delegate.html.erb | 3 ++- config/routes.rb | 2 ++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 0c45605..4bbec15 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -1,10 +1,30 @@ class TournamentsController < ApplicationController - before_action :set_tournament, only: [:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] - before_filter :check_access_manage, only: [:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches] - before_filter :check_access_destroy, only: [:destroy,:delegate] + before_action :set_tournament, only: [:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] + before_filter :check_access_manage, only: [:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches] + before_filter :check_access_destroy, only: [:destroy,:delegate,:remove_delegate] before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets] + def remove_delegate + if params[:delegate] + @delegate = TournamentDelegate.find(params[:delegate]) + @delegate.destroy + respond_to do |format| + format.html { redirect_to "/tournaments/#{@tournament.id}/delegate", notice: 'Delegated permissions removed successfully' } + end + end + end + + def remove_school_delegate + if params[:delegate] + @delegate = SchoolDelegate.find(params[:delegate]) + @delegate.destroy + respond_to do |format| + format.html { redirect_to "/tournaments/#{@tournament.id}/school_delegate", notice: 'Delegated permissions removed successfully' } + end + end + end + def school_delegate if params[:search] @users = User.search(params[:search]) diff --git a/app/views/tournaments/delegate.html.erb b/app/views/tournaments/delegate.html.erb index f8bfa90..4c945db 100644 --- a/app/views/tournaments/delegate.html.erb +++ b/app/views/tournaments/delegate.html.erb @@ -50,13 +50,14 @@ User Email + <% @users_delegates.each do |delegate| %> <%= delegate.user.email %> - + <%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_delegate", method: :delete, confirm: 'Are you sure?', :class=>"btn btn-danger btn-sm" %> <% end %> diff --git a/app/views/tournaments/school_delegate.html.erb b/app/views/tournaments/school_delegate.html.erb index e5803ca..291206c 100644 --- a/app/views/tournaments/school_delegate.html.erb +++ b/app/views/tournaments/school_delegate.html.erb @@ -54,6 +54,7 @@ User Email School + @@ -61,7 +62,7 @@ <%= delegate.user.email %> <%= delegate.school.name %> - + <%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_school_delegate", method: :delete, confirm: 'Are you sure?', :class=>"btn btn-danger btn-sm" %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 175c963..34be217 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,8 +42,10 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/matches' => 'tournaments#matches' get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate post 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate + delete 'tournaments/:id/:delegate/remove_delegate' => 'tournaments#remove_delegate', :as => :delete_delegate_path get 'tournaments/:id/school_delegate' => 'tournaments#school_delegate', :as => :school_delegate post 'tournaments/:id/school_delegate' => 'tournaments#school_delegate', :as => :set_school_delegate + delete 'tournaments/:id/:delegate/remove_school_delegate' => 'tournaments#remove_school_delegate', :as => :delete_school_delegate_path # Example of regular route: # get 'products/:id' => 'catalog#view' From cffd70e9f631b93b2245ca3426355d99508da9fe Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 13:17:30 +0000 Subject: [PATCH 09/25] Only tournament owners can delegate tournament permissions --- app/views/layouts/_lsidebar.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_lsidebar.html.erb b/app/views/layouts/_lsidebar.html.erb index ff69005..48df452 100644 --- a/app/views/layouts/_lsidebar.html.erb +++ b/app/views/layouts/_lsidebar.html.erb @@ -21,7 +21,9 @@
<%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %>
<%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %>
<%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" %> -
<%= link_to "Tournament Delegation" , "/tournaments/#{@tournament.id}/delegate" %> + <% if can? :destroy, @tournament %> +
<%= link_to "Tournament Delegation" , "/tournaments/#{@tournament.id}/delegate" %> + <% end %>
<%= link_to "School Delegation" , "/tournaments/#{@tournament.id}/school_delegate"%>

Time Savers
From 1bd4782a860f9e62cf4c06c23b5b543acfe70098 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 13:46:31 +0000 Subject: [PATCH 10/25] Dropdown for user pages --- app/views/layouts/_header.html.erb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 71977c8..4089ac7 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -7,9 +7,15 @@
  • <%= link_to "Browse Tournaments", "/tournaments/" %>
  • <%= link_to "About", "/static_pages/about" %>
  • <% if user_signed_in? %> -
  • <%=link_to "Log out", destroy_user_session_url ,:method => 'delete' %>
  • -
  • <%=link_to "Edit user", edit_user_registration_path %>
  • -
  • <%=link_to "My tournaments","/static_pages/my_tournaments" %>
  • + <% else %>
  • <%= link_to "Log In" , new_user_session_path %>
  • <% end %> From 4491b2eddf13677c4c5947581045aef5d3219e6f Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 13:52:52 +0000 Subject: [PATCH 11/25] School show page was too busy --- app/views/schools/show.html.erb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb index 5fff49f..bb7cc11 100644 --- a/app/views/schools/show.html.erb +++ b/app/views/schools/show.html.erb @@ -39,8 +39,6 @@ Name Weight Seed - Record - Seed Criteria Team Points Scored Extra? Next Bout/Mat @@ -57,8 +55,6 @@ <%= wrestler.original_seed %> - <%= wrestler.season_win %>-<%= wrestler.season_loss %> - <%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>% <%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %> <% if wrestler.extra? == true %> Yes From 1ed4caba0c1ac805ced7af9d10817bc4bfeb5163 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 14:13:48 +0000 Subject: [PATCH 12/25] Removed glitchy add button --- app/views/layouts/_rsidebar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index 6bff4e5..f67ed9a 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -1,6 +1,6 @@ <% if Rails.env.production? %>
    - +
    <% end %>
     
    From 76eef7ce87cfc936a4a4bec7077b6e9e557025ca Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 15:19:17 +0000 Subject: [PATCH 13/25] Added ad back with conditions --- app/views/layouts/_rsidebar.html.erb | 6 +++++- config/routes.rb | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index f67ed9a..3915c83 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -1,6 +1,10 @@ <% if Rails.env.production? %>
    - + <% if !user_signed_in? %> + <% if !current_page?(root_url) and !current_page?(new_user_session_url) and !params[:print] %> + + <% end %> + <% end %>
    <% end %>
     
    diff --git a/config/routes.rb b/config/routes.rb index 34be217..78c826b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,7 +22,6 @@ Wrestling::Application.routes.draw do # You can have the root of your site routed with "root" root 'static_pages#home' - get 'admin/index' get 'static_pages/control_match' get 'static_pages/not_allowed' get 'static_pages/about' @@ -34,10 +33,10 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/create_custom_weights' => 'tournaments#create_custom_weights' get 'tournaments/:id/all_brackets' => 'tournaments#all_brackets' get 'tournaments/:id/brackets' => 'tournaments#brackets' - get 'tournaments/:id/brackets/:weight' => 'tournaments#bracket' + get 'tournaments/:id/brackets/:weight' => 'tournaments#bracket', :as => :weight_bracket get 'tournaments/:id/generate_matches' => 'tournaments#generate_matches' get 'tournaments/:id/team_scores' => 'tournaments#team_scores' - get 'tournaments/:id/up_matches' => 'tournaments#up_matches' + get 'tournaments/:id/up_matches' => 'tournaments#up_matches', :as => :up_matches get 'tournaments/:id/no_matches' => 'tournaments#no_matches' get 'tournaments/:id/matches' => 'tournaments#matches' get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate From 0d364a5134db4f8da70dedce8447995405edc4e1 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 18:35:18 +0000 Subject: [PATCH 14/25] Moved ad provider --- app/views/layouts/_rsidebar.html.erb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index 3915c83..c3bafa0 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -1,10 +1,15 @@ <% if Rails.env.production? %>
    - <% if !user_signed_in? %> - <% if !current_page?(root_url) and !current_page?(new_user_session_url) and !params[:print] %> - - <% end %> - <% end %> + +
    <% end %>
     
    From 6dc8a57119668cf3089afcb2ee42b21a3794fb09 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 18:47:59 +0000 Subject: [PATCH 15/25] Ad typo --- app/views/layouts/_rsidebar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index c3bafa0..818a568 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -6,7 +6,7 @@ var unit = {"calltype":"async[2]","publisher":"cwimer","width":120,"height":600,"sid":"Chitika Default"}; var placement_id = window.CHITIKA.units.length; window.CHITIKA.units.push(unit); - document.write('
    '); + document.write('
    '); }()); From f84fc145edfdd4a393267c990c90464e3d151325 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 19:02:00 +0000 Subject: [PATCH 16/25] Separate mobile and desktop ads --- app/views/layouts/_cdn.html.erb | 3 +++ app/views/layouts/_rsidebar.html.erb | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/views/layouts/_cdn.html.erb b/app/views/layouts/_cdn.html.erb index 3cedd27..18a559a 100644 --- a/app/views/layouts/_cdn.html.erb +++ b/app/views/layouts/_cdn.html.erb @@ -12,5 +12,8 @@ + + + diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index 818a568..66f1428 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -1,6 +1,17 @@ <% if Rails.env.production? %>
    From 64c81764124bf4f3e1e2ba66304832016e26bb94 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 19:08:41 +0000 Subject: [PATCH 17/25] Ad typo --- app/views/layouts/_rsidebar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index 66f1428..68cad3a 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -9,7 +9,7 @@ var s = document.createElement('script'); s.src = '//cdn.chitika.net/getads.js'; try { document.getElementsByTagName('head')[0].appendChild(s); } catch(e) { document.write(s.outerHTML);} - }()) + }()); } else { //Desktop ad (function (){ From d5a29c4f4c5726650c74d4ef2d8ec228c5438390 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 8 Jan 2016 19:16:22 +0000 Subject: [PATCH 18/25] Changed mobile ad type --- app/views/layouts/_rsidebar.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index 68cad3a..a678a3d 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -3,12 +3,12 @@ + +
    + <% end %> diff --git a/app/views/layouts/_rsidebar.html.erb b/app/views/layouts/_rsidebar.html.erb index a678a3d..1cd9989 100644 --- a/app/views/layouts/_rsidebar.html.erb +++ b/app/views/layouts/_rsidebar.html.erb @@ -1,5 +1,5 @@ <% if Rails.env.production? %> -
    +