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 #267 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Sep 8, 2018
2 parents 951d580 + 3e5c37a commit fe78ccc
Show file tree
Hide file tree
Showing 31 changed files with 1,060 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# OPs team
.circleci @msdundar @roktas @huseyin @ecylmz
.vagrant @roktas @huseyin @ecylmz @sinansh
.buildpacks @roktas @huseyin @ecylmz @sinansh
.ruby-version @roktas @isubas @ecmelkytz @huseyin @ecylmz @sinansh
Vagrantfile @roktas @huseyin @ecylmz @sinansh
Expand All @@ -11,6 +10,7 @@ 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 All @@ -19,4 +19,4 @@ Vagrantfile @roktas @huseyin @ecylmz @sinansh
/lib/ @msdundar @ecmelkytz @dilara @isubas @sinansh
/test/ @msdundar @ecmelkytz @dilara @isubas @sinansh
Gemfile @msdundar @ecmelkytz @dilara @isubas @sinansh
package.json @msdundar @ecmelkytz @dilara @isubas @sinansh
package.json @msdundar @ecmelkytz @dilara @isubas @sinansh
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, with: :not_found

def set_locale
language = language_params
language = locale_params

if user_signed_in?
current_user.update(preferred_language: language) if language
Expand All @@ -26,7 +26,7 @@ def default_url_options

protected

def language_params
def locale_params
params[:locale] && I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil
end

Expand Down
48 changes: 48 additions & 0 deletions app/controllers/languages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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
end

def show; end

def new
@language = Language.new
end

def create
@language = Language.new(language_params)
@language.save ? redirect_to(@language, notice: t('.success')) : render(:new)
end

def edit; end

def update
@language.update(language_params) ? redirect_to(@language, notice: t('.success')) : render(:edit)
end

def destroy
@language.destroy ? redirect_to(languages_path, notice: t('.success')) : redirect_with('warning')
end

private

def set_language
@language = Language.find(params[:id])
end

def language_params
params.require(:language).permit(:name, :iso, :yoksis_code)
end
end
22 changes: 22 additions & 0 deletions app/models/language.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

class Language < ApplicationRecord
# search
include PgSearch
pg_search_scope(
:search,
against: %i[name iso yoksis_code],
using: { tsearch: { prefix: true } }
)

# validations
validates :name, presence: true, uniqueness: true
validates :iso, presence: true, uniqueness: true
validates :yoksis_code, uniqueness: true, allow_nil: true

# callbacks
before_save do
self.name = name.capitalize_all
self.iso = iso.upcase_tr
end
end
2 changes: 1 addition & 1 deletion app/views/account/duties/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<%= f.input :start_date, required: true %>
</div>
<div class='form-group col-sm-4'>
<%= f.input :end_date, required: true %>
<%= f.input :end_date, include_blank: true %>
</div>
<div class='form-group col-sm-12'>
<%= f.input :temporary, required: true %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/account/positions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<%= f.input :start_date, required: true %>
</div>
<div class='form-group col-sm-4'>
<%= f.input :end_date %>
<%= f.input :end_date, include_blank: true %>
</div>
<div class='form-group col-sm-12'>
<%= f.button :submit, class: 'btn btn-outline-success btn-sm' %>
Expand Down
32 changes: 32 additions & 0 deletions app/views/languages/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class='row'>
<div class='col-sm-12'>
<div class='card'>
<div class='card-header'>
<%= fa_icon 'calendar' %>
<strong><%= form_title %></strong>
</div>
<div class='card-body'>
<%= simple_form_for(language) do |f| %>
<div class='row'>
<div class='form-group col-sm-12'>
<%= f.error_notification %>
</div>
<div class='form-group col-sm-4'>
<%= f.input :name, required: true %>
</div>
<div class='form-group col-sm-4'>
<%= f.input :iso, required: true %>
</div>
<div class='form-group col-sm-4'>
<%= f.input :yoksis_code, required: true %>
</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>
1 change: 1 addition & 0 deletions app/views/languages/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render 'form', language: @language, form_title: t('.form_title') %>
51 changes: 51 additions & 0 deletions app/views/languages/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<div class='alert alert-light'>
<%= link_to_new new_language_path, t('.new_language_link') %>
</div>

<div class='row'>
<div class='col-lg-12'>
<div class='card'>
<div class='card-header'>
<%= fa_icon 'language', text: t('.card_header') %>
</div>
<div class='card-body'>
<%= form_tag languages_path, method: :get do %>
<div class="form-group">
<%= text_field_tag 'term', params[:term], placeholder: t('.name'), class: 'form-control' %>
</div>
<%= submit_tag t('search'), class: 'btn btn-primary' %>
<% end %>
<hr \>
<table class='table table-responsive-sm table-striped'>
<thead>
<tr>
<th><%= t('.name') %></th>
<th><%= t('.iso') %></th>
<th><%= t('.yoksis_code') %></th>
<th><%= t('actions') %></th>
</tr>
</thead>
<tbody>
<% @languages.each do |language| %>
<tr>
<td><%= language.name %></td>
<td><%= language.iso %></td>
<td><%= language.yoksis_code %></td>
<td>
<%= link_to_show(language_path(language)) %>
<%= link_to_edit(edit_language_path(language)) %>
<%= link_to_destroy(language) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<nav aria-label='pagination'>
<ul class='pagination justify-content-center'>
<%== pagy_nav_bootstrap(@pagy) %>
</ul>
</nav>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/languages/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render 'form', language: @language, form_title: t('.form_title') %>
36 changes: 36 additions & 0 deletions app/views/languages/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<%= fa_icon 'language' %><strong><%= @language.name %></strong>
<div class="card-header-actions">
<%= link_to_edit(edit_language_path(@language)) %>
<%= link_to_destroy(@language) %>
</div>
</div>

<div class="card-body">
<table class="table table-responsive-sm">
<tbody>
<tr>
<td><%= t('.name') %></td>
<td><%= @language.name %></td>
</tr>
<tr>
<td><%= t('.iso') %></td>
<td><%= @language.iso %></td>
</tr>
<tr>
<td><%= t('.yoksis_code') %></td>
<td><%= @language.yoksis_code %></td>
</tr>
</tbody>
</table>
</div>

<div class="card-footer">
<%= link_to_back(languages_path) %>
</div>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions app/views/layouts/shared/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<%= fa_icon('user', text: t('.users'), class: 'nav-icon') %>
<% end %>
</li>
<li class="nav-item">
<%= link_to languages_path, class: 'nav-link' do %>
<%= fa_icon('language', text: t('.languages'), class: 'nav-icon') %>
<% end %>
</li>
<li class="nav-item nav-dropdown">
<a class="nav-link nav-dropdown-toggle" href="#">
<%= fa_icon('university', class: 'nav-icon') %><%= t('.references') %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/layouts/shared/sidebar_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ en:
academic_terms: Academic Terms
academic_calendars: Academic Calendars
courses: Courses
languages: Languages
users: Users
references: References
student_disability_types: Disability Types
Expand Down
1 change: 1 addition & 0 deletions config/locales/layouts/shared/sidebar_tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tr:
academic_terms: Akademik Dönemler
academic_calendars: Akademik Takvimler
courses: Dersler
languages: Diller
users: Kullanıcılar
references: Referanslar
student_disability_types: Engel Türleri
Expand Down
32 changes: 32 additions & 0 deletions config/locales/models/languages/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
en:
activerecord:
attributes:
language: &language_attributes
name: Name
iso: ISO Code
yoksis_code: YOKSIS Code
helpers:
submit:
language:
create: Create Language
update: Update Language
languages:
common:
languages: Languages
show:
<<: *language_attributes
index:
<<: *language_attributes
new_language_link: Create a New Language
card_header: Languages
new:
form_title: Create a Language
edit:
form_title: Update the Language
update:
success: Language successfully updated.
create:
success: Language successfully created.
destroy:
success: Language successfully deleted!
warning: Language can not be deleted.
32 changes: 32 additions & 0 deletions config/locales/models/languages/tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
tr:
activerecord:
attributes:
language: &language_attributes
name: Ad
iso: ISO Kodu
yoksis_code: YOKSIS Kodu
helpers:
submit:
language:
create: Dil Oluştur
update: Dil Güncelle
languages:
common:
languages: Diller
show:
<<: *language_attributes
index:
<<: *language_attributes
new_language_link: Yeni Dil Oluştur
card_header: Diller
new:
form_title: Dil Oluştur
edit:
form_title: Dil Güncelle
update:
success: Dil başarıyla güncellendi.
create:
success: Dil başarıyla oluşturuldu.
destroy:
success: Dil başarıyla silindi!
warning: Dil silinemedi.
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
resources :calendar_titles, except: :show
resources :calendar_types
end


resources :languages
resources :units

scope module: :curriculum do
Expand Down
4 changes: 2 additions & 2 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
# Environmental secrets are only available for that specific environment.

development:
secret_key_base: 680c6a3936e37a410b058dec0f4f7e116ac85cf51b83bf20ae098226cd9c3a4f4c05326aae2bdc018848d0ccf1398fcde18215fa8c8135971d6acba1feeb68a8
secret_key_base: <%= Rails.application.credentials.development[:secret_key_base] %>

test:
secret_key_base: adb1c563638c0ae5c95b707ca48562cb0fe286dce5f3a0b211eba297e9a50308f44720bb24c6df0178a8a100ca4ca009ba6d104977c10e09ba85016eecc966ee
secret_key_base: <%= Rails.application.credentials.test[:secret_key_base] %>

beta:
secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20180906103618_create_languages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateLanguages < ActiveRecord::Migration[5.2]
def change
create_table :languages do |t|
t.string :name, null: false, unique: true
t.string :iso, null: false, unique: true
t.integer :yoksis_code

t.timestamps
end
end
end
Loading

0 comments on commit fe78ccc

Please sign in to comment.