From 1a83436626e6c6e6831fc25facfe513a748ea1c8 Mon Sep 17 00:00:00 2001 From: Sinan Sahin Date: Tue, 11 Sep 2018 18:34:27 +0300 Subject: [PATCH 01/48] =?UTF-8?q?Kullan=C4=B1c=C4=B1=20profillerine=20mern?= =?UTF-8?q?is=20butonlar=C4=B1=20ekle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit users_controller için 2 metod eklendi: * save_address_from_mernis * save_identity_from_mernis view tarafında ilgili butonlar eklendi. locales çalışması yapıldı. redirect_with metodu güncellendi. References: #144 --- app/controllers/users_controller.rb | 32 ++++++++++++++++++++++++++-- app/views/users/_addresses.html.erb | 8 +++++++ app/views/users/_identities.html.erb | 7 ++++++ config/locales/models/user/en.yml | 14 ++++++++++++ config/locales/models/user/tr.yml | 12 +++++++++++ config/routes.rb | 2 ++ db/schema.rb | 4 ++-- 7 files changed, 75 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 65a980fd1..ae0fc3d26 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,10 +2,13 @@ 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? @@ -41,6 +44,16 @@ def destroy @user.destroy ? redirect_with('.success') : redirect_with('.warning') end + def save_address_from_mernis + Kps::AddressSaveJob.perform_later(@user) + redirect_with('will_update') + end + + def save_identity_from_mernis + Kps::IdentitySaveJob.perform_later(@user) + redirect_with('will_update') + end + private def set_user @@ -55,11 +68,26 @@ 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 def redirect_with(message) - redirect_to(users_path, notice: t(".#{message}")) + redirect_to(users_path, notice: t(".#{message}")) if @user.blank? + redirect_to(user_path(@user), notice: t(".#{message}")) end end diff --git a/app/views/users/_addresses.html.erb b/app/views/users/_addresses.html.erb index df3b0e523..bfdf1fbdb 100644 --- a/app/views/users/_addresses.html.erb +++ b/app/views/users/_addresses.html.erb @@ -1,6 +1,14 @@
+
+
+
+ <%= 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" %> +
+
+
+ <% if @addresses.any? %> <% @addresses.each do |address| %>
diff --git a/app/views/users/_identities.html.erb b/app/views/users/_identities.html.erb index 1320687e8..89775ca3d 100644 --- a/app/views/users/_identities.html.erb +++ b/app/views/users/_identities.html.erb @@ -1,6 +1,13 @@
+
+
+
+ <%= 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" %> +
+
+
<% if @identities.any? %> <% @identities.each do |identity| %>
diff --git a/config/locales/models/user/en.yml b/config/locales/models/user/en.yml index f16cb074a..04c8b0596 100644 --- a/config/locales/models/user/en.yml +++ b/config/locales/models/user/en.yml @@ -71,6 +71,12 @@ en: new_user_link: Create a New User addresses: Addresses identities: Identities + 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 account: <<: *user_attributes employees: @@ -87,6 +93,8 @@ en: identities: Identities addresses: Addresses employees: Employees + update_from_mernis: Update from MERNİS + create_from_mernis: Create from MERNIS search: smart_search: Smart Search smart_search_placeholder: TC/YU number, e-mail address, first of last name @@ -102,3 +110,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..f663abd96 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 @@ -102,3 +108,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..f1fb9047e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/db/schema.rb b/db/schema.rb index c6de63938..6d1563584 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -254,8 +254,8 @@ end create_table "languages", force: :cascade do |t| - t.string "name" - t.string "iso" + t.string "name", null: false + t.string "iso", null: false t.integer "yoksis_code" t.datetime "created_at", null: false t.datetime "updated_at", null: false From 772053310a65370c2a645f44ec8659e0e6828348 Mon Sep 17 00:00:00 2001 From: Sinan Sahin Date: Wed, 12 Sep 2018 12:27:04 +0300 Subject: [PATCH 02/48] =?UTF-8?q?Y=C3=B6nlendirme=20hatas=C4=B1n=C4=B1=20d?= =?UTF-8?q?=C3=BCzelt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kullanıcı profillerinden yapılan mernis isteklerinde \n kullanıcıyı yine profil sayfasına yönlendir. --- app/controllers/concerns/last_update_from_mernis.rb | 4 +++- app/controllers/users_controller.rb | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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/users_controller.rb b/app/controllers/users_controller.rb index ae0fc3d26..ccd18db13 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -46,12 +46,12 @@ def destroy def save_address_from_mernis Kps::AddressSaveJob.perform_later(@user) - redirect_with('will_update') + redirect_to(@user, notice: t('.will_update')) end def save_identity_from_mernis Kps::IdentitySaveJob.perform_later(@user) - redirect_with('will_update') + redirect_to(@user, notice: t('.will_update')) end private @@ -87,7 +87,6 @@ def user_params end def redirect_with(message) - redirect_to(users_path, notice: t(".#{message}")) if @user.blank? - redirect_to(user_path(@user), notice: t(".#{message}")) + redirect_to(users_path, notice: t(".#{message}")) end end From e0cef3a072ae01eeccb9aa37c7e416ab512d37d2 Mon Sep 17 00:00:00 2001 From: msdundar Date: Wed, 12 Sep 2018 14:58:24 +0300 Subject: [PATCH 03/48] Remove redundant text from user management page --- app/views/users/_addresses.html.erb | 77 +++++++---------- app/views/users/_identities.html.erb | 122 ++++++++++++--------------- config/routes.rb | 2 +- 3 files changed, 86 insertions(+), 115 deletions(-) diff --git a/app/views/users/_addresses.html.erb b/app/views/users/_addresses.html.erb index bfdf1fbdb..b25a1772b 100644 --- a/app/views/users/_addresses.html.erb +++ b/app/views/users/_addresses.html.erb @@ -1,60 +1,45 @@ - -
-
+
<%= 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" %>
- - <% if @addresses.any? %> - <% @addresses.each do |address| %> -
-
-
-
- <%= link_to_edit(edit_address_path(address)) %> - <%= link_to_destroy(address) %> -
-
- -
- - - - - - - - - - - - - - - - - -
<%= 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 %>
-
-
-
- <% 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 89775ca3d..f0b68295e 100644 --- a/app/views/users/_identities.html.erb +++ b/app/views/users/_identities.html.erb @@ -1,5 +1,3 @@ - -
@@ -8,76 +6,64 @@
- <% 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 %>
-
-
-
- <% 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/config/routes.rb b/config/routes.rb index f1fb9047e..095b3869f 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 From 310a3bec4939c3ca39592f1009f7167c3e2acc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Recai=20Okta=C5=9F?= Date: Wed, 12 Sep 2018 23:27:15 +0300 Subject: [PATCH 04/48] Revert "Create /docs/product with a sane .gitignore inside" This reverts commit 44f9153874e9fbe2d059c11299bb44cdd2bbc1d9. --- docs/product/.gitignore | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 docs/product/.gitignore 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 From 95fbf6c66e4510d16e9181a4012c89e11dd51746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Recai=20Okta=C5=9F?= Date: Wed, 12 Sep 2018 23:29:52 +0300 Subject: [PATCH 05/48] Revert "Set the ownership of /docs/product/ path to @omu/product group" This reverts commit 71a12c05238726802bd929af0a7c0f11d5561e54. --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) 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 From 84c2a225554b90c2c8884bd66c962917d54dc158 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Thu, 13 Sep 2018 10:43:33 +0300 Subject: [PATCH 06/48] Create AgendaType model and it's VC --- .../committee/agenda_types_controller.rb | 50 +++++++++++++++++++ app/models/committees/agenda_type.rb | 17 +++++++ .../committee/agenda_types/_form.html.erb | 26 ++++++++++ .../committee/agenda_types/edit.html.erb | 1 + .../committee/agenda_types/index.html.erb | 46 +++++++++++++++++ app/views/committee/agenda_types/new.html.erb | 1 + config/locales/layouts/shared/sidebar_en.yml | 1 + config/locales/layouts/shared/sidebar_tr.yml | 1 + config/locales/models/committees/en.yml | 27 ++++++++++ config/locales/models/committees/tr.yml | 27 ++++++++++ config/routes.rb | 4 ++ .../20180912131204_create_agenda_types.rb | 8 +++ db/schema.rb | 8 ++- test/fixtures/agenda_types.yml | 8 +++ test/models/committees/agenda_type_test.rb | 12 +++++ 15 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 app/controllers/committee/agenda_types_controller.rb create mode 100644 app/models/committees/agenda_type.rb create mode 100644 app/views/committee/agenda_types/_form.html.erb create mode 100644 app/views/committee/agenda_types/edit.html.erb create mode 100644 app/views/committee/agenda_types/index.html.erb create mode 100644 app/views/committee/agenda_types/new.html.erb create mode 100644 config/locales/models/committees/en.yml create mode 100644 config/locales/models/committees/tr.yml create mode 100644 db/migrate/20180912131204_create_agenda_types.rb create mode 100644 test/fixtures/agenda_types.yml create mode 100644 test/models/committees/agenda_type_test.rb diff --git a/app/controllers/committee/agenda_types_controller.rb b/app/controllers/committee/agenda_types_controller.rb new file mode 100644 index 000000000..2dc87e3e7 --- /dev/null +++ b/app/controllers/committee/agenda_types_controller.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Committee + class AgendaTypesController < ApplicationController + include Pagy::Backend + + before_action :set_agenda_type, only: %i[edit update destroy] + + def index + @pagy, @agenda_types = if params[:term].present? + pagy(AgendaType.all.search(params[:term])) + else + pagy(AgendaType.all) + end + 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/models/committees/agenda_type.rb b/app/models/committees/agenda_type.rb new file mode 100644 index 000000000..fd2fd370b --- /dev/null +++ b/app/models/committees/agenda_type.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AgendaType < ApplicationRecord + # search + include PgSearch + pg_search_scope( + :search, + against: :name, + using: { tsearch: { prefix: true } } + ) + + # validations + validates :name, presence: true + + # callbacks + before_save { self.name = name.capitalize_all } +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..592ccadba --- /dev/null +++ b/app/views/committee/agenda_types/_form.html.erb @@ -0,0 +1,26 @@ +
+
+
+
+ <%= fa_icon 'calendar' %> + <%= 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..98df69aa3 --- /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 'tasks', 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..171a73df5 --- /dev/null +++ b/app/views/committee/agenda_types/new.html.erb @@ -0,0 +1 @@ +<%= render 'form', city: @agenda_type, form_title: t('.form_title') %> diff --git a/config/locales/layouts/shared/sidebar_en.yml b/config/locales/layouts/shared/sidebar_en.yml index 0c214525e..1a0df0b81 100644 --- a/config/locales/layouts/shared/sidebar_en.yml +++ b/config/locales/layouts/shared/sidebar_en.yml @@ -28,3 +28,4 @@ en: unit_types: Unit Types university_types: University Types studies: Academic Studies + committees: Committees/Commissions diff --git a/config/locales/layouts/shared/sidebar_tr.yml b/config/locales/layouts/shared/sidebar_tr.yml index 2ea5a54f0..698e9cbfa 100644 --- a/config/locales/layouts/shared/sidebar_tr.yml +++ b/config/locales/layouts/shared/sidebar_tr.yml @@ -28,3 +28,4 @@ tr: unit_types: Birim Türleri university_types: Üniversite Türleri studies: Akademik Çalışmalar + committees: Kurullar/Komisyonlar diff --git a/config/locales/models/committees/en.yml b/config/locales/models/committees/en.yml new file mode 100644 index 000000000..1166b424f --- /dev/null +++ b/config/locales/models/committees/en.yml @@ -0,0 +1,27 @@ +en: + activerecord: + attributes: + agenda_type: &agenda_type_attributes + name: Name of Agenda Type + helpers: + submit: + agenda_type: + create: Create Agenda Type + update: Update Agenda Type + committee: + 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 + update: + success: Agenda Type successfully updated. + create: + success: Agenda Type successfully created. + destroy: + success: Agenda Type successfully deleted. + warning: Agenda Type can not be deleted! diff --git a/config/locales/models/committees/tr.yml b/config/locales/models/committees/tr.yml new file mode 100644 index 000000000..054e1d04f --- /dev/null +++ b/config/locales/models/committees/tr.yml @@ -0,0 +1,27 @@ +tr: + activerecord: + attributes: + agenda_type: &agenda_type_attributes + name: Gündem Türü Adı + helpers: + submit: + agenda_type: + create: Gündem Türü Oluştur + update: Gündem Türü Güncelle + committee: + 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! diff --git a/config/routes.rb b/config/routes.rb index 095b3869f..b9428c582 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -93,4 +93,8 @@ get '/studies/projects', to: 'projects#index' get '/studies/certifications', to: 'certifications#index' end + + scope module: :committee do + resources :agenda_types, except: :show + end 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/schema.rb b/db/schema.rb index 6632e1bd7..14bc734ae 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_12_131204) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -73,6 +73,12 @@ 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 "articles", force: :cascade do |t| t.integer "yoksis_id", null: false t.integer "scope" 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/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 From f8c97aacc33b544394e70bd6b5c56854b7591909 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Thu, 13 Sep 2018 13:15:58 +0300 Subject: [PATCH 07/48] Create the Agenda model and its test --- app/models/committees/agenda.rb | 14 +++++++++++ app/models/committees/agenda_type.rb | 3 +++ db/migrate/20180913075455_create_agendas.rb | 11 +++++++++ db/schema.rb | 15 +++++++++++- test/fixtures/agendas.yml | 11 +++++++++ test/fixtures/units.yml | 12 +++++++++ test/models/committees/agenda_test.rb | 27 +++++++++++++++++++++ 7 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 app/models/committees/agenda.rb create mode 100644 db/migrate/20180913075455_create_agendas.rb create mode 100644 test/fixtures/agendas.yml create mode 100644 test/models/committees/agenda_test.rb diff --git a/app/models/committees/agenda.rb b/app/models/committees/agenda.rb new file mode 100644 index 000000000..7dda693b0 --- /dev/null +++ b/app/models/committees/agenda.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class Agenda < ApplicationRecord + # relations + belongs_to :unit + belongs_to :agenda_type + + # validations + validates :description, presence: true + validates :status, presence: true + + # enums + enum status: { newly: 0, settle: 1, delay: 2 } +end diff --git a/app/models/committees/agenda_type.rb b/app/models/committees/agenda_type.rb index fd2fd370b..067befb63 100644 --- a/app/models/committees/agenda_type.rb +++ b/app/models/committees/agenda_type.rb @@ -9,6 +9,9 @@ class AgendaType < ApplicationRecord using: { tsearch: { prefix: true } } ) + # reloations + has_many :agendas, dependent: :nullify + # validations validates :name, presence: true 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/schema.rb b/db/schema.rb index 14bc734ae..241bf92ca 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_12_131204) do +ActiveRecord::Schema.define(version: 2018_09_13_075455) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -79,6 +79,17 @@ 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" @@ -462,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/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/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/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 From 9f7460ded31d71f4d42ca0be930e4e0e0abeffa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdullah=20Da=C4=9Fl=C4=B1?= Date: Thu, 13 Sep 2018 21:28:18 +0300 Subject: [PATCH 08/48] =?UTF-8?q?Use=20case=20issue=20template'i=20olu?= =?UTF-8?q?=C5=9Ftur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/use-case.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/use-case.md diff --git a/.github/ISSUE_TEMPLATE/use-case.md b/.github/ISSUE_TEMPLATE/use-case.md new file mode 100644 index 000000000..21d484221 --- /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, uygulama da 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.) From aaa87deb57cdd1ff4d4050ee639c1ea8b6dd7bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdullah=20Da=C4=9Fl=C4=B1?= Date: Thu, 13 Sep 2018 22:14:40 +0300 Subject: [PATCH 09/48] =?UTF-8?q?Harf=20hatas=C4=B1n=C4=B1=20d=C3=BCzelt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/use-case.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/use-case.md b/.github/ISSUE_TEMPLATE/use-case.md index 21d484221..3a48d70d8 100644 --- a/.github/ISSUE_TEMPLATE/use-case.md +++ b/.github/ISSUE_TEMPLATE/use-case.md @@ -14,7 +14,7 @@ about: Product ekibi tarafından hazırlanmış `use case` için iş kaydı. * [ ] İş 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ı? +* [ ] Use case ve oluşturulan mockup'lar müşteri tarafından onaylandı mı? **Ek içerik:** From 61d039d5561caa8aeb5ca9f326afe887ad705964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdullah=20Da=C4=9Fl=C4=B1?= Date: Thu, 13 Sep 2018 22:33:28 +0300 Subject: [PATCH 10/48] =?UTF-8?q?s/uygulama=20da/uygulamada/=20d=C3=BCzenl?= =?UTF-8?q?emesini=20yap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/use-case.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/use-case.md b/.github/ISSUE_TEMPLATE/use-case.md index 3a48d70d8..784686817 100644 --- a/.github/ISSUE_TEMPLATE/use-case.md +++ b/.github/ISSUE_TEMPLATE/use-case.md @@ -8,7 +8,7 @@ about: Product ekibi tarafından hazırlanmış `use case` için iş kaydı. **Açıklama:** -[//]: # (Kısa ve net bir şekilde konuyla ilişkili olarak sizin önerileriniz neler, sizin öneriniz kabul edilirse neler olacak, uygulama da neler iyileşecek açıklayınız.) +[//]: # (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** From 90566c6ab6aec6e24ec46d3a23cb6024c0eeeb8c Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Fri, 14 Sep 2018 11:46:26 +0300 Subject: [PATCH 11/48] Add agenda models's views, controller and locals --- .../committee/agendas_controller.rb | 57 ++++++++++++++++++ .../committee/dashboard_controller.rb | 26 +++++++++ app/models/committees/agenda.rb | 10 +++- app/models/unit.rb | 2 + .../committee/agenda_types/_form.html.erb | 2 +- app/views/committee/agenda_types/new.html.erb | 2 +- app/views/committee/agendas/_form.html.erb | 36 ++++++++++++ app/views/committee/agendas/edit.html.erb | 1 + app/views/committee/agendas/index.html.erb | 52 +++++++++++++++++ app/views/committee/agendas/new.html.erb | 1 + app/views/committee/dashboard/index.html.erb | 51 ++++++++++++++++ app/views/committee/dashboard/show.html.erb | 58 +++++++++++++++++++ config/locales/models/committees/en.yml | 50 +++++++++++++++- config/locales/models/committees/tr.yml | 48 +++++++++++++++ config/routes.rb | 6 ++ 15 files changed, 397 insertions(+), 5 deletions(-) create mode 100644 app/controllers/committee/agendas_controller.rb create mode 100644 app/controllers/committee/dashboard_controller.rb create mode 100644 app/views/committee/agendas/_form.html.erb create mode 100644 app/views/committee/agendas/edit.html.erb create mode 100644 app/views/committee/agendas/index.html.erb create mode 100644 app/views/committee/agendas/new.html.erb create mode 100644 app/views/committee/dashboard/index.html.erb create mode 100644 app/views/committee/dashboard/show.html.erb diff --git a/app/controllers/committee/agendas_controller.rb b/app/controllers/committee/agendas_controller.rb new file mode 100644 index 000000000..dc72d6fe2 --- /dev/null +++ b/app/controllers/committee/agendas_controller.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Committee + class AgendasController < ApplicationController + include Pagy::Backend + + before_action :set_agenda, only: %i[edit update destroy] + before_action :set_committee + + def index + agendas = Agenda.where(unit: @committee).includes(:unit, :agenda_type) + @pagy, @agendas = if params[:term].present? + pagy(agendas.search(params[:term])) + else + pagy(agendas) + end + end + + def new + @agenda = Agenda.new + end + + def edit; end + + def create + @agenda = Agenda.new(agenda_params) + @agenda.save ? redirect_with('success') : render(:new) + end + + def update + @committee = Unit.find(agenda_params[:unit_id]) + @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_agenda + @agenda = Agenda.find(params[:id]) + end + + def set_committee + @committee = Unit.find(params[:committee_id]) + 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..7def4a784 --- /dev/null +++ b/app/controllers/committee/dashboard_controller.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Committee + class DashboardController < ApplicationController + include Pagy::Backend + + def index + units = Unit.committees.includes(:unit_type, :unit_status, district: :city) + @pagy, @committees = if params[:term].present? + pagy(units.search(params[:term])) + else + pagy(units) + end + end + + def show + @committee = Unit.find(params[:id]) + agendas = @committee.agendas.includes(:agenda_type) + @pagy, @agendas = if params[:term].present? + pagy(agendas.search(params[:term])) + else + pagy(agendas) + end + end + end +end diff --git a/app/models/committees/agenda.rb b/app/models/committees/agenda.rb index 7dda693b0..468270148 100644 --- a/app/models/committees/agenda.rb +++ b/app/models/committees/agenda.rb @@ -1,6 +1,14 @@ # 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 @@ -10,5 +18,5 @@ class Agenda < ApplicationRecord validates :status, presence: true # enums - enum status: { newly: 0, settle: 1, delay: 2 } + enum status: { newly: 0, desided: 1, delayed: 2 } end diff --git a/app/models/unit.rb b/app/models/unit.rb index 5586bfbc9..8d99c1361 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(name: 'Kurul / Komisyon')) } end diff --git a/app/views/committee/agenda_types/_form.html.erb b/app/views/committee/agenda_types/_form.html.erb index 592ccadba..a2b35f269 100644 --- a/app/views/committee/agenda_types/_form.html.erb +++ b/app/views/committee/agenda_types/_form.html.erb @@ -6,7 +6,7 @@ <%= form_title %>
- <%= simple_form_for(@agenda_type) do |f| %> + <%= simple_form_for(agenda_type) do |f| %>
<%= f.error_notification %> diff --git a/app/views/committee/agenda_types/new.html.erb b/app/views/committee/agenda_types/new.html.erb index 171a73df5..f1f2692cb 100644 --- a/app/views/committee/agenda_types/new.html.erb +++ b/app/views/committee/agenda_types/new.html.erb @@ -1 +1 @@ -<%= render 'form', city: @agenda_type, form_title: t('.form_title') %> +<%= 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..396a7c7d8 --- /dev/null +++ b/app/views/committee/agendas/_form.html.erb @@ -0,0 +1,36 @@ +
+
+
+
+ <%= fa_icon 'calendar' %> + <%= form_title %> +
+
+ <%= simple_form_for([:committee, agenda]) 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..708eb146b --- /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.name %><%= agenda.agenda_type.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..210402c6b --- /dev/null +++ b/app/views/committee/dashboard/index.html.erb @@ -0,0 +1,51 @@ +
+
+
+
+ <%= fa_icon 'tasks', 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') %>
<%= committee.name %><%= 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..1d4dc1666 --- /dev/null +++ b/app/views/committee/dashboard/show.html.erb @@ -0,0 +1,58 @@ +
+
+
+
+
<%= @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('.unit') %><%= t('.agenda_type') %><%= t('.status') %><%= t('.actions') %>
<%= agenda.description %><%= agenda.unit.parent.name %><%= agenda.agenda_type.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/config/locales/models/committees/en.yml b/config/locales/models/committees/en.yml index 1166b424f..c070780f5 100644 --- a/config/locales/models/committees/en.yml +++ b/config/locales/models/committees/en.yml @@ -1,14 +1,44 @@ en: activerecord: attributes: + agenda: &agenda_attributes + description: Agenda Description + agenda_type: Agenda Type + status: Agenda Status agenda_type: &agenda_type_attributes name: Name of Agenda Type + enums: + agenda: + statuses: + newly: Yeni + desided: 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 + 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 @@ -18,10 +48,26 @@ en: form_title: Create a Agenda Type edit: form_title: Update the Agenda Type - update: - success: Agenda Type successfully updated. 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 + 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 index 054e1d04f..4f8fbf995 100644 --- a/config/locales/models/committees/tr.yml +++ b/config/locales/models/committees/tr.yml @@ -1,14 +1,46 @@ tr: activerecord: attributes: + agenda: &agenda_attributes + description: Gündem Açıklaması + agenda_type: 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: + newly: Yeni + desided: 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 + 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 @@ -25,3 +57,19 @@ tr: 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 + 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/routes.rb b/config/routes.rb index b9428c582..01c499857 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,5 +96,11 @@ scope module: :committee do resources :agenda_types, except: :show + get '/committees', to: 'dashboard#index' + get '/committees/:id', to: 'dashboard#show', as: :committee + end + +resources :committees, only: [] do + resources :agendas, except: :show, module: :committee end end From 5a3ceebb97ac83b2cc1b3c72e6310a38a9475b6b Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Fri, 14 Sep 2018 12:24:35 +0300 Subject: [PATCH 12/48] Add committes link to sidebar --- app/views/layouts/shared/_sidebar.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/layouts/shared/_sidebar.html.erb b/app/views/layouts/shared/_sidebar.html.erb index 9cb1fc49d..b345db3bf 100644 --- a/app/views/layouts/shared/_sidebar.html.erb +++ b/app/views/layouts/shared/_sidebar.html.erb @@ -141,6 +141,11 @@ <%= fa_icon('file-text-o', text: t('.studies'), class: 'nav-icon') %> <% end %> + From 46eb75f6a342f79da620cde4acdee319a1dbb8c8 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Fri, 14 Sep 2018 12:36:44 +0300 Subject: [PATCH 13/48] Fix indent --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 01c499857..c7310d4bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -100,7 +100,7 @@ get '/committees/:id', to: 'dashboard#show', as: :committee end -resources :committees, only: [] do + resources :committees, only: [] do resources :agendas, except: :show, module: :committee end end From 1db72028cfcdb764d1ff2996f707b34f498f8d93 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Fri, 14 Sep 2018 16:19:00 +0300 Subject: [PATCH 14/48] Escape unscoped find --- .../committee/agendas_controller.rb | 18 +++++++++--------- app/views/committee/agendas/_form.html.erb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/committee/agendas_controller.rb b/app/controllers/committee/agendas_controller.rb index dc72d6fe2..395f0f677 100644 --- a/app/controllers/committee/agendas_controller.rb +++ b/app/controllers/committee/agendas_controller.rb @@ -4,11 +4,11 @@ module Committee class AgendasController < ApplicationController include Pagy::Backend - before_action :set_agenda, only: %i[edit update destroy] before_action :set_committee + before_action :set_agenda, only: %i[edit update destroy] def index - agendas = Agenda.where(unit: @committee).includes(:unit, :agenda_type) + agendas = @committee.agendas.includes(:agenda_type) @pagy, @agendas = if params[:term].present? pagy(agendas.search(params[:term])) else @@ -17,18 +17,17 @@ def index end def new - @agenda = Agenda.new + @agenda = @committee.agendas.new end def edit; end def create - @agenda = Agenda.new(agenda_params) + @agenda = @committee.agendas.new(agenda_params) @agenda.save ? redirect_with('success') : render(:new) end def update - @committee = Unit.find(agenda_params[:unit_id]) @agenda.update(agenda_params) ? redirect_with('success') : render(:edit) end @@ -42,12 +41,13 @@ def redirect_with(message) redirect_to(committee_agendas_path(@committee), notice: t(".#{message}")) end - def set_agenda - @agenda = Agenda.find(params[:id]) - end - def set_committee @committee = Unit.find(params[:committee_id]) + not_found unless @committee + end + + def set_agenda + @agenda = @committee.agendas.find(params[:id]) if @committee end def agenda_params diff --git a/app/views/committee/agendas/_form.html.erb b/app/views/committee/agendas/_form.html.erb index 396a7c7d8..960e592f7 100644 --- a/app/views/committee/agendas/_form.html.erb +++ b/app/views/committee/agendas/_form.html.erb @@ -6,7 +6,7 @@ <%= form_title %>
- <%= simple_form_for([:committee, agenda]) do |f| %> + <%= simple_form_for([@committee, agenda], url: committee_agendas_path(@committee.id), method: :post) do |f| %>
<%= f.error_notification %> From a8c7b14e6f374e814bd0fb3ee5543188fa35f5b1 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Fri, 14 Sep 2018 16:39:43 +0300 Subject: [PATCH 15/48] Remove not_found code line --- app/controllers/committee/agendas_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/committee/agendas_controller.rb b/app/controllers/committee/agendas_controller.rb index 395f0f677..800c08e4c 100644 --- a/app/controllers/committee/agendas_controller.rb +++ b/app/controllers/committee/agendas_controller.rb @@ -43,7 +43,6 @@ def redirect_with(message) def set_committee @committee = Unit.find(params[:committee_id]) - not_found unless @committee end def set_agenda From b51fc44e16296ed622cec0b478e8e975c2dd7bc2 Mon Sep 17 00:00:00 2001 From: Dilara Koca Date: Sat, 15 Sep 2018 16:33:24 +0300 Subject: [PATCH 16/48] Controller testlerini ekle --- .../accounts/duties_controller_test.rb | 70 ++++++++++++++++++ .../accounts/employees_controller_test.rb | 69 ++++++++++++++++++ .../accounts/positions_controller_test.rb | 71 +++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 test/controllers/accounts/duties_controller_test.rb create mode 100644 test/controllers/accounts/employees_controller_test.rb create mode 100644 test/controllers/accounts/positions_controller_test.rb 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 From 2b4317d800ac52dbeb6b534838b810d3e4486a83 Mon Sep 17 00:00:00 2001 From: Dilara Koca Date: Sat, 15 Sep 2018 16:38:15 +0300 Subject: [PATCH 17/48] =?UTF-8?q?Position=20fixture'=C4=B1=20validasyona?= =?UTF-8?q?=20uygun=20hale=20getir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fixtures/positions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 8d5556db0376df4116ab9381fb24837c5d9bc85b Mon Sep 17 00:00:00 2001 From: isubas Date: Sun, 16 Sep 2018 02:53:40 +0300 Subject: [PATCH 18/48] =?UTF-8?q?Pagy=20i=C3=A7in=20DRY=20iyile=C5=9Ftirme?= =?UTF-8?q?lerini=20yap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 ++ .../calendar/academic_calendars_controller.rb | 8 ++++---- .../calendar/academic_terms_controller.rb | 4 +--- .../calendar/calendar_titles_controller.rb | 8 +------- .../calendar/calendar_types_controller.rb | 6 ++---- app/controllers/concerns/reference_resource.rb | 3 +-- app/controllers/curriculum/courses_controller.rb | 5 +---- app/controllers/languages_controller.rb | 10 +--------- app/controllers/locations/cities_controller.rb | 10 +--------- .../locations/countries_controller.rb | 16 ++-------------- app/controllers/studies/articles_controller.rb | 2 -- app/controllers/units_controller.rb | 10 ++-------- app/controllers/users_controller.rb | 7 +------ app/helpers/application_helper.rb | 1 + app/helpers/units_helper.rb | 5 ----- 15 files changed, 20 insertions(+), 77 deletions(-) delete mode 100644 app/helpers/units_helper.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e06a13229..eae3cff71 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 PagyBackendWithSearch + protect_from_forgery with: :exception before_action :configure_permitted_parameters, if: :devise_controller? 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/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..e5ba1b7fa 100644 --- a/app/controllers/curriculum/courses_controller.rb +++ b/app/controllers/curriculum/courses_controller.rb @@ -2,13 +2,10 @@ 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 = pagy_by_search(Course.includes(:unit)) end def show; 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 ccd18db13..6f9b30e27 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true class UsersController < ApplicationController - include Pagy::Backend include LastUpdateFromMernis before_action :set_user, only: %i[show edit update destroy save_address_from_mernis save_identity_from_mernis] @@ -11,11 +10,7 @@ class UsersController < ApplicationController 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 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 From 418b65cbe4d8e1709e03dd1101d709b86045c884 Mon Sep 17 00:00:00 2001 From: isubas Date: Sun, 16 Sep 2018 02:56:49 +0300 Subject: [PATCH 19/48] =?UTF-8?q?Pagy=20i=C3=A7in=20concern=20geli=C5=9Fti?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../concerns/pagy_backend_with_search.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/controllers/concerns/pagy_backend_with_search.rb diff --git a/app/controllers/concerns/pagy_backend_with_search.rb b/app/controllers/concerns/pagy_backend_with_search.rb new file mode 100644 index 000000000..a8729ce74 --- /dev/null +++ b/app/controllers/concerns/pagy_backend_with_search.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module PagyBackendWithSearch + extend ActiveSupport::Concern + include Pagy::Backend + + included do + def pagy_by_search(collection) + @pagy, items = pagy( + (term = params[:term]).present? ? collection.search(term) : collection + ) + items + end + end +end From 391006f5f7b40f9a64738d8c38a13f82a0871186 Mon Sep 17 00:00:00 2001 From: isubas Date: Sun, 16 Sep 2018 12:12:05 +0300 Subject: [PATCH 20/48] Refactor and rename pagy concern --- app/controllers/application_controller.rb | 2 +- .../concerns/pagy_backend_with_helpers.rb | 11 +++++++++++ .../concerns/pagy_backend_with_search.rb | 15 --------------- 3 files changed, 12 insertions(+), 16 deletions(-) create mode 100644 app/controllers/concerns/pagy_backend_with_helpers.rb delete mode 100644 app/controllers/concerns/pagy_backend_with_search.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eae3cff71..bed8edd37 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class ApplicationController < ActionController::Base - include PagyBackendWithSearch + include PagyBackendWithHelpers protect_from_forgery with: :exception 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/pagy_backend_with_search.rb b/app/controllers/concerns/pagy_backend_with_search.rb deleted file mode 100644 index a8729ce74..000000000 --- a/app/controllers/concerns/pagy_backend_with_search.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module PagyBackendWithSearch - extend ActiveSupport::Concern - include Pagy::Backend - - included do - def pagy_by_search(collection) - @pagy, items = pagy( - (term = params[:term]).present? ? collection.search(term) : collection - ) - items - end - end -end From c0debfd64ed1a1876647d9589b2bdaae8ef1af51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 17 Sep 2018 00:13:46 +0000 Subject: [PATCH 21/48] Bump rubocop from 0.59.0 to 0.59.1 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.59.0 to 0.59.1. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.59.0...v0.59.1) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e8d22c5f6..d5eb06ff7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) From 2008d9f25ecfa09122e3e48d26efe738cd4f9af0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 17 Sep 2018 00:14:08 +0000 Subject: [PATCH 22/48] Bump uglifier from 4.1.18 to 4.1.19 Bumps [uglifier](https://github.com/lautis/uglifier) from 4.1.18 to 4.1.19. - [Release notes](https://github.com/lautis/uglifier/releases) - [Changelog](https://github.com/lautis/uglifier/blob/master/CHANGELOG.md) - [Commits](https://github.com/lautis/uglifier/compare/v4.1.18...v4.1.19) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e8d22c5f6..19fe67f08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 From 94a9b777ef95ec0ef93b2ea443d39e2b69d37490 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 17 Sep 2018 00:14:42 +0000 Subject: [PATCH 23/48] Bump bootsnap from 1.3.1 to 1.3.2 Bumps [bootsnap](https://github.com/Shopify/bootsnap) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/Shopify/bootsnap/releases) - [Changelog](https://github.com/Shopify/bootsnap/blob/master/CHANGELOG.md) - [Commits](https://github.com/Shopify/bootsnap/compare/v1.3.1...v1.3.2) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e8d22c5f6..be98558fc 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) From 7bf52032d7f89e2412d5a13510f0a560ff6c9f79 Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:18:28 +0300 Subject: [PATCH 24/48] =?UTF-8?q?Dinamik=20arama=20=C3=B6zelli=C4=9Fini=20?= =?UTF-8?q?geli=C5=9Ftir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 6 +++++ app/models/concerns/dynamic_search.rb | 31 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 app/models/concerns/dynamic_search.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e06a13229..fed2d4fc5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,6 +26,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/models/concerns/dynamic_search.rb b/app/models/concerns/dynamic_search.rb new file mode 100644 index 000000000..289549fab --- /dev/null +++ b/app/models/concerns/dynamic_search.rb @@ -0,0 +1,31 @@ +# 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? + query = build_search_query(params) + query.present? ? where(query) : current_scope + end + + private + + def build_search_query(params) + dynamic_search_keys.each_with_object({}) do |key, hash| + hash[key] = params[key] if params.key?(key) && params[key].present? + end + end + end +end From 340f02f80c8cd8f2b9ad0009bbce61f7379c7771 Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:29:13 +0300 Subject: [PATCH 25/48] Fix rubocop offenses --- app/models/concerns/dynamic_search.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/concerns/dynamic_search.rb b/app/models/concerns/dynamic_search.rb index 289549fab..a2901bd93 100644 --- a/app/models/concerns/dynamic_search.rb +++ b/app/models/concerns/dynamic_search.rb @@ -10,12 +10,14 @@ def search_keys(*keys) 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? + query = build_search_query(params) query.present? ? where(query) : current_scope end From 9166c776beae8c001790ac0be1bcd9ea672ca9ad Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:31:15 +0300 Subject: [PATCH 26/48] =?UTF-8?q?Course=20modelini=20geli=C5=9Ftir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/curriculums/course.rb | 32 +++++++++++-------- ...ses.rb => 20180916113158_create_course.rb} | 9 +++--- db/schema.rb | 9 +++--- 3 files changed, 28 insertions(+), 22 deletions(-) rename db/migrate/{20180621072455_create_courses.rb => 20180916113158_create_course.rb} (71%) mode change 100755 => 100644 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/db/migrate/20180621072455_create_courses.rb b/db/migrate/20180916113158_create_course.rb old mode 100755 new mode 100644 similarity index 71% rename from db/migrate/20180621072455_create_courses.rb rename to db/migrate/20180916113158_create_course.rb index d462dcbc8..c9ac22cce --- a/db/migrate/20180621072455_create_courses.rb +++ b/db/migrate/20180916113158_create_course.rb @@ -1,4 +1,4 @@ -class CreateCourses < ActiveRecord::Migration[5.2] +class CreateCourse < ActiveRecord::Migration[5.2] def change create_table :courses do |t| t.string :name, null: false @@ -8,11 +8,10 @@ def change t.integer :laboratory, null: false t.decimal :credit, precision: 5, scale: 2, default: 0, null: false t.references :unit, foreign_key: true - t.integer :education_type, null: false - t.string :language, null: false + t.integer :program_type, null: false + t.references :language, foreign_key: true t.integer :status, null: false - t.date :abrogated_date t.timestamps end end -end \ No newline at end of file +end diff --git a/db/schema.rb b/db/schema.rb index 6632e1bd7..cfd239e76 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_16_113158) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -184,12 +184,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.bigint "language_id" t.integer "status", null: false - t.date "abrogated_date" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["language_id"], name: "index_courses_on_language_id" t.index ["unit_id"], name: "index_courses_on_unit_id" end @@ -463,6 +463,7 @@ add_foreign_key "calendar_title_types", "calendar_types", column: "type_id" add_foreign_key "certifications", "users" add_foreign_key "cities", "countries" + add_foreign_key "courses", "languages" add_foreign_key "courses", "units" add_foreign_key "districts", "cities" add_foreign_key "duties", "employees" From bf61f7c8d01b6aeaeab85acd34ea6bfcc4185fbc Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:33:36 +0300 Subject: [PATCH 27/48] =?UTF-8?q?Dersler=20i=C3=A7in=20contoller=20ve=20vi?= =?UTF-8?q?ewleri=20d=C3=BCzenle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../curriculum/courses_controller.rb | 9 +- app/views/curriculum/courses/_form.html.erb | 6 +- app/views/curriculum/courses/_search.html.erb | 114 ++++++++++++++++++ .../curriculum/courses/_select2.html.erb | 2 +- app/views/curriculum/courses/index.html.erb | 30 +++-- app/views/curriculum/courses/show.html.erb | 6 +- 6 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 app/views/curriculum/courses/_search.html.erb diff --git a/app/controllers/curriculum/courses_controller.rb b/app/controllers/curriculum/courses_controller.rb index df047d057..ffabb4e1c 100644 --- a/app/controllers/curriculum/courses_controller.rb +++ b/app/controllers/curriculum/courses_controller.rb @@ -7,8 +7,9 @@ class CoursesController < ApplicationController 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 +46,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/views/curriculum/courses/_form.html.erb b/app/views/curriculum/courses/_form.html.erb index 475154c73..2cfb209b8 100644 --- a/app/views/curriculum/courses/_form.html.erb +++ b/app/views/curriculum/courses/_form.html.erb @@ -28,11 +28,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..b120cce8b --- /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 @@ - - + + - + From 1c933303d3cc3fe02734819e987aca043ac759fb Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:34:56 +0300 Subject: [PATCH 28/48] =?UTF-8?q?Course=20modeli=20i=C3=A7in=20eksik=20?= =?UTF-8?q?=C3=A7evirileri=20ekle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/defaults/en.yml | 6 +++++- config/locales/defaults/tr.yml | 5 ++++- config/locales/models/curriculums/en.yml | 9 ++++++--- config/locales/models/curriculums/tr.yml | 11 +++++++---- 4 files changed, 22 insertions(+), 9 deletions(-) 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/models/curriculums/en.yml b/config/locales/models/curriculums/en.yml index 2ea424001..55ad17c04 100644 --- a/config/locales/models/curriculums/en.yml +++ b/config/locales/models/curriculums/en.yml @@ -2,7 +2,7 @@ en: course_attributes: &course_attributes credit: Credit code: Code - education_type: Education Type + program_type: Program Type laboratory: Laboratory language: Language name: Name @@ -15,14 +15,14 @@ en: 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 +36,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..86bb84255 100644 --- a/config/locales/models/curriculums/tr.yml +++ b/config/locales/models/curriculums/tr.yml @@ -2,7 +2,7 @@ tr: course_attributes: &course_attributes credit: Kredi code: Dersin Kodu - education_type: Eğitim Türü + program_type: Program Türü laboratory: Laboratuvar language: Dil name: Dersin Adı @@ -15,14 +15,14 @@ tr: 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 +36,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: From 727c97c5eed542929904cd509110bcf6713362f2 Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:35:32 +0300 Subject: [PATCH 29/48] =?UTF-8?q?Laguage=20modeline=20courses=20ili=C5=9Fk?= =?UTF-8?q?isini=20ekle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/language.rb | 3 +++ 1 file changed, 3 insertions(+) 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 From f154470292c441486b9d5053cd6d0c3a444f3d42 Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:37:10 +0300 Subject: [PATCH 30/48] =?UTF-8?q?Enum=20de=C4=9Fi=C5=9Fikli=C4=9Finden=20d?= =?UTF-8?q?olay=C4=B1=20olu=C5=9Fan=20test=20hatas=C4=B1n=C4=B1=20d=C3=BCz?= =?UTF-8?q?elt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/helpers/enum_i18n_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 81531790a6cdddd06f89a9fdae8e1683888f2416 Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 04:41:25 +0300 Subject: [PATCH 31/48] =?UTF-8?q?Course=20modeli=20ile=20ilgili=20testleri?= =?UTF-8?q?=20d=C3=BCzenle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../curriculum/courses_controller_test.rb | 15 +++--- test/fixtures/courses.yml | 22 ++++---- test/models/curriculums/course_test.rb | 50 +++++++++---------- test/models/language_test.rb | 4 ++ 4 files changed, 46 insertions(+), 45 deletions(-) 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/courses.yml b/test/fixtures/courses.yml index bf12389ad..ad2d80463 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 + program_type: :undergraduate + language: turkce status: :active - abrogated_date: nil ydi: name: İngilizce @@ -19,10 +18,9 @@ ydi: credit: 2 laboratory: 1 unit: omu - education_type: :undergraduate - language: İngilizce + program_type: :undergraduate + language: ingilizce status: :active - abrogated_date: nil test: name: 'Test Course' @@ -32,10 +30,9 @@ test: credit: 3 laboratory: 0 unit: omu - education_type: :undergraduate - language: Türkçe + program_type: :undergraduate + language: turkce status: :active - abrogated_date: nil 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/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 From adec15d85f9160353a844b4908378c079b4b85c6 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Mon, 17 Sep 2018 12:31:21 +0300 Subject: [PATCH 32/48] Change agenda enums --- app/models/committees/agenda.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/committees/agenda.rb b/app/models/committees/agenda.rb index 468270148..b1971b793 100644 --- a/app/models/committees/agenda.rb +++ b/app/models/committees/agenda.rb @@ -18,5 +18,5 @@ class Agenda < ApplicationRecord validates :status, presence: true # enums - enum status: { newly: 0, desided: 1, delayed: 2 } + enum status: { recent: 0, decided: 1, delayed: 2 } end From 815590b7c8eba5b8f5611e606c3549fabc854d9d Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Mon, 17 Sep 2018 12:39:27 +0300 Subject: [PATCH 33/48] Add agenda types link to the sidebar --- app/views/layouts/shared/_sidebar.html.erb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/shared/_sidebar.html.erb b/app/views/layouts/shared/_sidebar.html.erb index b345db3bf..2b9245813 100644 --- a/app/views/layouts/shared/_sidebar.html.erb +++ b/app/views/layouts/shared/_sidebar.html.erb @@ -141,10 +141,22 @@ <%= fa_icon('file-text-o', text: t('.studies'), class: 'nav-icon') %> <% end %> - From 9e4e76391b970c049292604a2800ebaccfc6a486 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Mon, 17 Sep 2018 12:43:37 +0300 Subject: [PATCH 34/48] Add some missing words to locales and changes views --- app/views/committee/agenda_types/_form.html.erb | 2 +- app/views/committee/agenda_types/index.html.erb | 2 +- app/views/committee/agendas/_form.html.erb | 2 +- app/views/committee/agendas/index.html.erb | 4 ++-- app/views/committee/dashboard/index.html.erb | 6 +++++- app/views/committee/dashboard/show.html.erb | 4 +--- config/locales/layouts/shared/sidebar_en.yml | 2 ++ config/locales/layouts/shared/sidebar_tr.yml | 2 ++ config/locales/models/committees/en.yml | 8 +++++--- config/locales/models/committees/tr.yml | 8 +++++--- 10 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/views/committee/agenda_types/_form.html.erb b/app/views/committee/agenda_types/_form.html.erb index a2b35f269..319c00f87 100644 --- a/app/views/committee/agenda_types/_form.html.erb +++ b/app/views/committee/agenda_types/_form.html.erb @@ -2,7 +2,7 @@
- <%= fa_icon 'calendar' %> + <%= fa_icon 'tags' %> <%= form_title %>
diff --git a/app/views/committee/agenda_types/index.html.erb b/app/views/committee/agenda_types/index.html.erb index 98df69aa3..81c8f04e3 100644 --- a/app/views/committee/agenda_types/index.html.erb +++ b/app/views/committee/agenda_types/index.html.erb @@ -6,7 +6,7 @@
- <%= fa_icon 'tasks', text: t('.card_header') %> + <%= fa_icon 'tags', text: t('.card_header') %>
<%= form_tag agenda_types_path, method: :get do %> diff --git a/app/views/committee/agendas/_form.html.erb b/app/views/committee/agendas/_form.html.erb index 960e592f7..1dce7eadf 100644 --- a/app/views/committee/agendas/_form.html.erb +++ b/app/views/committee/agendas/_form.html.erb @@ -2,7 +2,7 @@
- <%= fa_icon 'calendar' %> + <%= fa_icon 'tasks' %> <%= form_title %>
diff --git a/app/views/committee/agendas/index.html.erb b/app/views/committee/agendas/index.html.erb index 708eb146b..6228906ac 100644 --- a/app/views/committee/agendas/index.html.erb +++ b/app/views/committee/agendas/index.html.erb @@ -30,8 +30,8 @@ <% @agendas.each do |agenda| %>
- - + + - @@ -34,8 +33,7 @@ <% @agendas.each do |agenda| %> - - + <% @committees.each do |committee| %> - + diff --git a/config/routes.rb b/config/routes.rb index c7310d4bd..f569aa53c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,13 +94,9 @@ get '/studies/certifications', to: 'certifications#index' end - scope module: :committee do - resources :agenda_types, except: :show - get '/committees', to: 'dashboard#index' - get '/committees/:id', to: 'dashboard#show', as: :committee - end + resources :agenda_types, except: :show, module: :committee - resources :committees, only: [] do + resources :committees, only: %i[index show], controller: 'committee/dashboard' do resources :agendas, except: :show, module: :committee end end From 346c243b37f07dc5f20efaddc761270ba5c7a66f Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Mon, 17 Sep 2018 13:52:23 +0300 Subject: [PATCH 37/48] Add AgendaType's controller test --- config/locales/layouts/shared/sidebar_en.yml | 4 +- .../committee/agenda_types_controller_test.rb | 72 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 test/controllers/committee/agenda_types_controller_test.rb diff --git a/config/locales/layouts/shared/sidebar_en.yml b/config/locales/layouts/shared/sidebar_en.yml index 9a9a34652..2108c895c 100644 --- a/config/locales/layouts/shared/sidebar_en.yml +++ b/config/locales/layouts/shared/sidebar_en.yml @@ -28,6 +28,6 @@ en: unit_types: Unit Types university_types: University Types studies: Academic Studies - committees: Committees/Commissions - committee_units: Committe/Commission Units + committees: Committees + committee_units: Committee Units agenda_types: Agenda Types 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 From 934414f52bc598fac25c03524b94be513e4f0711 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Mon, 17 Sep 2018 16:47:12 +0300 Subject: [PATCH 38/48] Add Agendas's controller test --- .../committee/agendas_controller_test.rb | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 test/controllers/committee/agendas_controller_test.rb 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 From db3d5d11eefc5483fc82e59bcf9aa1f266e0e0be Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 17:06:50 +0300 Subject: [PATCH 39/48] =?UTF-8?q?Ders=20tan=C4=B1mlamalar=C4=B1=20i=C3=A7i?= =?UTF-8?q?n=20ufak=20d=C3=BCzeltmeler=20yap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ders modeli için çeviri dosyasınındaki eksiklikler giderildi. - Ders ekleme ve düzenleme formunda kayıt esnasından oluşan hataların liste şeklinde görüntülenmesi sağlandı. --- app/views/curriculum/courses/_form.html.erb | 11 +++++++++- config/locales/models/curriculums/en.yml | 23 +++++++++++---------- config/locales/models/curriculums/tr.yml | 23 +++++++++++---------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/app/views/curriculum/courses/_form.html.erb b/app/views/curriculum/courses/_form.html.erb index 2cfb209b8..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? %> +
    + <% f.object.errors.full_messages.each do |message| %> +
  • + <%= message %> +
  • + <% end %> +
+ <% end %> +
<%= f.association :unit %>
diff --git a/config/locales/models/curriculums/en.yml b/config/locales/models/curriculums/en.yml index 55ad17c04..37165d2b8 100644 --- a/config/locales/models/curriculums/en.yml +++ b/config/locales/models/curriculums/en.yml @@ -1,16 +1,17 @@ en: - course_attributes: &course_attributes - credit: Credit - code: Code - program_type: Program 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: diff --git a/config/locales/models/curriculums/tr.yml b/config/locales/models/curriculums/tr.yml index 86bb84255..94bb9963a 100644 --- a/config/locales/models/curriculums/tr.yml +++ b/config/locales/models/curriculums/tr.yml @@ -1,16 +1,17 @@ tr: - course_attributes: &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 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: From 0fd22042e16454613a9b70b740fe39417d7c221c Mon Sep 17 00:00:00 2001 From: isubas Date: Mon, 17 Sep 2018 17:11:13 +0300 Subject: [PATCH 40/48] Fixes typo --- app/views/curriculum/courses/_search.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/curriculum/courses/_search.html.erb b/app/views/curriculum/courses/_search.html.erb index b120cce8b..ebb139f32 100644 --- a/app/views/curriculum/courses/_search.html.erb +++ b/app/views/curriculum/courses/_search.html.erb @@ -1,4 +1,4 @@ -
+
<%= 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') %>
<%= agenda.description %><%= agenda.unit.name %><%= agenda.agenda_type.name %><%= agenda.unit.try(:name) %><%= agenda.agenda_type.try(:name) %> <%= enum_t(agenda, :status) %> <%= link_to_edit(edit_committee_agenda_path(@committee.id, agenda.id)) %> diff --git a/app/views/committee/dashboard/index.html.erb b/app/views/committee/dashboard/index.html.erb index 210402c6b..6c04fd908 100644 --- a/app/views/committee/dashboard/index.html.erb +++ b/app/views/committee/dashboard/index.html.erb @@ -1,8 +1,12 @@ +
+ <%= link_to_new new_unit_path, t('.new_committee_link') %> +
+
- <%= fa_icon 'tasks', text: t('.card_header') %> + <%= fa_icon 'cubes', text: t('.card_header') %>
<%= form_tag committees_path, method: :get do %> diff --git a/app/views/committee/dashboard/show.html.erb b/app/views/committee/dashboard/show.html.erb index 1d4dc1666..3d6bf2bb1 100644 --- a/app/views/committee/dashboard/show.html.erb +++ b/app/views/committee/dashboard/show.html.erb @@ -24,7 +24,6 @@
<%= t('.description') %><%= t('.unit') %> <%= t('.agenda_type') %> <%= t('.status') %> <%= t('.actions') %>
<%= agenda.description %><%= agenda.unit.parent.name %><%= agenda.agenda_type.name %><%= agenda.agenda_type.try(:name) %> <%= enum_t(agenda, :status) %> <%= link_to_edit(edit_committee_agenda_path(@committee.id, agenda.id)) %> diff --git a/config/locales/layouts/shared/sidebar_en.yml b/config/locales/layouts/shared/sidebar_en.yml index 1a0df0b81..9a9a34652 100644 --- a/config/locales/layouts/shared/sidebar_en.yml +++ b/config/locales/layouts/shared/sidebar_en.yml @@ -29,3 +29,5 @@ en: university_types: University Types studies: Academic Studies committees: Committees/Commissions + committee_units: Committe/Commission Units + agenda_types: Agenda Types diff --git a/config/locales/layouts/shared/sidebar_tr.yml b/config/locales/layouts/shared/sidebar_tr.yml index 698e9cbfa..c8afc602b 100644 --- a/config/locales/layouts/shared/sidebar_tr.yml +++ b/config/locales/layouts/shared/sidebar_tr.yml @@ -29,3 +29,5 @@ tr: 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 index c070780f5..00692b054 100644 --- a/config/locales/models/committees/en.yml +++ b/config/locales/models/committees/en.yml @@ -3,15 +3,15 @@ en: attributes: agenda: &agenda_attributes description: Agenda Description - agenda_type: Agenda Type + agenda_type_id: Agenda Type status: Agenda Status agenda_type: &agenda_type_attributes name: Name of Agenda Type enums: agenda: statuses: - newly: Yeni - desided: Karar Verildi + recent: Yeni + decided: Karar Verildi delayed: Ertelendi helpers: submit: @@ -28,6 +28,7 @@ en: new_agenda_link: Create a New Agenda card_header: Agendas unit: Unit + agenda_type: Agenda Type new: form_title: Create a Agenda edit: @@ -64,6 +65,7 @@ en: unit_type: Unit Type district: Location card_header: Committee / Commission + new_committee_link: Create a New Committee/Commission show: description: Description unit: Parent Unit diff --git a/config/locales/models/committees/tr.yml b/config/locales/models/committees/tr.yml index 4f8fbf995..e496b05e6 100644 --- a/config/locales/models/committees/tr.yml +++ b/config/locales/models/committees/tr.yml @@ -3,7 +3,7 @@ tr: attributes: agenda: &agenda_attributes description: Gündem Açıklaması - agenda_type: Gündem Türü + agenda_type_id: Gündem Türü status: Gündem Durumu agenda_type: &agenda_type_attributes name: Gündem Türü Adı @@ -12,8 +12,8 @@ tr: enums: agenda: statuses: - newly: Yeni - desided: Karar Verildi + recent: Yeni + decided: Karar Verildi delayed: Ertelendi helpers: submit: @@ -30,6 +30,7 @@ tr: 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: @@ -66,6 +67,7 @@ tr: 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 From 63c4996e3072f059971deab8fbe0aa2628193c87 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Mon, 17 Sep 2018 13:09:50 +0300 Subject: [PATCH 35/48] Add new UnitType for committee and create rake task --- app/models/unit.rb | 2 +- db/seeds.rb | 3 +++ lib/tasks/post_deploy/create_unit_type_for_committee.rake | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/tasks/post_deploy/create_unit_type_for_committee.rake diff --git a/app/models/unit.rb b/app/models/unit.rb index 8d99c1361..b51eb4dc7 100644 --- a/app/models/unit.rb +++ b/app/models/unit.rb @@ -39,5 +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(name: 'Kurul / Komisyon')) } + scope :committees, -> { where(unit_type: UnitType.find_by(code: 200)) } end 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/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 From 84f231ca9c01fd5deb6de2c3ffeeb43c50d28893 Mon Sep 17 00:00:00 2001 From: ecmelkytz Date: Mon, 17 Sep 2018 13:12:23 +0300 Subject: [PATCH 36/48] Change routes --- app/views/committee/dashboard/index.html.erb | 2 +- config/routes.rb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/views/committee/dashboard/index.html.erb b/app/views/committee/dashboard/index.html.erb index 6c04fd908..eb4a01e70 100644 --- a/app/views/committee/dashboard/index.html.erb +++ b/app/views/committee/dashboard/index.html.erb @@ -31,7 +31,7 @@
<%= committee.name %><%= link_to(committee.name, unit_path(committee)) %> <%= committee.yoksis_id %> <%= committee.detsis_id %> <%= committee.unit_status.name %>