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 #462 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
isubas authored Oct 23, 2018
2 parents aab1a90 + e719621 commit 2afe8ec
Show file tree
Hide file tree
Showing 83 changed files with 2,447 additions and 316 deletions.
4 changes: 0 additions & 4 deletions .buildpacks

This file was deleted.

17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ jobs:
- run: bin/yarn install
- run: bundle exec rake quality:rails
- run: bundle exec rake security:all
- run: bin/yarn run lint
deploy_develop:
machine:
enabled: true
steps:
- checkout
- run:
name: Deploy Develop to Dokku
command: |
git remote add develop [email protected]:nokul-develop &&
git push develop develop:master
deploy:
machine:
enabled: true
Expand Down Expand Up @@ -138,6 +149,12 @@ workflows:
- karma:
requires:
- bundle_assets
- deploy_develop:
requires:
- karma
filters:
branches:
only: develop
- deploy:
requires:
- karma
Expand Down
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "standard"
}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ondokuz/ruby-stretch:0.10.0

ARG RAILS_ENV
ENV RAILS_ENV=$RAILS_ENV

ARG RAILS_MASTER_KEY
ENV RAILS_MASTER_KEY=$RAILS_MASTER_KEY

ENV RAILS_SERVE_STATIC_FILES=enabled
ENV RAILS_LOG_TO_STDOUT=enabled

WORKDIR /app

COPY .ruby-version ./
COPY Gemfile Gemfile.lock ./
COPY package.json yarn.lock ./

RUN bundle install --without development:test -j4 --deployment
RUN yarn install

COPY . ./

RUN bundle exec rake assets:precompile

EXPOSE 3000

CMD bundle exec puma -C config/puma.rb
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative 'lib/support/import_from_yml'
require_relative 'lib/support/utils/rake_utils'
require_relative 'lib/support/ext/progress_bar'

Rails.application.load_tasks
Empty file modified app/assets/images/profile/avatar_placeholder.svg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
//= require select2/dist/js/select2.min
//= require jquery.maskedinput/src/jquery.maskedinput
//= require Chart.bundle
//= require chartkick
//= require chartkick
2 changes: 1 addition & 1 deletion app/assets/javascripts/cable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
// App.cable = ActionCable.createConsumer();
}).call(this);
*/
*/
4 changes: 2 additions & 2 deletions app/assets/javascripts/helpers/dynamic_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict'

var DynamicSelect = function (parameters) {
var DynamicSelect = function (parameters) { // eslint-disable-line no-unused-vars
function init () {
$.each(parameters, function (k, parameter) {
$(parameter['el']).change(function (event) {
Expand Down Expand Up @@ -87,4 +87,4 @@ var OptionsBuilder = function (datas, placeholder, config = {}) {
build: build,
setSelectBox: setSelectBox
}
}
}
2 changes: 1 addition & 1 deletion app/assets/javascripts/shared/cocoon.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//= require cocoon
//= require cocoon
8 changes: 5 additions & 3 deletions app/assets/javascripts/shared/toastr_config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
toastr.options.closeButton = true;
toastr.options.showMethod = "slideDown";
toastr.options.progressBar = true;
/* global toastr:true */

toastr.options.closeButton = true
toastr.options.showMethod = 'slideDown'
toastr.options.progressBar = true
2 changes: 1 addition & 1 deletion app/controllers/committee/agendas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def redirect_with(message)
end

def set_committee
@committee = Unit.find(params[:committee_id])
@committee = Unit.committees.find(params[:committee_id])
end

def set_agenda
Expand Down
44 changes: 44 additions & 0 deletions app/controllers/committee/decisions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

module Committee
class DecisionsController < ApplicationController
before_action :set_committee_and_agenda
before_action :set_decision, only: %i[show edit update]

def show; end

def new
@decision = @agenda.build_decision
end

def create
@decision = @agenda.build_decision(decision_params)
@decision.save ? redirect_with('success') : render(:new)
end

def edit; end

def update
@decision.update(decision_params) ? redirect_with('success') : render(:edit)
end

private

def redirect_with(message)
redirect_to(committee_meeting_path(@committee, @agenda.committee_meeting), notice: t(".#{message}"))
end

def set_committee_and_agenda
@committee = Unit.committees.find(params[:committee_id])
@agenda = @committee.meeting_agendas.find(params[:meeting_agenda_id])
end

def set_decision
@decision = @agenda.decision
end

def decision_params
params.require(:committee_decision).permit(:description)
end
end
end
14 changes: 11 additions & 3 deletions app/controllers/committee/meetings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
module Committee
class MeetingsController < ApplicationController
before_action :set_committee
before_action :set_meeting, only: %i[edit update destroy]
before_action :set_meeting, only: %i[show edit update destroy]

def index
@meetings = @committee.meetings.order(year: :desc, meeting_no: :asc)
end

def show
@agendas = @meeting.meeting_agendas.includes(:decision, agenda: :agenda_type).order(:sequence_no)
end

def new
@meeting = @committee.meetings.new
end
Expand All @@ -35,15 +39,19 @@ def redirect_with(message)
end

def set_committee
@committee = Unit.find(params[:committee_id])
@committee = Unit.committees.find(params[:committee_id])
end

def set_meeting
@meeting = @committee.meetings.find(params[:id])
end

def meeting_params
params.require(:committee_meeting).permit(:meeting_no, :meeting_date)
params.require(:committee_meeting)
.permit(:meeting_no, :meeting_date,
meeting_agendas_attributes: %i[
id agenda_id committee_meeting_id sequence_no _destroy
])
end
end
end
2 changes: 2 additions & 0 deletions app/controllers/course_management/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class CoursesController < ApplicationController

def index
courses = Course.includes(:unit, :language)
.order('units.name, courses.name')
.dynamic_search(search_params(Course))

@pagy, @courses = pagy(courses)
end

Expand Down
8 changes: 5 additions & 3 deletions app/controllers/course_management/curriculums_controller.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ class CurriculumsController < ApplicationController
before_action :set_curriculum, only: %i[show edit update destroy]

def index
@pagy, @curriculums = pagy(
Curriculum.includes(:unit).dynamic_search(search_params(Curriculum))
)
curriculums = Curriculum.includes(:unit)
.order(status: :desc, name: :asc)
.order('units.name')
.dynamic_search(search_params(Curriculum))
@pagy, @curriculums = pagy(curriculums)
end

def show; end
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/units_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def courses
end

def programs
@units = @unit.children.includes(
:unit_status, :unit_instruction_language, :unit_instruction_type, :unit_type, district: [:city]
).programs.active
@units = @unit.subprograms.active.order(:name)
render json: @units
end

Expand Down
5 changes: 5 additions & 0 deletions app/models/agenda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ class Agenda < ApplicationRecord
has_one_attached :agenda_file
belongs_to :unit
belongs_to :agenda_type
has_many :meeting_agendas, dependent: :destroy
has_many :meetings, through: :meeting_agendas, source: :committee_meeting

# validations
validates :description, presence: true
validates :status, presence: true

# enums
enum status: { recent: 0, decided: 1, delayed: 2 }

# scopes
scope :active, -> { where(status: %i[recent delayed]) }
end
30 changes: 30 additions & 0 deletions app/models/committee_decision.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

class CommitteeDecision < ApplicationRecord
# relations
belongs_to :meeting_agenda
has_one :agenda, through: :meeting_agenda

# validations
validates :description, presence: true
validates :decision_no, presence: true, uniqueness: true
validates :year, presence: true

# callbacks
before_validation :set_year_and_decision_no, on: :create
after_create { agenda.update(status: :decided) }

# delegates
delegate :meeting_no, :meeting_date, :year, :unit, to: :meeting_agenda, prefix: true

def count_of_decisions_by_year(year)
meeting_agenda_unit.decisions.where(year: year).count
end

private

def set_year_and_decision_no
self.year = meeting_agenda_year
self.decision_no = "#{year}/#{count_of_decisions_by_year(year) + 1}"
end
end
4 changes: 4 additions & 0 deletions app/models/committee_meeting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
class CommitteeMeeting < ApplicationRecord
# relations
belongs_to :unit
has_many :meeting_agendas, dependent: :destroy
has_many :agendas, through: :meeting_agendas
has_many :decisions, through: :meeting_agendas, class_name: 'CommitteeDecision'
accepts_nested_attributes_for :meeting_agendas, allow_destroy: true

# validations
validates :meeting_no, presence: true, uniqueness: { scope: %i[unit year] },
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/dynamic_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def dynamic_search(params = {})

results = dynamic_where(params)

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

private

def dynamic_where(params)
query = build_query_for_dynamic_where(params)
query.present? ? where(query) : current_scope
query.present? ? where(query) : (current_scope || all)
end

def build_query_for_dynamic_where(params)
Expand Down
6 changes: 5 additions & 1 deletion app/models/curriculum.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class Curriculum < ApplicationRecord
include PgSearch
include DynamicSearch

MAX_NUMBER_OF_SEMESTERS = 12

pg_search_scope(
:search,
against: %i[name],
Expand All @@ -21,7 +23,9 @@ class Curriculum < ApplicationRecord

# validations
validates :name, presence: true, uniqueness: { scope: :unit_id }
validates :number_of_semesters, numericality: { greater_than: 0 }
validates :number_of_semesters, numericality: {
greater_than: 0, less_than_or_equal_to: MAX_NUMBER_OF_SEMESTERS
}
validates :status, presence: true

# enumerations
Expand Down
17 changes: 17 additions & 0 deletions app/models/meeting_agenda.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

class MeetingAgenda < ApplicationRecord
# relations
belongs_to :agenda
belongs_to :committee_meeting
has_one :decision, dependent: :destroy, class_name: 'CommitteeDecision'

# validations
validates :sequence_no, presence: true, uniqueness: { scope: %i[committee_meeting] },
numericality: { only_integer: true, greater_than_or_equal_to: 1 }
validates :agenda_id, presence: true, uniqueness: { scope: :committee_meeting }

# delegates
delegate :description, :status, :agenda_type, to: :agenda
delegate :meeting_no, :meeting_date, :year, :unit, to: :committee_meeting
end
9 changes: 9 additions & 0 deletions app/models/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Unit < ApplicationRecord
has_many :administrative_functions, through: :duties
has_many :agendas, dependent: :nullify
has_many :meetings, dependent: :nullify, class_name: 'CommitteeMeeting'
has_many :meeting_agendas, through: :meetings
has_many :decisions, through: :meeting_agendas, class_name: 'CommitteeDecision'
has_many :courses, dependent: :nullify
has_many :registration_documents, dependent: :destroy
has_many :prospective_students, dependent: :destroy
Expand Down Expand Up @@ -63,4 +65,11 @@ class Unit < ApplicationRecord
.or(institutes)
.or(rectorships)
}

scope :curriculumable, -> { coursable }

# custom methods
def subprograms
descendants.programs
end
end
5 changes: 5 additions & 0 deletions app/views/committee/agendas/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div class='alert alert-light'>
<%= link_to_new new_committee_agenda_path(@committee), t('.new_agenda_link') %>
<span class="pull-right">
<%= link_to(fa_icon('archive', text: t('.meetings')),
committee_meetings_path(@committee),
class: 'btn btn-dark btn-sm') %>
</span>
</div>

<div class='row'>
Expand Down
Loading

0 comments on commit 2afe8ec

Please sign in to comment.