diff --git a/src/app/app/assets/javascripts/application.js b/src/app/app/assets/javascripts/application.js index c0f402bc..201086f6 100644 --- a/src/app/app/assets/javascripts/application.js +++ b/src/app/app/assets/javascripts/application.js @@ -36,35 +36,26 @@ $( window ).on( 'load', resizeIcons ); $( window ).on( 'resize', resizeIcons ); $(document).ready(function(){ - $('.favorite_colleges#show .jumbotron .collegebox .college').click(function() { - var $this = $(this).children('.details'); - var openDetails = $('.favorite_colleges#show .jumbotron .collegebox .college .details').not($this).filter(function () { - return this.style.display == 'block' - }); - openDetails.css('display', 'none'); - - if( $this.css('display') === 'block' ){ - $this.css('display', 'none'); - } else { - $this.css('display', 'block'); - } - }); + var htmlClasses = ['.favorite_colleges#show .jumbotron .collegebox .college', '.colleges#index .jumbotron .collegebox .college']; - $('.colleges#index .jumbotron .collegebox .college').click(function() { - var $this = $(this).children('.details'); + for(var i = 0; i "college_whitelists/pending" - when "rejected" - render :template => "college_whitelists/rejected" - end - else - @college_whitelist = CollegeWhitelist.new - render :new - end + check_college_access_permission end end @@ -119,4 +106,27 @@ def set_college def college_whitelist_params params.require(:college_whitelist).permit(:status) end + + def check_college_access_permission + @college_whitelist = CollegeWhitelist.find_by(user_id: current_user.id, college_id: @college.id) + if !@college_whitelist.nil? + check_request_access_status(@college_whitelist) + else + @college_whitelist = CollegeWhitelist.new + render :new + end + end + + def check_request_access_status(college_whitelist) + case college_whitelist.status + when "approved" + redirect_to college_spotteds_path(college_id: @college.id) + when "pending" + render :template => "college_whitelists/pending" + when "rejected" + render :template => "college_whitelists/rejected" + end + end + + end \ No newline at end of file diff --git a/src/app/app/controllers/spotteds_controller.rb b/src/app/app/controllers/spotteds_controller.rb index 3445c9e6..51a00f40 100644 --- a/src/app/app/controllers/spotteds_controller.rb +++ b/src/app/app/controllers/spotteds_controller.rb @@ -84,13 +84,24 @@ def set_college def set_style @college_style = '' + check_to_set_background_image + check_to_set_background_color + check_to_set_font_family_and_color + end + def check_to_set_background_image if @college.background_image.present? @college_style.concat('body { background-image: url(' + @college.background_image + '); }') - elsif @college.background_color.present? + end + end + + def check_to_set_background_color + if @college.background_color.present? @college_style.concat('body { background-color:' + @college.background_color + ';}') end - + end + + def check_to_set_font_family_and_color if @college.font_family.present? && @college.font_color.present? @college_style.concat('#content-container { font-family: ' + @college.font_family + '!important; color: ' + @college.font_color + '; }') elsif @college.font_family.present? @@ -100,6 +111,7 @@ def set_style end end + def set_font_google response = HTTParty.get('https://fonts.googleapis.com/css?family=' + @college.font_family)