diff --git a/app/assets/javascripts/grades.coffee b/app/assets/javascripts/grades.coffee index 24f83d1..4d9727f 100644 --- a/app/assets/javascripts/grades.coffee +++ b/app/assets/javascripts/grades.coffee @@ -1,3 +1,14 @@ # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ + +match = undefined +pl = /\+/g # Regex for replacing addition symbol with a space +search = /([^&=]+)=?([^&]*)/g +decode = (s) -> decodeURIComponent(s.replace(pl, " ")) +query = window.location.search.substring(1) + +window.urlParams = {} +while (match = search.exec(query)) + urlParams[decode(match[1])] = decode(match[2]) +$ -> $("p[data-search-info]").html("You searched for lecturer: " + window.urlParams["lecturer"]) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a21e864..66a4b26 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,8 +4,7 @@ class ApplicationController < ActionController::Base private def kick_out - flash[:error] = "You do not have access to this site." - redirect_to root_url + raise ActionController::RoutingError.new('Not Found') end def logged_in_as_student diff --git a/app/controllers/grades_controller.rb b/app/controllers/grades_controller.rb index a140d1f..21b044e 100644 --- a/app/controllers/grades_controller.rb +++ b/app/controllers/grades_controller.rb @@ -19,7 +19,6 @@ class GradesController < ApplicationController render :index_lecturer elsif logged_in_as_student if params[:lecturer] - #FIX: @grades = Grade.joins(lecture: :lecturer).where("grades.student_id = #{current_user.id.to_s} AND users.login LIKE ?", "%#{params[:lecturer]}%") @grades = Grade.joins(lecture: :lecturer).where("grades.student_id = #{current_user.id.to_s} AND users.login LIKE '%#{params[:lecturer]}%'") else @grades = Grade.where(:student_id => current_user.id) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fe1bd14..d8d84a3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -32,9 +32,6 @@ class UsersController < ApplicationController end elsif logged_in_as_lecturer @user = User.new(users_params) - # FIX: do not allow creation of lecturers or admins - # FIX: if not params[:role] == "student" - # FIX: kick_out if @user.save flash[:success] = "Account registered!" redirect_to root_path diff --git a/app/views/grades/index_admin.html.erb b/app/views/grades/index_admin.html.erb index a0f74e7..2ac2402 100644 --- a/app/views/grades/index_admin.html.erb +++ b/app/views/grades/index_admin.html.erb @@ -15,7 +15,6 @@ <%= grade.student.login %> <%= grade.grade %> - <% if grade.comment %> <%= grade.comment.html_safe %> <% end %> diff --git a/app/views/grades/index_lecturer.html.erb b/app/views/grades/index_lecturer.html.erb index 6284910..41fb931 100644 --- a/app/views/grades/index_lecturer.html.erb +++ b/app/views/grades/index_lecturer.html.erb @@ -15,7 +15,6 @@ <%= grade.student.login %> <%= grade.grade %> - <% if grade.comment %> <%= grade.comment.html_safe %> <% end %> diff --git a/app/views/grades/index_student.html.erb b/app/views/grades/index_student.html.erb index fb2e8d8..6cee92b 100644 --- a/app/views/grades/index_student.html.erb +++ b/app/views/grades/index_student.html.erb @@ -1,3 +1,5 @@ +

+ @@ -12,7 +14,6 @@
Lecturer<%= grade.lecture.name %> <%= grade.grade %> - <% if grade.comment %> <%= grade.comment.html_safe %> <% end %> diff --git a/config/initializers/noheaders.rb b/config/initializers/noheaders.rb new file mode 100644 index 0000000..69aa3da --- /dev/null +++ b/config/initializers/noheaders.rb @@ -0,0 +1 @@ +Rails.application.config.action_dispatch.default_headers.clear