diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index cf940e833..45bd7fb96 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,7 +10,6 @@ Vagrantfile @roktas @huseyin @ecylmz @sinansh .gitignore @msdundar @roktas @isubas @ecmelkytz .rubocop.yml @msdundar @roktas @isubas @ecmelkytz /docs/ @msdundar @roktas @isubas @ecmelkytz -/docs/product/ @omu/product # Back-end /app/ @msdundar @ecmelkytz @dilara @isubas @sinansh diff --git a/.github/ISSUE_TEMPLATE/use-case.md b/.github/ISSUE_TEMPLATE/use-case.md new file mode 100644 index 000000000..784686817 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/use-case.md @@ -0,0 +1,21 @@ +--- +name: Use Case +about: Product ekibi tarafından hazırlanmış `use case` için iş kaydı. + +--- + +**Use case dokümanı:** + +**Açıklama:** + +[//]: # (Kısa ve net bir şekilde konuyla ilişkili olarak sizin önerileriniz neler, sizin öneriniz kabul edilirse neler olacak, uygulamada neler iyileşecek açıklayınız.) + +**Kontrol listesi** + +* [ ] İş kaydınızın başlığı kurallara (sadece ilk harf büyük, emir kipinde problem cümlesi vb.) uygun mu? +* [ ] Use case, product ekibi tarafından incelenip onaylandı mı? +* [ ] Use case ve oluşturulan mockup'lar müşteri tarafından onaylandı mı? + +**Ek içerik:** + +[//]: # (Kaynaklar, dış bağlantılar, ekran görüntüleri, örnek çözümler ve benzeri diğer kaynakları ekleyiniz.) diff --git a/Gemfile.lock b/Gemfile.lock index e8d22c5f6..361216d56 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,7 +81,7 @@ GEM nokogiri (~> 1.6, >= 1.6.8) bcrypt (3.1.12) bindex (0.5.0) - bootsnap (1.3.1) + bootsnap (1.3.2) msgpack (~> 1.0) brakeman (4.3.1) builder (3.2.3) @@ -255,7 +255,7 @@ GEM railties (>= 4.2.0, < 5.3) rollbar (2.17.0) multi_json - rubocop (0.59.0) + rubocop (0.59.1) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) @@ -323,7 +323,7 @@ GEM tilt (2.0.8) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.18) + uglifier (4.1.19) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e06a13229..98608f51b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class ApplicationController < ActionController::Base + include PagyBackendWithHelpers + protect_from_forgery with: :exception before_action :configure_permitted_parameters, if: :devise_controller? @@ -26,6 +28,12 @@ def default_url_options protected + def search_params(model = nil) + parameters = [:term] + parameters << model.dynamic_search_keys if model + params.permit(parameters) + end + def locale_params params[:locale] && I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil end diff --git a/app/controllers/calendar/academic_calendars_controller.rb b/app/controllers/calendar/academic_calendars_controller.rb index 260445d71..d8a92961f 100644 --- a/app/controllers/calendar/academic_calendars_controller.rb +++ b/app/controllers/calendar/academic_calendars_controller.rb @@ -2,16 +2,16 @@ module Calendar class AcademicCalendarsController < ApplicationController - include Pagy::Backend - before_action :set_academic_calendar, only: %i[show edit update destroy] def index - @pagy, @academic_calendars = pagy(AcademicCalendar.includes(:academic_term, :calendar_type)) + @academic_calendars = pagy_by_search( + AcademicCalendar.includes(:academic_term, :calendar_type) + ) end def show - @pagy, @events = pagy(@academic_calendar.calendar_events.includes(:calendar_title)) + @events = pagy_by_search(@academic_calendar.calendar_events.includes(:calendar_title)) end def new diff --git a/app/controllers/calendar/academic_terms_controller.rb b/app/controllers/calendar/academic_terms_controller.rb index ebf21c7dc..b473dec3c 100644 --- a/app/controllers/calendar/academic_terms_controller.rb +++ b/app/controllers/calendar/academic_terms_controller.rb @@ -2,12 +2,10 @@ module Calendar class AcademicTermsController < ApplicationController - include Pagy::Backend - before_action :set_academic_term, only: %i[edit update destroy] def index - @pagy, @academic_terms = pagy(AcademicTerm.all) + @academic_terms = pagy_by_search(AcademicTerm.all) end def new diff --git a/app/controllers/calendar/calendar_titles_controller.rb b/app/controllers/calendar/calendar_titles_controller.rb index ce754813e..0de1a9adb 100644 --- a/app/controllers/calendar/calendar_titles_controller.rb +++ b/app/controllers/calendar/calendar_titles_controller.rb @@ -2,16 +2,10 @@ module Calendar class CalendarTitlesController < ApplicationController - include Pagy::Backend - before_action :set_calendar_title, only: %i[edit update destroy] def index - @pagy, @calendar_titles = if params[:term].present? - pagy(CalendarTitle.search(params[:term])) - else - pagy(CalendarTitle.all) - end + @calendar_titles = pagy_by_search(CalendarTitle.all) end def new diff --git a/app/controllers/calendar/calendar_types_controller.rb b/app/controllers/calendar/calendar_types_controller.rb index f87a834f1..78648f289 100644 --- a/app/controllers/calendar/calendar_types_controller.rb +++ b/app/controllers/calendar/calendar_types_controller.rb @@ -2,16 +2,14 @@ module Calendar class CalendarTypesController < ApplicationController - include Pagy::Backend - before_action :set_calendar_type, only: %i[show edit update destroy] def index - @pagy, @calendar_types = pagy(CalendarType.all) + @calendar_types = pagy_by_search(CalendarType.all) end def show - @pagy, @titles = pagy(@calendar_type.titles) + @titles = pagy_by_search(@calendar_type.titles) end def new diff --git a/app/controllers/committee/agenda_types_controller.rb b/app/controllers/committee/agenda_types_controller.rb new file mode 100644 index 000000000..71bde2116 --- /dev/null +++ b/app/controllers/committee/agenda_types_controller.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Committee + class AgendaTypesController < ApplicationController + before_action :set_agenda_type, only: %i[edit update destroy] + + def index + @agenda_types = pagy_by_search(AgendaType.all) + end + + def new + @agenda_type = AgendaType.new + end + + def edit; end + + def create + @agenda_type = AgendaType.new(agenda_type_params) + @agenda_type.save ? redirect_with('success') : render(:new) + end + + def update + @agenda_type.update(agenda_type_params) ? redirect_with('success') : render(:edit) + end + + def destroy + @agenda_type.destroy ? redirect_with('success') : redirect_with('warning') + end + + private + + def redirect_with(message) + redirect_to(agenda_types_path, notice: t(".#{message}")) + end + + def set_agenda_type + @agenda_type = AgendaType.find(params[:id]) + end + + def agenda_type_params + params.require(:agenda_type).permit(:name) + end + end +end diff --git a/app/controllers/committee/agendas_controller.rb b/app/controllers/committee/agendas_controller.rb new file mode 100644 index 000000000..6636303c5 --- /dev/null +++ b/app/controllers/committee/agendas_controller.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module Committee + class AgendasController < ApplicationController + before_action :set_committee + before_action :set_agenda, only: %i[edit update destroy] + + def index + @agendas = pagy_by_search(@committee.agendas.includes(:agenda_type)) + end + + def new + @agenda = @committee.agendas.new + end + + def edit; end + + def create + @agenda = @committee.agendas.new(agenda_params) + @agenda.save ? redirect_with('success') : render(:new) + end + + def update + @agenda.update(agenda_params) ? redirect_with('success') : render(:edit) + end + + def destroy + @agenda.destroy ? redirect_with('success') : redirect_with('warning') + end + + private + + def redirect_with(message) + redirect_to(committee_agendas_path(@committee), notice: t(".#{message}")) + end + + def set_committee + @committee = Unit.find(params[:committee_id]) + end + + def set_agenda + @agenda = @committee.agendas.find(params[:id]) if @committee + end + + def agenda_params + params.require(:agenda).permit(:description, :status, :unit_id, :agenda_type_id) + end + end +end diff --git a/app/controllers/committee/dashboard_controller.rb b/app/controllers/committee/dashboard_controller.rb new file mode 100644 index 000000000..1cc1e002d --- /dev/null +++ b/app/controllers/committee/dashboard_controller.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Committee + class DashboardController < ApplicationController + def index + @committees = pagy_by_search( + Unit.committees.includes(:unit_type, :unit_status, district: :city) + ) + end + + def show + @agendas = pagy_by_search( + Unit.find(params[:id]).agendas.includes(:agenda_type) + ) + end + end +end diff --git a/app/controllers/concerns/last_update_from_mernis.rb b/app/controllers/concerns/last_update_from_mernis.rb index d58a9b908..54c53d70b 100644 --- a/app/controllers/concerns/last_update_from_mernis.rb +++ b/app/controllers/concerns/last_update_from_mernis.rb @@ -5,6 +5,8 @@ module LastUpdateFromMernis def elapsed_time(resource) elapsed_time = (Time.zone.now - resource.updated_at) / 1.day - redirect_with('wait') if elapsed_time.present? && elapsed_time < 7 + return unless elapsed_time.blank? || elapsed_time < 7 + + @user.present? ? redirect_to(@user, notice: t('.wait')) : redirect_with('wait') end end diff --git a/app/controllers/concerns/pagy_backend_with_helpers.rb b/app/controllers/concerns/pagy_backend_with_helpers.rb new file mode 100644 index 000000000..6607bb398 --- /dev/null +++ b/app/controllers/concerns/pagy_backend_with_helpers.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module PagyBackendWithHelpers + extend ActiveSupport::Concern + include Pagy::Backend + + def pagy_by_search(collection) + @pagy, items = pagy((term = params[:term]).present? ? collection.search(term) : collection) + items + end +end diff --git a/app/controllers/concerns/reference_resource.rb b/app/controllers/concerns/reference_resource.rb index e4e029bfd..838202891 100644 --- a/app/controllers/concerns/reference_resource.rb +++ b/app/controllers/concerns/reference_resource.rb @@ -2,7 +2,6 @@ module ReferenceResource extend ActiveSupport::Concern - include Pagy::Backend # rubocop:disable Metrics/BlockLength # rubocop:disable Rails/LexicallyScopedActionFilter @@ -11,7 +10,7 @@ module ReferenceResource before_action :set_resource, only: %i[edit update destroy] def index - @pagy, value = pagy(@model_name.all) + value = pagy_by_search(@model_name.all) instance_variable_set("@#{controller_name}", value) end diff --git a/app/controllers/curriculum/courses_controller.rb b/app/controllers/curriculum/courses_controller.rb index df047d057..b339df01a 100644 --- a/app/controllers/curriculum/courses_controller.rb +++ b/app/controllers/curriculum/courses_controller.rb @@ -2,13 +2,12 @@ module Curriculum class CoursesController < ApplicationController - include Pagy::Backend - before_action :set_course, only: %i[show edit update destroy] def index - @courses = Course.includes(:unit).all - @pagy, @courses = pagy(@courses) + courses = Course.includes(:unit) + .dynamic_search(search_params(Course)) + @pagy, @courses = pagy(courses) end def show; end @@ -45,8 +44,8 @@ def set_course def course_params params.require(:course).permit( - :unit_id, :name, :code, :theoric, :practice, :education_type, - :language, :laboratory, :status + :unit_id, :name, :code, :theoric, :practice, :program_type, + :language_id, :laboratory, :status ) end end diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index 2a1968500..90763d087 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -1,18 +1,10 @@ # frozen_string_literal: true class LanguagesController < ApplicationController - include Pagy::Backend - before_action :set_language, only: %i[show edit update destroy] def index - languages = Language.all - - @pagy, @languages = if params[:term].present? - pagy(languages.search(params[:term])) - else - pagy(languages) - end + @languages = pagy_by_search(Language.all) end def show; end diff --git a/app/controllers/locations/cities_controller.rb b/app/controllers/locations/cities_controller.rb index fc53da8a9..54207004c 100644 --- a/app/controllers/locations/cities_controller.rb +++ b/app/controllers/locations/cities_controller.rb @@ -2,19 +2,11 @@ module Locations class CitiesController < ApplicationController - include Pagy::Backend - before_action :set_country before_action :set_city, only: %i[show edit update destroy] def show - districts = @city.districts - - @pagy, @districts = if params[:term].present? - pagy(districts.search(params[:term])) - else - pagy(districts) - end + @districts = pagy_by_search(@city.districts) end def new diff --git a/app/controllers/locations/countries_controller.rb b/app/controllers/locations/countries_controller.rb index 735f9aef8..66f9e3bd3 100644 --- a/app/controllers/locations/countries_controller.rb +++ b/app/controllers/locations/countries_controller.rb @@ -2,26 +2,14 @@ module Locations class CountriesController < ApplicationController - include Pagy::Backend - before_action :set_country, only: %i[show edit update destroy] def index - countries = Country.all - - @pagy, @countries = if params[:term].present? - pagy(countries.search(params[:term])) - else - pagy(countries) - end + @countries = pagy_by_search(Country.all) end def show - @pagy, @cities = if params[:term].present? - pagy(@country.cities.search(params[:term])) - else - pagy(@country.cities) - end + @cities = pagy_by_search(@country.cities) end def new diff --git a/app/controllers/studies/articles_controller.rb b/app/controllers/studies/articles_controller.rb index 6cd9b83b9..2db2c7e13 100644 --- a/app/controllers/studies/articles_controller.rb +++ b/app/controllers/studies/articles_controller.rb @@ -2,8 +2,6 @@ module Studies class ArticlesController < ApplicationController - include Pagy::Backend - def index; end end end diff --git a/app/controllers/units_controller.rb b/app/controllers/units_controller.rb index e80f2edfd..ff429d784 100644 --- a/app/controllers/units_controller.rb +++ b/app/controllers/units_controller.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true class UnitsController < ApplicationController - include Pagy::Backend - before_action :set_unit, only: %i[edit update destroy show] def index @@ -10,11 +8,7 @@ def index :unit_status, :unit_instruction_language, :unit_instruction_type, :unit_type, district: [:city] ) - @pagy, @units = if params[:term].present? - pagy(smart_search(units)) - else - pagy(dynamic_search(units)) - end + @pagy, @units = pagy(smart_search(units)) end def show; end @@ -41,7 +35,7 @@ def destroy private def smart_search(units) - units.search(params[:term]) + params[:term].present? ? units.search(params[:term]) : dynamic_search(units) end def dynamic_search(units) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 65a980fd1..6f9b30e27 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,18 +1,16 @@ # frozen_string_literal: true class UsersController < ApplicationController - include Pagy::Backend + include LastUpdateFromMernis - before_action :set_user, only: %i[show edit update destroy] + before_action :set_user, only: %i[show edit update destroy save_address_from_mernis save_identity_from_mernis] before_action :set_identities, only: :show before_action :set_addresses, only: :show + before_action :set_address_elapsed_time, only: %i[save_address_from_mernis] + before_action :set_identity_elapsed_time, only: %i[save_identity_from_mernis] def index - @pagy, @users = if params[:term].present? - pagy(User.all.search(params[:term])) - else - pagy(User.all) - end + @users = pagy_by_search(User.all) end def show @@ -41,6 +39,16 @@ def destroy @user.destroy ? redirect_with('.success') : redirect_with('.warning') end + def save_address_from_mernis + Kps::AddressSaveJob.perform_later(@user) + redirect_to(@user, notice: t('.will_update')) + end + + def save_identity_from_mernis + Kps::IdentitySaveJob.perform_later(@user) + redirect_to(@user, notice: t('.will_update')) + end + private def set_user @@ -55,6 +63,20 @@ def set_addresses @addresses = @user.addresses end + def set_address_elapsed_time + formal_address = @user.addresses.formal + return if formal_address.blank? + + elapsed_time(formal_address.first) + end + + def set_identity_elapsed_time + formal_identity = @user.identities.user_identity + return if formal_identity.blank? + + elapsed_time(formal_identity) + end + def user_params params.require(:user).permit(:id_number, :email, :password, :password_confirmation, :preferred_language) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 15b06f0f6..0e0edb496 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true module ApplicationHelper + include Pagy::Frontend end diff --git a/app/helpers/units_helper.rb b/app/helpers/units_helper.rb deleted file mode 100644 index 0fd4e06ef..000000000 --- a/app/helpers/units_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -module UnitsHelper - include Pagy::Frontend -end diff --git a/app/models/committees/agenda.rb b/app/models/committees/agenda.rb new file mode 100644 index 000000000..b1971b793 --- /dev/null +++ b/app/models/committees/agenda.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class Agenda < ApplicationRecord + # search + include PgSearch + pg_search_scope( + :search, + against: %i[description], + using: { tsearch: { prefix: true } } + ) + + # relations + belongs_to :unit + belongs_to :agenda_type + + # validations + validates :description, presence: true + validates :status, presence: true + + # enums + enum status: { recent: 0, decided: 1, delayed: 2 } +end diff --git a/app/models/committees/agenda_type.rb b/app/models/committees/agenda_type.rb new file mode 100644 index 000000000..067befb63 --- /dev/null +++ b/app/models/committees/agenda_type.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AgendaType < ApplicationRecord + # search + include PgSearch + pg_search_scope( + :search, + against: :name, + using: { tsearch: { prefix: true } } + ) + + # reloations + has_many :agendas, dependent: :nullify + + # validations + validates :name, presence: true + + # callbacks + before_save { self.name = name.capitalize_all } +end diff --git a/app/models/concerns/dynamic_search.rb b/app/models/concerns/dynamic_search.rb new file mode 100644 index 000000000..74ba73bc0 --- /dev/null +++ b/app/models/concerns/dynamic_search.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module DynamicSearch + extend ActiveSupport::Concern + + class_methods do + def search_keys(*keys) + @dynamic_search_keys = keys.flatten + end + + def dynamic_search_keys + raise ArgumentError, 'must be defined in search_keys' unless @dynamic_search_keys + + @dynamic_search_keys + end + + 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) + end + + private + + def dynamic_where(params) + query = build_query_for_dynamic_where(params) + query.present? ? where(query) : current_scope + end + + def build_query_for_dynamic_where(params) + dynamic_search_keys.each_with_object({}) do |key, hash| + hash[key] = params[key] if params[key].present? + end + end + end +end diff --git a/app/models/curriculums/course.rb b/app/models/curriculums/course.rb index ffbfd0073..4ddca8a15 100644 --- a/app/models/curriculums/course.rb +++ b/app/models/curriculums/course.rb @@ -1,36 +1,42 @@ # frozen_string_literal: true class Course < ApplicationRecord - self.inheritance_column = nil + # search + include PgSearch + include DynamicSearch + + pg_search_scope( + :search, + against: %i[name code], + using: { tsearch: { prefix: true } } + ) + + # dynamic_search + search_keys :program_type, :language_id, :unit_id, :status # relations belongs_to :unit + belongs_to :language # validations - validates :abrogated_date, presence: true, if: :abrogated? validates :code, presence: true, uniqueness: true validates :credit, presence: true, numericality: { greater_than: 0 } - validates :education_type, presence: true + validates :program_type, presence: true validates :laboratory, presence: true, numericality: { greater_than_or_equal_to: 0 } - validates :language, presence: true - validates :name, presence: true, uniqueness: { scope: :code } + validates :name, presence: true, uniqueness: { scope: :unit_id } validates :practice, presence: true, numericality: { greater_than_or_equal_to: 0 } validates :status, presence: true validates :theoric, presence: true, numericality: { greater_than_or_equal_to: 0 } # callbacks before_validation do - self.name = name.capitalize_all if name - self.abrogated_date = (abrogated? ? Time.zone.today : nil) if status_changed? - self.credit = calculate_credit + self.name = name.capitalize_all if name + self.credit = calculate_credit end # enumerations - enum education_type: { undergraduate: 0, master: 1, doctoral: 2 } - enum status: { passive: 0, active: 1, abrogated: 2 } - - # scopes - default_scope -> { order('name DESC') } + enum program_type: { associate: 0, undergraduate: 1, master: 2, doctoral: 3 } + enum status: { passive: 0, active: 1 } def calculate_credit theoric.to_f + (practice.to_f / 2) diff --git a/app/models/language.rb b/app/models/language.rb index 60c6b69d8..7017a9302 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -9,6 +9,9 @@ class Language < ApplicationRecord using: { tsearch: { prefix: true } } ) + # relations + has_many :courses, dependent: :nullify + # validations validates :name, presence: true, uniqueness: true validates :iso, presence: true, uniqueness: true diff --git a/app/models/unit.rb b/app/models/unit.rb index 5586bfbc9..b51eb4dc7 100644 --- a/app/models/unit.rb +++ b/app/models/unit.rb @@ -23,6 +23,7 @@ class Unit < ApplicationRecord has_many :users, through: :employees has_many :positions, through: :duties has_many :administrative_functions, through: :duties + has_many :agendas, dependent: :nullify # validations validates :yoksis_id, uniqueness: true, allow_blank: true, numericality: { only_integer: true } @@ -38,4 +39,5 @@ class Unit < ApplicationRecord scope :unit_status_id, ->(id) { where(unit_status_id: id) } scope :unit_instruction_type_id, ->(id) { where(unit_instruction_type_id: id) } scope :unit_instruction_language_id, ->(id) { where(unit_instruction_language_id: id) } + scope :committees, -> { where(unit_type: UnitType.find_by(code: 200)) } end diff --git a/app/views/committee/agenda_types/_form.html.erb b/app/views/committee/agenda_types/_form.html.erb new file mode 100644 index 000000000..319c00f87 --- /dev/null +++ b/app/views/committee/agenda_types/_form.html.erb @@ -0,0 +1,26 @@ +
+
+
+
+ <%= fa_icon 'tags' %> + <%= form_title %> +
+
+ <%= simple_form_for(agenda_type) do |f| %> +
+
+ <%= f.error_notification %> +
+
+ <%= f.input :name, required: true %> +
+
+ <%= f.button :submit, class: 'btn btn-outline-success btn-sm' %> + <%= link_to_back(:back) %> +
+
+ <% end %> +
+
+
+
diff --git a/app/views/committee/agenda_types/edit.html.erb b/app/views/committee/agenda_types/edit.html.erb new file mode 100644 index 000000000..f1f2692cb --- /dev/null +++ b/app/views/committee/agenda_types/edit.html.erb @@ -0,0 +1 @@ +<%= render 'form', agenda_type: @agenda_type, form_title: t('.form_title') %> diff --git a/app/views/committee/agenda_types/index.html.erb b/app/views/committee/agenda_types/index.html.erb new file mode 100644 index 000000000..81c8f04e3 --- /dev/null +++ b/app/views/committee/agenda_types/index.html.erb @@ -0,0 +1,46 @@ +
+ <%= link_to_new new_agenda_type_path, t('.new_agenda_type_link') %> +
+ +
+
+
+
+ <%= fa_icon 'tags', text: t('.card_header') %> +
+
+ <%= form_tag agenda_types_path, method: :get do %> +
+ <%= text_field_tag 'term', params[:term], placeholder: t('.name'), class: 'form-control' %> +
+ <%= submit_tag t('search'), class: 'btn btn-primary' %> + <% end %> +
+ + + + + + + + + <% @agenda_types.each do |agenda_type| %> + + + + + <% end %> + +
<%= t('.name') %><%= t('actions') %>
<%= agenda_type.name %> + <%= link_to_edit(edit_agenda_type_path(agenda_type)) %> + <%= link_to_destroy(agenda_type) %> +
+
+
+ +
+
diff --git a/app/views/committee/agenda_types/new.html.erb b/app/views/committee/agenda_types/new.html.erb new file mode 100644 index 000000000..f1f2692cb --- /dev/null +++ b/app/views/committee/agenda_types/new.html.erb @@ -0,0 +1 @@ +<%= render 'form', agenda_type: @agenda_type, form_title: t('.form_title') %> diff --git a/app/views/committee/agendas/_form.html.erb b/app/views/committee/agendas/_form.html.erb new file mode 100644 index 000000000..1dce7eadf --- /dev/null +++ b/app/views/committee/agendas/_form.html.erb @@ -0,0 +1,36 @@ +
+
+
+
+ <%= fa_icon 'tasks' %> + <%= form_title %> +
+
+ <%= simple_form_for([@committee, agenda], url: committee_agendas_path(@committee.id), method: :post) do |f| %> +
+
+ <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> +
+
+ <%= f.input :unit_id, as: :hidden, input_html: { value: @committee.id } %> +
+
+ <%= f.input :description, required: true %> +
+
+ <%= f.input :agenda_type_id, collection: AgendaType.all %> +
+
+ <%= f.input :status, collection: enum_options_for_select(f.object.class, :status) %> +
+
+ <%= f.button :submit, class: 'btn btn-outline-success btn-sm' %> + <%= link_to_back(:back) %> +
+
+ <% end %> +
+
+
+
diff --git a/app/views/committee/agendas/edit.html.erb b/app/views/committee/agendas/edit.html.erb new file mode 100644 index 000000000..8fcaccbcb --- /dev/null +++ b/app/views/committee/agendas/edit.html.erb @@ -0,0 +1 @@ +<%= render 'form', agenda: @agenda, form_title: t('.form_title') %> diff --git a/app/views/committee/agendas/index.html.erb b/app/views/committee/agendas/index.html.erb new file mode 100644 index 000000000..6228906ac --- /dev/null +++ b/app/views/committee/agendas/index.html.erb @@ -0,0 +1,52 @@ +
+ <%= link_to_new new_committee_agenda_path(@committee), t('.new_agenda_link') %> +
+ +
+
+
+
+ <%= fa_icon 'tasks', text: t('.card_header') %> +
+
+ <%= form_tag committee_agendas_path, method: :get do %> +
+ <%= text_field_tag 'term', params[:term], placeholder: t('.description'), class: 'form-control' %> +
+ <%= submit_tag t('search'), class: 'btn btn-primary' %> + <% end %> +
+ + + + + + + + + + + + <% @agendas.each do |agenda| %> + + + + + + + + <% end %> + +
<%= t('.description') %><%= t('.unit') %><%= t('.agenda_type') %><%= t('.status') %><%= t('actions') %>
<%= agenda.description %><%= agenda.unit.try(:name) %><%= agenda.agenda_type.try(:name) %><%= enum_t(agenda, :status) %> + <%= link_to_edit(edit_committee_agenda_path(@committee.id, agenda.id)) %> + <%= link_to_destroy(committee_agenda_path(@committee.id, agenda.id)) %> +
+
+
+ +
+
diff --git a/app/views/committee/agendas/new.html.erb b/app/views/committee/agendas/new.html.erb new file mode 100644 index 000000000..8fcaccbcb --- /dev/null +++ b/app/views/committee/agendas/new.html.erb @@ -0,0 +1 @@ +<%= render 'form', agenda: @agenda, form_title: t('.form_title') %> diff --git a/app/views/committee/dashboard/index.html.erb b/app/views/committee/dashboard/index.html.erb new file mode 100644 index 000000000..eb4a01e70 --- /dev/null +++ b/app/views/committee/dashboard/index.html.erb @@ -0,0 +1,55 @@ +
+ <%= link_to_new new_unit_path, t('.new_committee_link') %> +
+ +
+
+
+
+ <%= fa_icon 'cubes', text: t('.card_header') %> +
+
+ <%= form_tag committees_path, method: :get do %> +
+ <%= text_field_tag 'term', params[:term], placeholder: t('.name'), class: 'form-control' %> +
+ <%= submit_tag t('search'), class: 'btn btn-primary' %> + <% end %> +
+ + + + + + + + + + + + + + <% @committees.each do |committee| %> + + + + + + + + + + <% end %> + +
<%= t('.name') %><%= t('.yoksis_id') %><%= t('.detsis_id') %><%= t('.unit_status') %><%= t('.unit_type') %><%= t('.district') %><%= t('actions') %>
<%= link_to(committee.name, unit_path(committee)) %><%= committee.yoksis_id %><%= committee.detsis_id %><%= committee.unit_status.name %><%= committee.unit_type.try(:name) %><%= committee.district.name %> / <%= committee.district.city.name %> + <%= link_to_show(committee_path(committee)) %> +
+
+
+ +
+
diff --git a/app/views/committee/dashboard/show.html.erb b/app/views/committee/dashboard/show.html.erb new file mode 100644 index 000000000..3d6bf2bb1 --- /dev/null +++ b/app/views/committee/dashboard/show.html.erb @@ -0,0 +1,56 @@ +
+
+
+
+
<%= @committee.name %>
+
+
+
+
+ <%= fa_icon 'tasks', text: t('.agenda_card_header') %> +
+ <%= link_to_new(new_committee_agenda_path(@committee.id)) %> +
+
+
+ <%= form_tag committee_path(@committee.id), method: :get do %> +
+ <%= text_field_tag 'term', params[:term], placeholder: t('.description'), class: 'form-control' %> +
+ <%= submit_tag t('search'), class: 'btn btn-primary' %> + <% end %> +
+ + + + + + + + + + + <% @agendas.each do |agenda| %> + + + + + + + <% end %> + +
<%= t('.description') %><%= t('.agenda_type') %><%= t('.status') %><%= t('.actions') %>
<%= agenda.description %><%= agenda.agenda_type.try(:name) %><%= enum_t(agenda, :status) %> + <%= link_to_edit(edit_committee_agenda_path(@committee.id, agenda.id)) %> + <%= link_to_destroy(committee_agenda_path(@committee.id, agenda.id)) %> +
+
+
+ +
+
+
+
diff --git a/app/views/curriculum/courses/_form.html.erb b/app/views/curriculum/courses/_form.html.erb index 475154c73..a22161f39 100644 --- a/app/views/curriculum/courses/_form.html.erb +++ b/app/views/curriculum/courses/_form.html.erb @@ -8,7 +8,16 @@
<%= simple_form_for(@course) do |f| %> <%= f.error_notification %> -
+ <% if f.object.errors.any? %> + + <% end %> +
<%= f.association :unit %>
@@ -28,11 +37,11 @@ <%= f.input :laboratory %>
- <%= f.input :education_type, - collection: enum_options_for_select(f.object.class, :education_type) %> + <%= f.input :program_type, + collection: enum_options_for_select(f.object.class, :program_type) %>
- <%= f.input :language %> + <%= f.association :language %>
<%= f.input :status, diff --git a/app/views/curriculum/courses/_search.html.erb b/app/views/curriculum/courses/_search.html.erb new file mode 100644 index 000000000..ebb139f32 --- /dev/null +++ b/app/views/curriculum/courses/_search.html.erb @@ -0,0 +1,114 @@ +
+
+ +
+
+ <%= form_tag courses_path, method: :get do %> +
+ <%= text_field_tag :term, + params[:term], + placeholder: t('.smart_search_placeholder'), + class: 'form-control' %> +
+ <%= submit_tag t('search'), class: 'btn btn-primary' %> + <% end %> +
+
+
+
+ +
+
+ <%= form_tag courses_path, method: :get do %> +
+
+
+ <%= label_tag(:unit_id, t('.unit')) %> + <%= select_tag(:unit_id, + options_from_collection_for_select(Unit.all, :id, :name, params[:unit_id]), + include_blank: true, + class: 'form-control', + style: 'width: 100%') %> +
+
+
+
+ <%= label_tag(:program_type, t('.program_type')) %> + <%= select_tag(:program_type, + options_for_select(enum_options_for_select(Course, :program_type), params[:program_type]), + include_blank: true, + class: 'form-control', + style: 'width: 100%') %> +
+
+ +
+
+ <%= label_tag(:language_id, t('.language')) %> + <%= select_tag(:language_id, + options_from_collection_for_select(Language.all, :id, :name, params[:language_id]), + include_blank: true, + class: 'form-control', + style: 'width: 100%') %> +
+
+ +
+
+ <%= label_tag(:status, t('.status')) %> + <%= select_tag(:status, + options_for_select(enum_options_for_select(Course, :status), params[:status]), + include_blank: true, + class: 'form-control', + style: 'width: 100%') %> +
+
+
+
+
+ <%= submit_tag t('search'), class: 'btn btn-primary' %> +
+
+ <% end %> +
+
+
+
+ + \ No newline at end of file diff --git a/app/views/curriculum/courses/_select2.html.erb b/app/views/curriculum/courses/_select2.html.erb index 6578abd02..1bba59b10 100644 --- a/app/views/curriculum/courses/_select2.html.erb +++ b/app/views/curriculum/courses/_select2.html.erb @@ -1,5 +1,5 @@ diff --git a/app/views/curriculum/courses/index.html.erb b/app/views/curriculum/courses/index.html.erb index 63d0fcc47..29c4ec4fa 100644 --- a/app/views/curriculum/courses/index.html.erb +++ b/app/views/curriculum/courses/index.html.erb @@ -2,6 +2,8 @@ <%= link_to_new new_course_path, t('.add_new_course') %>
+<%= render 'search' %> +
@@ -10,15 +12,18 @@
- + - - - - + + @@ -30,15 +35,18 @@ - - - - - + + + diff --git a/app/views/curriculum/courses/show.html.erb b/app/views/curriculum/courses/show.html.erb index c69e2cec5..9202d587c 100644 --- a/app/views/curriculum/courses/show.html.erb +++ b/app/views/curriculum/courses/show.html.erb @@ -41,12 +41,12 @@ - - + + - + diff --git a/app/views/layouts/shared/_sidebar.html.erb b/app/views/layouts/shared/_sidebar.html.erb index 9cb1fc49d..2b9245813 100644 --- a/app/views/layouts/shared/_sidebar.html.erb +++ b/app/views/layouts/shared/_sidebar.html.erb @@ -141,6 +141,23 @@ <%= fa_icon('file-text-o', text: t('.studies'), class: 'nav-icon') %> <% end %> + diff --git a/app/views/units/_search.html.erb b/app/views/units/_search.html.erb index f4a5ebe14..5b3f2a144 100644 --- a/app/views/units/_search.html.erb +++ b/app/views/units/_search.html.erb @@ -3,7 +3,7 @@ @@ -22,7 +22,7 @@ diff --git a/app/views/users/_addresses.html.erb b/app/views/users/_addresses.html.erb index df3b0e523..b25a1772b 100644 --- a/app/views/users/_addresses.html.erb +++ b/app/views/users/_addresses.html.erb @@ -1,52 +1,45 @@ - -
- <% if @addresses.any? %> - <% @addresses.each do |address| %> -
-
-
-
- <%= link_to_edit(edit_address_path(address)) %> - <%= link_to_destroy(address) %> -
-
- -
-
<%= t('.name') %> <%= t('.code') %> <%= t('.unit') %><%= t('.theoric') %><%= t('.practice') %><%= t('.credit') %><%= t('.education_type') %> + T: <%= t('.theoric') %> + P: <%= t('.practice') %> + L: <%= t('.laboratory') %> + K: <%= t('.credit') %> + <%= t('.program_type') %> <%= t('.language') %> <%= t('.status') %> <%= t('actions') %><%= course.name %> <%= course.code %> <%= course.unit.try(:name) %><%= course.theoric %><%= course.practice %><%= course.credit %><%= enum_t(course, :education_type) %><%= course.language %> + T: <%= course.theoric %> + P: <%= course.practice %> + L: <%= course.laboratory %> + K: <%= course.credit %> + <%= enum_t(course, :program_type) %><%= course.language.try(:name) %> <%= enum_t(course, :status) %> <%= link_to_show course %> - <%= link_to_edit edit_course_path(course) %> + <%= link_to_edit [:edit, course] %> <%= link_to_destroy course %>
<%= @course.credit %>
<%= t('.education_type') %><%= enum_t(@course, :education_type) %><%= t('.program_type') %><%= enum_t(@course, :program_type) %>
<%= t('.language') %><%= @course.language %><%= @course.language.try(:name) %>
<%= t('.status') %>
- - - - - - - - - - - - - - - - -
<%= t('activerecord.attributes.address.name') %> - - <%= fa_icon('gavel', text: t('activerecord.enums.address.names.formal')) if address.formal? %> - <%= fa_icon('address-book', text: t('activerecord.enums.address.names.informal')) if address.informal? %> - -
<%= t('activerecord.attributes.address.phone_number') %><%= address.phone_number %>
<%= t('activerecord.attributes.address.full_address') %><%= address.full_address %>
<%= t('activerecord.attributes.address.district') %><%= address.district.name %> / <%= address.district.city.name %>
-
-
+
+
+
+ <%= link_to (@user.addresses.formal.present? ? t('.update_from_mernis') : t('.create_from_mernis') ), save_address_from_mernis_user_path, class: "btn btn-outline-primary btn-sm" %>
- <% end %> - <% else %> -
+
+
+ <% @addresses.each do |address| %> +
+
+ <%= link_to_edit(edit_address_path(address)) %> + <%= link_to_destroy(address) %> +
+
- Kullanıcının adres bilgisi bulunmuyor. MERNİS'ten getir. + + + + + + + + + + + + + + + + + +
<%= t('activerecord.attributes.address.name') %> + + <%= fa_icon('gavel', text: t('activerecord.enums.address.names.formal')) if address.formal? %> + <%= fa_icon('address-book', text: t('activerecord.enums.address.names.informal')) if address.informal? %> + +
<%= t('activerecord.attributes.address.phone_number') %><%= address.phone_number %>
<%= t('activerecord.attributes.address.full_address') %><%= address.full_address %>
<%= t('activerecord.attributes.address.district') %><%= address.district.name %> / <%= address.district.city.name %>
diff --git a/app/views/users/_identities.html.erb b/app/views/users/_identities.html.erb index 1320687e8..f0b68295e 100644 --- a/app/views/users/_identities.html.erb +++ b/app/views/users/_identities.html.erb @@ -1,76 +1,69 @@ - -
- <% if @identities.any? %> - <% @identities.each do |identity| %> -
-
-
-
- <%= link_to_edit(edit_identity_path(identity)) %> - <%= link_to_destroy(identity) %> -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= t('activerecord.attributes.identity.name') %> - - <%= fa_icon('gavel', text: t('activerecord.enums.identity.names.formal')) if identity.formal? %> - <%= fa_icon('user', text: t('activerecord.enums.identity.names.informal')) if identity.informal? %> - -
<%= t('activerecord.attributes.identity.last_name') %><%= identity.last_name %>
<%= t('activerecord.attributes.identity.first_name') %><%= identity.first_name %>
<%= t('activerecord.attributes.identity.mothers_name') %><%= identity.mothers_name %>
<%= t('activerecord.attributes.identity.fathers_name') %><%= identity.fathers_name %>
<%= t('activerecord.attributes.identity.gender') %><%= enum_t(identity, :gender) %>
<%= t('activerecord.attributes.identity.marital_status') %><%= enum_t(identity, :marital_status) %>
<%= t('activerecord.attributes.identity.place_of_birth') %><%= identity.place_of_birth %>
<%= t('activerecord.attributes.identity.date_of_birth') %><%= identity.date_of_birth %>
<%= t('activerecord.attributes.identity.registered_to') %><%= identity.registered_to %>
-
-
+
+
+
+ <%= link_to (@user.identities.formal.present? ? t('.update_from_mernis') : t('.create_from_mernis') ), save_identity_from_mernis_user_path, class: "btn btn-outline-primary btn-sm" %>
- <% end %> - <% else %> -
+
+
+ <% @identities.each do |identity| %> +
+
+ <%= link_to_edit(edit_identity_path(identity)) %> + <%= link_to_destroy(identity) %> +
+
- Kullanıcının kimlik bilgisi bulunmuyor. MERNİS'ten getir. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t('activerecord.attributes.identity.name') %> + + <%= fa_icon('gavel', text: t('activerecord.enums.identity.names.formal')) if identity.formal? %> + <%= fa_icon('user', text: t('activerecord.enums.identity.names.informal')) if identity.informal? %> + +
<%= t('activerecord.attributes.identity.last_name') %><%= identity.last_name %>
<%= t('activerecord.attributes.identity.first_name') %><%= identity.first_name %>
<%= t('activerecord.attributes.identity.mothers_name') %><%= identity.mothers_name %>
<%= t('activerecord.attributes.identity.fathers_name') %><%= identity.fathers_name %>
<%= t('activerecord.attributes.identity.gender') %><%= enum_t(identity, :gender) %>
<%= t('activerecord.attributes.identity.marital_status') %><%= enum_t(identity, :marital_status) %>
<%= t('activerecord.attributes.identity.place_of_birth') %><%= identity.place_of_birth %>
<%= t('activerecord.attributes.identity.date_of_birth') %><%= identity.date_of_birth %>
<%= t('activerecord.attributes.identity.registered_to') %><%= identity.registered_to %>
diff --git a/app/views/users/_search.html.erb b/app/views/users/_search.html.erb index 805757076..f0b909f1a 100644 --- a/app/views/users/_search.html.erb +++ b/app/views/users/_search.html.erb @@ -3,7 +3,7 @@ diff --git a/config/locales/defaults/en.yml b/config/locales/defaults/en.yml index 5389858bf..3331da262 100644 --- a/config/locales/defaults/en.yml +++ b/config/locales/defaults/en.yml @@ -15,4 +15,8 @@ en: created_at: Created At updated_at: Updated At 'yes': 'Yes' - 'no': 'No' \ No newline at end of file + 'no': 'No' + detailed_search: Detailed Search + reset: Reset + smart_search: Smart Search + \ No newline at end of file diff --git a/config/locales/defaults/tr.yml b/config/locales/defaults/tr.yml index 38e143959..7ab6e5181 100644 --- a/config/locales/defaults/tr.yml +++ b/config/locales/defaults/tr.yml @@ -15,4 +15,7 @@ tr: created_at: Oluşturulma Tarihi updated_at: Güncellenme Tarihi 'yes': Evet - 'no': Hayır \ No newline at end of file + 'no': Hayır + detailed_search: Detaylı Arama + reset: Reset + smart_search: Akıllı Arama diff --git a/config/locales/layouts/shared/sidebar_en.yml b/config/locales/layouts/shared/sidebar_en.yml index 0c214525e..2108c895c 100644 --- a/config/locales/layouts/shared/sidebar_en.yml +++ b/config/locales/layouts/shared/sidebar_en.yml @@ -28,3 +28,6 @@ en: unit_types: Unit Types university_types: University Types studies: Academic Studies + committees: Committees + committee_units: Committee Units + agenda_types: Agenda Types diff --git a/config/locales/layouts/shared/sidebar_tr.yml b/config/locales/layouts/shared/sidebar_tr.yml index 2ea5a54f0..c8afc602b 100644 --- a/config/locales/layouts/shared/sidebar_tr.yml +++ b/config/locales/layouts/shared/sidebar_tr.yml @@ -28,3 +28,6 @@ tr: unit_types: Birim Türleri university_types: Üniversite Türleri studies: Akademik Çalışmalar + committees: Kurullar/Komisyonlar + committee_units: Kurul/Komisyon Birimleri + agenda_types: Gündem Türleri diff --git a/config/locales/models/committees/en.yml b/config/locales/models/committees/en.yml new file mode 100644 index 000000000..00692b054 --- /dev/null +++ b/config/locales/models/committees/en.yml @@ -0,0 +1,75 @@ +en: + activerecord: + attributes: + agenda: &agenda_attributes + description: Agenda Description + agenda_type_id: Agenda Type + status: Agenda Status + agenda_type: &agenda_type_attributes + name: Name of Agenda Type + enums: + agenda: + statuses: + recent: Yeni + decided: Karar Verildi + delayed: Ertelendi + helpers: + submit: + agenda: + create: Create Agenda + update: Update Agenda + agenda_type: + create: Create Agenda Type + update: Update Agenda Type + committee: + agendas: + index: + <<: *agenda_attributes + new_agenda_link: Create a New Agenda + card_header: Agendas + unit: Unit + agenda_type: Agenda Type + new: + form_title: Create a Agenda + edit: + form_title: Update a Agenda + create: + success: Agenda successfully created. + update: + success: Agenda successfully updated. + destroy: + success: Agenda successfully deleted. + warning: Agenda can not be deleted! + agenda_types: + index: + <<: *agenda_type_attributes + new_agenda_type_link: Create a New Agenda Type + card_header: Agenda Types + new: + form_title: Create a Agenda Type + edit: + form_title: Update the Agenda Type + create: + success: Agenda Type successfully created. + update: + success: Agenda Type successfully updated. + destroy: + success: Agenda Type successfully deleted. + warning: Agenda Type can not be deleted! + dashboard: + index: + name: Committee / Commission Name + detsis_id: DETSIS ID + yoksis_id: YOKSIS ID + unit_status: Unit Status + unit_type: Unit Type + district: Location + card_header: Committee / Commission + new_committee_link: Create a New Committee/Commission + show: + description: Description + unit: Parent Unit + agenda_type: Agenda Type + status: Agenda Status + actions: Actions + agenda_card_header: Agendas diff --git a/config/locales/models/committees/tr.yml b/config/locales/models/committees/tr.yml new file mode 100644 index 000000000..e496b05e6 --- /dev/null +++ b/config/locales/models/committees/tr.yml @@ -0,0 +1,77 @@ +tr: + activerecord: + attributes: + agenda: &agenda_attributes + description: Gündem Açıklaması + agenda_type_id: Gündem Türü + status: Gündem Durumu + agenda_type: &agenda_type_attributes + name: Gündem Türü Adı + dashboard: + name: Kurul / Komisyon Adı + enums: + agenda: + statuses: + recent: Yeni + decided: Karar Verildi + delayed: Ertelendi + helpers: + submit: + agenda: + create: Gündem Oluştur + update: Gündem Güncelle + agenda_type: + create: Gündem Türü Oluştur + update: Gündem Türü Güncelle + committee: + agendas: + index: + <<: *agenda_attributes + new_agenda_link: Yeni Bir Gündem Oluştur + card_header: Gündemler + unit: Birim + agenda_type: Gündem Türü + new: + form_title: Gündem Oluştur + edit: + form_title: Gündem Güncelle + create: + success: Gündem başarıyla oluşturuldu. + update: + success: Gündem başarıyla güncellendi. + destroy: + success: Gündem başarıyla silindi. + warning: Gündem silinemedi! + agenda_types: + index: + <<: *agenda_type_attributes + new_agenda_type_link: Yeni Bir Gündem Türü Oluştur + card_header: Gündem Türleri + new: + form_title: Gündem Türü Oluştur + edit: + form_title: Gündem Türü Güncelle + create: + success: Gündem Türü başarıyla oluşturuldu. + update: + success: Gündem Türü başarıyla güncellendi. + destroy: + success: Gündem Türü başarıyla silindi. + warning: Gündem Türü silinemedi! + dashboard: + index: + name: Kurul / Komisyon Adı + detsis_id: DETSIS ID + yoksis_id: YOKSIS ID + unit_status: Birim Durumu + unit_type: Birim Türü + district: Bulunduğu İlçe + card_header: Kurul / Komisyon + new_committee_link: Yeni Bir Kurul/Komisyon Oluştur + show: + description: Açıklama + unit: Üst Birim + agenda_type: Gündem Türü + status: Gündem Durumu + actions: İşlemler + agenda_card_header: Gündemler diff --git a/config/locales/models/curriculums/en.yml b/config/locales/models/curriculums/en.yml index 2ea424001..37165d2b8 100644 --- a/config/locales/models/curriculums/en.yml +++ b/config/locales/models/curriculums/en.yml @@ -1,28 +1,29 @@ en: - course_attributes: &course_attributes - credit: Credit - code: Code - education_type: Education Type - laboratory: Laboratory - language: Language - name: Name - practice: Practice - status: Status - theoric: Theoric - unit: Unit activerecord: + attributes: + course: &course_attributes + credit: Credit + code: Code + program_type: Program Type + laboratory: Laboratory + language: Language + name: Name + practice: Practice + status: Status + theoric: Theoric + unit: Unit models: course: Course enums: course: - education_types: + program_types: + associate: Associate undergraduate: Undergraduate master: Master doctoral: Doctoral statuses: passive: Passive active: Active - abrogated: Abrogated curriculum: courses: new: @@ -36,6 +37,9 @@ en: error: An error occured when deleting the course. update: success: Course successfully updated. + search: + smart_search_placeholder: Course name or code + <<: *course_attributes show: <<: *course_attributes index: diff --git a/config/locales/models/curriculums/tr.yml b/config/locales/models/curriculums/tr.yml index 1abc41a4f..94bb9963a 100644 --- a/config/locales/models/curriculums/tr.yml +++ b/config/locales/models/curriculums/tr.yml @@ -1,28 +1,29 @@ tr: - course_attributes: &course_attributes - credit: Kredi - code: Dersin Kodu - education_type: Eğitim Türü - laboratory: Laboratuvar - language: Dil - name: Dersin Adı - practice: Uygulama - status: Durumu - theoric: Teorik - unit: Birim activerecord: + attributes: + course: &course_attributes + credit: Kredi + code: Dersin Kodu + program_type: Program Türü + laboratory: Laboratuvar + language: Dil + name: Dersin Adı + practice: Uygulama + status: Durumu + theoric: Teorik + unit: Birim models: course: Ders enums: course: - education_types: - undergraduate: Önlisans/Lisans + program_types: + associate: Önlisans + undergraduate: Lisans master: Yüksek Lisans doctoral: Doktora statuses: passive: Pasif active: Aktif - abrogated: Yürürlükten Kaldırılmış curriculum: courses: new: @@ -36,6 +37,9 @@ tr: error: Ders silinirken bir hata oluştu. update: success: Ders başarıyla güncellendi. + search: + smart_search_placeholder: Ders adı veya kodu + <<: *course_attributes show: <<: *course_attributes index: diff --git a/config/locales/models/units/en.yml b/config/locales/models/units/en.yml index 4bbc3d1a6..aa475f6bc 100644 --- a/config/locales/models/units/en.yml +++ b/config/locales/models/units/en.yml @@ -26,8 +26,6 @@ en: units: Units search: smart_search_placeholder: Unit name or YOKSIS ID - smart_search: Smart Search - detailed_search: Detailed Search duration: Duration of Instruction unit_status: Unit Status unit_instruction_language: Language of Instruction diff --git a/config/locales/models/units/tr.yml b/config/locales/models/units/tr.yml index 41adc82eb..2118d6afd 100644 --- a/config/locales/models/units/tr.yml +++ b/config/locales/models/units/tr.yml @@ -26,8 +26,6 @@ tr: units: Birimler search: smart_search_placeholder: Birim adı veya YOKSIS numarası - smart_search: Akıllı Arama - detailed_search: Detaylı Arama duration: Öğretim Süresi unit_status: Birim Durumu unit_instruction_language: Öğretim Dili diff --git a/config/locales/models/user/en.yml b/config/locales/models/user/en.yml index f16cb074a..acde8fd3e 100644 --- a/config/locales/models/user/en.yml +++ b/config/locales/models/user/en.yml @@ -73,6 +73,12 @@ en: identities: Identities account: <<: *user_attributes + addresses: + update_from_mernis: Update from MERNIS + create_from_mernis: Create from MERNIS + identities: + update_from_mernis: Update from MERNIS + create_from_mernis: Create from MERNIS employees: active: Is Active? title: Title @@ -88,9 +94,7 @@ en: addresses: Addresses employees: Employees search: - smart_search: Smart Search smart_search_placeholder: TC/YU number, e-mail address, first of last name - detailed_search: Detailed Search edit: form_title: Edit Account new: @@ -102,3 +106,9 @@ en: destroy: success: User successfully deleted! warning: User can not be deleted. + save_address_from_mernis: + wait: The address was recently created or updated. You can update the address once a week. + will_update: We have received your request to create or update addresses, the address will be updated within a few seconds. + save_identity_from_mernis: + wait: The identity was recently created or updated. You can update the identity once a week. + will_update: We have received your request for an identity creation or an update, and within a few seconds/minutes the identity will be updated. diff --git a/config/locales/models/user/tr.yml b/config/locales/models/user/tr.yml index 060ceff5b..0a50c77bb 100644 --- a/config/locales/models/user/tr.yml +++ b/config/locales/models/user/tr.yml @@ -73,6 +73,12 @@ tr: identities: Kimlik Bilgileri account: <<: *user_attributes + addresses: + update_from_mernis: MERNİS'ten Güncelle + create_from_mernis: MERNİS'ten Oluştur + identities: + update_from_mernis: MERNİS'ten Güncelle + create_from_mernis: MERNİS'ten Oluştur employees: active: Aktif mi? title: Ünvan @@ -88,9 +94,7 @@ tr: addresses: Adres Bilgileri employees: Personel İşlemleri search: - smart_search: Akıllı Arama smart_search_placeholder: TC/YU numarası, e-mail adresi, ad veya soyad - detailed_search: Detaylı Arama edit: form_title: Hesabı Düzenle new: @@ -102,3 +106,9 @@ tr: destroy: success: Kullanıcı başarıyla silindi! warning: Kullanıcı silinemedi! + save_address_from_mernis: + wait: Adres yakın bir zamanda oluşturulmuş veya güncellenmiş. Adresi haftada bir güncelleyebilirsiniz. + will_update: Adres oluşturma veya güncelleme talebinizi aldık, bir kaç saniye/dakika içerisinde adres güncellenecek. + save_identity_from_mernis: + wait: Kimlik yakın bir zamanda oluşturulmuş veya güncellenmiş. Kimliği haftada bir güncelleyebilirsiniz. + will_update: Kimlik oluşturma veya güncelleme talebinizi aldık, bir kaç saniye/dakika içerisinde kimlik güncellenecek. diff --git a/config/routes.rb b/config/routes.rb index fb6c50933..f569aa53c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,7 +34,7 @@ resources :calendar_titles, except: :show resources :calendar_types end - + resources :languages resources :units @@ -52,6 +52,8 @@ end resources :users do + get 'save_address_from_mernis', on: :member + get 'save_identity_from_mernis', on: :member scope module: :account do resources :employees, except: %i[index show] resources :duties, except: %i[index show] @@ -91,4 +93,10 @@ get '/studies/projects', to: 'projects#index' get '/studies/certifications', to: 'certifications#index' end + + resources :agenda_types, except: :show, module: :committee + + resources :committees, only: %i[index show], controller: 'committee/dashboard' do + resources :agendas, except: :show, module: :committee + end end diff --git a/db/migrate/20180621072455_create_courses.rb b/db/migrate/20180621072455_create_courses.rb old mode 100755 new mode 100644 index d462dcbc8..8221f6e8d --- a/db/migrate/20180621072455_create_courses.rb +++ b/db/migrate/20180621072455_create_courses.rb @@ -1,7 +1,7 @@ class CreateCourses < ActiveRecord::Migration[5.2] def change create_table :courses do |t| - t.string :name, null: false + t.string :name, null: false t.string :code, null: false t.integer :theoric, null: false t.integer :practice, null: false @@ -15,4 +15,4 @@ def change t.timestamps end end -end \ No newline at end of file +end diff --git a/db/migrate/20180912131204_create_agenda_types.rb b/db/migrate/20180912131204_create_agenda_types.rb new file mode 100644 index 000000000..46e9c9892 --- /dev/null +++ b/db/migrate/20180912131204_create_agenda_types.rb @@ -0,0 +1,8 @@ +class CreateAgendaTypes < ActiveRecord::Migration[5.2] + def change + create_table :agenda_types do |t| + t.string :name, null: false + t.timestamps + end + end +end diff --git a/db/migrate/20180913075455_create_agendas.rb b/db/migrate/20180913075455_create_agendas.rb new file mode 100644 index 000000000..92694cf2c --- /dev/null +++ b/db/migrate/20180913075455_create_agendas.rb @@ -0,0 +1,11 @@ +class CreateAgendas < ActiveRecord::Migration[5.2] + def change + create_table :agendas do |t| + t.text :description, null: false + t.references :unit, foreign_key: true + t.references :agenda_type, foreign_key: true + t.integer :status, null: false, default: 0 + t.timestamps + end + end +end diff --git a/db/migrate/20180917205042_remove_language_and_abrogated_date_from_courses.rb b/db/migrate/20180917205042_remove_language_and_abrogated_date_from_courses.rb new file mode 100644 index 000000000..5268ecbf6 --- /dev/null +++ b/db/migrate/20180917205042_remove_language_and_abrogated_date_from_courses.rb @@ -0,0 +1,6 @@ +class RemoveLanguageAndAbrogatedDateFromCourses < ActiveRecord::Migration[5.2] + def change + remove_column :courses, :language, :string + remove_column :courses, :abrogated_date, :date + end +end diff --git a/db/migrate/20180917205119_rename_education_type_to_program_type.rb b/db/migrate/20180917205119_rename_education_type_to_program_type.rb new file mode 100644 index 000000000..52fd35361 --- /dev/null +++ b/db/migrate/20180917205119_rename_education_type_to_program_type.rb @@ -0,0 +1,5 @@ +class RenameEducationTypeToProgramType < ActiveRecord::Migration[5.2] + def change + rename_column :courses, :education_type, :program_type + end +end diff --git a/db/migrate/20180917205157_add_language_id_to_courses.rb b/db/migrate/20180917205157_add_language_id_to_courses.rb new file mode 100644 index 000000000..a0c42283d --- /dev/null +++ b/db/migrate/20180917205157_add_language_id_to_courses.rb @@ -0,0 +1,6 @@ +class AddLanguageIdToCourses < ActiveRecord::Migration[5.2] + def change + add_column :courses, :language_id, :integer, foreign_key: true + add_index :courses, :language_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 6632e1bd7..c467127d0 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: 2018_09_10_105541) do +ActiveRecord::Schema.define(version: 2018_09_17_205157) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -73,6 +73,23 @@ t.integer "code", null: false end + create_table "agenda_types", force: :cascade do |t| + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "agendas", force: :cascade do |t| + t.text "description", null: false + t.bigint "unit_id" + t.bigint "agenda_type_id" + t.integer "status", default: 0, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["agenda_type_id"], name: "index_agendas_on_agenda_type_id" + t.index ["unit_id"], name: "index_agendas_on_unit_id" + end + create_table "articles", force: :cascade do |t| t.integer "yoksis_id", null: false t.integer "scope" @@ -184,12 +201,12 @@ t.integer "laboratory", null: false t.decimal "credit", precision: 5, scale: 2, default: "0.0", null: false t.bigint "unit_id" - t.integer "education_type", null: false - t.string "language", null: false + t.integer "program_type", null: false t.integer "status", null: false - t.date "abrogated_date" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "language_id" + t.index ["language_id"], name: "index_courses_on_language_id" t.index ["unit_id"], name: "index_courses_on_unit_id" end @@ -433,7 +450,7 @@ t.string "preferred_language", default: "tr" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.datetime "password_changed_at", default: -> { "now()" }, null: false + t.datetime "password_changed_at", default: -> { "CURRENT_TIMESTAMP" }, null: false t.integer "articles_count" t.integer "projects_count" t.string "slug" @@ -456,6 +473,8 @@ add_foreign_key "academic_calendars", "calendar_types" add_foreign_key "addresses", "districts" add_foreign_key "addresses", "users" + add_foreign_key "agendas", "agenda_types" + add_foreign_key "agendas", "units" add_foreign_key "articles", "users" add_foreign_key "calendar_events", "academic_calendars" add_foreign_key "calendar_events", "calendar_titles" diff --git a/db/seeds.rb b/db/seeds.rb index 2c47b5407..828f0b058 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -54,6 +54,9 @@ # Import Academic Staff from YOKSIS Rake::Task['yoksis:fetch_academic_staff'].invoke +# Create UnitType for Committee/Commission +UnitType.create(name: 'Kurul / Komisyon', code: 200) + # Produced data for beta environment if Rails.env.beta? || Rails.env.development? Dir[Rails.root.join('db', 'beta_seed', '*.rb')].sort.each do |seed| diff --git a/docs/product/.gitignore b/docs/product/.gitignore deleted file mode 100644 index 0a10022bc..000000000 --- a/docs/product/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.pdf -*.PDF -*.docx -*.DOCX -*.doc -*.DOC -*.zip -*.ZIP diff --git a/lib/tasks/post_deploy/create_unit_type_for_committee.rake b/lib/tasks/post_deploy/create_unit_type_for_committee.rake new file mode 100644 index 000000000..24eb77a4f --- /dev/null +++ b/lib/tasks/post_deploy/create_unit_type_for_committee.rake @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +task create_unit_type_for_committee: :environment do + UnitType.create(name: 'Kurul / Komisyon', code: 200) +end diff --git a/test/controllers/accounts/duties_controller_test.rb b/test/controllers/accounts/duties_controller_test.rb new file mode 100644 index 000000000..44c6de592 --- /dev/null +++ b/test/controllers/accounts/duties_controller_test.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require 'test_helper' + +module Accounts + class DutiesController < ActionDispatch::IntegrationTest + setup do + @user = users(:serhat) + @unit = units(:cbu) + sign_in @user + end + + test 'should get new' do + get new_user_duty_path(@user) + assert_response :success + end + + test 'should create duty' do + assert_difference('@user.duties.count') do + post user_duties_path(@user), params: { + duty: { + employee_id: employees(:serhat_active).id, unit_id: @unit.id, temporary: true, start_date: '01.09.2018' + } + } + end + + duty = @user.duties.last + + assert_equal employees(:serhat_active), duty.employee + assert_equal @unit, duty.unit + assert_equal true, duty.temporary + + assert_redirected_to user_path(@user) + assert_equal translate('.create.success'), flash[:notice] + end + + test 'should update duty' do + duty = @user.duties.first + + patch user_duty_path(@user, duty), params: { + duty: { + unit_id: @unit.id, temporary: true + } + } + + duty.reload + + assert_equal @unit, duty.unit + assert_equal true, duty.temporary + + assert_redirected_to user_path(@user) + assert_equal translate('.update.success'), flash[:notice] + end + + test 'should destroy duty' do + assert_difference('@user.duties.count', -1) do + delete user_duty_path(@user, @user.duties.last) + end + + assert_redirected_to user_path(@user) + assert_equal translate('.destroy.success'), flash[:notice] + end + + private + + def translate(key) + t("account.duties#{key}") + end + end +end diff --git a/test/controllers/accounts/employees_controller_test.rb b/test/controllers/accounts/employees_controller_test.rb new file mode 100644 index 000000000..31f7c9735 --- /dev/null +++ b/test/controllers/accounts/employees_controller_test.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'test_helper' + +module Accounts + class EmployeesController < ActionDispatch::IntegrationTest + setup do + @user = users(:serhat) + @title = titles(:chief) + sign_in @user + end + + test 'should get new' do + get new_user_employee_path(@user) + assert_response :success + end + + test 'should create employee' do + assert_difference('@user.employees.count') do + post user_employees_path(@user), params: { + employee: { + title_id: @title.id, active: false + } + } + end + + employee = @user.employees.last + + assert_equal @title, employee.title + assert_equal false, employee.active + + assert_redirected_to user_path(@user) + assert_equal translate('.create.success'), flash[:notice] + end + + test 'should update employee' do + employee = @user.employees.first + + patch user_employee_path(@user, employee), params: { + employee: { + title_id: @title.id, active: false + } + } + + employee.reload + + assert_equal @title, employee.title + assert_equal false, employee.active + + assert_redirected_to user_path(@user) + assert_equal translate('.update.success'), flash[:notice] + end + + test 'should destroy employee' do + assert_difference('@user.employees.count', -1) do + delete user_employee_path(@user, @user.employees.last) + end + + assert_redirected_to user_path(@user) + assert_equal translate('.destroy.success'), flash[:notice] + end + + private + + def translate(key) + t("account.employees#{key}") + end + end +end diff --git a/test/controllers/accounts/positions_controller_test.rb b/test/controllers/accounts/positions_controller_test.rb new file mode 100644 index 000000000..296406b33 --- /dev/null +++ b/test/controllers/accounts/positions_controller_test.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +require 'test_helper' + +module Accounts + class PositionsController < ActionDispatch::IntegrationTest + setup do + @user = users(:serhat) + @administrative_function = administrative_functions(:yok_member) + @duty = duties(:baum) + sign_in @user + end + + test 'should get new' do + get new_user_position_path(@user) + assert_response :success + end + + test 'should create position' do + assert_difference('@user.positions.count') do + post user_positions_path(@user), params: { + position: { + administrative_function_id: @administrative_function.id, duty_id: @duty.id, + start_date: '01.01.2013', end_date: '01.01.2015' + } + } + end + + position = @user.positions.last + + assert_equal @administrative_function, position.administrative_function + assert_equal @duty, position.duty + + assert_redirected_to user_path(@user) + assert_equal translate('.create.success'), flash[:notice] + end + + test 'should update position' do + position = @user.positions.first + + patch user_position_path(@user, position), params: { + position: { + duty_id: @duty.id, administrative_function_id: @administrative_function.id + } + } + + position.reload + + assert_equal @duty, position.duty + assert_equal @administrative_function, position.administrative_function + + assert_redirected_to user_path(@user) + assert_equal translate('.update.success'), flash[:notice] + end + + test 'should destroy position' do + assert_difference('@user.positions.count', -1) do + delete user_position_path(@user, @user.positions.last) + end + + assert_redirected_to user_path(@user) + assert_equal translate('.destroy.success'), flash[:notice] + end + + private + + def translate(key) + t("account.positions#{key}") + end + end +end diff --git a/test/controllers/committee/agenda_types_controller_test.rb b/test/controllers/committee/agenda_types_controller_test.rb new file mode 100644 index 000000000..98e78f13e --- /dev/null +++ b/test/controllers/committee/agenda_types_controller_test.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +require 'test_helper' + +module Committee + class AgendaTypesControllerTest < ActionDispatch::IntegrationTest + setup do + sign_in users(:serhat) + @agenda_type = agenda_types(:one) + end + + test 'should get index' do + get agenda_types_path + assert_response :success + assert_select '#add-button', translate('.index.new_agenda_type_link') + end + + test 'should get new' do + get new_agenda_type_path + assert_response :success + end + + test 'should create agenda type' do + assert_difference('AgendaType.count') do + post agenda_types_path, params: { + agenda_type: { name: 'Yeni Müfredat Oluşturma' } + } + end + + agenda_type = AgendaType.last + + assert_equal 'Yeni Müfredat Oluşturma', agenda_type.name + assert_redirected_to agenda_types_path + assert_equal translate('.create.success'), flash[:notice] + end + + test 'should get edit' do + get edit_agenda_type_path(@agenda_type) + assert_response :success + assert_select '.card-header strong', translate('.edit.form_title') + end + + test 'should update agenda type' do + agenda_type = AgendaType.last + patch agenda_type_path(agenda_type), + params: { + agenda_type: { name: 'Yeni Müfredat' } + } + + agenda_type.reload + + assert_equal 'Yeni Müfredat', agenda_type.name + assert_redirected_to agenda_types_path + assert_equal translate('.update.success'), flash[:notice] + end + + test 'should destroy agenda type' do + assert_difference('AgendaType.count', -1) do + delete agenda_type_path(AgendaType.last) + end + + assert_redirected_to agenda_types_path + assert_equal translate('.destroy.success'), flash[:notice] + end + + private + + def translate(key) + t("committee.agenda_types#{key}") + end + end +end diff --git a/test/controllers/committee/agendas_controller_test.rb b/test/controllers/committee/agendas_controller_test.rb new file mode 100644 index 000000000..03ca63f05 --- /dev/null +++ b/test/controllers/committee/agendas_controller_test.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +require 'test_helper' + +module Committee + class AgendasControllerTest < ActionDispatch::IntegrationTest + setup do + sign_in users(:serhat) + @agenda = agendas(:one) + @committee = units(:mühendislik_fakültesi_yönetim_kurulu) + end + + test 'should get index' do + get committee_agendas_path(@committee) + assert_response :success + assert_select '#add-button', translate('.index.new_agenda_link') + end + + test 'should get new' do + get new_committee_agenda_path(@committee) + assert_response :success + end + + test 'should create agenda' do + assert_difference('Agenda.count') do + post committee_agendas_path(@committee), + params: { + agenda: { + description: 'Test Agenda', status: :recent, + unit_id: units(:mühendislik_fakültesi_yönetim_kurulu).id, + agenda_type_id: agenda_types(:two).id + } + } + end + + agenda = Agenda.last + + assert_equal 'Test Agenda', agenda.description + assert_equal units(:mühendislik_fakültesi_yönetim_kurulu).id, agenda.unit.id + assert_equal 'recent', agenda.status + assert_equal agenda_types(:two).id, agenda.agenda_type_id + assert_redirected_to committee_agendas_path(@committee) + assert_equal translate('.create.success'), flash[:notice] + end + + test 'should get edit' do + get edit_committee_agenda_path(@committee, @agenda) + assert_response :success + assert_select '.card-header strong', translate('.edit.form_title') + end + + test 'should update agenda' do + agenda = Agenda.last + patch committee_agenda_path(@committee, agenda), + params: { + agenda: { + description: 'Test Agenda Update', status: :recent, + unit_id: units(:mühendislik_fakültesi_yönetim_kurulu).id, + agenda_type_id: agenda_types(:one).id + } + } + + agenda.reload + + assert_equal 'Test Agenda Update', agenda.description + assert_equal units(:mühendislik_fakültesi_yönetim_kurulu).id, agenda.unit_id + assert_equal 'recent', agenda.status + assert_equal agenda_types(:one).id, agenda.agenda_type_id + assert_redirected_to committee_agendas_path(@committee) + assert_equal translate('.update.success'), flash[:notice] + end + + test 'should destroy agenda type' do + assert_difference('Agenda.count', -1) do + delete committee_agenda_path(@committee, Agenda.last) + end + + assert_redirected_to committee_agendas_path(@committee) + assert_equal translate('.destroy.success'), flash[:notice] + end + + private + + def translate(key) + t("committee.agendas#{key}") + end + end +end diff --git a/test/controllers/curriculum/courses_controller_test.rb b/test/controllers/curriculum/courses_controller_test.rb index 57c99d61e..9bd7fc801 100644 --- a/test/controllers/curriculum/courses_controller_test.rb +++ b/test/controllers/curriculum/courses_controller_test.rb @@ -13,6 +13,8 @@ class CoursesControllerTest < ActionDispatch::IntegrationTest get courses_path assert_response :success assert_select '#add-button', translate('.index.add_new_course') + assert_select '#collapseSmartSearchLink', t('smart_search') + assert_select '#collapseDetailedSearchLink', t('detailed_search') end test 'should get show' do @@ -29,17 +31,18 @@ class CoursesControllerTest < ActionDispatch::IntegrationTest assert_difference('Course.count') do post courses_path, params: { course: { - name: 'Test Course', code: 'TTC', theoric: 3, practice: 0, - laboratory: 0, unit_id: units(:omu).id, education_type: :undergraduate, - language: 'Türkçe', status: :active + name: 'Test Controller Course', code: 'TTC', theoric: 3, practice: 0, + laboratory: 0, unit_id: units(:omu).id, program_type: :undergraduate, + language_id: languages(:turkce).id, status: :active } } end - course = Course.unscope(:order).last + course = Course.last - assert_equal 'Test Course', course.name + assert_equal 'Test Controller Course', course.name assert_equal 3.0, course.credit.to_f + assert_equal 'undergraduate', course.program_type assert_equal units(:omu), course.unit assert course.active? assert_redirected_to courses_path @@ -53,7 +56,7 @@ class CoursesControllerTest < ActionDispatch::IntegrationTest end test 'should update course' do - course = Course.unscope(:order).last + course = Course.last patch course_path(course), params: { course: { name: 'Test Course Update', code: 'TTCU', theoric: 4, practice: 2 diff --git a/test/fixtures/agenda_types.yml b/test/fixtures/agenda_types.yml new file mode 100644 index 000000000..7b9e904ec --- /dev/null +++ b/test/fixtures/agenda_types.yml @@ -0,0 +1,8 @@ +one: + name: Ders Ekleme + +two: + name: Müfredat Değişikliği + +three: + name: Diğer diff --git a/test/fixtures/agendas.yml b/test/fixtures/agendas.yml new file mode 100644 index 000000000..8eb96668a --- /dev/null +++ b/test/fixtures/agendas.yml @@ -0,0 +1,11 @@ +one: + description: Gündemdeki maddelerin okunması ve bir önceki fakülte yönetim kurulu kararlarının onaylanması. + unit: mühendislik_fakültesi_yönetim_kurulu + agenda_type: three + status: newly + +two: + description: 2018-2019 Eğitim öğretim yılı danışmanlık hizmetleri verecek personelin belirlenmesi konusunun görülmesi. + unit: mühendislik_fakültesi_yönetim_kurulu + agenda_type: three + status: newly diff --git a/test/fixtures/courses.yml b/test/fixtures/courses.yml index bf12389ad..5bb58419b 100644 --- a/test/fixtures/courses.yml +++ b/test/fixtures/courses.yml @@ -6,10 +6,9 @@ ati: credit: 2 laboratory: 0 unit: omu - education_type: :undergraduate - language: Türkçe - status: :active - abrogated_date: nil + program_type: undergraduate + language: turkce + status: active ydi: name: İngilizce @@ -19,10 +18,9 @@ ydi: credit: 2 laboratory: 1 unit: omu - education_type: :undergraduate - language: İngilizce - status: :active - abrogated_date: nil + program_type: undergraduate + language: ingilizce + status: active test: name: 'Test Course' @@ -32,10 +30,9 @@ test: credit: 3 laboratory: 0 unit: omu - education_type: :undergraduate - language: Türkçe - status: :active - abrogated_date: nil + program_type: undergraduate + language: turkce + status: active fi_tarihi: name: 'Fi Tarihi' @@ -45,7 +42,6 @@ fi_tarihi: credit: 2 laboratory: 0 unit: omu - education_type: :undergraduate - language: Türkçe - status: :abrogated - abrogated_date: 15.05.2018 \ No newline at end of file + program_type: undergraduate + language: turkce + status: passive \ No newline at end of file diff --git a/test/fixtures/positions.yml b/test/fixtures/positions.yml index f84c1466d..781c80cdd 100644 --- a/test/fixtures/positions.yml +++ b/test/fixtures/positions.yml @@ -1,7 +1,7 @@ baum_dean: administrative_function: dean duty: baum - start_date: 01.01.2017 + start_date: 01.01.2016 end_date: <%= Time.zone.now - 2.years %> omu_rector: administrative_function: rector diff --git a/test/fixtures/units.yml b/test/fixtures/units.yml index d01d5f9f2..43e32d69f 100644 --- a/test/fixtures/units.yml +++ b/test/fixtures/units.yml @@ -54,3 +54,15 @@ baum: unit_status: active unit_instruction_language: turkish unit_instruction_type: normal_education + +mühendislik_fakültesi_yönetim_kurulu: + name: Mühendislik Fakültesi Yönetim Kurulu + yoksis_id: + detsis_id: 96980227 + founded_at: + duration: + unit_type: + district: atakum + unit_status: active + unit_instruction_language: + unit_instruction_type: \ No newline at end of file diff --git a/test/helpers/enum_i18n_helper_test.rb b/test/helpers/enum_i18n_helper_test.rb index 945d65003..7406e4ad0 100644 --- a/test/helpers/enum_i18n_helper_test.rb +++ b/test/helpers/enum_i18n_helper_test.rb @@ -5,7 +5,7 @@ class EnumI18nHelperTest < ActionView::TestCase test 'enum_options_for_select method' do assert_equal enum_options_for_select(Course, :status), [ - %w[Pasif passive], %w[Aktif active], ['Yürürlükten Kaldırılmış', 'abrogated'] + %w[Pasif passive], %w[Aktif active] ] end end diff --git a/test/models/committees/agenda_test.rb b/test/models/committees/agenda_test.rb new file mode 100644 index 000000000..ab38e0394 --- /dev/null +++ b/test/models/committees/agenda_test.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'test_helper' + +class AgendaTest < ActiveSupport::TestCase + # relations + %i[ + unit + agenda_type + ].each do |property| + test "a agenda can communicate with #{property}" do + assert agendas(:one).send(property) + end + end + + # validations: presence + %i[ + description + status + ].each do |property| + test "presence validations for #{property} of a agenda" do + agendas(:one).send("#{property}=", nil) + assert_not agendas(:one).valid? + assert_not_empty agendas(:one).errors[property] + end + end +end diff --git a/test/models/committees/agenda_type_test.rb b/test/models/committees/agenda_type_test.rb new file mode 100644 index 000000000..6af7898e2 --- /dev/null +++ b/test/models/committees/agenda_type_test.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'test_helper' + +class AgendaTypeTest < ActiveSupport::TestCase + # validations: presence + test 'should not save agenda_type without name' do + agenda_types(:one).name = nil + assert_not agenda_types(:one).valid? + assert_not_empty agenda_types(:one).errors[:name] + end +end diff --git a/test/models/curriculums/course_test.rb b/test/models/curriculums/course_test.rb index 1b5567404..6d30e2740 100644 --- a/test/models/curriculums/course_test.rb +++ b/test/models/curriculums/course_test.rb @@ -3,71 +3,69 @@ require 'test_helper' class CourseTest < ActiveSupport::TestCase - test 'course can communicate with unit' do - assert courses(:ati).unit + setup do + @course = courses(:test) + end + + %i[ + unit + language + ].each do |property| + test "course can communicate with #{property}" do + assert @course.send(property) + end end # validations: presence %i[ code - education_type + program_type laboratory language name practice status theoric + unit ].each do |property| test "presence validations for #{property} of a course" do - courses(:ati).send("#{property}=", nil) - assert_not courses(:ati).valid? - assert_not_empty courses(:ati).errors[property] + @course.send("#{property}=", nil) + assert_not @course.valid? + assert_not_empty @course.errors[property] end end - test 'presence validations for abrogated_date of a course' do - courses(:fi_tarihi).abrogated_date = nil - assert_not courses(:fi_tarihi).valid? - assert_not_empty courses(:fi_tarihi).errors[:abrogated_date] - end - # validations: uniqueness test 'uniqueness validations for code of a course' do - fake = courses(:ati).dup + fake = @course.dup assert_not fake.valid? assert_not_empty fake.errors[:code] end test 'uniqueness validations for name of a course' do - fake = courses(:ati).dup + fake = @course.dup + fake.code = 'TB01' assert_not fake.valid? - fake.code = 'TEST001' - assert fake.valid? + assert_not_empty fake.errors[:name] end # callbacks test 'callbacks must titlecase the name for a course' do - course = courses(:test).dup + course = @course.dup course.update(code: 'DD101', name: 'deNEme dErSi') assert_equal course.name, 'Deneme Dersi' end - test 'callbacks must set value the abrogated date for a course' do - course = courses(:test).dup - course.update(code: 'DD101', status: :abrogated) - assert_equal course.abrogated_date, Time.zone.today - end - test 'callbacks must set value the credit for a course' do - course = courses(:test).dup + course = @course.dup course.update(code: 'DD101', theoric: 10, practice: 3) assert_equal course.credit, 11.5 end # enums { - status: { passive: 0, active: 1, abrogated: 2 }, - education_type: { undergraduate: 0, master: 1, doctoral: 2 } + status: { passive: 0, active: 1 }, + program_type: { associate: 0, undergraduate: 1, master: 2, doctoral: 3 } }.each do |property, hash| hash.each do |key, value| test "have a #{key} value of #{property} enum" do diff --git a/test/models/language_test.rb b/test/models/language_test.rb index 5453f236b..3a93fbefd 100644 --- a/test/models/language_test.rb +++ b/test/models/language_test.rb @@ -7,6 +7,10 @@ class LanguageTest < ActiveSupport::TestCase @language = languages(:turkce) end + test 'langugage can communicate with courses' do + assert @language.courses + end + # validations: presence %i[ name