Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #413 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Sep 28, 2018
2 parents 22bedb2 + 8e677ff commit 450c625
Show file tree
Hide file tree
Showing 122 changed files with 2,267 additions and 2,002 deletions.
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ group :development, :test do
gem 'simplecov', require: false
end

group :test do
gem 'capybara'
gem 'chromedriver-helper'
gem 'selenium-webdriver'
end

group :development do
gem 'bullet'
gem 'fit-commit'
Expand Down
24 changes: 24 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ GEM
nokogiri
ancestry (3.0.2)
activerecord (>= 3.2.0)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (9.0.0)
ast (2.4.0)
aws-eventstream (1.0.1)
Expand Down Expand Up @@ -83,7 +85,19 @@ GEM
bundler (~> 1.2)
thor (~> 0.18)
byebug (10.0.2)
capybara (3.8.2)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
xpath (~> 3.1)
chartkick (3.0.1)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (2.1.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
cocoon (1.2.11)
codacy-coverage (2.1.0)
simplecov
Expand Down Expand Up @@ -143,6 +157,7 @@ GEM
image_processing (1.7.0)
mini_magick (~> 4.0)
ruby-vips (>= 2.0.13, < 3)
io-like (0.3.0)
jaro_winkler (1.5.1)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -253,6 +268,7 @@ GEM
ruby-vips (2.0.13)
ffi (~> 1.9)
ruby_dep (1.5.0)
rubyzip (1.2.2)
sass (3.6.0)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand All @@ -276,6 +292,9 @@ GEM
nokogiri (>= 1.8.1)
nori (~> 2.4)
wasabi (~> 3.4)
selenium-webdriver (3.14.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
sidekiq (5.2.2)
connection_pool (~> 2.2, >= 2.2.2)
rack-protection (>= 1.5.0)
Expand Down Expand Up @@ -334,6 +353,8 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
xpath (3.1.0)
nokogiri (~> 1.8)

PLATFORMS
ruby
Expand All @@ -347,7 +368,9 @@ DEPENDENCIES
bullet
bundler-audit
byebug
capybara
chartkick
chromedriver-helper
cocoon
codacy-coverage
coffee-rails (~> 4.2)
Expand Down Expand Up @@ -375,6 +398,7 @@ DEPENDENCIES
ruby-progressbar
sassc-rails
savon (~> 2.12.0)
selenium-webdriver
sidekiq
simple_form
simplecov
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
*= require coreui
*= require toastr/build/toastr.min
*= require select2/dist/css/select2.min
*= require custom/select2
*/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/custom/select2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.select2 {
width: 100% !important; /* csslint allow: known-properties, important */
}
6 changes: 5 additions & 1 deletion app/controllers/account/duties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def update
end

def destroy
@duty.destroy ? redirect_to(@user, notice: t('.success')) : redirect_with('warning')
if @duty.destroy
redirect_to(@user, notice: t('.success'))
else
redirect_to(users_path(@user), alert: t('.warning'))
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/account/employees_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def update
end

def destroy
@employee.destroy ? redirect_to(@user, notice: t('.success')) : redirect_with('warning')
if @employee.destroy
redirect_to(@user, notice: t('.success'))
else
redirect_to(users_path(@user), alert: t('.warning'))
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/account/positions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def update
end

def destroy
@position.destroy ? redirect_to(@user, notice: t('.success')) : redirect_with('warning')
if @position.destroy
redirect_to(@user, notice: t('.success'))
else
redirect_to(users_path(@user), alert: t('.warning'))
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/reference_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module ReferenceResource
before_action :set_resource, only: %i[edit update destroy]

def index
value = pagy_by_search(@model_name.order(:code))
value = pagy_by_search(@model_name.order(:name))
instance_variable_set("@#{controller_name}", value)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CourseGroupTypesController < ApplicationController
before_action :set_course_group_type, only: %i[edit update destroy]

def index
@course_group_types = pagy_by_search(CourseGroupType.all)
@course_group_types = pagy_by_search(CourseGroupType.order(:name))
end

def new
Expand All @@ -26,7 +26,11 @@ def update
end

def destroy
@course_group_type.destroy ? redirect_with('success') : redirect_with('warning')
if @course_group_type.destroy
redirect_with('success')
else
redirect_to(course_group_types_path, alert: t('.warning'))
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/course_management/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CoursesController < ApplicationController
before_action :set_course, only: %i[show edit update destroy]

def index
courses = Course.includes(:unit)
courses = Course.includes(:unit, :language)
.dynamic_search(search_params(Course))
@pagy, @courses = pagy(courses)
end
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DocumentsController < ApplicationController
before_action :set_document, only: %i[edit update destroy show]

def index
@pagy, @documents = pagy(Document.all)
@pagy, @documents = pagy(Document.order(:name))
end

def show; end
Expand All @@ -27,7 +27,11 @@ def update
end

def destroy
@document.destroy ? redirect_to(documents_path, notice: t('.success')) : redirect_with('warning')
if @document.destroy
redirect_to(documents_path, notice: t('.success'))
else
redirect_to(documents_path, alert: t('.warning'))
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/references/cities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def update
end

def destroy
@city.destroy ? redirect_to(@country, notice: t('.success')) : redirect_with('warning')
if @city.destroy
redirect_to(@country, notice: t('.success'))
else
redirect_to(@country, alert: t('.warning'))
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/references/countries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def update
end

def destroy
@country.destroy ? redirect_to(countries_path, notice: t('.success')) : redirect_with('warning')
if @country.destroy
redirect_to(countries_path, notice: t('.success'))
else
redirect_to(countries_path, alert: t('.warning'))
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/references/districts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def update
end

def destroy
@district.destroy ? redirect_to([@city.country, @city], notice: t('.success')) : redirect_with('warning')
if @district.destroy
redirect_to([@city.country, @city], notice: t('.success'))
else
redirect_to([@city.country, @city], alert: t('.warning'))
end
end

private
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/references/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module References
class HomeController < ApplicationController
def index; end
end
end
6 changes: 5 additions & 1 deletion app/controllers/references/languages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def update
end

def destroy
@language.destroy ? redirect_to(languages_path, notice: t('.success')) : redirect_with('warning')
if @language.destroy
redirect_to(languages_path, notice: t('.success'))
else
redirect_to(languages_path, alert: t('.warning'))
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/registration_documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def update
end

def destroy
@registration_document.destroy ? redirect_to(@unit, notice: t('.success')) : redirect_with('warning')
if @registration_document.destroy
redirect_to(@unit, notice: t('.success'))
else
redirect_to(@unit, alert: t('.warning'))
end
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,45 @@ module StudentManagement
class ProspectiveStudentsController < ApplicationController
include PagyBackendWithHelpers

before_action :set_prospective_student, only: %i[show]
before_action :set_prospective_student, only: %i[show register]
before_action :can_register?, only: :register

def index
prospective_students = ProspectiveStudent.includes(:unit).dynamic_search(search_params(ProspectiveStudent))
prospective_students = ProspectiveStudent.includes(:unit, :student_entrance_type)
.dynamic_search(search_params(ProspectiveStudent))
@pagy, @prospective_students = pagy(prospective_students)
end

def show; end

private
def register
prospective_student = ProspectiveStudentService.new(@prospective_student)
user = prospective_student.create_user

def redirect_with(message)
redirect_to prospective_students_path, flash: { info: t(".#{message}") }
if user.save
student = prospective_student.create_student
student.save ? redirect_with_success : redirect_with_warning('.warning')
else
redirect_with_warning('.warning')
end
end

private

def set_prospective_student
@prospective_student = ProspectiveStudent.find(params[:id])
end

def can_register?
redirect_with_warning('.can_not_register') unless @prospective_student.can_temporarily_register?
end

def redirect_with_success
redirect_to(prospective_students_path, flash: { notice: t('.success') })
end

def redirect_with_warning(message)
redirect_to(prospective_students_path, flash: { alert: t(".#{message}") })
end
end
end
6 changes: 5 additions & 1 deletion app/controllers/units_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def update
end

def destroy
@unit.destroy ? redirect_to(units_path, notice: t('.success')) : redirect_with('warning')
if @unit.destroy
redirect_to(units_path, notice: t('.success'))
else
redirect_to(units_path, alert: t('.warning'))
end
end

def courses
Expand Down
3 changes: 2 additions & 1 deletion app/jobs/osym/import_prospective_students_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def perform
military_status_date: parse_date(military_status_date),
obs_status: obs_status.eql?('0') ? true : false,
obs_status_date: parse_date(obs_status_date),
obs_registered_program: obs_registered_program
obs_registered_program: obs_registered_program,
student_entrance_type: StudentEntranceType.find_by(code: 1) # TODO: will be dynamic in the future
)
progress_bar.increment
end
Expand Down
8 changes: 8 additions & 0 deletions app/models/academic_calendar.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# frozen_string_literal: true

class AcademicCalendar < ApplicationRecord
# search
include PgSearch
pg_search_scope(
:search,
against: %i[name],
using: { tsearch: { prefix: true } }
)

# relations
belongs_to :academic_term
belongs_to :calendar_type
Expand Down
5 changes: 3 additions & 2 deletions app/models/concerns/dynamic_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def dynamic_search_keys

def dynamic_search(params = {})
raise ArgumentError, 'parameter must be Hash' unless [ActionController::Parameters, Hash].include?(params.class)
return search(params[:term]) if params[:term].present?

dynamic_where(params)
results = dynamic_where(params)

params[:term].present? ? results.search(params[:term]) : results
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Language < ApplicationRecord
include PgSearch
pg_search_scope(
:search,
against: %i[name iso yoksis_code],
against: %i[name iso],
using: { tsearch: { prefix: true } }
)

Expand Down
Loading

0 comments on commit 450c625

Please sign in to comment.