Skip to content

Commit

Permalink
Merge branch 'master' into implementando-testes
Browse files Browse the repository at this point in the history
  • Loading branch information
leogiraldimg committed Dec 3, 2019
2 parents 5607707 + 308c54c commit 5ef26f3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 41 deletions.
41 changes: 16 additions & 25 deletions src/app/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<htmlClasses.length; i++) {

var openDetails = $('.colleges#index .jumbotron .collegebox .college .details').not($this).filter(function () {
return this.style.display == 'block'
$(htmlClasses[i]).click(function() {
var $this = $(this).children('.details');

var openDetails = $(htmlClasses[i] + ' .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');
}
});
openDetails.css('display', 'none');

if( $this.css('display') === 'block' ){
$this.css('display', 'none');
} else {
$this.css('display', 'block');
}
});
}
});

$(document).ready(function(){
Expand Down
38 changes: 24 additions & 14 deletions src/app/app/controllers/college_whitelists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@ def verify_permission
if @college.request_to_participate == "0"
redirect_to college_spotteds_path(college_id: @college.id)
else
@college_whitelist = CollegeWhitelist.find_by(user_id: current_user.id, college_id: @college.id)
if !@college_whitelist.nil?
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
else
@college_whitelist = CollegeWhitelist.new
render :new
end
check_college_access_permission
end
end

Expand Down Expand Up @@ -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
16 changes: 14 additions & 2 deletions src/app/app/controllers/spotteds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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)

Expand Down

0 comments on commit 5ef26f3

Please sign in to comment.