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

Commit

Permalink
Merge pull request #306 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Sep 18, 2018
2 parents 900342a + 93e53cc commit b48ecc7
Show file tree
Hide file tree
Showing 88 changed files with 1,646 additions and 333 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/use-case.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Use Case
about: Product ekibi tarafından hazırlanmış `use case` için iş kaydı.

---

**Use case dokümanı:**

**Açıklama:**

[//]: # (Kısa ve net bir şekilde konuyla ilişkili olarak sizin önerileriniz neler, sizin öneriniz kabul edilirse neler olacak, uygulamada neler iyileşecek açıklayınız.)

**Kontrol listesi**

* [ ] İş kaydınızın başlığı kurallara (sadece ilk harf büyük, emir kipinde problem cümlesi vb.) uygun mu?
* [ ] Use case, product ekibi tarafından incelenip onaylandı mı?
* [ ] Use case ve oluşturulan mockup'lar müşteri tarafından onaylandı mı?

**Ek içerik:**

[//]: # (Kaynaklar, dış bağlantılar, ekran görüntüleri, örnek çözümler ve benzeri diğer kaynakları ekleyiniz.)
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
include PagyBackendWithHelpers

protect_from_forgery with: :exception

before_action :configure_permitted_parameters, if: :devise_controller?
Expand All @@ -26,6 +28,12 @@ def default_url_options

protected

def search_params(model = nil)
parameters = [:term]
parameters << model.dynamic_search_keys if model
params.permit(parameters)
end

def locale_params
params[:locale] && I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil
end
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/calendar/academic_calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/calendar/academic_terms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/calendar/calendar_titles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/calendar/calendar_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions app/controllers/committee/agenda_types_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

module Committee
class AgendaTypesController < ApplicationController
before_action :set_agenda_type, only: %i[edit update destroy]

def index
@agenda_types = pagy_by_search(AgendaType.all)
end

def new
@agenda_type = AgendaType.new
end

def edit; end

def create
@agenda_type = AgendaType.new(agenda_type_params)
@agenda_type.save ? redirect_with('success') : render(:new)
end

def update
@agenda_type.update(agenda_type_params) ? redirect_with('success') : render(:edit)
end

def destroy
@agenda_type.destroy ? redirect_with('success') : redirect_with('warning')
end

private

def redirect_with(message)
redirect_to(agenda_types_path, notice: t(".#{message}"))
end

def set_agenda_type
@agenda_type = AgendaType.find(params[:id])
end

def agenda_type_params
params.require(:agenda_type).permit(:name)
end
end
end
49 changes: 49 additions & 0 deletions app/controllers/committee/agendas_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

module Committee
class AgendasController < ApplicationController
before_action :set_committee
before_action :set_agenda, only: %i[edit update destroy]

def index
@agendas = pagy_by_search(@committee.agendas.includes(:agenda_type))
end

def new
@agenda = @committee.agendas.new
end

def edit; end

def create
@agenda = @committee.agendas.new(agenda_params)
@agenda.save ? redirect_with('success') : render(:new)
end

def update
@agenda.update(agenda_params) ? redirect_with('success') : render(:edit)
end

def destroy
@agenda.destroy ? redirect_with('success') : redirect_with('warning')
end

private

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

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

def set_agenda
@agenda = @committee.agendas.find(params[:id]) if @committee
end

def agenda_params
params.require(:agenda).permit(:description, :status, :unit_id, :agenda_type_id)
end
end
end
17 changes: 17 additions & 0 deletions app/controllers/committee/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Committee
class DashboardController < ApplicationController
def index
@committees = pagy_by_search(
Unit.committees.includes(:unit_type, :unit_status, district: :city)
)
end

def show
@agendas = pagy_by_search(
Unit.find(params[:id]).agendas.includes(:agenda_type)
)
end
end
end
4 changes: 3 additions & 1 deletion app/controllers/concerns/last_update_from_mernis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions app/controllers/concerns/pagy_backend_with_helpers.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions app/controllers/concerns/reference_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module ReferenceResource
extend ActiveSupport::Concern
include Pagy::Backend

# rubocop:disable Metrics/BlockLength
# rubocop:disable Rails/LexicallyScopedActionFilter
Expand All @@ -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

Expand Down
11 changes: 5 additions & 6 deletions app/controllers/curriculum/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

module Curriculum
class CoursesController < ApplicationController
include Pagy::Backend

before_action :set_course, only: %i[show edit update destroy]

def index
@courses = Course.includes(:unit).all
@pagy, @courses = pagy(@courses)
courses = Course.includes(:unit)
.dynamic_search(search_params(Course))
@pagy, @courses = pagy(courses)
end

def show; end
Expand Down Expand Up @@ -45,8 +44,8 @@ def set_course

def course_params
params.require(:course).permit(
:unit_id, :name, :code, :theoric, :practice, :education_type,
:language, :laboratory, :status
:unit_id, :name, :code, :theoric, :practice, :program_type,
:language_id, :laboratory, :status
)
end
end
Expand Down
10 changes: 1 addition & 9 deletions app/controllers/languages_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 1 addition & 9 deletions app/controllers/locations/cities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit b48ecc7

Please sign in to comment.