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 #430 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Oct 4, 2018
2 parents 2024040 + eb59148 commit f774eea
Show file tree
Hide file tree
Showing 27 changed files with 411 additions and 114 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'
ruby File.read('.ruby-version')

# core
gem 'bootsnap', '>= 1.1.0', require: false # Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
gem 'pg'
gem 'puma', '~> 3.11'
gem 'rails', '~> 5.2.1'
Expand All @@ -22,7 +22,6 @@ gem 'image_processing', '~> 1.0'
gem 'devise'

# assets: core asset dependencies
gem 'coffee-rails', '~> 4.2'
gem 'sassc-rails'
gem 'uglifier', '>= 1.3.0'

Expand Down
12 changes: 2 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ GEM
ast (2.4.0)
aws-eventstream (1.0.1)
aws-partitions (1.105.0)
aws-sdk-core (3.28.0)
aws-sdk-core (3.29.0)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
Expand Down Expand Up @@ -106,13 +106,6 @@ GEM
coderay (1.1.2)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
connection_pool (2.2.2)
crass (1.0.4)
Expand Down Expand Up @@ -194,7 +187,7 @@ GEM
mini_portile2 (~> 2.3.0)
nori (2.6.0)
orm_adapter (0.5.0)
pagy (0.19.3)
pagy (0.20.0)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
Expand Down Expand Up @@ -373,7 +366,6 @@ DEPENDENCIES
chromedriver-helper
cocoon
codacy-coverage
coffee-rails (~> 4.2)
devise
dotenv-rails
email_address
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/committee/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,5 @@ def index
Unit.committees.includes(:unit_type, :unit_status, district: :city)
)
end

def show
@committee = Unit.committees.find(params[:id])
@agendas = pagy_by_search(
@committee.agendas.includes(:agenda_type, agenda_file_attachment: :blob)
)
end
end
end
49 changes: 49 additions & 0 deletions app/controllers/committee/meetings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

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

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

def new
@meeting = @committee.meetings.new
end

def edit; end

def create
@meeting = @committee.meetings.new(meeting_params)
@meeting.save ? redirect_with('success') : render(:new)
end

def update
@meeting.update(meeting_params) ? redirect_with('success') : render(:edit)
end

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

private

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

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

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

def meeting_params
params.require(:committee_meeting).permit(:meeting_no, :meeting_date)
end
end
end
15 changes: 15 additions & 0 deletions app/models/committee_meeting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

class CommitteeMeeting < ApplicationRecord
# relations
belongs_to :unit

# validations
validates :meeting_no, presence: true, uniqueness: { scope: %i[unit year] },
numericality: { only_integer: true, greater_than_or_equal_to: 1 }
validates :meeting_date, presence: true
validates :year, presence: true

# callbacks
before_validation { self.year = meeting_date.try(:year) }
end
1 change: 1 addition & 0 deletions app/models/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Unit < ApplicationRecord
has_many :positions, through: :duties
has_many :administrative_functions, through: :duties
has_many :agendas, dependent: :nullify
has_many :meetings, dependent: :nullify, class_name: 'CommitteeMeeting'
has_many :courses, dependent: :nullify
has_many :registration_documents, dependent: :destroy
has_many :prospective_students, dependent: :destroy
Expand Down
2 changes: 1 addition & 1 deletion app/views/committee/agendas/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<strong><%= form_title %></strong>
</div>
<div class='card-body'>
<%= simple_form_for([@committee, agenda], url: committee_agendas_path(@committee.id), method: :post) do |f| %>
<%= simple_form_for([@committee, agenda], url: url, method: method) do |f| %>
<div class='row'>
<div class='form-group col-sm-12'>
<%= f.error_notification %>
Expand Down
5 changes: 4 additions & 1 deletion app/views/committee/agendas/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<%= render 'form', agenda: @agenda, form_title: t('.form_title') %>
<%= render 'form',
agenda: @agenda,
url: committee_agenda_path(@committee, @agenda),
method: :patch, form_title: t('.form_title') %>
5 changes: 4 additions & 1 deletion app/views/committee/agendas/new.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<%= render 'form', agenda: @agenda, form_title: t('.form_title') %>
<%= render 'form',
agenda: @agenda,
url: committee_agendas_path(@committee),
method: :post, form_title: t('.form_title') %>
4 changes: 3 additions & 1 deletion app/views/committee/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
<td><%= committee.unit_type.try(:name) %></td>
<td><%= committee.district.name %> / <%= committee.district.city.name %></td>
<td>
<%= link_to(fa_icon('archive', text: t('.meetings')),
committee_meetings_path(committee),
class: 'btn btn-secondary btn-sm') %>
<%= link_to(fa_icon('tasks', text: t('.agendas')),
committee_agendas_path(committee),
class: 'btn btn-secondary btn-sm') %>
<%= link_to_show(committee_path(committee)) %>
</td>
</tr>
<% end %>
Expand Down
53 changes: 0 additions & 53 deletions app/views/committee/dashboard/show.html.erb

This file was deleted.

30 changes: 30 additions & 0 deletions app/views/committee/meetings/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div class='row'>
<div class='col-sm-12'>
<div class='card'>
<div class='card-header'>
<%= fa_icon 'archive' %>
<strong><%= form_title %></strong>
</div>
<div class='card-body'>
<%= simple_form_for(meeting, url: url, method: method) do |f| %>
<div class='row'>
<div class='form-group col-sm-12'>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
</div>
<div class='form-group col-sm-6'>
<%= f.input :meeting_no, required: true, input_html: { min: 1 } %>
</div>
<div class='form-group col-sm-6'>
<%= f.input :meeting_date %>
</div>
<div class='form-group col-sm-12'>
<%= f.button :submit, class: 'btn btn-outline-success btn-sm' %>
<%= link_to_back(:back) %>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
3 changes: 3 additions & 0 deletions app/views/committee/meetings/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= render 'form', meeting: @meeting,
url: committee_meeting_path(@committee, @meeting),
method: :patch, form_title: t('.form_title') %>
40 changes: 40 additions & 0 deletions app/views/committee/meetings/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div class='alert alert-light'>
<%= link_to_new new_committee_meeting_path(@committee), t('.new_committee_meeting_link') %>
</div>

<div class='row'>
<div class='col-lg-12'>
<div class='card'>
<div class='card-header'>
<%= fa_icon 'archive', text: t('.card_header') %>
</div>
<div class='card-body'>
<table class='table table-responsive-sm table-striped'>
<thead>
<tr>
<th><%= t('.meeting_no') %></th>
<th><%= t('.meeting_date') %></th>
<th><%= t('.year') %></th>
<th><%= t('.unit') %></th>
<th><%= t('actions') %></th>
</tr>
</thead>
<tbody>
<% @meetings.each do |meeting| %>
<tr>
<td><%= meeting.meeting_no %></td>
<td><%= meeting.meeting_date %></td>
<td><%= meeting.year %></td>
<td><%= meeting.unit.name %></td>
<td>
<%= link_to_edit(edit_committee_meeting_path(@committee, meeting)) %>
<%= link_to_destroy(committee_meeting_path(@committee, meeting)) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
3 changes: 3 additions & 0 deletions app/views/committee/meetings/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= render 'form', meeting: @meeting,
url: committee_meetings_path(@committee),
method: :post, form_title: t('.form_title') %>
32 changes: 15 additions & 17 deletions config/locales/gems/pagy/en.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
---
en:
pagy:
compact:
of: of
page: Page
nav:
prev: "&lsaquo;&nbsp;Prev"
next: "Next&nbsp;&rsaquo;"
gap: "&hellip;"
info:
item_name:
one: item
other: items
zero: items
multiple_pages: Displaying %{item_name} <b>%{from}-%{to}</b> of <b>%{count}</b> in total
single_page:
one: Displaying <b>1</b> %{item_name}
other: Displaying <b>all %{count}</b> %{item_name}
zero: No %{item_name} found
zero: "No %{item_name} found"
one: "Displaying <b>1</b> %{item_name}"
other: "Displaying <b>all %{count}</b> %{item_name}"
multiple_pages: "Displaying %{item_name} <b>%{from}-%{to}</b> of <b>%{count}</b> in total"
item_name:
zero: "items"
one: "item"
other: "items"
compact: "Page %{page_input} of %{pages}"
items:
items: items per page
show: Show
nav:
gap: "&hellip;"
next: Next&nbsp;&rsaquo;
prev: "&lsaquo;&nbsp;Prev"
one: "Show %{items_input} item per page"
other: "Show %{items_input} items per page"
30 changes: 14 additions & 16 deletions config/locales/gems/pagy/tr.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
---
tr:
pagy:
compact:
of: "/"
page: Sayfa
nav:
prev: "&lsaquo;&nbsp;Önceki"
next: "Sonraki&nbsp;&rsaquo;"
gap: "&hellip;"
info:
item_name:
one: kayıt
other: kayıt
zero: kayıt
multiple_pages: "<b>%{count}</b> %{item_name} içerisinden <b>%{from}-%{to}</b> kadarı gösteriliyor."
single_page:
zero: "Hiç %{item_name} bulunamadı."
one: "<b>1</b> %{item_name} gösteriliyor."
other: Toplam <b>%{count}</b> %{item_name} gösteriliyor.
zero: Hiç %{item_name} bulunamadı.
other: "Toplam <b>%{count}</b> %{item_name} gösteriliyor."
multiple_pages: "<b>%{count}</b> %{item_name} içerisinden <b>%{from}-%{to}</b> kadarı gösteriliyor."
item_name:
zero: "kayıt"
one: "kayıt"
other: "kayıt"
compact: "Sayfa %{page_input} / %{pages}"
items:
items: sayfa başı
show: Göster
nav:
gap: "&hellip;"
next: Sonraki&nbsp;&rsaquo;
prev: "&lsaquo;&nbsp;Önceki"
one: "Sayfada %{items_input} kayıt göster"
other: "Sayfada %{items_input} kayıt göster"
Loading

0 comments on commit f774eea

Please sign in to comment.