+
@@ -113,341 +703,18694 @@
6.25 % covered
1
- require_relative 'boot'
+ class AdminsController < ApplicationController
+
+
+
+ 1
+
+ layout 'admin_layout', :only => [:home, :update_semester, :updateCurrentSemester, :rating_tutors, :update_courses, :tutor_hours, :update_password, :update_student_priorities]
+
+
+
+ 1
+
+ before_action :set_admin, except: [:landing, :destroyAdminSession]
+
+
+
+ 1
+
+ before_action :check_logged_in, except: [:landing, :createAdminSession, :destroyAdminSession]
+
+
+
+
+
+
+
+
+
+ 1
+
+ def landing
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def tutor_hours
+
+
+
+ 1
+
+ @admin = Admin.find(Admin.master_admin_index)
+
+
+
+ 1
+
+ @current_semester = Admin.current_semester_formatted
+
+
+
+ 1
+
+ @tutors = Tutor.all
+
+
+
+ 1
+
+ @meeting = Meeting.all
+
+
+
+ 1
+
+ @evaluations = Evaluation.all
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def createAdminSession
+
+
+
+ 23
+
+ @admin = Admin.find(Admin.master_admin_index)
+
+
+
+ 23
+
+ if @admin and @admin.authenticate(params[:password])
+
+
+
+ 22
+
+ session[:admin_logged_in] = true
+
+
+
+ 22
+
+ redirect_to admin_home_path
+
+
+
+
+
+ else
+
+
+
+ 1
+
+ redirect_to admin_landing_path
+
+
+
+
+
+ end
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def destroyAdminSession
+
+
+
+ 1
+
+ session[:admin_logged_in] = false
+
+
+
+ 1
+
+ redirect_to admin_landing_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def home
+
+
+
+ 22
+
+ @semester_options = Admin.semester_possibilities
+
+
+
+ 22
+
+ @current_semester = Admin.current_semester_formatted
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_semester
+
+
+
+ 6
+
+ @semester_options = Admin.semester_possibilities
+
+
+
+ 6
+
+ @current_semester = Admin.current_semester_formatted
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def updateCurrentSemester
+
+
+
+ 3
+
+ if not params[:update_current_semester].nil?
+
+
+
+ 3
+
+ c_sem, c_year = updateSemesterHelper(:update_current_semester)
+
+
+
+
+
+ end
+
+
+
+ 3
+
+ if not c_sem.nil? and not c_year.nil? and Admin.validate_year(c_year)
+
+
+
+
+
+ # also update the courses along with updating the semester
+
+
+
+ 2
+
+ flash[:message] = "Current semester was successfully updated."
+
+
+
+ 2
+
+ @old_semester_courses = Course.current_courses_formatted
+
+
+
+ 2
+
+ @admin.update(:current_semester => c_sem + c_year)
+
+
+
+ 2
+
+ Course.update_courses(@old_semester_courses) # relies on the current semester so should auto populate the new semester with the old courses
+
+
+
+
+
+ else
+
+
+
+ 1
+
+ flash[:notice] = "Error updating current semester, year is likely mistyped"
+
+
+
+
+
+ end
+
+
+
+ 3
+
+ redirect_to admin_update_semester_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def rating_tutors
+
+
+
+ 2
+
+ @current_semester = Admin.current_semester_formatted
+
+
+
+ 2
+
+ @meetings = Meeting.all
+
+
+
+ 2
+
+ @ratings = calculate_ratings
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def calculate_ratings
+
+
+
+ 2
+
+ @tutor_ratings = Array.new
+
+
+
+ 2
+
+ @meetings.each do |meet|
+
+
+
+ 6
+
+ tutorId = meet.tutor_id
+
+
+
+
+
+ #a bug fix, sometimes meetings populate more than cucumber test
+
+
+
+ 6
+
+ if Tutor.find_by_id(tutorId).nil?
+
+
+
+
+
+ next
+
+
+
+
+
+ end
+
+
+
+ 6
+
+ first = Tutor.find_by_id(tutorId).first_name
+
+
+
+ 6
+
+ last = Tutor.find_by_id(tutorId).last_name
+
+
+
+ 6
+
+ knowledgeable, helpful, clarity, composite = _calculate_score_helper(meet)
+
+
+
+ 6
+
+ found, rate = _check_existing_tutor_helper(@tutor_ratings, tutorId)
+
+
+
+
+
+
+
+
+
+ 6
+
+ if found
+
+
+
+ 2
+
+ rate[:knowledgeable] = _calculate_average_helper(rate[:knowledgeable], knowledgeable)
+
+
+
+ 2
+
+ rate[:helpful] = _calculate_average_helper(rate[:helpful], helpful)
+
+
+
+ 2
+
+ rate[:clarity] = _calculate_average_helper(rate[:clarity], clarity)
+
+
+
+ 2
+
+ rate[:composite] = _calculate_average_helper(rate[:composite], composite)
+
+
+
+
+
+ else
+
+
+
+ 4
+
+ @tutor_ratings << {tutorId=> "#{first + " " + last}",:knowledgeable => knowledgeable, :helpful => helpful,
+
+
+
+
+
+ :clarity => clarity, :composite => composite}
+
+
+
+
+
+ end
+
+
+
+
+
+ end
+
+
+
+ 2
+
+ @tutor_ratings
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def _check_existing_tutor_helper(tutor_rating_list, tutor_id)
+
+
+
+ 6
+
+ tutor_rating_list.each do |rate|
+
+
+
+ 6
+
+ if rate.include?(tutor_id)
+
+
+
+ 2
+
+ return true, rate
+
+
+
+
+
+ end
+
+
+
+
+
+ end
+
+
+
+ 4
+
+ return false, nil
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def _calculate_score_helper(meet)
+
+
+
+ 6
+
+ knowledgeable_sc = Evaluation.find_by_id(meet.evaluation_id).knowledgeable
+
+
+
+ 6
+
+ knowledgeable_sc = (knowledgeable_sc.nil?) ? 0.0 : knowledgeable_sc
+
+
+
+ 6
+
+ helpful_sc = Evaluation.find_by_id(meet.evaluation_id).helpful
+
+
+
+ 6
+
+ helpful_sc = (helpful_sc.nil?) ? 0.0 : helpful_sc
+
+
+
+ 6
+
+ clarity_sc = Evaluation.find_by_id(meet.evaluation_id).clarity
+
+
+
+ 6
+
+ clarity_sc = (clarity_sc.nil?) ? 0.0 : helpful_sc
+
+
+
+
+
+
+
+
+
+ 6
+
+ composite_sc = (knowledgeable_sc + helpful_sc + clarity_sc) / 3.0
+
+
+
+ 6
+
+ return knowledgeable_sc, helpful_sc, clarity_sc, composite_sc
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def _calculate_average_helper(a, b)
+
+
+
+ 8
+
+ return (a + b) / 2.0
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def updateSemesterHelper val
+
+
+
+ 3
+
+ return params[val][:semester], params[val][:year]
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_courses
+
+
+
+ 10
+
+ @current_courses = Course.current_courses_formatted
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def post_update_courses
+
+
+
+ 4
+
+ if not params[:update_courses].nil? and not params[:update_courses][:courses].nil? and Course.update_courses(params[:update_courses][:courses])
+
+
+
+ 4
+
+ flash[:message] = "Courses updated. Any new courses should be visible below, if not try again."
+
+
+
+
+
+ else
+
+
+
+
+
+ flash[:notice] = "Courses update failed. Make sure courses are properly separated (one per line)."
+
+
+
+
+
+ end
+
+
+
+ 4
+
+ redirect_to admin_update_courses_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_password
+
+
+
+
+
+
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def post_update_password
+
+
+
+ 2
+
+ password, confirmation_password = params[:update_password][:password], params[:update_password][:password_confirmation]
+
+
+
+ 2
+
+ if password == confirmation_password
+
+
+
+ 1
+
+ if @admin.update(:password => password)
+
+
+
+ 1
+
+ flash[:message] = "Admin password successfully updated."
+
+
+
+
+
+ end
+
+
+
+
+
+ else
+
+
+
+ 1
+
+ flash[:notice] = "Passwords do not match"
+
+
+
+
+
+ end
+
+
+
+ 2
+
+ redirect_to admin_update_password_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_student_priorities
+
+
+
+ 16
+
+ @current_cs61a_scholars = Tutee.get_current_cs61a_sids_formatted
+
+
+
+ 16
+
+ @current_cs61b_scholars = Tutee.get_current_cs61b_sids_formatted
+
+
+
+ 16
+
+ @current_cs61c_scholars = Tutee.get_current_cs61c_sids_formatted
+
+
+
+ 16
+
+ @current_cs70_scholars = Tutee.get_current_cs70_sids_formatted
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_student_priorities_61A
+
+
+
+ 2
+
+ if not params[:update_student_priorities].nil? and not params[:update_student_priorities][:CS61A].nil? and Tutee.update_cs61a_privileges(params[:update_student_priorities][:CS61A])
+
+
+
+ 2
+
+ flash[:message] = "CS61A privileges have been updated. Any new courses should be visible below, if not try again."
+
+
+
+
+
+ else
+
+
+
+
+
+ flash[:notice] = "CS61A privileges update failed. Make sure courses are properly separated (one per line)."
+
+
+
+
+
+ end
+
+
+
+ 2
+
+ redirect_to admin_update_student_priorities_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_student_priorities_61B
+
+
+
+ 2
+
+ if not params[:update_student_priorities].nil? and not params[:update_student_priorities][:CS61B].nil? and Tutee.update_cs61b_privileges(params[:update_student_priorities][:CS61B])
+
+
+
+ 2
+
+ flash[:message] = "CS61B privileges have been updated. Any new courses should be visible below, if not try again."
+
+
+
+
+
+ else
+
+
+
+
+
+ flash[:notice] = "CS61B privileges update failed. Make sure courses are properly separated (one per line)."
+
+
+
+
+
+ end
+
+
+
+ 2
+
+ puts (not params[:update_student_priorities].nil?)
+
+
+
+ 2
+
+ puts (not params[:update_student_priorities][:CS61B].nil?)
+
+
+
+ 2
+
+ redirect_to admin_update_student_priorities_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_student_priorities_61C
+
+
+
+ 2
+
+ if not params[:update_student_priorities].nil? and not params[:update_student_priorities][:CS61C].nil? and Tutee.update_cs61c_privileges(params[:update_student_priorities][:CS61C])
+
+
+
+ 2
+
+ flash[:message] = "CS61C privileges have been updated. Any new courses should be visible below, if not try again."
+
+
+
+
+
+ else
+
+
+
+
+
+ flash[:notice] = "CS61C privileges update failed. Make sure courses are properly separated (one per line)."
+
+
+
+
+
+ end
+
+
+
+ 2
+
+ redirect_to admin_update_student_priorities_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ def update_student_priorities_70
+
+
+
+ 2
+
+ if not params[:update_student_priorities].nil? and not params[:update_student_priorities][:CS70].nil? and Tutee.update_cs70_privileges(params[:update_student_priorities][:CS70])
+
+
+
+ 2
+
+ flash[:message] = "CS70 privileges have been updated. Any new courses should be visible below, if not try again."
+
+
+
+
+
+ else
+
+
+
+
+
+ flash[:notice] = "CS70 privileges update failed. Make sure courses are properly separated (one per line)."
+
+
+
+
+
+ end
+
+
+
+ 2
+
+ redirect_to admin_update_student_priorities_path
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+ 1
+
+ private
+
+
+
+
+
+
+
+
+
+ 1
+
+ def check_logged_in
+
+
+
+ 79
+
+ if session[:admin_logged_in].nil? or not session[:admin_logged_in]
+
+
+
+ 1
+
+ redirect_to admin_landing_path
+
+
+
+
+
+ end
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+ # Use callbacks to share common setup or constraints between actions.
+
+
+
+ 1
+
+ def set_admin
+
+
+
+ 102
+
+ @admin = Admin.find(Admin.master_admin_index)
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+
+
+
+ 1
+
+ def admin_params
+
+
+
+
+
+ params.require(:admin).permit(:password, :password_confirmation, :statistics_semester, :current_semester)
+
+
+
+
+
+ end
+
+
+
+
+
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class ApplicationController < ActionController::Base
+
+
+ -
+ 1
+
+
protect_from_forgery
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
before_action :configure_permitted_parameters, if: :devise_controller?
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
protected
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def configure_permitted_parameters
+
+
+ -
+ 177
+
+
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :sid, :privilege, :email, :birthdate, :gender, :ethnicity,
+
+
+ -
+
+
+
:major, :dsp, :transfer, :year, :pronoun])
+
+
+ -
+ 177
+
+
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :sid, :privilege, :email, :birthdate, :gender, :ethnicity,
+
+
+ -
+
+
+
:major, :dsp, :transfer, :year, :pronoun])
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def after_sign_in_path_for(resource)
+
+
+ -
+
+
+
# return the path based on resource
+
+
+ -
+ 31
+
+
puts resource
+
+
+ -
+ 31
+
+
if resource.is_a? Tutor
+
+
+ -
+ 4
+
+
session[:tutor_id] = resource.id
+
+
+ -
+ 4
+
+
tutor_path(current_tutor)
+
+
+ -
+
+
+
else
+
+
+ -
+ 27
+
+
session[:tutee_id] = resource.id
+
+
+ -
+ 27
+
+
tutee_path(current_tutee)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def after_sign_out_path_for(resource)
+
+
+ -
+ 2
+
+
session[:tutee_logged_in] = false
+
+
+ -
+ 2
+
+
session[:tutee_id] = nil
+
+
+ -
+ 2
+
+
session[:tutor_logged_in] = false
+
+
+ -
+ 2
+
+
session[:tutor_id] = nil
+
+
+ -
+ 2
+
+
if resource == :tutee
+
+
+ -
+ 2
+
+
new_tutee_session_path
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
new_tutor_session_path
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def check_tutee_logged_in
+
+
+ -
+ 64
+
+
puts 'CHECK TUTEE LOGGED IN '
+
+
+ -
+ 64
+
+
puts 'params:'
+
+
+ -
+ 64
+
+
puts params
+
+
+ -
+ 64
+
+
tutee_id = params.has_key?(:tutee_id) ? params[:tutee_id] : -1
+
+
+ -
+ 64
+
+
if tutee_id == -1 and params.has_key?(:id)
+
+
+ -
+ 47
+
+
tutee_id = params[:id]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 64
+
+
if !(session[:tutee_id].to_i == tutee_id.to_i)
+
+
+ -
+ 3
+
+
sign_out :tutee
+
+
+ -
+ 3
+
+
redirect_to new_tutee_session_path
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def check_tutor_logged_in
+
+
+ -
+ 8
+
+
puts 'CHECK TUTOR LOGGED IN '
+
+
+ -
+ 8
+
+
puts 'params:'
+
+
+ -
+ 8
+
+
puts params
+
+
+ -
+ 8
+
+
tutor_id = params.has_key?(:tutor_id) ? params[:tutor_id] : -1
+
+
+ -
+ 8
+
+
if tutor_id == -1 and params.has_key?(:id)
+
+
+ -
+ 8
+
+
tutor_id = params[:id]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 8
+
+
if !(session[:tutor_id].to_i == tutor_id.to_i)
+
+
+ -
+ 2
+
+
sign_out :tutor
+
+
+ -
+ 2
+
+
redirect_to new_tutor_session_path
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module Friendlyable
+
+
+ -
+ 1
+
+
extend ActiveSupport::Concern
+
+
+ -
+ 1
+
+
included do
+
+
+ -
+ 1
+
+
extend ::FriendlyId
+
+
+ -
+ 1
+
+
before_create :set_hash_id
+
+
+ -
+ 1
+
+
friendly_id :hash_id
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def set_hash_id
+
+
+ -
+ 18
+
+
hash_id = nil
+
+
+ -
+ 18
+
+
loop do
+
+
+ -
+ 18
+
+
hash_id = SecureRandom.urlsafe_base64(9).gsub(/-|_/,('a'..'z').to_a[rand(26)])
+
+
+ -
+ 18
+
+
break unless self.class.name.constantize.where(:hash_id => hash_id).exists?
+
+
+ -
+
+
+
end
+
+
+ -
+ 18
+
+
self.hash_id = hash_id
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class EvaluationsController < ApplicationController
+
+
+ -
+ 1
+
+
layout 'tutee_layout', :only => [:edit, :index]
+
+
+ -
+ 1
+
+
def evaluation_params
+
+
+ -
+ 8
+
+
params.require(:evaluation).permit(:topics, :hours, :positive, :best, :feedback, :knowledgeable, :helpful, :clarity, :pacing, :final_comments, :took_place, :status, :hash_id)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def create
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def edit
+
+
+ -
+ 4
+
+
@tutee = Tutee.find params[:tutee_id]
+
+
+ -
+ 4
+
+
@evaluation = Evaluation.friendly.find params[:id]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def update
+
+
+ -
+ 4
+
+
@evaluation = Evaluation.find_by_hash_id params[:id]
+
+
+ -
+ 4
+
+
@evaluation.update(evaluation_params)
+
+
+ -
+ 4
+
+
puts evaluation_params
+
+
+ -
+
+
+
+
+
+ -
+ 4
+
+
if params.has_key?(:tutee_id)
+
+
+ -
+ 3
+
+
_update_params_has_key_helper(:tutee_id, @evaluation)
+
+
+ -
+
+
+
else
+
+
+ -
+ 1
+
+
_update_params_has_no_key_helper(@evaluation)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def _update_params_has_key_helper(tutee_id, eval)
+
+
+ -
+ 3
+
+
@tutee = Tutee.find params[:tutee_id]
+
+
+ -
+ 3
+
+
if eval.save
+
+
+ -
+ 2
+
+
flash[:message] = 'Evaluation form submitted sucessfully!'
+
+
+ -
+ 2
+
+
redirect_to tutee_evaluations_path(@tutee)
+
+
+ -
+
+
+
else
+
+
+ -
+ 1
+
+
flash[:notice] = 'Evaluation form submitted unsucessfully!'
+
+
+ -
+ 1
+
+
redirect_to edit_tutee_evaluation_path(@tutee)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def _update_params_has_no_key_helper(eval)
+
+
+ -
+ 1
+
+
if eval.save
+
+
+ -
+ 1
+
+
flash[:message] = 'Evaluation form submitted sucessfully!'
+
+
+ -
+ 1
+
+
redirect_to evaluation_path(eval)
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
flash[:notice] = 'Evaluation form submitted unsucessfully!'
+
+
+ -
+
+
+
redirect_to edit_evaluation_path(eval)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def index
+
+
+ -
+ 6
+
+
@tutee = Tutee.find params[:tutee_id]
+
+
+ -
+ 6
+
+
@evaluations = @tutee.evaluations.where(:status => 'Pending')
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def show
+
+
+ -
+
+
+
@evaluation = Evaluation.find_by_id params[:id]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def public_edit
+
+
+ -
+ 1
+
+
@evaluation = Evaluation.find_by_hash_id params[:id]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def public_show
+
+
+ -
+ 1
+
+
@evaluation = Evaluation.find_by_hash_id params[:id]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class MeetingsController < ApplicationController
+
+
+ -
+ 1
+
+
before_action :check_tutee_logged_in, :except => [:index]
+
+
+ -
+ 1
+
+
layout 'tutee_layout'
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def meeting_params
+
+
+ -
+
+
+
params.permit(:tutee, :tutor_id, :evaluation_id, :dates, :request_id, :tutee_id)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def index
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def show
+
+
+ -
+ 4
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+ 4
+
+
@req = Request.where(tutee_id: params[:tutee_id])
+
+
+ -
+ 4
+
+
@meeting = Meeting.where(request_id: @req).last
+
+
+ -
+
+
+
+
+
+ -
+ 4
+
+
if not @meeting.nil?
+
+
+ -
+ 3
+
+
@tutor = Tutor.find_by_id(@meeting.tutor_id)
+
+
+ -
+ 3
+
+
@eval = Evaluation.find_by_id(@meeting.evaluation_id)
+
+
+ -
+ 3
+
+
if @eval.status == "Complete"
+
+
+ -
+
+
+
@meeting = nil
+
+
+ -
+
+
+
return
+
+
+ -
+
+
+
end
+
+
+ -
+ 12
+
+
@dates = @meeting.times.map.with_index {|time, i| [time.strftime("%A %d at %l:%M %p at ") + @meeting.locations[i], i]}.to_h
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def new
+
+
+ -
+
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+
+
+
#@dates = [Time.now]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def edit
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def create
+
+
+ -
+
+
+
# Checks if parameters are good
+
+
+ -
+ 1
+
+
@req = Request.where(tutee_id: params[:tutee_id])
+
+
+ -
+ 1
+
+
@meeting = Meeting.where(request_id: @req).last
+
+
+ -
+ 1
+
+
@meeting.set_time = @meeting.times[params[:meeting][:set_time].to_i]
+
+
+ -
+ 1
+
+
@meeting.set_location = @meeting.locations[params[:meeting][:set_time].to_i]
+
+
+ -
+ 1
+
+
@meeting.is_scheduled = true
+
+
+ -
+ 1
+
+
@meeting.save!
+
+
+ -
+ 1
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
redirect_to tutee_meeting_path(@tutee, 1)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def update
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def destroy
+
+
+ -
+ 1
+
+
@req = Request.where(tutee_id: params[:tutee_id])
+
+
+ -
+ 1
+
+
@meeting = Meeting.where(request_id: @req).last
+
+
+ -
+ 1
+
+
@eval = Evaluation.find_by_id(@meeting.evaluation_id)
+
+
+ -
+ 1
+
+
@meeting.destroy!
+
+
+ -
+ 1
+
+
@eval.destroy!
+
+
+ -
+ 1
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
flash[:message] = "Your meeting was successfully cancelled. Another tutor will match with you."
+
+
+ -
+ 1
+
+
redirect_to tutee_meeting_path(@tutee, 1)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class RequestsController < ApplicationController
+
+
+ -
+ 1
+
+
before_action :check_tutee_logged_in, :except => [:email, :index]
+
+
+ -
+ 1
+
+
layout 'tutee_layout', :only => [:history, :new]
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def request_params
+
+
+ -
+ 9
+
+
params.require(:request).permit(:tutee_id, :course_id, :subject, :meeting_length)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def index
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def show
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def history
+
+
+ -
+ 1
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+ 1
+
+
@requests = Request.where(:tutee_id => params[:tutee_id])
+
+
+ -
+ 1
+
+
@evaluations = @tutee.evaluations.where(:status => 'Complete')
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def new
+
+
+ -
+ 6
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+ 6
+
+
@course_array = Course.course_array
+
+
+ -
+ 6
+
+
@meeting_time = %w(60\ minutes 90\ minutes 120\ minutes)
+
+
+ -
+ 6
+
+
@tutee_last_req = @tutee.requests.last
+
+
+ -
+ 6
+
+
if not @tutee_last_req.nil?
+
+
+ -
+
+
+
@meet_for_last_req = @tutee.meetings.where(:request_id => @tutee_last_req.id).first
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
if @tutee.privilege == 'No'
+
+
+ -
+ 3
+
+
@has_privilege = false
+
+
+ -
+
+
+
else
+
+
+ -
+ 3
+
+
@has_privilege = true
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def edit
+
+
+ -
+
+
+
# Checks if parameters are good
+
+
+ -
+
+
+
@request = Request.find_by_id(params[:id])
+
+
+ -
+
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+
+
+
if request_params[:subject].blank?
+
+
+ -
+
+
+
flash[:notice] = "Invalid request: Subject should be filled out."
+
+
+ -
+
+
+
redirect_to new_tutee_request_path(:tutee_id => params[:tutee_id])
+
+
+ -
+
+
+
return
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
@request.course_id = request_params[:course_id]
+
+
+ -
+
+
+
@request.subject = request_params[:subject]
+
+
+ -
+
+
+
if @tutee.privilege == 'No'
+
+
+ -
+
+
+
@request.meeting_length = '60 minutes'
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
@request.meeting_length = request_params[:meeting_length]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
@request.save!
+
+
+ -
+
+
+
+
+
+ -
+
+
+
flash[:message] = "Tutoring request for class #{@request.course.name} was successfully changed!"
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
redirect_to tutee_path(@tutee)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def create
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Checks if parameters are good
+
+
+ -
+ 4
+
+
if request_params[:subject].blank?
+
+
+ -
+ 2
+
+
flash[:notice] = "Invalid request: Subject should be filled out."
+
+
+ -
+ 2
+
+
redirect_to new_tutee_request_path
+
+
+ -
+ 2
+
+
return
+
+
+ -
+
+
+
else
+
+
+ -
+ 2
+
+
@tutee = Tutee.find_by_id(params[:tutee_id])
+
+
+ -
+ 2
+
+
@request = Request.new(request_params)
+
+
+ -
+ 2
+
+
@request.tutee_id = @tutee.id
+
+
+ -
+ 2
+
+
@request.course_id = request_params[:course_id]
+
+
+ -
+ 2
+
+
if @tutee.privilege == 'No'
+
+
+ -
+ 1
+
+
@request.meeting_length = '60 minutes'
+
+
+ -
+
+
+
else
+
+
+ -
+ 1
+
+
@request.meeting_length = request_params[:meeting_length]
+
+
+ -
+
+
+
end
+
+
+ -
+ 2
+
+
@request.save!
+
+
+ -
+
+
+
+
+
+ -
+ 2
+
+
flash[:message] = "Tutoring request for class #{@request.course.name} was successfully created!"
+
+
+ -
+
+
+
end
+
+
+ -
+ 2
+
+
redirect_to tutee_path(@tutee)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def update
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def destroy
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def email
+
+
+ -
+
+
+
tid = params[:tutor_id]
+
+
+ -
+
+
+
sid = params[:student][:id]
+
+
+ -
+
+
+
requestid = params[:student][:requestid]
+
+
+ -
+
+
+
#tutee_id = params[:tutee_id]
+
+
+ -
+
+
+
tutor_message = ""
+
+
+ -
+
+
+
@eval = Evaluation.create!()
+
+
+ -
+
+
+
+
+
+ -
+
+
+
@times = []
+
+
+ -
+
+
+
i = 1
+
+
+ -
+
+
+
while not params["Date" + i.to_s].nil?
+
+
+ -
+
+
+
@d1 = params["Date" + i.to_s]
+
+
+ -
+
+
+
@temp = @d1[0..1]
+
+
+ -
+
+
+
@d1[0,1] = @d1[3,4]
+
+
+ -
+
+
+
@d1[3,5] = @temp
+
+
+ -
+
+
+
@times << Time.parse(@d1 + " " + params["Time" + i.to_s])
+
+
+ -
+
+
+
@d1 = ""
+
+
+ -
+
+
+
@temp = ""
+
+
+ -
+
+
+
i += 1
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
@locs = []
+
+
+ -
+
+
+
i = 1
+
+
+ -
+
+
+
while not params["Location" + i.to_s].nil?
+
+
+ -
+
+
+
@locs << params["Location" + i.to_s]
+
+
+ -
+
+
+
i += 1
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
@meeting = Meeting.create({:tutor_id => tid.to_i, :request_id => requestid.to_i, :evaluation_id => @eval.id, :tutee_id => sid, :times => @times, :locations => @locs});
+
+
+ -
+
+
+
#TutorMailer.invite_student(tid, sid, tutor_message, requestid, @eval.id).deliver_now
+
+
+ -
+
+
+
flash[:notice] = "Successfully matched!"
+
+
+ -
+
+
+
redirect_to tutor_path(tid)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# frozen_string_literal: true
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
class Tutees::RegistrationsController < Devise::RegistrationsController
+
+
+ -
+ 1
+
+
layout 'tutee_layout', :only => [:show, :edit, :update]
+
+
+ -
+
+
+
# before_action :configure_sign_up_params, only: [:create]
+
+
+ -
+
+
+
# before_action :configure_account_update_params, only: [:update]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /resource/sign_up
+
+
+ -
+
+
+
# def new
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# POST /resource
+
+
+ -
+ 1
+
+
def create
+
+
+ -
+ 11
+
+
@tutee = Tutee.new(tutee_params)
+
+
+ -
+ 11
+
+
if @tutee.save
+
+
+ -
+ 1
+
+
respond_to do |format|
+
+
+ -
+ 1
+
+
flash[:notice] = "#{@tutee.first_name} #{@tutee.last_name} was successfully created."
+
+
+ -
+ 1
+
+
puts "tutee created"
+
+
+ -
+ 1
+
+
puts @tutee.id
+
+
+ -
+ 1
+
+
params[:id] = @tutee.id
+
+
+ -
+ 2
+
+
format.html { redirect_to tutee_path(@tutee.id)}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
else
+
+
+ -
+ 10
+
+
flash[:notice] = "Student was not successfully created."
+
+
+ -
+ 10
+
+
redirect_to new_tutee_session_path
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def tutee_params
+
+
+ -
+ 11
+
+
params.require(:tutee).permit(:year, :email, :first_name,
+
+
+ -
+
+
+
:last_name, :birthdate, :sid, :gender, :pronoun, :ethnicity, :dsp, :transfer, :major, :password, :password_confirmation, :privilege)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /resource/edit
+
+
+ -
+
+
+
# def edit
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# PUT /resource
+
+
+ -
+
+
+
# def update
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# DELETE /resource
+
+
+ -
+
+
+
# def destroy
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /resource/cancel
+
+
+ -
+
+
+
# Forces the session data which is usually expired after sign
+
+
+ -
+
+
+
# in to be expired now. This is useful if the user wants to
+
+
+ -
+
+
+
# cancel oauth signing in/up in the middle of the process,
+
+
+ -
+
+
+
# removing all OAuth session data.
+
+
+ -
+
+
+
# def cancel
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# protected
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If you have extra params to permit, append them to the sanitizer.
+
+
+ -
+
+
+
# def configure_sign_up_params
+
+
+ -
+
+
+
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If you have extra params to permit, append them to the sanitizer.
+
+
+ -
+
+
+
# def configure_account_update_params
+
+
+ -
+
+
+
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# # The path used after sign up.
+
+
+ -
+
+
+
# def after_sign_up_path_for(resource)
+
+
+ -
+
+
+
# new_tutee_session_path(resource_name)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# The path used after sign up for inactive accounts.
+
+
+ -
+
+
+
# def after_inactive_sign_up_path_for(resource)
+
+
+ -
+
+
+
# super(resource)
+
+
+ -
+
+
+
# end
+
+
+ -
+ 1
+
+
def after_update_path_for(resource)
+
+
+ -
+ 4
+
+
puts 'resource!!'
+
+
+ -
+ 4
+
+
puts resource
+
+
+ -
+ 4
+
+
sign_in_after_change_password? ? tutee_path(resource) : new_tutee_session_path(resource)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class TuteesController < ApplicationController
+
+
+ -
+ 1
+
+
layout 'tutee_layout', :only => [:show, :edit]
+
+
+ -
+
+
+
# Authorization section
+
+
+ -
+ 1
+
+
before_action :check_tutee_logged_in, except: [:index, :login, :createTuteeSession, :new, :create]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def index
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def show
+
+
+ -
+
+
+
# puts 'SHOW '
+
+
+ -
+
+
+
# puts 'params:'
+
+
+ -
+
+
+
# puts params
+
+
+ -
+ 44
+
+
@courses = [Course.find_by_semester(Course.current_semester)]
+
+
+ -
+ 44
+
+
@tutee = Tutee.find_by_id(params[:id])
+
+
+ -
+ 44
+
+
@requests = @tutee.requests.where('created_at >= ?', Date.today.beginning_of_week.strftime("%Y-%m-%d"))
+
+
+ -
+ 44
+
+
@evaluations = @tutee.evaluations
+
+
+ -
+ 44
+
+
@meeting = Meeting.where(request_id: @requests).last
+
+
+ -
+ 44
+
+
if not @meeting.nil?
+
+
+ -
+ 14
+
+
@lastEval = Evaluation.find_by_id( @meeting.evaluation_id)
+
+
+ -
+ 14
+
+
if @lastEval.status == "Complete"
+
+
+ -
+ 2
+
+
@meeting = nil
+
+
+ -
+
+
+
return
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def new
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def edit
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def create
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def update
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# frozen_string_literal: true
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
class Tutors::RegistrationsController < Devise::RegistrationsController
+
+
+ -
+ 1
+
+
layout 'tutor_layout', :only => [:show, :edit, :update]
+
+
+ -
+
+
+
# before_action :configure_sign_up_params, only: [:create]
+
+
+ -
+
+
+
# before_action :configure_account_update_params, only: [:update]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /resource/sign_up
+
+
+ -
+
+
+
# def new
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def new
+
+
+ -
+ 2
+
+
@tutor = Tutor.new
+
+
+ -
+ 2
+
+
@berkeley_classes = BerkeleyClass.all_classes
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# POST /resource
+
+
+ -
+
+
+
# def create
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+ 1
+
+
def create
+
+
+ -
+ 2
+
+
@tutor = Tutor.new(tutor_params)
+
+
+ -
+ 2
+
+
if params[:classes].blank?
+
+
+ -
+ 1
+
+
flash[:notice] = "You must select at least one class."
+
+
+ -
+ 1
+
+
redirect_to new_tutor_path
+
+
+ -
+ 1
+
+
return
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
@bc = BerkeleyClass.new(classes_params)
+
+
+ -
+ 1
+
+
@bc.save
+
+
+ -
+ 1
+
+
@tutor.berkeley_classes_id = @bc.id
+
+
+ -
+ 1
+
+
if @tutor.save
+
+
+ -
+ 1
+
+
flash[:notice] = "#{@tutor.first_name} #{@tutor.last_name} was successfully created."
+
+
+ -
+ 1
+
+
puts 'tutor created'
+
+
+ -
+ 1
+
+
respond_to do |format|
+
+
+ -
+ 1
+
+
flash[:notice] = "#{@tutor.first_name} #{@tutor.last_name} was successfully created."
+
+
+ -
+ 1
+
+
params[:id] = @tutor.id
+
+
+ -
+ 2
+
+
format.html { redirect_to tutor_path(@tutor.id)}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
flash[:notice] = "Tutor was not successfully created."
+
+
+ -
+
+
+
redirect_to new_tutor_path
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def tutor_params
+
+
+ -
+ 2
+
+
params.require(:tutor).permit(:type_of_tutor, :grade_level, :email, :first_name,
+
+
+ -
+
+
+
:last_name, :birthday, :sid, :gender, :dsp?, :transfer?, :major, :password, :password_confirmation)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def classes_params
+
+
+ -
+ 1
+
+
BerkeleyClass.all_classes.each do |current_class|
+
+
+ -
+ 9
+
+
params[:classes][current_class] = params[:classes].has_key?(current_class) #true hash string => all hash boolean
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
params.require(:classes).permit(:CS61A, :CS61B, :CS61C, :CS70, :EE16A, :EE16B, :CS88, :CS10, :DATA8) #maybe store this list as a constant
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /resource/edit
+
+
+ -
+
+
+
# def edit
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# PUT /resource
+
+
+ -
+
+
+
# def update
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# DELETE /resource
+
+
+ -
+
+
+
# def destroy
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /resource/cancel
+
+
+ -
+
+
+
# Forces the session data which is usually expired after sign
+
+
+ -
+
+
+
# in to be expired now. This is useful if the user wants to
+
+
+ -
+
+
+
# cancel oauth signing in/up in the middle of the process,
+
+
+ -
+
+
+
# removing all OAuth session data.
+
+
+ -
+
+
+
# def cancel
+
+
+ -
+
+
+
# super
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# protected
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If you have extra params to permit, append them to the sanitizer.
+
+
+ -
+
+
+
# def configure_sign_up_params
+
+
+ -
+
+
+
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If you have extra params to permit, append them to the sanitizer.
+
+
+ -
+
+
+
# def configure_account_update_params
+
+
+ -
+
+
+
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# # The path used after sign up.
+
+
+ -
+
+
+
# def after_sign_up_path_for(resource)
+
+
+ -
+
+
+
# new_tutee_session_path(resource_name)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# The path used after sign up for inactive accounts.
+
+
+ -
+
+
+
# def after_inactive_sign_up_path_for(resource)
+
+
+ -
+
+
+
# super(resource)
+
+
+ -
+
+
+
# end
+
+
+ -
+ 1
+
+
def after_update_path_for(resource)
+
+
+ -
+
+
+
puts 'resource!!'
+
+
+ -
+
+
+
puts resource
+
+
+ -
+
+
+
sign_in_after_change_password? ? tutor_path(resource) : new_tutor_session_path(resource)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
require 'date'
+
+
+ -
+ 1
+
+
class TutorsController < ApplicationController
+
+
+ -
+ 1
+
+
before_action :set_tutor, only: [:show, :edit, :update, :find_students]
+
+
+ -
+ 1
+
+
before_action :check_tutor_logged_in, only: [:index, :show]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /tutors
+
+
+ -
+
+
+
# GET /tutors.json
+
+
+ -
+ 1
+
+
def index
+
+
+ -
+
+
+
@tutors = Tutor.all
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def find_students
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /tutors/1
+
+
+ -
+
+
+
# GET /tutors/1.json
+
+
+ -
+ 1
+
+
def show
+
+
+ -
+ 6
+
+
@tutor = Tutor.find_by_id(params[:id])
+
+
+ -
+ 6
+
+
@meetings = Meeting.where("set_time > ? and tutor_id = ?", Time.now, params[:id])
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
@test = Request.all
+
+
+ -
+ 6
+
+
@testing = @test.map{|req| req.evaluation.nil?}
+
+
+ -
+ 6
+
+
@abc = @testing.last
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
@meeting_times = @meetings.map{|meet| meet.set_time.strftime("on %A %d at %l:%M %p")}
+
+
+ -
+ 6
+
+
@meeting_locations = @meetings.map{|meet| meet.set_location.titleize}
+
+
+ -
+ 6
+
+
@meeting_evals = @meetings.map{|meet| Evaluation.find_by_id(meet.evaluation_id)}
+
+
+ -
+ 6
+
+
@meeting_evals_status = @meeting_evals.map{|eval| eval.status}
+
+
+ -
+ 6
+
+
@meeting_evals_took_place = @meeting_evals.map{|eval| eval.took_place}
+
+
+ -
+ 6
+
+
@meeting_tutees = @meetings.map{|meet| Tutee.find_by_id(meet.tutee_id)}
+
+
+ -
+ 6
+
+
@meeting_emails = @meeting_tutees.map{|tutee| tutee.email}
+
+
+ -
+ 6
+
+
@meeting_names = @meeting_tutees.map{|tutee| tutee.first_name + " " + tutee.last_name}
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /tutors/new
+
+
+ -
+ 1
+
+
def new
+
+
+ -
+
+
+
@tutor = Tutor.new
+
+
+ -
+
+
+
@berkeley_classes = BerkeleyClass.all_classes
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# GET /tutors/1/edit
+
+
+ -
+ 1
+
+
def edit
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# POST /tutors
+
+
+ -
+
+
+
# POST /tutors.json
+
+
+ -
+ 1
+
+
def create
+
+
+ -
+
+
+
@tutor = Tutor.new(tutor_params)
+
+
+ -
+
+
+
if params[:classes].blank?
+
+
+ -
+
+
+
flash[:notice] = "You must select at least one class."
+
+
+ -
+
+
+
redirect_to new_tutor_path
+
+
+ -
+
+
+
return
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
@bc = BerkeleyClass.new(classes_params)
+
+
+ -
+
+
+
@bc.save
+
+
+ -
+
+
+
@tutor.berkeley_classes_id = @bc.id
+
+
+ -
+
+
+
if @tutor.save
+
+
+ -
+
+
+
# flash[:notice] = "#{@tutor.first_name} #{@tutor.last_name} was successfully created."
+
+
+ -
+
+
+
respond_to do |format|
+
+
+ -
+
+
+
flash[:notice] = "#{@tutor.first_name} #{@tutor.last_name} was successfully created."
+
+
+ -
+
+
+
params[:id] = @tutor.id
+
+
+ -
+
+
+
format.html { redirect_to tutor_path(@tutor.id)}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
flash[:notice] = "Tutor was not successfully created."
+
+
+ -
+
+
+
redirect_to new_tutor_path
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def total_hours
+
+
+ -
+ 6
+
+
@tutor= Tutor.find(params[:id])
+
+
+ -
+ 6
+
+
return Tutor.total_hours_helper(@tutor)
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
helper_method :total_hours
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def hours_this_week
+
+
+ -
+ 6
+
+
@tutor= Tutor.find(params[:id])
+
+
+ -
+ 6
+
+
return Tutor.hours_this_week_helper(@tutor)
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
helper_method :hours_this_week
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def average_hours
+
+
+ -
+ 6
+
+
@tutor= Tutor.find(params[:id])
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
return Tutor.average_hours_helper(@tutor)
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
helper_method :average_hours
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def update
+
+
+ -
+ 3
+
+
tutor = params[:tutor]
+
+
+ -
+ 3
+
+
email = tutor[:email]
+
+
+ -
+ 3
+
+
classes = params[:classes]
+
+
+ -
+
+
+
+
+
+ -
+ 3
+
+
if classes.blank?
+
+
+ -
+ 1
+
+
flash[:notice] = "Preferred Classes cannot be blank."
+
+
+ -
+ 1
+
+
redirect_to edit_tutor_path(@tutor.id)
+
+
+ -
+ 1
+
+
return
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 2
+
+
respond_to do |format|
+
+
+ -
+ 2
+
+
if @tutor.update(tutor_params) && @class_obj.update(classes_params)
+
+
+ -
+ 4
+
+
format.html { redirect_to @tutor, notice: 'Tutor was successfully updated.' }
+
+
+ -
+ 2
+
+
format.json { render :show, status: :ok, location: @tutor }
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
format.html { render :edit }
+
+
+ -
+
+
+
format.json { render json: @tutor.errors, status: :unprocessable_entity }
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def destroy
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def requests
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
private
+
+
+ -
+
+
+
# Use callbacks to share common setup or constraints between actions.
+
+
+ -
+ 1
+
+
VALID_EMAIL_REGEX = /A[\w+\-.]+@berkeley.edu/
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def set_tutor
+
+
+ -
+ 17
+
+
if params[:id] == "sign_out" || params[:id] == "new"
+
+
+ -
+ 1
+
+
redirect_to new_tutor_session_path
+
+
+ -
+
+
+
else
+
+
+ -
+ 16
+
+
if params[:id]
+
+
+ -
+ 15
+
+
@tutor = Tutor.find(params[:id])
+
+
+ -
+
+
+
else
+
+
+ -
+ 1
+
+
@tutor = Tutor.find(params[:tutor_id])
+
+
+ -
+
+
+
end
+
+
+ -
+ 16
+
+
@all_classes = BerkeleyClass.all_classes
+
+
+ -
+ 16
+
+
@class_obj = BerkeleyClass.find(@tutor.berkeley_classes_id)
+
+
+ -
+ 16
+
+
@true_classes = @class_obj.true_classes
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def validate_email (email)
+
+
+ -
+
+
+
/\A[\w+\-.]+@berkeley.edu/.match(email)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Never trust parameters from the scary internet, only allow the white list through.
+
+
+ -
+ 1
+
+
def tutor_params
+
+
+ -
+ 2
+
+
params.require(:tutor).permit(:type_of_tutor, :grade_level, :email, :first_name,
+
+
+ -
+
+
+
:last_name, :birthday, :sid, :gender, :dsp?, :transfer?, :major)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def classes_params
+
+
+ -
+ 2
+
+
BerkeleyClass.all_classes.each do |current_class|
+
+
+ -
+ 18
+
+
params[:classes][current_class] = params[:classes].has_key?(current_class) #true hash string => all hash boolean
+
+
+ -
+
+
+
end
+
+
+ -
+ 2
+
+
params.require(:classes).permit(:CS61A, :CS61B, :CS61C, :CS70, :EE16A, :EE16B, :CS88, :CS10, :DATA8) #maybe store this list as a constant
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class WelcomeController < ApplicationController
+
+
+ -
+ 1
+
+
skip_before_action :verify_authenticity_token
+
+
+ -
+ 1
+
+
def index
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def tutor
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def login
+
+
+ -
+
+
+
email = params[:email]
+
+
+ -
+
+
+
password = params[:password]
+
+
+ -
+
+
+
if Tutor.where(email: email).exists?
+
+
+ -
+
+
+
params[:id] = Tutor.where(email: email).first.id
+
+
+ -
+
+
+
flash[:notice] = "Welcome back"
+
+
+ -
+
+
+
redirect_to tutor_path(params[:id])
+
+
+ -
+
+
+
return
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
respond_to do |format|
+
+
+ -
+
+
+
flash[:notice] = "Email '#{email}' does not exists."
+
+
+ -
+
+
+
format.html {redirect_to welcome_tutor_path}
+
+
+ -
+
+
+
format.json { head :no_content }
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module AdminsHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module ApplicationHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module CoursesHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module EvaluationsHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module RequestsHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module TuteesHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module TutorsHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
module WelcomeHelper
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class Admin < ApplicationRecord
+
+
+ -
+ 1
+
+
has_secure_password
+
+
+ -
+
+
+
# The Admin table should only contain 1 row! This row holds all global variables that are configurable by an admin
+
+
+ -
+ 1
+
+
class<<self
+
+
+ -
+ 1
+
+
def master_admin_index
+
+
+ -
+
+
+
# All admins access/modify the same row
+
+
+ -
+ 266
+
+
return 1
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def semester_possibilities
+
+
+ -
+
+
+
# This should have to change much unless we move to the quater system
+
+
+ -
+
+
+
# Can not be all caps else _formatted functions wont work
+
+
+ -
+ 28
+
+
return %w(Spring Fall Summer)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def current_semester
+
+
+ -
+
+
+
# do some error handing for test cases
+
+
+ -
+ 140
+
+
@admin = self.find_by_id(master_admin_index)
+
+
+ -
+ 140
+
+
if @admin
+
+
+ -
+ 90
+
+
return @admin.current_semester
+
+
+ -
+ 50
+
+
elsif Course.first
+
+
+ -
+
+
+
# return first semester for testing or just in case admin hasnt been created
+
+
+ -
+ 30
+
+
return Course.first.semester
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
# return nothing if semesters havent been seeded/aren't important
+
+
+ -
+
+
+
return nil
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def current_semester_formatted
+
+
+ -
+ 31
+
+
return self.current_semester.gsub(/(?<=[a-z])(?=[0-9])/, ' ')
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def statistics_semester
+
+
+ -
+
+
+
# Adds space between lower case and numbers
+
+
+ -
+
+
+
return self.find(master_admin_index).statistics_semester
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def statistics_semester_formatted
+
+
+ -
+
+
+
# Adds space between lower case and numbers
+
+
+ -
+
+
+
return self.statistics_semester.gsub(/(?<=[a-z])(?=[0-9])/, ' ')
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def validate_year(year)
+
+
+ -
+ 3
+
+
return year.match(/^\d{4}$/)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class ApplicationRecord < ActiveRecord::Base
+
+
+ -
+ 1
+
+
self.abstract_class = true
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class BerkeleyClass < ApplicationRecord
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def true_classes
+
+
+ -
+ 16
+
+
@preferred_classes = []
+
+
+ -
+ 16
+
+
self.attributes.each_pair do |name, value|
+
+
+ -
+ 160
+
+
if value == true
+
+
+ -
+ 43
+
+
@preferred_classes.push(name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+ 16
+
+
@preferred_classes
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def self.all_classes
+
+
+ -
+ 21
+
+
@classes = []
+
+
+ -
+ 21
+
+
BerkeleyClass.column_names.each do |colunm_name|
+
+
+ -
+ 210
+
+
@classes.push(colunm_name) if colunm_name != "id"
+
+
+ -
+
+
+
end
+
+
+ -
+ 21
+
+
@classes
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class Course < ApplicationRecord
+
+
+ -
+ 1
+
+
has_many :requests
+
+
+ -
+
+
+
# class functions
+
+
+ -
+ 1
+
+
class<<self
+
+
+ -
+ 1
+
+
def current_semester
+
+
+ -
+ 109
+
+
return Admin.current_semester
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def current_courses_formatted
+
+
+ -
+ 12
+
+
formated_string = ""
+
+
+ -
+ 12
+
+
self.current_active_courses.pluck(:name).each do |course_name|
+
+
+ -
+
+
+
# temp fix for nil name in database
+
+
+ -
+ 34
+
+
if course_name.nil?
+
+
+ -
+
+
+
next
+
+
+ -
+
+
+
end
+
+
+ -
+ 34
+
+
formated_string += course_name +"\r\n"
+
+
+ -
+
+
+
end
+
+
+ -
+ 12
+
+
return formated_string[0..-2] # removes the final \n from the string
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def current_active_courses
+
+
+ -
+ 24
+
+
self.where(:semester => self.current_semester, :active => true)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# used to convert all active courses into an array
+
+
+ -
+ 1
+
+
def course_array
+
+
+ -
+ 18
+
+
self.current_active_courses.all.map { |course| [course.name, course.id] }
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
#accepts a string separated by '\n'
+
+
+ -
+ 1
+
+
def update_courses(courses)
+
+
+ -
+ 44
+
+
courses = courses.to_s.split("\r\n").map { |c| c.upcase.gsub(/\s+/, "") }.map{ |name| {:name => name, :semester => self.current_semester}} #split, remove spaces/capitialize, and turn into an array of hashes
+
+
+ -
+
+
+
#should now look like ex: [{:name => CS61A, :semester => "Spring2019"}, {:name => CS170, :semester => "Spring2019"}]
+
+
+ -
+
+
+
# can verify correctness of hashes by uncommenting lines below
+
+
+ -
+
+
+
# courses2.each do |c|
+
+
+ -
+
+
+
# puts(c[:name])
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# update all current_semester_courses to be inactive
+
+
+ -
+ 6
+
+
self.where(semester: self.current_semester).update_all(:active => false)
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# find existing courses and update to active or create new courses
+
+
+ -
+ 6
+
+
courses.each do |course|
+
+
+ -
+ 19
+
+
@c = self.where(course).first_or_create
+
+
+ -
+ 19
+
+
@c.update(:active => true)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# verify that the number of active courses is now the same.
+
+
+ -
+ 6
+
+
return self.current_active_courses.count == courses.uniq.count
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class Evaluation < ApplicationRecord
+
+
+ -
+ 1
+
+
include Friendlyable
+
+
+ -
+ 1
+
+
has_one :meeting
+
+
+ -
+ 1
+
+
has_one :request, through: :meeting
+
+
+ -
+ 1
+
+
has_one :tutor, through: :meeting
+
+
+ -
+ 1
+
+
has_one :tutee, through: :request
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
validates :took_place, inclusion: { in: [ true, false ] }, on: :update
+
+
+ -
+ 1
+
+
validates :topics, presence: true, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :hours, presence: true, numericality: {only_float: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 5}, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :positive, presence: true, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :best, presence: true, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :feedback, presence: true, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :knowledgeable, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 5, message: "Must be valid rating integer"}, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :helpful, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 5, message: "Must be valid rating integer"}, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :clarity, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 5, message: "Must be valid rating integer"}, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :pacing, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 5, message: "Must be valid rating integer"}, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :final_comments, presence: true, on: :update, :if => :took_place
+
+
+ -
+ 1
+
+
validates :status, presence: true, inclusion: { in: %w(Pending Complete), message: "Must be valid status"}, on: :update, :if => :took_place
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class Meeting < ApplicationRecord
+
+
+ -
+ 1
+
+
belongs_to :tutor
+
+
+ -
+ 1
+
+
belongs_to :request
+
+
+ -
+ 1
+
+
belongs_to :evaluation
+
+
+ -
+ 1
+
+
has_one :tutee
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def isExpired
+
+
+ -
+ 1
+
+
if self.set_time.nil?
+
+
+ -
+
+
+
return false
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
return self.set_time < Time.now
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class Request < ApplicationRecord
+
+
+ -
+ 1
+
+
belongs_to :tutee
+
+
+ -
+ 1
+
+
belongs_to :course
+
+
+ -
+ 1
+
+
has_one :meeting
+
+
+ -
+ 1
+
+
has_one :tutor, through: :meeting
+
+
+ -
+ 1
+
+
has_one :evaluation, through: :meeting
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def get_class
+
+
+ -
+
+
+
Course.find_by_id(course_id).name
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class Tutee < ApplicationRecord
+
+
+ -
+
+
+
# Include default devise modules. Others available are:
+
+
+ -
+
+
+
# :lockable, :timeoutable, :trackable and :omniauthable
+
+
+ -
+ 1
+
+
devise :database_authenticatable, :registerable, :confirmable, :validatable, :recoverable, :rememberable, stretches: 12
+
+
+ -
+ 1
+
+
has_many :requests
+
+
+ -
+ 1
+
+
has_many :courses, through: :requests
+
+
+ -
+ 1
+
+
has_many :meetings, through: :requests
+
+
+ -
+ 1
+
+
has_many :evaluations, through: :requests
+
+
+ -
+ 1
+
+
has_many :tutors, through: :requests
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
validates :birthdate, presence: {message: "Birthdate cannot be blank"}, format: {with: /\d{4}-\d{2}-\d{2}/, message: "Invalid Birthdate format"}
+
+
+ -
+ 1
+
+
validates :sid, presence: true, numericality: { message: "%{attribute} must be a number" }, format: {with: /\d{5,12}/, message: "Must be at 6-12 digits"}
+
+
+ -
+ 1
+
+
validates :first_name, presence: true, format: {with: /\A[a-zA-Z\u00C0-\u017F\s.'-]*\z/, message: "First name cannot contain numbers or specail character"}
+
+
+ -
+ 1
+
+
validates :last_name, presence: {message: "Last name cannot be blank"}, format: {with: /\A[a-zA-Z\u00C0-\u017F\s.'-]*\z/, message: "Last name cannot contain numbers or specail character"}
+
+
+ -
+ 1
+
+
validates :gender, presence: {message: "Gender cannot be blank"}
+
+
+ -
+ 1
+
+
validates :ethnicity, presence: {message: "Ethnicity cannot be blank"}
+
+
+ -
+ 1
+
+
validates :dsp, presence: {message: "DSP cannot be blank"}
+
+
+ -
+ 1
+
+
validates :transfer,presence: {message: "Transfer cannot be blank"}
+
+
+ -
+ 1
+
+
validates :major,presence: {message: "Major cannot be empty"}
+
+
+ -
+ 1
+
+
validates :pronoun, presence: {message: "Pronoun cannot be empty"}
+
+
+ -
+ 1
+
+
validates :year, presence: {message: "Year cannot be left empty"}
+
+
+ -
+ 1
+
+
validates :privilege, presence: {message: "Privilege cannot be left empty"}
+
+
+ -
+ 1
+
+
validates :email, presence: {message: "Email cannot be blank"}, format: {with: /\A[a-z0-9\+\-_\.]+@berkeley.edu/i, message: "Must be a berkeley email"}
+
+
+ -
+ 1
+
+
validate :validate_birth
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
private
+
+
+ -
+ 1
+
+
def validate_birth
+
+
+ -
+ 122
+
+
if birthdate.present? && birthdate > Time.now
+
+
+ -
+ 2
+
+
errors.add(:birthdate, 'Your birthdate cannot be in the future')
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# class functions
+
+
+ -
+ 1
+
+
class<<self
+
+
+ -
+ 1
+
+
def get_cs61a_privileged_students
+
+
+ -
+ 18
+
+
return self.where(:privilege => "cs61a")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def get_current_cs61a_sids_formatted
+
+
+ -
+ 16
+
+
return format_sids(self.get_cs61a_privileged_students)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def get_cs61b_privileged_students
+
+
+ -
+ 18
+
+
return self.where(:privilege => "cs61b")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def get_current_cs61b_sids_formatted
+
+
+ -
+ 16
+
+
return format_sids(self.get_cs61b_privileged_students)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def get_cs61c_privileged_students
+
+
+ -
+ 18
+
+
return self.where(:privilege => "cs61c")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def get_current_cs61c_sids_formatted
+
+
+ -
+ 16
+
+
return format_sids(self.get_cs61c_privileged_students)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def get_cs70_privileged_students
+
+
+ -
+ 18
+
+
return self.where(:privilege => "cs70")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def get_current_cs70_sids_formatted
+
+
+ -
+ 16
+
+
return format_sids(self.get_cs70_privileged_students)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def format_sids(some_search_function)
+
+
+ -
+ 64
+
+
formated_string = ""
+
+
+ -
+ 64
+
+
some_search_function.pluck(:sid).each do |sid|
+
+
+ -
+ 64
+
+
formated_string += (sid.to_s) + "\r\n"
+
+
+ -
+
+
+
end
+
+
+ -
+ 64
+
+
return formated_string[0..-2] # removes the final \n from the string
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def update_cs61a_privileges(sids)
+
+
+ -
+ 2
+
+
return update_privileges(sids, self.get_cs61a_privileged_students, "cs61a")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def update_cs61b_privileges(sids)
+
+
+ -
+ 2
+
+
return update_privileges(sids, self.get_cs61b_privileged_students, "cs61b")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def update_cs61c_privileges(sids)
+
+
+ -
+ 2
+
+
return update_privileges(sids, self.get_cs61c_privileged_students, "cs61c")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def update_cs70_privileges(sids)
+
+
+ -
+ 2
+
+
return update_privileges(sids, self.get_cs70_privileged_students, "cs70")
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
def update_privileges(sids, some_search_function, privilege_to_change_to)
+
+
+ -
+ 20
+
+
sids = sids.to_s.split("\r\n").map { |c| c.gsub(/\s+/, "") }#.map{ |sid| {:sid => sid}} #split, remove spaces
+
+
+ -
+
+
+
#should now be a array of sids
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# update all students currently with that privilege to not have that privilege anymore
+
+
+ -
+ 8
+
+
some_search_function.update_all(:privilege => "No")
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# find students with a given sid and update to have that privilege, do nothing if sid doesnt correspond to a tutee account.
+
+
+ -
+ 8
+
+
sids.each do |sid|
+
+
+ -
+ 12
+
+
@tutee = self.find_by_sid(sid).try(:update_attributes, {:privilege => privilege_to_change_to})
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Code below currently not needed because if a student doesnt have account yet then sids will be larger than the current sids with that privilege
+
+
+ -
+
+
+
# verify that the number of active courses is now the same. (uniq is to ignore duplicates)
+
+
+ -
+
+
+
# return some_search_function.count == sids.uniq.count
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
class Tutor < ApplicationRecord
+
+
+ -
+
+
+
# Include default devise modules. Others available are:
+
+
+ -
+
+
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
+
+
+ -
+ 1
+
+
devise :database_authenticatable, :registerable, :confirmable, :validatable, :recoverable, :rememberable, stretches: 12
+
+
+ -
+ 1
+
+
has_one :berkeley_class
+
+
+ -
+ 1
+
+
has_many :meetings
+
+
+ -
+ 1
+
+
has_many :requests, through: :meetings
+
+
+ -
+ 1
+
+
has_many :tutees, through: :requests
+
+
+ -
+ 1
+
+
has_many :evaluations, through: :meetings
+
+
+ -
+ 1
+
+
validates :type_of_tutor, presence: true
+
+
+ -
+ 1
+
+
validates :grade_level, presence: true
+
+
+ -
+ 1
+
+
validates :first_name, presence: true
+
+
+ -
+ 1
+
+
validates :last_name, presence: true
+
+
+ -
+ 1
+
+
validates :email, format: {with: /\A[\w+\-.]+@berkeley.edu/, message:"Please give a valid Berkeley email address "}, :on => :create
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def self.total_hours_helper tutor
+
+
+ -
+ 6
+
+
@all_evals = tutor.evaluations
+
+
+ -
+ 6
+
+
return @all_evals.sum(:hours)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def self.hours_this_week_helper tutor
+
+
+ -
+ 6
+
+
return tutor.evaluations.where(created_at: Time.now.beginning_of_week.strftime("%Y-%m-%d")..Time.now).sum(:hours)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
def self.average_hours_helper tutor
+
+
+ -
+ 6
+
+
all_evals = tutor.evaluations
+
+
+ -
+ 6
+
+
if all_evals.empty?
+
+
+ -
+ 6
+
+
return "Not Available"
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
earliest_timestamp = all_evals.order(:created_at).first.created_at
+
+
+ -
+
+
+
latest_timestamp = all_evals.order(:created_at).last.created_at
+
+
+ -
+
+
+
if !earliest_timestamp.nil? and !latest_timestamp.nil?
+
+
+ -
+
+
+
puts 'latest_timestamp: ' + latest_timestamp.to_s
+
+
+ -
+
+
+
puts 'earliest_timestamp: ' + earliest_timestamp.to_s
+
+
+ -
+
+
+
difference = latest_timestamp - earliest_timestamp
+
+
+ -
+
+
+
if difference == 0
+
+
+ -
+
+
+
return total_hours_helper(tutor)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
total_days = (difference / 86400)
+
+
+ -
+
+
+
total_weeks = total_days / 7
+
+
+ -
+
+
+
return total_hours_helper(tutor)/total_weeks
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
require_relative 'boot'
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
require "rails"
+
+
+ -
+
+
+
# Pick the frameworks you want:
+
+
+ -
+ 1
+
+
require "active_model/railtie"
+
+
+ -
+ 1
+
+
require "active_job/railtie"
+
+
+ -
+ 1
+
+
require "active_record/railtie"
+
+
+ -
+ 1
+
+
require "active_storage/engine"
+
+
+ -
+ 1
+
+
require "action_controller/railtie"
+
+
+ -
+ 1
+
+
require "action_mailer/railtie"
+
+
+ -
+ 1
+
+
require "action_view/railtie"
+
+
+ -
+ 1
+
+
require "action_cable/engine"
+
+
+ -
+ 1
+
+
require "sprockets/railtie"
+
+
+ -
+
+
+
# require "rails/test_unit/railtie"
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Require the gems listed in Gemfile, including any gems
+
+
+ -
+
+
+
# you've limited to :test, :development, or :production.
+
+
+ -
+ 1
+
+
Bundler.require(*Rails.groups)
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
module Cs370
+
+
+ -
+ 1
+
+
class Application < Rails::Application
+
+
+ -
+
+
+
# Initialize configuration defaults for originally generated Rails version.
+
+
+ -
+ 1
+
+
config.load_defaults 5.2
+
+
+ -
+ 1
+
+
config.time_zone = "Pacific Time (US & Canada)"
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Settings in config/environments/* take precedence over those specified here.
+
+
+ -
+
+
+
# Application configuration can go into files in config/initializers
+
+
+ -
+
+
+
# -- all .rb files in that directory are automatically loaded after loading
+
+
+ -
+
+
+
# the framework and any gems in your application.
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
config.before_configuration do
+
+
+ -
+ 1
+
+
env_file = File.join(Rails.root, 'config','local_env.yml')
+
+
+ -
+ 1
+
+
p env_file
+
+
+ -
+
+
+
YAML.load(File.open(env_file)).each do |key, value|
+
+
+ -
+
+
+
ENV[key.to_s] = value
+
+
+ -
+ 1
+
+
end if File.exists?(env_file)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Don't generate system test files.\end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
require 'bundler/setup' # Set up gems listed in the Gemfile.
+
+
+ -
+ 1
+
+
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Load the Rails application.
+
+
+ -
+ 1
+
+
require_relative 'application'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Initialize the Rails application.
+
+
+ -
+ 1
+
+
Rails.application.initialize!
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.configure do
+
+
+ -
+
+
+
# Settings specified here will take precedence over those in config/application.rb.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# The test environment is used exclusively to run your application's
+
+
+ -
+
+
+
# test suite. You never need to work with it otherwise. Remember that
+
+
+ -
+
+
+
# your test database is "scratch space" for the test suite and is wiped
+
+
+ -
+
+
+
# and recreated between test runs. Don't rely on the data there!
+
+
+ -
+ 1
+
+
config.cache_classes = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Do not eager load code on boot. This avoids loading your whole application
+
+
+ -
+
+
+
# just for the purpose of running a single test. If you are using a tool that
+
+
+ -
+
+
+
# preloads Rails for running tests, you may have to set it to true.
+
+
+ -
+ 1
+
+
config.eager_load = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure public file server for tests with Cache-Control for performance.
+
+
+ -
+ 1
+
+
config.public_file_server.enabled = true
+
+
+ -
+ 1
+
+
config.public_file_server.headers = {
+
+
+ -
+
+
+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
+
+
+ -
+
+
+
}
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Show full error reports and disable caching.
+
+
+ -
+ 1
+
+
config.consider_all_requests_local = true
+
+
+ -
+ 1
+
+
config.action_controller.perform_caching = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Raise exceptions instead of rendering exception templates.
+
+
+ -
+ 1
+
+
config.action_dispatch.show_exceptions = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Disable request forgery protection in test environment.
+
+
+ -
+ 1
+
+
config.action_controller.allow_forgery_protection = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Store uploaded files on the local file system in a temporary directory
+
+
+ -
+ 1
+
+
config.active_storage.service = :test
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
config.action_mailer.perform_caching = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Tell Action Mailer not to deliver emails to the real world.
+
+
+ -
+
+
+
# The :test delivery method accumulates sent emails in the
+
+
+ -
+
+
+
# ActionMailer::Base.deliveries array.
+
+
+ -
+ 1
+
+
config.action_mailer.delivery_method = :test
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Print deprecation notices to the stderr.
+
+
+ -
+ 1
+
+
config.active_support.deprecation = :stderr
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Raises error for missing translations
+
+
+ -
+
+
+
# config.action_view.raise_on_missing_translations = true
+
+
+ -
+ 1
+
+
Rails.application.routes.default_url_options[:host] = 'localhost:3000'
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ActiveSupport::Reloader.to_prepare do
+
+
+ -
+
+
+
# ApplicationController.renderer.defaults.merge!(
+
+
+ -
+
+
+
# http_host: 'example.org',
+
+
+ -
+
+
+
# https: false
+
+
+ -
+
+
+
# )
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Version of your assets, change this if you want to expire all your assets.
+
+
+ -
+ 1
+
+
Rails.application.config.assets.version = '1.0'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Add additional assets to the asset load path.
+
+
+ -
+
+
+
# Rails.application.config.assets.paths << Emoji.images_path
+
+
+ -
+
+
+
# Add Yarn node_modules folder to the asset load path.
+
+
+ -
+ 1
+
+
Rails.application.config.assets.paths << Rails.root.join('node_modules')
+
+
+ -
+
+
+
#Rails.application.config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Precompile additional assets.
+
+
+ -
+
+
+
# application.js, application.css, and all non-JS/CSS in the app/assets
+
+
+ -
+
+
+
# folder are already added.
+
+
+ -
+
+
+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( tutors.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( tutors_index.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( tutors_new.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( welcome.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( welcome_tutor.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( navbar.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( notice_success.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( tutors_edit.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( tutor_request.css )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( email.js )
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.config.assets.precompile += %w( dataTables.bootstrap4.min.css )
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+
+
+ -
+
+
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+
+
+ -
+
+
+
# Rails.backtrace_cleaner.remove_silencers!
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Define an application-wide content security policy
+
+
+ -
+
+
+
# For further information see the following documentation
+
+
+ -
+
+
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Rails.application.config.content_security_policy do |policy|
+
+
+ -
+
+
+
# policy.default_src :self, :https
+
+
+ -
+
+
+
# policy.font_src :self, :https, :data
+
+
+ -
+
+
+
# policy.img_src :self, :https, :data
+
+
+ -
+
+
+
# policy.object_src :none
+
+
+ -
+
+
+
# policy.script_src :self, :https
+
+
+ -
+
+
+
# policy.style_src :self, :https
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# # Specify URI for violation reports
+
+
+ -
+
+
+
# # policy.report_uri "/csp-violation-report-endpoint"
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If you are using UJS then enable automatic nonce generation
+
+
+ -
+
+
+
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Report CSP violations to a specified URI
+
+
+ -
+
+
+
# For further information see the following documentation:
+
+
+ -
+
+
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
+
+
+ -
+
+
+
# Rails.application.config.content_security_policy_report_only = true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Specify a serializer for the signed and encrypted cookie jars.
+
+
+ -
+
+
+
# Valid options are :json, :marshal, and :hybrid.
+
+
+ -
+ 1
+
+
Rails.application.config.action_dispatch.cookies_serializer = :json
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# frozen_string_literal: true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Use this hook to configure devise mailer, warden hooks and so forth.
+
+
+ -
+
+
+
# Many of these configuration options can be set straight in your model.
+
+
+ -
+ 1
+
+
Devise.setup do |config|
+
+
+ -
+
+
+
# The secret key used by Devise. Devise uses this key to generate
+
+
+ -
+
+
+
# random tokens. Changing this key will render invalid all existing
+
+
+ -
+
+
+
# confirmation, reset password and unlock tokens in the database.
+
+
+ -
+
+
+
# Devise will use the `secret_key_base` as its `secret_key`
+
+
+ -
+
+
+
# by default. You can change it below and use your own secret key.
+
+
+ -
+
+
+
# config.secret_key = '6f067efd532499b171e2d8f8f46255505c46051b62f4777b9d861ae6b40266c702222ea702f9209128396c200da3f75514a07da6ab7b56c6f06a9914c49f36a3'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Controller configuration
+
+
+ -
+
+
+
# Configure the parent class to the devise controllers.
+
+
+ -
+
+
+
# config.parent_controller = 'DeviseController'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Mailer Configuration
+
+
+ -
+
+
+
# Configure the e-mail address which will be shown in Devise::Mailer,
+
+
+ -
+
+
+
# note that it will be overwritten if you use your own mailer class
+
+
+ -
+
+
+
# with default "from" parameter.
+
+
+ -
+ 1
+
+
config.mailer_sender = 'non.reply.bear.email@gmail.com'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure the class responsible to send e-mails.
+
+
+ -
+
+
+
# config.mailer = 'Devise::Mailer'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure the parent class responsible to send e-mails.
+
+
+ -
+
+
+
# config.parent_mailer = 'ActionMailer::Base'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> ORM configuration
+
+
+ -
+
+
+
# Load and configure the ORM. Supports :active_record (default) and
+
+
+ -
+
+
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
+
+
+ -
+
+
+
# available as additional gems.
+
+
+ -
+ 1
+
+
require 'devise/orm/active_record'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for any authentication mechanism
+
+
+ -
+
+
+
# Configure which keys are used when authenticating a user. The default is
+
+
+ -
+
+
+
# just :email. You can configure it to use [:username, :subdomain], so for
+
+
+ -
+
+
+
# authenticating a user, both parameters are required. Remember that those
+
+
+ -
+
+
+
# parameters are used only when authenticating and not when retrieving from
+
+
+ -
+
+
+
# session. If you need permissions, you should implement that in a before filter.
+
+
+ -
+
+
+
# You can also supply a hash where the value is a boolean determining whether
+
+
+ -
+
+
+
# or not authentication should be aborted when the value is not present.
+
+
+ -
+
+
+
# config.authentication_keys = [:email]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure parameters from the request object used for authentication. Each entry
+
+
+ -
+
+
+
# given should be a request method and it will automatically be passed to the
+
+
+ -
+
+
+
# find_for_authentication method and considered in your model lookup. For instance,
+
+
+ -
+
+
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+
+
+ -
+
+
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
+
+
+ -
+
+
+
# config.request_keys = []
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure which authentication keys should be case-insensitive.
+
+
+ -
+
+
+
# These keys will be downcased upon creating or modifying a user and when used
+
+
+ -
+
+
+
# to authenticate or find a user. Default is :email.
+
+
+ -
+ 1
+
+
config.case_insensitive_keys = [:email]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure which authentication keys should have whitespace stripped.
+
+
+ -
+
+
+
# These keys will have whitespace before and after removed upon creating or
+
+
+ -
+
+
+
# modifying a user and when used to authenticate or find a user. Default is :email.
+
+
+ -
+ 1
+
+
config.strip_whitespace_keys = [:email]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Tell if authentication through request.params is enabled. True by default.
+
+
+ -
+
+
+
# It can be set to an array that will enable params authentication only for the
+
+
+ -
+
+
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
+
+
+ -
+
+
+
# enable it only for database (email + password) authentication.
+
+
+ -
+
+
+
# config.params_authenticatable = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Tell if authentication through HTTP Auth is enabled. False by default.
+
+
+ -
+
+
+
# It can be set to an array that will enable http authentication only for the
+
+
+ -
+
+
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
+
+
+ -
+
+
+
# enable it only for database authentication. The supported strategies are:
+
+
+ -
+
+
+
# :database = Support basic authentication with authentication key + password
+
+
+ -
+
+
+
# config.http_authenticatable = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If 401 status code should be returned for AJAX requests. True by default.
+
+
+ -
+
+
+
# config.http_authenticatable_on_xhr = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# The realm used in Http Basic Authentication. 'Application' by default.
+
+
+ -
+
+
+
# config.http_authentication_realm = 'Application'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# It will change confirmation, password recovery and other workflows
+
+
+ -
+
+
+
# to behave the same regardless if the e-mail provided was right or wrong.
+
+
+ -
+
+
+
# Does not affect registerable.
+
+
+ -
+
+
+
# config.paranoid = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# By default Devise will store the user in session. You can skip storage for
+
+
+ -
+
+
+
# particular strategies by setting this option.
+
+
+ -
+
+
+
# Notice that if you are skipping storage for all authentication paths, you
+
+
+ -
+
+
+
# may want to disable generating routes to Devise's sessions controller by
+
+
+ -
+
+
+
# passing skip: :sessions to `devise_for` in your config/routes.rb
+
+
+ -
+ 1
+
+
config.skip_session_storage = [:http_auth]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# By default, Devise cleans up the CSRF token on authentication to
+
+
+ -
+
+
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
+
+
+ -
+
+
+
# requests for sign in and sign up, you need to get a new CSRF token
+
+
+ -
+
+
+
# from the server. You can disable this option at your own risk.
+
+
+ -
+
+
+
# config.clean_up_csrf_token_on_authentication = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When false, Devise will not attempt to reload routes on eager load.
+
+
+ -
+
+
+
# This can reduce the time taken to boot the app but if your application
+
+
+ -
+
+
+
# requires the Devise mappings to be loaded during boot time the application
+
+
+ -
+
+
+
# won't boot properly.
+
+
+ -
+
+
+
# config.reload_routes = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :database_authenticatable
+
+
+ -
+
+
+
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
+
+
+ -
+
+
+
# using other algorithms, it sets how many times you want the password to be hashed.
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Limiting the stretches to just one in testing will increase the performance of
+
+
+ -
+
+
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+
+
+ -
+
+
+
# a value less than 10 in other environments. Note that, for bcrypt (the default
+
+
+ -
+
+
+
# algorithm), the cost increases exponentially with the number of stretches (e.g.
+
+
+ -
+
+
+
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
+
+
+ -
+ 1
+
+
config.stretches = Rails.env.test? ? 1 : 11
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Set up a pepper to generate the hashed password.
+
+
+ -
+
+
+
# config.pepper = '55f933babc69f7a9a34b156e62521abf265064b6248bd21a9550cfe8c6ae6bf06f9225e7e47d782b61df33cbdddc47448306ddc510124de2f250d188aa4187cd'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Send a notification to the original email when the user's email is changed.
+
+
+ -
+
+
+
# config.send_email_changed_notification = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Send a notification email when the user's password is changed.
+
+
+ -
+
+
+
# config.send_password_change_notification = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :confirmable
+
+
+ -
+
+
+
# A period that the user is allowed to access the website even without
+
+
+ -
+
+
+
# confirming their account. For instance, if set to 2.days, the user will be
+
+
+ -
+
+
+
# able to access the website for two days without confirming their account,
+
+
+ -
+
+
+
# access will be blocked just in the third day.
+
+
+ -
+
+
+
# You can also set it to nil, which will allow the user to access the website
+
+
+ -
+
+
+
# without confirming their account.
+
+
+ -
+
+
+
# Default is 0.days, meaning the user cannot access the website without
+
+
+ -
+
+
+
# confirming their account.
+
+
+ -
+
+
+
# config.allow_unconfirmed_access_for = 2.days
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# A period that the user is allowed to confirm their account before their
+
+
+ -
+
+
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
+
+
+ -
+
+
+
# their account within 3 days after the mail was sent, but on the fourth day
+
+
+ -
+
+
+
# their account can't be confirmed with the token any more.
+
+
+ -
+
+
+
# Default is nil, meaning there is no restriction on how long a user can take
+
+
+ -
+
+
+
# before confirming their account.
+
+
+ -
+
+
+
# config.confirm_within = 3.days
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If true, requires any email changes to be confirmed (exactly the same way as
+
+
+ -
+
+
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
+
+
+ -
+
+
+
# db field (see migrations). Until confirmed, new email is stored in
+
+
+ -
+
+
+
# unconfirmed_email column, and copied to email column on successful confirmation.
+
+
+ -
+ 1
+
+
config.reconfirmable = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Defines which key will be used when confirming an account
+
+
+ -
+
+
+
# config.confirmation_keys = [:email]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :rememberable
+
+
+ -
+
+
+
# The time the user will be remembered without asking for credentials again.
+
+
+ -
+
+
+
# config.remember_for = 2.weeks
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Invalidates all the remember me tokens when the user signs out.
+
+
+ -
+ 1
+
+
config.expire_all_remember_me_on_sign_out = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# If true, extends the user's remember period when remembered via cookie.
+
+
+ -
+
+
+
# config.extend_remember_period = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Options to be passed to the created cookie. For instance, you can set
+
+
+ -
+
+
+
# secure: true in order to force SSL only cookies.
+
+
+ -
+
+
+
# config.rememberable_options = {}
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :validatable
+
+
+ -
+
+
+
# Range for password length.
+
+
+ -
+ 1
+
+
config.password_length = 6..128
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Email regex used to validate email formats. It simply asserts that
+
+
+ -
+
+
+
# one (and only one) @ exists in the given string. This is mainly
+
+
+ -
+
+
+
# to give user feedback and not to assert the e-mail validity.
+
+
+ -
+ 1
+
+
config.email_regexp = /\A[^@\s]+@berkeley.edu\z/
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :timeoutable
+
+
+ -
+
+
+
# The time you want to timeout the user session without activity. After this
+
+
+ -
+
+
+
# time the user will be asked for credentials again. Default is 30 minutes.
+
+
+ -
+
+
+
# config.timeout_in = 30.minutes
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :lockable
+
+
+ -
+
+
+
# Defines which strategy will be used to lock an account.
+
+
+ -
+
+
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
+
+
+ -
+
+
+
# :none = No lock strategy. You should handle locking by yourself.
+
+
+ -
+
+
+
# config.lock_strategy = :failed_attempts
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Defines which key will be used when locking and unlocking an account
+
+
+ -
+
+
+
# config.unlock_keys = [:email]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Defines which strategy will be used to unlock an account.
+
+
+ -
+
+
+
# :email = Sends an unlock link to the user email
+
+
+ -
+
+
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
+
+
+ -
+
+
+
# :both = Enables both strategies
+
+
+ -
+
+
+
# :none = No unlock strategy. You should handle unlocking by yourself.
+
+
+ -
+
+
+
# config.unlock_strategy = :both
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Number of authentication tries before locking an account if lock_strategy
+
+
+ -
+
+
+
# is failed attempts.
+
+
+ -
+
+
+
# config.maximum_attempts = 20
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
+
+
+ -
+
+
+
# config.unlock_in = 1.hour
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Warn on the last attempt before the account is locked.
+
+
+ -
+
+
+
# config.last_attempt_warning = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :recoverable
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Defines which key will be used when recovering the password for an account
+
+
+ -
+
+
+
# config.reset_password_keys = [:email]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Time interval you can reset your password with a reset password key.
+
+
+ -
+
+
+
# Don't put a too small interval or your users won't have the time to
+
+
+ -
+
+
+
# change their passwords.
+
+
+ -
+ 1
+
+
config.reset_password_within = 6.hours
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When set to false, does not sign a user in automatically after their password is
+
+
+ -
+
+
+
# reset. Defaults to true, so a user is signed in automatically after a reset.
+
+
+ -
+
+
+
# config.sign_in_after_reset_password = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :encryptable
+
+
+ -
+
+
+
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
+
+
+ -
+
+
+
# You can use :sha1, :sha512 or algorithms from others authentication tools as
+
+
+ -
+
+
+
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
+
+
+ -
+
+
+
# for default behavior) and :restful_authentication_sha1 (then you should set
+
+
+ -
+
+
+
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
+
+
+ -
+
+
+
# config.encryptor = :sha512
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Scopes configuration
+
+
+ -
+
+
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
+
+
+ -
+
+
+
# "users/sessions/new". It's turned off by default because it's slower if you
+
+
+ -
+
+
+
# are using only default views.
+
+
+ -
+
+
+
# config.scoped_views = false
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure the default scope given to Warden. By default it's the first
+
+
+ -
+
+
+
# devise role declared in your routes (usually :user).
+
+
+ -
+
+
+
# config.default_scope = :user
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Set this configuration to false if you want /users/sign_out to sign out
+
+
+ -
+
+
+
# only the current scope. By default, Devise signs out all scopes.
+
+
+ -
+
+
+
# config.sign_out_all_scopes = true
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Navigation configuration
+
+
+ -
+
+
+
# Lists the formats that should be treated as navigational. Formats like
+
+
+ -
+
+
+
# :html, should redirect to the sign in page when the user does not have
+
+
+ -
+
+
+
# access, but formats like :xml or :json, should return 401.
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# If you have any extra navigational formats, like :iphone or :mobile, you
+
+
+ -
+
+
+
# should add them to the navigational formats lists.
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# The "*/*" below is required to match Internet Explorer requests.
+
+
+ -
+
+
+
# config.navigational_formats = ['*/*', :html]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# The default HTTP method used to sign out a resource. Default is :delete.
+
+
+ -
+ 1
+
+
config.sign_out_via = :delete
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> OmniAuth
+
+
+ -
+
+
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
+
+
+ -
+
+
+
# up on your models and hooks.
+
+
+ -
+
+
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Warden configuration
+
+
+ -
+
+
+
# If you want to use other strategies, that are not supported by Devise, or
+
+
+ -
+
+
+
# change the failure app, you can configure them inside the config.warden block.
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# config.warden do |manager|
+
+
+ -
+
+
+
# manager.intercept_401 = false
+
+
+ -
+
+
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Mountable engine configurations
+
+
+ -
+
+
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
+
+
+ -
+
+
+
# is mountable, there are some extra configurations to be taken into account.
+
+
+ -
+
+
+
# The following options are available, assuming the engine is mounted as:
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# mount MyEngine, at: '/my_engine'
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# The router that invoked `devise_for`, in the example above, would be:
+
+
+ -
+
+
+
# config.router_name = :my_engine
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
+
+
+ -
+
+
+
# so you need to do it manually. For the users scope, it would be:
+
+
+ -
+
+
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Turbolinks configuration
+
+
+ -
+
+
+
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
+
+
+ -
+
+
+
#
+
+
+ -
+ 1
+
+
ActiveSupport.on_load(:devise_failure_app) do
+
+
+ -
+ 1
+
+
include Turbolinks::Controller
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# ==> Configuration for :registerable
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When set to false, does not sign a user in automatically after their password is
+
+
+ -
+
+
+
# changed. Defaults to true, so a user is signed in automatically after changing a password.
+
+
+ -
+
+
+
# config.sign_in_after_change_password = true
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Configure sensitive parameters which will be filtered from the log file.
+
+
+ -
+ 1
+
+
Rails.application.config.filter_parameters += [:password]
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Add new inflection rules using the following format. Inflections
+
+
+ -
+
+
+
# are locale specific, and you may define rules for as many different
+
+
+ -
+
+
+
# locales as you wish. All of these examples are active by default:
+
+
+ -
+
+
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
+
+
+ -
+
+
+
# inflect.plural /^(ox)$/i, '\1en'
+
+
+ -
+
+
+
# inflect.singular /^(ox)en/i, '\1'
+
+
+ -
+
+
+
# inflect.irregular 'person', 'people'
+
+
+ -
+
+
+
# inflect.uncountable %w( fish sheep )
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# These inflection rules are supported but not enabled by default:
+
+
+ -
+
+
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
+
+
+ -
+
+
+
# inflect.acronym 'RESTful'
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Add new mime types for use in respond_to blocks:
+
+
+ -
+
+
+
# Mime::Type.register "text/richtext", :rtf
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# ActionMailer::Base.smtp_settings = {
+
+
+ -
+
+
+
# :address => 'smtp.gmail.com',
+
+
+ -
+
+
+
# :port => 587,
+
+
+ -
+
+
+
# :domain => 'gmail.com',
+
+
+ -
+
+
+
# :user_name => 'non.reply.bear.email@gmail.com',
+
+
+ -
+
+
+
# :password => '#goBears',
+
+
+ -
+
+
+
# :authentication => :plain,
+
+
+ -
+
+
+
# :openssl_verify_mode => 'none'
+
+
+ -
+
+
+
# }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Be sure to restart your server when you modify this file.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# This file contains settings for ActionController::ParamsWrapper which
+
+
+ -
+
+
+
# is enabled by default.
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+
+
+ -
+ 1
+
+
ActiveSupport.on_load(:action_controller) do
+
+
+ -
+ 2
+
+
wrap_parameters format: [:json]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# To enable root element in JSON for ActiveRecord objects.
+
+
+ -
+
+
+
# ActiveSupport.on_load(:active_record) do
+
+
+ -
+
+
+
# self.include_root_in_json = true
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
Rails.application.routes.draw do
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
devise_for :tutors, controllers: {registrations: 'tutors/registrations'}
+
+
+ -
+ 1
+
+
devise_for :tutees, controllers: {registrations: 'tutees/registrations'}
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
devise_scope :tutor do
+
+
+ -
+ 1
+
+
get "/sign_in" => "devise/sessions#new" # custom path to login/sign_in
+
+
+ -
+ 1
+
+
get "/sign_up" => "devise/registrations#new", as: "new_user_registration" # custom path to sign_up/registration
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
#resources :admins
+
+
+ -
+ 1
+
+
root "welcome#index", as: :homepage
+
+
+ -
+ 1
+
+
post '/welcome/login/' => 'welcome#login', as: :welcome_login
+
+
+ -
+ 1
+
+
get '/welcome/tutor' => 'welcome#tutor', as: :welcome_tutor
+
+
+ -
+ 1
+
+
get '/tutors/:tutor_id/find_students' => 'tutors#find_students', as: :tutor_find_students
+
+
+ -
+ 1
+
+
get '/tutors/:tutor_id/requests/email/' => 'requests#email', as: :requests_email_tutor
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
get 'admins/' => 'admins#landing', as: :admin_landing
+
+
+ -
+ 1
+
+
get 'admins/home' => 'admins#home', as: :admin_home
+
+
+ -
+ 1
+
+
post 'admins/login' => 'admins#createAdminSession', as: :admin_login
+
+
+ -
+ 1
+
+
get 'admins/logout' => 'admins#destroyAdminSession', as: :admin_logout
+
+
+ -
+ 1
+
+
get 'admins/update_semester' => 'admins#update_semester', as: :admin_update_semester
+
+
+ -
+ 1
+
+
post 'admins/current_semester_update' => 'admins#updateCurrentSemester', as: :admin_update_current_semester
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
get 'admins/rating_tutors' => 'admins#rating_tutors', as: :admin_rating_tutors
+
+
+ -
+ 1
+
+
get 'admins/tutor_hours' => 'admins#tutor_hours', as: :admin_tutor_hours
+
+
+ -
+
+
+
# post 'admins/statistics_semester_update' => 'admins#updateStatisticsSemester', as: :admin_update_statistics_semester
+
+
+ -
+ 1
+
+
get 'admins/courses_update' => 'admins#update_courses', as: :admin_update_courses
+
+
+ -
+ 1
+
+
post 'admins/courses_update' => 'admins#post_update_courses', as: :admin_post_update_courses
+
+
+ -
+ 1
+
+
get 'admins/update_password' => 'admins#update_password', as: :admin_update_password
+
+
+ -
+ 1
+
+
post 'admins/update_password' => 'admins#post_update_password', as: :admin_post_update_password
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
get 'admins/update_student_priorities' => 'admins#update_student_priorities', as: :admin_update_student_priorities
+
+
+ -
+ 1
+
+
post 'admins/update_student_priorities_61A' => 'admins#update_student_priorities_61A', as: :admin_update_student_priorities_61A
+
+
+ -
+ 1
+
+
post 'admins/update_student_priorities_61B' => 'admins#update_student_priorities_61B', as: :admin_update_student_priorities_61B
+
+
+ -
+ 1
+
+
post 'admins/update_student_priorities_61C' => 'admins#update_student_priorities_61C', as: :admin_update_student_priorities_61C
+
+
+ -
+ 1
+
+
post 'admins/update_student_priorities_70' => 'admins#update_student_priorities_70', as: :admin_update_student_priorities_70
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+
+ -
+ 1
+
+
resources :tutees, except: [:index, :create, :edit, :new, :update]
+
+
+ -
+ 1
+
+
resources :courses, :requests
+
+
+ -
+ 1
+
+
resources :evaluations, only: [:update, :destroy]
+
+
+ -
+ 1
+
+
resources :tutees do
+
+
+ -
+ 1
+
+
resources :requests, except: [:index, :email, :show]
+
+
+ -
+ 1
+
+
resources :meetings
+
+
+ -
+ 1
+
+
resources :evaluations
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
get 'tutees/login/:id' => 'tutees#createTuteeSession', as: :login_tutee
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
get 'requests/history/:tutee_id' => 'requests#history', as: :request_history_tutee
+
+
+ -
+ 1
+
+
get 'evaluations/:id' => 'evaluations#public_show', as: :evaluation_public
+
+
+ -
+ 1
+
+
get 'evaluations/:id/edit' => 'evaluations#public_edit', as: :edit_evaluation
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
mount JasmineRails::Engine => '/specs' if defined?(JasmineRails)
+
+
+ -
+
+
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
resources :tutors, except: [:index, :create, :edit, :new, :update]
+
+
+ -
+ 1
+
+
resources :tutors do
+
+
+ -
+ 1
+
+
resources :requests, except: [:index, :show, :new, :update]
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
Given /the following tutors exist/ do |tutors_table|
+
+
+ -
+ 17
+
+
tutors_table.hashes.each do |tutor|
+
+
+ -
+ 27
+
+
Tutor.create tutor
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /the following berkeley_classes exist/ do |berkeley_classes_table|
+
+
+ -
+ 14
+
+
berkeley_classes_table.hashes.each do |berkeley_class|
+
+
+ -
+ 20
+
+
BerkeleyClass.create berkeley_class
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# TL;DR: YOU SHOULD DELETE THIS FILE
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# This file was generated by Cucumber-Rails and is only here to get you a head start
+
+
+ -
+
+
+
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
+
+
+ -
+
+
+
# visit pages, interact with widgets and make assertions about page content.
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# If you use these step definitions as basis for your features you will quickly end up
+
+
+ -
+
+
+
# with features that are:
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# * Hard to maintain
+
+
+ -
+
+
+
# * Verbose to read
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# A much better approach is to write your own higher level step definitions, following
+
+
+ -
+
+
+
# the advice in the following blog posts:
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
+
+
+ -
+
+
+
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
+
+
+ -
+
+
+
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
require 'uri'
+
+
+ -
+ 1
+
+
require 'cgi'
+
+
+ -
+ 1
+
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
+
+
+ -
+ 1
+
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
module WithinHelpers
+
+
+ -
+ 1
+
+
def with_scope(locator)
+
+
+ -
+
+
+
locator ? within(*selector_for(locator)) { yield } : yield
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
World(WithinHelpers)
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Single-line step scoper
+
+
+ -
+
+
+
# When /^(.*) within (.*[^:])$/ do |step, parent|
+
+
+ -
+
+
+
# with_scope(parent) { When step }
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Multi-line step scoper
+
+
+ -
+
+
+
# When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
+
+
+ -
+
+
+
# with_scope(parent) { When "#{step}:", table_or_string }
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Given /^(?:|I )am on (.+)$/ do |page_name|
+
+
+ -
+
+
+
# visit path_to(page_name)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
+
+
+ -
+
+
+
# with_scope(parent) { When "#{step}:", table_or_string }
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Given /^(?:|I )am on (.+)$/ do |page_name|
+
+
+ -
+
+
+
# visit path_to(page_name)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^(?:|I )go to (.+)$/ do |page_name|
+
+
+ -
+ 7
+
+
visit path_to(page_name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When /^(?:|I )press "([^"]*)"$/ do |button|
+
+
+ -
+
+
+
# click_button(button)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
+
+
+ -
+
+
+
# click_link(link)
+
+
+ -
+ 5
+
+
first(:link, link, exact: true).click #handles ambiguous case
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
+
+
+ -
+
+
+
# fill_in(field, :with => value)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
+
+
+ -
+
+
+
# fill_in(field, :with => value)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Use this to fill in an entire form with data from a table. Example:
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# When I fill in the following:
+
+
+ -
+
+
+
# | Account Number | 5002 |
+
+
+ -
+
+
+
# | Expiry date | 2009-11-01 |
+
+
+ -
+
+
+
# | Note | Nice guy |
+
+
+ -
+
+
+
# | Wants Email? | |
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# TODO: Add support for checkbox, select or option
+
+
+ -
+
+
+
# based on naming conventions.
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# When /^(?:|I )fill in the following:$/ do |fields|
+
+
+ -
+
+
+
# fields.rows_hash.each do |name, value|
+
+
+ -
+
+
+
# When %{I fill in "#{name}" with "#{value}"}
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
+
+
+ -
+
+
+
# select(value, :from => field)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^(?:|I )check "([^"]*)"$/ do |field|
+
+
+ -
+ 3
+
+
check(field)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
+
+
+ -
+ 3
+
+
uncheck(field)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
+
+
+ -
+ 15
+
+
choose(field)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
+
+
+ -
+
+
+
# attach_file(field, File.expand_path(path))
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Then /^(?:|I )should see "([^"]*)"$/ do |text|
+
+
+ -
+
+
+
# if page.respond_to? :should
+
+
+ -
+
+
+
# page.should have_content(text)
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert page.has_content?(text)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
+
+
+ -
+
+
+
# regexp = Regexp.new(regexp)
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# if page.respond_to? :should
+
+
+ -
+
+
+
# page.should have_xpath('//*', :text => regexp)
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert page.has_xpath?('//*', :text => regexp)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
+
+
+ -
+ 17
+
+
if page.respond_to? :should
+
+
+ -
+ 17
+
+
page.should have_no_content(text)
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
assert page.has_no_content?(text)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
+
+
+ -
+
+
+
# regexp = Regexp.new(regexp)
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# if page.respond_to? :should
+
+
+ -
+
+
+
# page.should have_no_xpath('//*', :text => regexp)
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert page.has_no_xpath?('//*', :text => regexp)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
+
+
+ -
+
+
+
# with_scope(parent) do
+
+
+ -
+
+
+
# field = find_field(field)
+
+
+ -
+
+
+
# field_value = (field.tag_name == 'textarea') ? field.text : field.value
+
+
+ -
+
+
+
# if field_value.respond_to? :should
+
+
+ -
+
+
+
# field_value.should =~ /#{value}/
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert_match(/#{value}/, field_value)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
+
+
+ -
+
+
+
# with_scope(parent) do
+
+
+ -
+
+
+
# field = find_field(field)
+
+
+ -
+
+
+
# field_value = (field.tag_name == 'textarea') ? field.text : field.value
+
+
+ -
+
+
+
# if field_value.respond_to? :should_not
+
+
+ -
+
+
+
# field_value.should_not =~ /#{value}/
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert_no_match(/#{value}/, field_value)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^the "([^"]*)" field should have the error "([^"]*)"$/ do |field, error_message|
+
+
+ -
+
+
+
# element = find_field(field)
+
+
+ -
+
+
+
# classes = element.find(:xpath, '..')[:class].split(' ')
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# form_for_input = element.find(:xpath, 'ancestor::form[1]')
+
+
+ -
+
+
+
# using_formtastic = form_for_input[:class].include?('formtastic')
+
+
+ -
+
+
+
# error_class = using_formtastic ? 'error' : 'field_with_errors'
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# if classes.respond_to? :should
+
+
+ -
+
+
+
# classes.should include(error_class)
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert classes.include?(error_class)
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# if page.respond_to?(:should)
+
+
+ -
+
+
+
# if using_formtastic
+
+
+ -
+
+
+
# error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
+
+
+ -
+
+
+
# error_paragraph.should have_content(error_message)
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# page.should have_content("#{field.titlecase} #{error_message}")
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# if using_formtastic
+
+
+ -
+
+
+
# error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
+
+
+ -
+
+
+
# assert error_paragraph.has_content?(error_message)
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert page.has_content?("#{field.titlecase} #{error_message}")
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^the "([^"]*)" field should have no error$/ do |field|
+
+
+ -
+
+
+
# element = find_field(field)
+
+
+ -
+
+
+
# classes = element.find(:xpath, '..')[:class].split(' ')
+
+
+ -
+
+
+
# if classes.respond_to? :should
+
+
+ -
+
+
+
# classes.should_not include('field_with_errors')
+
+
+ -
+
+
+
# classes.should_not include('error')
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert !classes.include?('field_with_errors')
+
+
+ -
+
+
+
# assert !classes.include?('error')
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
+
+
+ -
+
+
+
# with_scope(parent) do
+
+
+ -
+
+
+
# field_checked = find_field(label)['checked']
+
+
+ -
+
+
+
# if field_checked.respond_to? :should
+
+
+ -
+
+
+
# field_checked.should be_true
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert field_checked
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
+
+
+ -
+
+
+
# with_scope(parent) do
+
+
+ -
+
+
+
# field_checked = find_field(label)['checked']
+
+
+ -
+
+
+
# if field_checked.respond_to? :should
+
+
+ -
+
+
+
# field_checked.should be_false
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert !field_checked
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^(?:|I )should be on (.+)$/ do |page_name|
+
+
+ -
+
+
+
# current_path = URI.parse(current_url).path
+
+
+ -
+
+
+
# if current_path.respond_to? :should
+
+
+ -
+
+
+
# # current_path.should == path_to(page_name)
+
+
+ -
+
+
+
# # else
+
+
+ -
+
+
+
# # assert_equal path_to(page_name), current_path
+
+
+ -
+
+
+
# # end
+
+
+ -
+
+
+
# # end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
+
+
+ -
+
+
+
# query = URI.parse(current_url).query
+
+
+ -
+
+
+
# actual_params = query ? CGI.parse(query) : {}
+
+
+ -
+
+
+
# expected_params = {}
+
+
+ -
+
+
+
# expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# if actual_params.respond_to? :should
+
+
+ -
+
+
+
# actual_params.should == expected_params
+
+
+ -
+
+
+
# else
+
+
+ -
+
+
+
# assert_equal expected_params, actual_params
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^show me the page$/ do
+
+
+ -
+
+
+
# save_and_open_page
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^"([^"]*)" is selected for "([^"]*)"$/ do |selected_text, dropdown|
+
+
+ -
+ 5
+
+
select selected_text, :from => dropdown
+
+
+ -
+
+
+
#msg = "Selected: #{sb_selected.text.inspect} - value:#{sb_selected.value.inspect}"
+
+
+ -
+
+
+
#assert page.has_select?(dropdown, selected: selected_text)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Then /^I should see a field "([^"]*)"$/ do |name|
+
+
+ -
+
+
+
# expectation = :should
+
+
+ -
+
+
+
# begin
+
+
+ -
+
+
+
# field = find_field(name)
+
+
+ -
+
+
+
# rescue Capybara::ElementNotFound
+
+
+ -
+
+
+
# # In Capybara 0.4+ #find_field raises an error instead of returning nil
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
# field.send(expectation, be_present)
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
Given /the following admins exist/ do |admins_table|
+
+
+ -
+ 25
+
+
admins_table.hashes.each do |admin|
+
+
+ -
+ 25
+
+
Admin.create admin
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see current semester "(.*)" title/ do |text|
+
+
+ -
+ 3
+
+
expect(page).to have_content(text)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make an update for current semester to "(.*)"/ do |text|
+
+
+ -
+ 3
+
+
input = text.split(' ')
+
+
+ -
+ 3
+
+
semester, year = input[0], input[1]
+
+
+ -
+ 3
+
+
steps %Q{When I choose "#{semester}" from semester list}
+
+
+ -
+ 3
+
+
steps %Q{When I input year "#{year}" for current semester}
+
+
+ -
+ 3
+
+
click_button("update_current_semester")
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I choose "(.*)" from semester list/ do |semester|
+
+
+ -
+ 9
+
+
page.find(:xpath, '//*[@id="update_current_semester_semester"]',visible: false).all(:css, 'option').find { |o| o.text == semester }.select_option
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I input year "(.*)" for current semester/ do |year|
+
+
+ -
+ 3
+
+
page.find(:xpath, '//*[@id="update_current_semester_year"]').set(year)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see courses "(.*)"/ do |course_list|
+
+
+ -
+ 10
+
+
course_list.to_s.split(", ").each do |course_name|
+
+
+ -
+ 31
+
+
expect(page).to have_content(course_name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can not see course "(.*)"/ do |course|
+
+
+ -
+ 1
+
+
expect(page).to have_no_content(course)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see tutor "(.*)" with tutor hours (.*)/ do |first,num|
+
+
+ -
+ 3
+
+
expect(page).to have_content(first)
+
+
+ -
+ 3
+
+
expect(page).to have_content(num)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see course "(.*)" only once/ do |course|
+
+
+ -
+ 1
+
+
expect(page).to have_content(course, maximum: 1)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make an update for courses to "(.*)"/ do |course_list|
+
+
+ -
+ 4
+
+
obj = page.find(:xpath, '//*[@id="update_courses_courses"]',visible: false)
+
+
+ -
+
+
+
# separate course list into a newline separated list rather than comma separated
+
+
+ -
+ 4
+
+
obj.set(course_list.to_s.gsub(/, /, "\r\n"))
+
+
+ -
+
+
+
# fill_in obj.field, with: course_list.to_s.gsub(/,/, "/r/n")
+
+
+ -
+ 4
+
+
click_button("update_courses")
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I update admin password with password "(.*)" and confirmation password "(.*)"/ do |pass, confirmation|
+
+
+ -
+ 2
+
+
page.find(:xpath, '//*[@id="update_password_password"]').set(pass)
+
+
+ -
+ 2
+
+
page.find(:xpath, '//*[@id="update_password_password_confirmation"]').set(confirmation)
+
+
+ -
+ 2
+
+
click_button("update_password")
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see the tutor name "(.*)"/ do |name|
+
+
+ -
+ 2
+
+
expect(page).to have_content(name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see the composition score of "(.*)"/ do |score|
+
+
+ -
+ 2
+
+
expect(page).to have_content(score)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /"(.*)" has a meeting with tutor "(.*)" meeting id "(.*)" request with tutuee id "(.*)" course name "(.*)" and evaluation status "(.*)" knowledge "(.*)" helpful "(.*)" clarity "(.*)"/ do |first_name, tutorname, meetid, tuteeid, coursename,stat, kl, hp, cl|
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
tutee = Tutee.find_by_first_name(first_name)
+
+
+ -
+ 6
+
+
tutor = Tutor.find_by_first_name(tutorname)
+
+
+ -
+ 6
+
+
request = Request.new()
+
+
+ -
+ 6
+
+
request.tutee_id = tutee.id
+
+
+ -
+ 6
+
+
course = Course.find_by_name(coursename)
+
+
+ -
+ 6
+
+
course.name = coursename
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
request.course_id = course.id
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
request.save!
+
+
+ -
+ 6
+
+
eval = Evaluation.new()
+
+
+ -
+ 6
+
+
eval.status = stat
+
+
+ -
+ 6
+
+
eval.knowledgeable = kl
+
+
+ -
+ 6
+
+
eval.helpful = hp
+
+
+ -
+ 6
+
+
eval.clarity = cl
+
+
+ -
+ 6
+
+
eval.save!
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
meeting = Meeting.new()
+
+
+ -
+ 6
+
+
meeting.request_id = request.id
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
meeting.tutor =tutor
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
meeting.evaluation_id = eval.id
+
+
+ -
+
+
+
+
+
+ -
+ 6
+
+
meeting.save!
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see sids "(.*)"/ do |sid_list|
+
+
+ -
+ 12
+
+
sid_list.to_s.split(", ").each do |sid|
+
+
+ -
+ 40
+
+
expect(page).to have_content(sid)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
Then /I can not see sid "(.*)"/ do |sid|
+
+
+ -
+ 12
+
+
expect(page).to have_no_content(sid)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make an update for CS61A scholars to "(.*)"/ do |sid_list|
+
+
+ -
+ 2
+
+
obj = page.find(:xpath, '//*[@id="update_student_priorities_CS61A"]',visible: false)
+
+
+ -
+ 2
+
+
obj.set(sid_list.to_s.gsub(/, /, "\r\n"))
+
+
+ -
+ 2
+
+
page.find(:xpath, '//*[@id="update_cs61a_scholars_button"]',visible: false).click
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make an update for CS61B scholars to "(.*)"/ do |sid_list|
+
+
+ -
+ 2
+
+
obj = page.find(:xpath, '//*[@id="update_student_priorities_CS61B"]',visible: false)
+
+
+ -
+ 2
+
+
obj.set(sid_list.to_s.gsub(/, /, "\r\n"))
+
+
+ -
+ 2
+
+
page.find(:xpath, '//*[@id="update_cs61b_scholars_button"]',visible: false).click
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make an update for CS61C scholars to "(.*)"/ do |sid_list|
+
+
+ -
+ 2
+
+
obj = page.find(:xpath, '//*[@id="update_student_priorities_CS61C"]',visible: false)
+
+
+ -
+ 2
+
+
obj.set(sid_list.to_s.gsub(/, /, "\r\n"))
+
+
+ -
+ 2
+
+
page.find(:xpath, '//*[@id="update_cs61c_scholars_button"]',visible: false).click
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make an update for CS70 scholars to "(.*)"/ do |sid_list|
+
+
+ -
+ 2
+
+
obj = page.find(:xpath, '//*[@id="update_student_priorities_CS70"]',visible: false)
+
+
+ -
+ 2
+
+
obj.set(sid_list.to_s.gsub(/, /, "\r\n"))
+
+
+ -
+ 2
+
+
page.find(:xpath, '//*[@id="update_cs70_scholars_button"]',visible: false).click
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
Given /the following courses exist/ do |courses_table|
+
+
+ -
+ 21
+
+
courses_table.hashes.each do |course|
+
+
+ -
+ 42
+
+
Course.create course
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
Given /the following meetings exist/ do |meetings_table|
+
+
+ -
+ 1
+
+
meetings_table.hashes.each do |meet|
+
+
+ -
+ 2
+
+
Meeting.create meet
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /the following evaluations exist/ do |evaluations_table|
+
+
+ -
+ 3
+
+
evaluations_table.hashes.each do |eval|
+
+
+ -
+ 4
+
+
Evaluation.create eval
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /can see my evaluation form with course name (.*)/ do |name|
+
+
+ -
+ 4
+
+
page.should have_content(name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /can see my evaluation form with tutor name (.*)/ do |name|
+
+
+ -
+ 4
+
+
page.should have_content(name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /can see my evaluation form with status(.*)/ do |name|
+
+
+ -
+ 4
+
+
page.should have_content(name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /"(.*)" had a meeting with tutor "(.*)" with meeting id "(.*)" request having tutuee id "(.*)" course name "(.*)" and evaluation status "(.*)" feedback "(.*)"/ do |first_name, tutorname, meetid, tuteeid, coursename,stat,feed|
+
+
+ -
+ 6
+
+
tutee = Tutee.find_by_first_name(first_name)
+
+
+ -
+ 6
+
+
tutor = Tutor.find_by_first_name(tutorname)
+
+
+ -
+ 6
+
+
request = Request.new()
+
+
+ -
+ 6
+
+
request.tutee_id = tutee.id
+
+
+ -
+ 6
+
+
course = Course.find_by_name(coursename)
+
+
+ -
+ 6
+
+
course.name = coursename
+
+
+ -
+ 6
+
+
request.course_id = course.id
+
+
+ -
+ 6
+
+
request.save!
+
+
+ -
+ 6
+
+
eval = Evaluation.new()
+
+
+ -
+ 6
+
+
eval.status = stat
+
+
+ -
+ 6
+
+
eval.feedback = feed
+
+
+ -
+ 6
+
+
eval.save!
+
+
+ -
+ 6
+
+
meeting = Meeting.new()
+
+
+ -
+ 6
+
+
meeting.request_id = request.id
+
+
+ -
+ 6
+
+
meeting.tutor_id = tutor.id
+
+
+ -
+ 6
+
+
meeting.evaluation_id = eval.id
+
+
+ -
+ 6
+
+
meeting.save!
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /"(.*)" had a meeting with tutor "(.*)" with meeting id "(.*)" request having tutuee id "(.*)" course name "(.*)" and evaluation status "(.*)" times "(.*)" and locations "(.*)"/ do |first_name, tutorname, meetid, tuteeid, coursename,stat, times, locations|
+
+
+ -
+ 2
+
+
tutee = Tutee.find_by_first_name(first_name)
+
+
+ -
+ 2
+
+
tutor = Tutor.find_by_first_name(tutorname)
+
+
+ -
+ 2
+
+
request = Request.new()
+
+
+ -
+ 2
+
+
puts "Tutee id"
+
+
+ -
+ 2
+
+
puts tutee.first_name
+
+
+ -
+ 2
+
+
request.tutee_id = tutee.id
+
+
+ -
+ 2
+
+
course = Course.find_by_name(coursename)
+
+
+ -
+ 2
+
+
course.name = coursename
+
+
+ -
+ 2
+
+
puts "course id"
+
+
+ -
+ 2
+
+
request.course_id = course.id
+
+
+ -
+ 2
+
+
puts course.id
+
+
+ -
+ 2
+
+
request.save!
+
+
+ -
+ 2
+
+
eval = Evaluation.new()
+
+
+ -
+ 2
+
+
eval.status = stat
+
+
+ -
+ 2
+
+
eval.save!
+
+
+ -
+ 2
+
+
meeting = Meeting.new()
+
+
+ -
+ 2
+
+
meeting.request_id = request.id
+
+
+ -
+ 2
+
+
meeting.times = times.split(",")
+
+
+ -
+ 2
+
+
meeting.locations = locations.split(",")
+
+
+ -
+
+
+
+
+
+ -
+ 2
+
+
puts request.id
+
+
+ -
+ 2
+
+
meeting.tutor_id = tutor.id
+
+
+ -
+ 2
+
+
puts tutor.id
+
+
+ -
+ 2
+
+
meeting.evaluation_id = eval.id
+
+
+ -
+ 2
+
+
puts eval.id
+
+
+ -
+ 2
+
+
meeting.save!
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
####################### NOT WORKING PROPERLY
+
+
+ -
+
+
+
# Given /"(.*)" requests tutoring for course name "(.*)"/ do |first_name, coursename,|
+
+
+ -
+
+
+
# tutee = Tutee.find_by_first_name(first_name)
+
+
+ -
+
+
+
# request = Request.new()
+
+
+ -
+
+
+
# request.tutee_id = tutee.id
+
+
+ -
+
+
+
# course = Course.find_by_name(coursename)
+
+
+ -
+
+
+
# course.name = coursename
+
+
+ -
+
+
+
# request.course_id = course.id
+
+
+ -
+
+
+
# request.save!
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Given /"(.*)" gets matched with tutor "(.*)" for course name "(.*)"/ do |first_name, tutorname, coursename,|
+
+
+ -
+
+
+
# tutee = Tutee.find_by_first_name(first_name)
+
+
+ -
+
+
+
# tutor = Tutor.find_by_first_name(tutorname)
+
+
+ -
+
+
+
# request = Request.new()
+
+
+ -
+
+
+
# request.tutee_id = tutee.id
+
+
+ -
+
+
+
# course = Course.find_by_name(coursename)
+
+
+ -
+
+
+
# course.name = coursename
+
+
+ -
+
+
+
# request.course_id = course.id
+
+
+ -
+
+
+
# request.save!
+
+
+ -
+
+
+
# eval = Evaluation.new()
+
+
+ -
+
+
+
# eval.status = "Pending"
+
+
+ -
+
+
+
# eval.save!
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# Then /I should have a new evaluation form created/ do
+
+
+ -
+
+
+
# eval = Evaluation.new()
+
+
+ -
+
+
+
# eval.status = "Pending"
+
+
+ -
+
+
+
# eval.save!
+
+
+ -
+
+
+
# end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
And /I fill out the evaluation that didn't happen and submit/ do
+
+
+ -
+ 1
+
+
step %{I choose "radioButton"}
+
+
+ -
+ 1
+
+
step %{I press "Submit Evaluation"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
And /I fill out the evaluation and submit/ do
+
+
+ -
+ 2
+
+
step %{I choose "radioButton2"}
+
+
+ -
+ 2
+
+
step %{I fill in "disabled1" with "Tree Recursion, blahh blahh"}
+
+
+ -
+ 2
+
+
step %{I choose "disabled8"}
+
+
+ -
+ 2
+
+
step %{I fill in "disabled9" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 2
+
+
step %{I fill in "disabled10" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 2
+
+
step %{I fill in "disabled11" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 2
+
+
step %{I choose "disabled13"}
+
+
+ -
+ 2
+
+
step %{I choose "disabled18"}
+
+
+ -
+ 2
+
+
step %{I choose "disabled23"}
+
+
+ -
+ 2
+
+
step %{I choose "disabled28"}
+
+
+ -
+ 2
+
+
step %{I fill in "disabled32" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 2
+
+
step %{I press "Submit Evaluation"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
And /I partially fill out the evaluation and submit/ do
+
+
+ -
+ 1
+
+
step %{I choose "radioButton2"}
+
+
+ -
+ 1
+
+
step %{I fill in "disabled1" with "Tree Recursion, blahh blahh"}
+
+
+ -
+ 1
+
+
step %{I choose "disabled8"}
+
+
+ -
+ 1
+
+
step %{I fill in "disabled9" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 1
+
+
step %{I fill in "disabled10" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 1
+
+
step %{I fill in "disabled11" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 1
+
+
step %{I fill in "disabled32" with "The bamba was a good movie, so tragic though. I like peanut butter scotch. I made ham."}
+
+
+ -
+ 1
+
+
step %{I press "Submit Evaluation"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /I was given the page with evaluation hash id "(.*)"/ do |hash|
+
+
+ -
+
+
+
# p Evaluation.all
+
+
+ -
+
+
+
@tutors = Tutor.all
+
+
+ -
+
+
+
p @tutors
+
+
+ -
+
+
+
@tutees = Tutee.all
+
+
+ -
+
+
+
p @tutees
+
+
+ -
+
+
+
@evaluation = Evaluation.all
+
+
+ -
+
+
+
p @evaluation
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# step %{I partially fill out the evaluation and submit}
+
+
+ -
+
+
+
# p eval
+
+
+ -
+
+
+
# visit edit_evaluation_path(@eval.hash_id)
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Given /I login as "(.*)"/ do |name|
+
+
+ -
+
+
+
# step %{I am on the login page}
+
+
+ -
+
+
+
# step %{I fill in "username" with "#{Tutee.find_by_first_name(name).email}"}
+
+
+ -
+
+
+
# step %{I fill in "password" with "topsecret"}
+
+
+ -
+
+
+
# step %{press "Log in"}
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
When /I click on "(.*)" link/ do |link|
+
+
+ -
+ 12
+
+
click_link(link)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /can see my history request with first_name "(.*)"/ do |name|
+
+
+ -
+ 1
+
+
page.should have_content(name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /can see my history request with course_name "(.*)"/ do |name|
+
+
+ -
+ 1
+
+
page.should have_content(name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /can see my history request with status evaluation "(.*)"/ do |status|
+
+
+ -
+ 1
+
+
page.should have_content(status)
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
Given /the following requests exist/ do |requests_table|
+
+
+ -
+ 10
+
+
requests_table.hashes.each do |request|
+
+
+ -
+ 12
+
+
Request.create request
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make a request for "(.*)" with topic "(.*)"/ do |course, topic|
+
+
+ -
+ 2
+
+
click_link("Request")
+
+
+ -
+ 2
+
+
steps %Q{When I choose "#{course}" from course list}
+
+
+ -
+ 2
+
+
steps %Q{When I input subject "#{topic}" I want to cover}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I choose "(.*)" from course list/ do |course|
+
+
+ -
+ 2
+
+
steps %Q{When I select "#{course}" from "request_course_id"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I input subject "(.*)" I want to cover/ do |subject|
+
+
+ -
+ 2
+
+
page.find(:xpath, '//*[@id="request_subject"]').set(subject)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I select Request Tuttor button/ do
+
+
+ -
+ 4
+
+
click_button('request_tutor')
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then /I can see "(.*)" message pop up/ do |text|
+
+
+ -
+ 6
+
+
expect(page).to have_content(text)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I make a request for "(.*)" without inputting topic/ do |course|
+
+
+ -
+ 2
+
+
click_link("Request")
+
+
+ -
+ 2
+
+
steps %Q{I choose #{course} from course list}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /I choose "(.*)" from meeting time list/ do |time|
+
+
+ -
+ 7
+
+
page.find(:xpath, '//*[@id="request_meeting_length"]',visible: false).all(:css, 'option').find { |o| o.text == time }.select_option
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Given /^(?:|I )am on "(.*)'s" tutee page/ do |tutee_name|
+
+
+ -
+
+
+
# visit tutee_path(Tutee.find_by_first_name(tutee_name))
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
require 'uri'
+
+
+ -
+ 1
+
+
require 'cgi'
+
+
+ -
+ 1
+
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
+
+
+ -
+ 1
+
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
module WithinHelpers
+
+
+ -
+ 1
+
+
def with_scope(locator)
+
+
+ -
+
+
+
locator ? within(*selector_for(locator)) { yield } : yield
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
World(WithinHelpers)
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /the following tutees exist/ do |tutees_table|
+
+
+ -
+ 42
+
+
tutees_table.hashes.each do |tutee|
+
+
+ -
+ 91
+
+
Tutee.create tutee
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /^(?:|I )am on (.+)$/ do |page_name|
+
+
+ -
+ 115
+
+
visit path_to(page_name)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
And /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
+
+
+ -
+ 201
+
+
fill_in(field, :with => value)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
And /^(?:|I )change "([^"]*)" to "([^"]*)"$/ do |field, value|
+
+
+ -
+ 12
+
+
fill_in(field, :with => value)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Then(/^I should see "(.*?)"$/) do |arg1|
+
+
+ -
+ 49
+
+
page.should have_content("#{arg1}")
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^(?:|I )press "([^"]*)"$/ do |button|
+
+
+ -
+ 98
+
+
click_button(button)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
When /^(?:|I )press link "([^"]*)"$/ do |link|
+
+
+ -
+ 40
+
+
click_link(link)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
And /^(?:|I )should be on (.+)$/ do |page_name|
+
+
+ -
+ 87
+
+
current_path = URI.parse(current_url).path
+
+
+ -
+ 87
+
+
if current_path.respond_to? :should
+
+
+ -
+ 87
+
+
current_path.should == path_to(page_name)
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
assert_equal path_to(page_name), current_path
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
And /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
+
+
+ -
+ 3
+
+
select(value, :from => field)
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
Given /I login as "(.*)"/ do |name|
+
+
+ -
+ 12
+
+
step %{I am on the login page}
+
+
+ -
+ 12
+
+
step %{I fill in "username" with "#{Tutee.find_by_first_name(name).email}"}
+
+
+ -
+ 12
+
+
step %{I fill in "password" with "topsecret"}
+
+
+ -
+ 12
+
+
step %{press "Log in"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# When /^(?:|I )try to access "([^"]*)"'s (.+)$/ do |tutee_first_name, page_name|
+
+
+ -
+
+
+
# # requested_uri = URI.parse(current_url)
+
+
+ -
+
+
+
# # expect(current_uri).eq(tutees/10)
+
+
+ -
+
+
+
# other_profile = Tutee.find_by_first_name(tutee_first_name)
+
+
+ -
+
+
+
# other_profile_id = Tutee.find(other_profile).id
+
+
+ -
+
+
+
# bad_url = "/tutees/"
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# good_url = browser.get()
+
+
+ -
+
+
+
# req_url = browser.refresh()
+
+
+ -
+
+
+
# assert_equal (bad_url)
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# Given /^(?:|I )am on the user page for "(.*)"/ do |email|
+
+
+ -
+
+
+
# visit tutee_path(Tutee.find_by_email(email))
+
+
+ -
+
+
+
# end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
module NavigationHelpers
+
+
+ -
+
+
+
# Maps a name to a path. Used by the
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# When /^I go to (.+)$/ do |page_name|
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# step definition in web_steps.rb
+
+
+ -
+
+
+
#
+
+
+ -
+ 1
+
+
def path_to(page_name)
+
+
+ -
+ 209
+
+
case page_name
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the login page/
+
+
+ -
+ 47
+
+
new_tutee_session_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the user page for "(.*)"$/
+
+
+ -
+ 18
+
+
tutee_path(Tutee.find_by_email($1)[:id])
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the update page for "(.*)"$/
+
+
+ -
+ 24
+
+
edit_tutee_registration_path(Tutee.find_by_email($1)[:id])
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the public edit page with feedback "(.*)"$/
+
+
+ -
+ 1
+
+
p Evaluation.all
+
+
+ -
+ 1
+
+
@allevals = Evaluation.all
+
+
+ -
+ 1
+
+
@eval1 = Evaluation.new()
+
+
+ -
+ 1
+
+
@allevals.each do |eval|
+
+
+ -
+ 1
+
+
if eval.feedback == ($1)
+
+
+ -
+ 1
+
+
hash = eval.hash_id
+
+
+ -
+ 1
+
+
@eval1 = eval.clone
+
+
+ -
+ 1
+
+
p hash
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
edit_evaluation_path(@eval1)
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the create account page/
+
+
+ -
+ 22
+
+
new_tutee_registration_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /"(.*)'s" tutee page$/
+
+
+ -
+ 14
+
+
tutee_path(Tutee.find_by_first_name($1))
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the update semester page/
+
+
+ -
+ 3
+
+
admin_update_semester_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the update courses page/
+
+
+ -
+ 6
+
+
admin_update_courses_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the update admin password/
+
+
+ -
+ 2
+
+
admin_update_password_path
+
+
+ -
+
+
+
when /the update priorities page/
+
+
+ -
+ 8
+
+
admin_update_student_priorities_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the rating tutors page/
+
+
+ -
+ 2
+
+
admin_rating_tutors_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /^the home\s?page$/
+
+
+ -
+ 6
+
+
'/'
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the admin landing page/
+
+
+ -
+ 28
+
+
admin_landing_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the admin home page/
+
+
+ -
+ 20
+
+
admin_home_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /tutor signup page/
+
+
+ -
+
+
+
new_tutor_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the welcome page/
+
+
+ -
+ 2
+
+
homepage_path
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the tutor update page for "(.*)"$/
+
+
+ -
+ 3
+
+
edit_tutor_path(Tutor.find_by_email($1)[:id])
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /the tutor page for "(.*)"$/
+
+
+ -
+ 2
+
+
tutor_path(Tutor.find_by_email($1)[:id])
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /find students page for "(.*)"$/
+
+
+ -
+ 1
+
+
tutor_find_students_path(Tutor.find_by_email($1)[:id])
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /tutor index page/
+
+
+ -
+
+
+
tutors_path
+
+
+ -
+
+
+
# Add more mappings here.
+
+
+ -
+
+
+
# Here is an example that pulls values out of the Regexp:
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# when /^(.*)'s profile page$/i
+
+
+ -
+
+
+
# user_profile_path(User.find_by_login($1))
+
+
+ -
+
+
+
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
puts "Can't find mapping"
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
World(NavigationHelpers)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
# TL;DR: YOU SHOULD DELETE THIS FILE
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# This file is used by web_steps.rb, which you should also delete
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# You have been warned
+
+
+ -
+ 1
+
+
module HtmlSelectorsHelpers
+
+
+ -
+
+
+
# Maps a name to a selector. Used primarily by the
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# When /^(.+) within (.+)$/ do |step, scope|
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# step definitions in web_steps.rb
+
+
+ -
+
+
+
#
+
+
+ -
+ 1
+
+
def selector_for(locator)
+
+
+ -
+
+
+
case locator
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when "the page"
+
+
+ -
+
+
+
"html > body"
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# Add more mappings here.
+
+
+ -
+
+
+
# Here is an example that pulls values out of the Regexp:
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# when /^the (notice|error|info) flash$/
+
+
+ -
+
+
+
# ".flash.#{$1}"
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# You can also return an array to use a different selector
+
+
+ -
+
+
+
# type, like:
+
+
+ -
+
+
+
#
+
+
+ -
+
+
+
# when /the header/
+
+
+ -
+
+
+
# [:xpath, "//header"]
+
+
+ -
+
+
+
+
+
+ -
+
+
+
# This allows you to provide a quoted selector as the scope
+
+
+ -
+
+
+
# for "within" steps as was previously the default for the
+
+
+ -
+
+
+
# web steps:
+
+
+ -
+
+
+
+
+
+ -
+
+
+
when /^"(.+)"$/
+
+
+ -
+
+
+
$1
+
+
+ -
+
+
+
+
+
+ -
+
+
+
else
+
+
+ -
+
+
+
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
+
+
+ -
+
+
+
"Now, go and add a mapping in #{__FILE__}"
+
+
+ -
+
+
+
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
World(HtmlSelectorsHelpers)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
FactoryBot.define do
+
+
+ -
+ 1
+
+
factory :admin do
+
+
+ -
+ 1
+
+
password { "" }
+
+
+ -
+ 1
+
+
statistics_semester { "MyString" }
+
+
+ -
+ 1
+
+
current_semester { "MyString" }
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
FactoryBot.define do
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
factory :tutor do
+
+
+ -
+
+
+
# id {1}
+
+
+ -
+ 1
+
+
type_of_tutor {"CSM"}
+
+
+ -
+ 1
+
+
grade_level {"SENIOR"}
+
+
+ -
+ 1
+
+
first_name {"Alvin"}
+
+
+ -
+ 1
+
+
last_name {"NGUYEN"}
+
+
+ -
+ 1
+
+
email {"alvinnguyen@berkeley.edu"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
factory :request do
+
+
+ -
+ 1
+
+
tutee {create(:tutee)}
+
+
+ -
+ 1
+
+
course {create(:course)}
+
+
+ -
+
+
+
# subject {"tree"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
factory :meeting do
+
+
+ -
+ 1
+
+
tutor
+
+
+ -
+ 1
+
+
request
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
FactoryBot.define do
+
+
+ -
+ 1
+
+
factory :course do
+
+
+ -
+
+
+
# id {1}
+
+
+ -
+
+
+
# name {"CS61A"}
+
+
+ -
+
+
+
# semester {"Sp2019"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
FactoryBot.define do
+
+
+ -
+ 1
+
+
factory :evaluation do
+
+
+ -
+ 1
+
+
id {1000}
+
+
+ -
+ 1
+
+
took_place {"No"}
+
+
+ -
+
+
+
end
+
+
+ -
+
+
+
end
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 1
+
+
FactoryBot.define do
+
+
+ -
+ 1
+
+
factory :tutee do
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
first_name {'Bob'}
+
+
+ -
+ 1
+
+
last_name {'Burgers'}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {123456789}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
password {'topsecret'}
+
+
+ -
+ 1
+
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
+
+
confirmed_at {'2019-05-07 05:07:48'}
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
factory :invalid_firstname_b, parent: :tutee do
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
first_name {nil}
+
+
+ -
+ 1
+
+
last_name {'Burgers'}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {'123456789'}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
first_name {'Bob'}
+
+
+ -
+ 1
+
+
last_name {'Burgers'}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {123456789}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
password {'topsecret'}
+
+
+ -
+ 1
+
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
+
+
confirmed_at {'2019-05-07 05:07:48'}
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
factory :invalid_lastname_b, parent: :tutee do
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
first_name {'Bob'}
+
+
+ -
+ 1
+
+
last_name {nil}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {123456789}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
first_name {'Bob'}
+
+
+ -
+ 1
+
+
last_name {'Burgers'}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {123456789}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
password {'topsecret'}
+
+
+ -
+ 1
+
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
+
+
confirmed_at {'2019-05-07 05:07:48'}
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
factory :invalid_firstname_d, parent: :tutee do
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
first_name {'Bob123'}
+
+
+ -
+ 1
+
+
last_name {"Burgers"}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {123456789}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
first_name {'Bob'}
+
+
+ -
+ 1
+
+
last_name {'Burgers'}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {123456789}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
password {'topsecret'}
+
+
+ -
+ 1
+
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
+
+
confirmed_at {'2019-05-07 05:07:48'}
+
+
+ -
+
+
+
end
+
+
+ -
+ 1
+
+
factory :invalid_lastname_d, parent: :tutee do
+
+
+ -
+
+
+
+
+
+ -
+ 1
+
+
first_name {'Bob'}
+
+
+ -
+ 1
+
+
last_name {"Burgers123"}
+
+
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
+
+
sid {123456789}
+
+
+ -
+ 1
+
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
+
+
first_name {'Bob'}
- -
-
+
-
+ 1
-
+ last_name {'Burgers'}
- -
-
+
-
+ 1
-
require "rails"
+ email {'bobburgers@berkeley.edu'}
- -
-
+
-
+ 1
-
# Pick the frameworks you want:
+ sid {123456789}
- -
+
-
+ 1
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
-
require "active_model/railtie"
+ password {'topsecret'}
- -
+
-
+ 1
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
-
require "active_job/railtie"
+ confirmed_at {'2019-05-07 05:07:48'}
- -
+
-
-
require "active_record/railtie"
+ end
- -
-
+
-
+ 1
-
require "active_storage/engine"
+ factory :invalid_email_b, parent: :tutee do
- -
+
-
-
require "action_controller/railtie"
+
- -
-
+
-
+ 1
-
require "action_mailer/railtie"
+ first_name {'Bob'}
- -
+
-
+ 1
+
last_name {"Burgers"}
+
+
+ -
+ 1
-
require "action_view/railtie"
+ email {nil}
- -
+
-
+ 1
+
sid {123456789}
+
+
+ -
+ 1
-
require "action_cable/engine"
+ birthdate {'1992-01-01'}
- -
+
-
+ 1
+
first_name {'Bob'}
+
+
+ -
+ 1
-
require "sprockets/railtie"
+ last_name {'Burgers'}
- -
+
-
+ 1
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
-
# require "rails/test_unit/railtie"
+ sid {123456789}
- -
+
-
+ 1
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
-
+ password {'topsecret'}
- -
+
-
+ 1
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
-
# Require the gems listed in Gemfile, including any gems
+ confirmed_at {'2019-05-07 05:07:48'}
- -
+
-
-
# you've limited to :test, :development, or :production.
+ end
- -
-
+
-
+ 1
-
Bundler.require(*Rails.groups)
+ factory :invalid_email_i, parent: :tutee do
- -
+
-
- -
-
+
-
+ 1
-
module Cs370
+ first_name {'Bob'}
- -
-
+
-
+ 1
-
class Application < Rails::Application
+ last_name {"Burgers"}
- -
-
+
-
+ 1
-
# Initialize configuration defaults for originally generated Rails version.
+ email {'bobburgers@gmail.com'}
- -
+
-
+ 1
+
sid {123456789}
+
+
+ -
+ 1
-
config.load_defaults 5.2
+ birthdate {'1992-01-01'}
- -
+
-
+ 1
+
first_name {'Bob'}
+
+
+ -
+ 1
-
config.time_zone = "Pacific Time (US & Canada)"
+ last_name {'Burgers'}
- -
+
-
+ 1
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
-
+ sid {123456789}
- -
+
-
+ 1
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
-
# Settings in config/environments/* take precedence over those specified here.
+ password {'topsecret'}
- -
+
-
+ 1
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
-
# Application configuration can go into files in config/initializers
+ confirmed_at {'2019-05-07 05:07:48'}
- -
+
-
-
# -- all .rb files in that directory are automatically loaded after loading
+ end
- -
-
+
-
+ 1
-
# the framework and any gems in your application.
+ factory :invalid_email_f, parent: :tutee do
- -
+
-
- -
-
+
-
+ 1
-
# config.before_configuration do
+ first_name {'Bob'}
- -
+
-
+ 1
+
last_name {"Burgers"}
+
+
+ -
+ 1
-
# env_file = File.join(Rails.root, 'config','local_env.yml')
+ email {'bobburgers@berkeley.edu'}
- -
+
-
+ 1
+
sid {123456789}
+
+
+ -
+ 1
-
# p env_file
+ birthdate {'3992-01-01'}
- -
+
-
+ 1
+
first_name {'Bob'}
+
+
+ -
+ 1
-
# YAML.load(File.open(env_file)).each do |key, value|
+ last_name {'Burgers'}
- -
+
-
+ 1
+
email {'bobburgers@berkeley.edu'}
+
+
+ -
+ 1
-
# ENV[key.to_s] = value
+ sid {123456789}
- -
+
-
+ 1
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
-
# end if File.exists?(env_file)
+ password {'topsecret'}
- -
+
-
+ 1
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
-
# end
+ confirmed_at {'2019-05-07 05:07:48'}
- -
+
-
end
- -
-
+
-
+ 1
-
+ factory :invalid_sid, parent: :tutee do
- -
+
-
-
# Don't generate system test files.\end
+
- -
-
+
-
+ 1
-
end
+ first_name {'Bob'}
-
-
-
-
-
-
-
-
-
-
-
- -
+
-
1
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+ last_name {'Burgers'}
- -
-
+
-
+ 1
-
+ email {'bobburgers@berkeley.edu'}
- -
+
-
1
-
require 'bundler/setup' # Set up gems listed in the Gemfile.
+ sid {nil}
- -
+
-
+ 1
+
birthdate {'1992-01-01'}
+
+
+ -
+ 1
-
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
+ first_name {'Bob'}
-
-
-
-
+
+ 1
+
+ last_name {'Burgers'}
+
-
-
-
-
-
+ -
+ 1
+
+
email {'bobburgers@berkeley.edu'}
+
- -
+
-
+ 1
+
sid {123456789}
+
+
+ -
+ 1
-
# Load the Rails application.
+ birthdate {'1992-01-01'}
- -
+
-
1
-
require_relative 'application'
+ password {'topsecret'}
- -
+
-
+ 1
+
password_confirmation {'topsecret'}
+
+
+ -
+ 1
-
+ confirmed_at {'2019-05-07 05:07:48'}
- -
+
-
-
# Initialize the Rails application.
+ end
- -
+
-
-
Rails.application.initialize!
+ end
+
+
+
+
+
+
diff --git a/db/.DS_Store b/db/.DS_Store
index 644d0f3c..7db661cf 100644
Binary files a/db/.DS_Store and b/db/.DS_Store differ
diff --git a/db/migrate/.DS_Store b/db/migrate/.DS_Store
index 40333269..a532c5c0 100644
Binary files a/db/migrate/.DS_Store and b/db/migrate/.DS_Store differ
diff --git a/db/migrate/20191212031134_change_set_time_name.rb b/db/migrate/20191212031134_change_set_time_name.rb
new file mode 100644
index 00000000..8f248cdd
--- /dev/null
+++ b/db/migrate/20191212031134_change_set_time_name.rb
@@ -0,0 +1,5 @@
+class ChangeSetTimeName < ActiveRecord::Migration[5.2]
+ def change
+ rename_column :meetings, :setTime, :set_time
+ end
+end
diff --git a/db/migrate/20191212041101_add_locations_to_meetings.rb b/db/migrate/20191212041101_add_locations_to_meetings.rb
new file mode 100644
index 00000000..bc2ec51f
--- /dev/null
+++ b/db/migrate/20191212041101_add_locations_to_meetings.rb
@@ -0,0 +1,5 @@
+class AddLocationsToMeetings < ActiveRecord::Migration[5.2]
+ def change
+ add_column :meetings, :locations, :string, array: true, default: []
+ end
+end
diff --git a/db/migrate/20191212041235_add_set_location_to_meetings.rb b/db/migrate/20191212041235_add_set_location_to_meetings.rb
new file mode 100644
index 00000000..06375a8e
--- /dev/null
+++ b/db/migrate/20191212041235_add_set_location_to_meetings.rb
@@ -0,0 +1,5 @@
+class AddSetLocationToMeetings < ActiveRecord::Migration[5.2]
+ def change
+ add_column :meetings, :set_location, :string
+ end
+end
diff --git a/db/migrate/20191212195514_add_is_scheduled_to_meetings.rb b/db/migrate/20191212195514_add_is_scheduled_to_meetings.rb
new file mode 100644
index 00000000..49724aae
--- /dev/null
+++ b/db/migrate/20191212195514_add_is_scheduled_to_meetings.rb
@@ -0,0 +1,5 @@
+class AddIsScheduledToMeetings < ActiveRecord::Migration[5.2]
+ def change
+ add_column :meetings, :is_scheduled, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 8c124e8e..83a2769b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_12_03_195925) do
+ActiveRecord::Schema.define(version: 2019_12_12_195514) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -86,8 +86,11 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "times", default: [], array: true
- t.datetime "setTime"
+ t.datetime "set_time"
t.bigint "tutee_id"
+ t.string "locations", default: [], array: true
+ t.string "set_location"
+ t.boolean "is_scheduled", default: false
t.index ["evaluation_id"], name: "index_meetings_on_evaluation_id"
t.index ["request_id"], name: "index_meetings_on_request_id"
t.index ["tutee_id"], name: "index_meetings_on_tutee_id"
diff --git a/db/seeds.rb b/db/seeds.rb
index d4b04c53..9f1013ef 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -44,9 +44,6 @@
# Request.create!(:tutee_id => 1, :course_id => i + 1, :subject => course)
# end
-courses.each do |course|
- Course.create!(course)
-end
# requests.each do |request|
# Request.create!(request)
diff --git a/features/meeting.feature b/features/meeting.feature
new file mode 100644
index 00000000..a723677e
--- /dev/null
+++ b/features/meeting.feature
@@ -0,0 +1,40 @@
+Feature: Set up meting with tutor
+ As a tutee
+ I want to set up a tutoring meeting
+ So that I can meet with my tutor
+
+ Background: There exists a tutee annd courses
+ Given the following berkeley_classes exist:
+ |CS61A | CS61B | CS61C | CS70 | EE16A | CS88 | CS10 | DATA8 |id|
+ |true | false | false | false | false | false | false | false |1 |
+
+ Given the following courses exist:
+ | course_num | name | semester |
+ | 1 | CS61A | Sp2019 |
+
+ Given the following tutors exist:
+ | type_of_tutor| grade_level | email | password | password_confirmation | confirmed_at | id | first_name | last_name | id | berkeley_classes_id |
+ | 20 hour TA | 3rd | testtutor@berkeley.edu | topsecret | topsecret | 2019-05-07 05:07:48 | 1 | test | tutor | 1 | 1 |
+
+ Given the following tutees exist:
+ | sid | first_name | last_name | email | privilege | birthdate | password | password_confirmation | confirmed_at | id
+ | 1234567890 | test | student | teststudent@berkeley.edu | No | 1992-01-01 | topsecret | topsecret | 2019-05-07 05:07:48 | 1
+
+ Given "test" had a meeting with tutor "test" with meeting id "1" request having tutuee id "1" course name "CS61A" and evaluation status "Pending" times "2020-12-07 05:07:48,2020-05-07 05:07:48,2020-05-07 05:07:48" and locations "soda,dwinelle,remote"
+
+ Scenario: Set up meeting
+ Given I login as "test"
+ Given I am on "test's" tutee page
+ And I follow "Meeting"
+ And I press "Schedule Meeting"
+ Then I should see "Your Next Meeting Info"
+ Then I should see "Sunday 06 at 9:07 PM"
+ Then I should see "Soda"
+
+
+ Scenario: Cancel meeting
+ Given I login as "test"
+ Given I am on "test's" tutee page
+ And I follow "Meeting"
+ And I press "Cancel Meeting"
+ Then I can see "Your meeting was successfully cancelled" message pop up
diff --git a/features/pending_evaluation.feature b/features/pending_evaluation.feature
index 4250a074..97373c18 100644
--- a/features/pending_evaluation.feature
+++ b/features/pending_evaluation.feature
@@ -30,15 +30,6 @@ Feature: submit evaluation
Given "an" had a meeting with tutor "alvin" with meeting id "1" request having tutuee id "1" course name "CS61A" and evaluation status "Pending" feedback "birthdaybirthdaybirthdaybirthdaybirthdaybirthdaybirthdaybirthdaybirthdaybirthday"
-######################### FAILING
-# Scenario: I have a new pending eval after matching
-# Given "an" gets matched with tutor "alvin" for course name "
"
-# And I login as "an"
-# And I am on "an's" tutee pages
-# When I click on "Evaluation" link
-# Then I can see my evaluation form with course name CS61A
-# And I can see my evaluation form with tutor name alvin
-
Scenario: Try to click on Evaluation tab
Given I login as "an"
And I am on "an's" tutee page
diff --git a/features/step_denifition/evaluation_steps.rb b/features/step_denifition/evaluation_steps.rb
index e68fd521..74ea7b4f 100644
--- a/features/step_denifition/evaluation_steps.rb
+++ b/features/step_denifition/evaluation_steps.rb
@@ -44,6 +44,36 @@
end
+Given /"(.*)" had a meeting with tutor "(.*)" with meeting id "(.*)" request having tutuee id "(.*)" course name "(.*)" and evaluation status "(.*)" times "(.*)" and locations "(.*)"/ do |first_name, tutorname, meetid, tuteeid, coursename,stat, times, locations|
+ tutee = Tutee.find_by_first_name(first_name)
+ tutor = Tutor.find_by_first_name(tutorname)
+ request = Request.new()
+ puts "Tutee id"
+ puts tutee.first_name
+ request.tutee_id = tutee.id
+ course = Course.find_by_name(coursename)
+ course.name = coursename
+ puts "course id"
+ request.course_id = course.id
+ puts course.id
+ request.save!
+ eval = Evaluation.new()
+ eval.status = stat
+ eval.save!
+ meeting = Meeting.new()
+ meeting.request_id = request.id
+ meeting.times = times.split(",")
+ meeting.locations = locations.split(",")
+
+ puts request.id
+ meeting.tutor_id = tutor.id
+ puts tutor.id
+ meeting.evaluation_id = eval.id
+ puts eval.id
+ meeting.save!
+
+end
+
####################### NOT WORKING PROPERLY
# Given /"(.*)" requests tutoring for course name "(.*)"/ do |first_name, coursename,|
# tutee = Tutee.find_by_first_name(first_name)
diff --git a/features/step_denifition/request_steps.rb b/features/step_denifition/request_steps.rb
index ef5455b9..8dcbe307 100644
--- a/features/step_denifition/request_steps.rb
+++ b/features/step_denifition/request_steps.rb
@@ -11,7 +11,7 @@
end
When /I choose "(.*)" from course list/ do |course|
- page.find(:xpath, '//*[@id="request_course_id"]',visible: true).all(:css, 'option').find { |o| o.text == course }.select_option
+ steps %Q{When I select "#{course}" from "request_course_id"}
end
When /I input subject "(.*)" I want to cover/ do |subject|
diff --git a/public/.DS_Store b/public/.DS_Store
new file mode 100644
index 00000000..3731747c
Binary files /dev/null and b/public/.DS_Store differ