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 #176 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Aug 5, 2018
2 parents ab84e7c + 13bf940 commit 6589569
Show file tree
Hide file tree
Showing 82 changed files with 1,246 additions and 512 deletions.
9 changes: 9 additions & 0 deletions app/assets/stylesheets/custom/guest_footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.app-footer {
position: fixed;
bottom: 0;
width: 100%;
height: 30px; /* Set the fixed height of the footer here */
line-height: 30px; /* Vertically center the text there */
background-color: #f5f5f5;
opacity: .8;
}
3 changes: 2 additions & 1 deletion app/assets/stylesheets/guest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
*= require font-awesome
*= require @coreui/coreui/dist/css/coreui.min
*= require toastr/build/toastr.min
*= require shared/background
*= require custom/guest_background
*= require custom/guest_footer
*/
15 changes: 5 additions & 10 deletions app/controllers/account/addresses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ class AddressesController < ApplicationController
include LastUpdateFromMernis

before_action :set_address, only: %i[edit update destroy]
before_action :check_formality, only: %i[edit update destroy]
before_action :set_elapsed_time, only: %i[save_from_mernis]

def index
@addresses = current_user.addresses.includes(district: [:city])
end

def new
@address = current_user.addresses.new
@address = current_user.addresses.informal.new
end

def edit; end

def create
@address = current_user.addresses.new(address_params)
@address = current_user.addresses.informal.new(address_params)
@address.save ? redirect_with('success') : render(:new)
end

Expand All @@ -39,25 +38,21 @@ def save_from_mernis
private

def set_address
@address = current_user.addresses.find(params[:id])
end

def check_formality
redirect_with('warning') if @address.formal?
@address = current_user.addresses.informal.find(params[:id])
end

def set_elapsed_time
formal_address = current_user.addresses.formal
return if formal_address.blank?
elapsed_time(formal_address)
elapsed_time(formal_address.first)
end

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

def address_params
params.require(:address).permit(:name, :phone_number, :full_address, :district_id)
params.require(:address).permit(:phone_number, :full_address, :district_id)
end
end
end
53 changes: 53 additions & 0 deletions app/controllers/account/duties_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

module Account
class DutiesController < ApplicationController
before_action :set_user
before_action :set_employee
before_action :set_duty, only: %i[show edit update destroy]

def show
@positions = @duty.positions.includes(:administrative_function)
end

def new
@duty = @employee.duties.new
end

def create
@duty = @employee.duties.new(duty_params)
@duty.save ? redirect_to([@user, @employee, @duty], notice: t('.success')) : render(:new)
end

def edit; end

def update
@duty.update(duty_params) ? redirect_to([@user, @employee, @duty], notice: t('.success')) : render(:edit)
end

def destroy
@duty.destroy ? redirect_to([@user, @employee], notice: t('.success')) : redirect_with('warning')
end

private

def set_user
@user = User.friendly.find(params[:user_id])
not_found unless @user
end

def set_employee
@employee = @user.employees.find(params[:employee_id])
not_found unless @employee
end

def set_duty
@duty = @employee.duties.find(params[:id])
not_found unless @duty
end

def duty_params
params.require(:duty).permit(:temporary, :start_date, :end_date, :unit_id)
end
end
end
47 changes: 47 additions & 0 deletions app/controllers/account/employees_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

module Account
class EmployeesController < ApplicationController
before_action :set_user
before_action :set_employee, only: %i[show edit update destroy]

def show
@duties = @employee.duties.includes(:unit)
end

def new
@employee = @user.employees.new
end

def create
@employee = @user.employees.new(employee_params)
@employee.save ? redirect_to([@user, @employee], notice: t('.success')) : render(:new)
end

def edit; end

def update
@employee.update(employee_params) ? redirect_to([@user, @employee], notice: t('.success')) : render(:edit)
end

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

private

def set_user
@user = User.friendly.find(params[:user_id])
not_found unless @user
end

def set_employee
@employee = @user.employees.find(params[:id])
not_found unless @employee
end

def employee_params
params.require(:employee).permit(:active, :title_id)
end
end
end
15 changes: 5 additions & 10 deletions app/controllers/account/identities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ class IdentitiesController < ApplicationController
include LastUpdateFromMernis

before_action :set_identity, only: %i[edit update destroy]
before_action :check_formality, only: %i[edit update destroy]
before_action :set_elapsed_time, only: %i[save_from_mernis]

def index
@identities = current_user.identities
@identities = current_user.identities.includes(:student)
end

def new
Expand Down Expand Up @@ -39,17 +38,13 @@ def save_from_mernis
private

def set_identity
@identity = current_user.identities.find(params[:id])
end

def check_formality
redirect_with('warning') if @identity.formal?
@identity = current_user.identities.informal.find(params[:id])
end

def set_elapsed_time
formal_identity = current_user.identities.formal
formal_identity = current_user.identities.user_identity
return if formal_identity.blank?
elapsed_time(formal_identity)
elapsed_time(formal_identity.first)
end

def redirect_with(message)
Expand All @@ -58,7 +53,7 @@ def redirect_with(message)

def identity_params
params.require(:identity).permit(
:name, :first_name, :last_name, :mothers_name, :fathers_name, :gender, :marital_status, :place_of_birth,
:first_name, :last_name, :mothers_name, :fathers_name, :gender, :marital_status, :place_of_birth,
:date_of_birth, :registered_to
)
end
Expand Down
55 changes: 55 additions & 0 deletions app/controllers/account/positions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# frozen_string_literal: true

module Account
class PositionsController < ApplicationController
before_action :set_user
before_action :set_employee
before_action :set_duty
before_action :set_position, only: %i[edit update destroy]

def new
@position = @duty.positions.new
end

def create
@position = @duty.positions.new(position_params)
@position.save ? redirect_to([@user, @employee, @duty], notice: t('.success')) : render(:new)
end

def edit; end

def update
@position.update(position_params) ? redirect_to([@user, @employee, @duty], notice: t('.success')) : render(:edit)
end

def destroy
@position.destroy ? redirect_to([@user, @employee, @duty], notice: t('.success')) : redirect_with('warning')
end

private

def set_user
@user = User.friendly.find(params[:user_id])
not_found unless @user
end

def set_employee
@employee = @user.employees.find(params[:employee_id])
not_found unless @employee
end

def set_duty
@duty = @user.duties.find(params[:duty_id])
not_found unless @duty
end

def set_position
@position = @user.positions.find(params[:id])
not_found unless @position
end

def position_params
params.require(:position).permit(:administrative_function_id)
end
end
end
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ def not_found

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: %i[id_number email])
devise_parameter_sanitizer.permit(:account_update, keys: %i[email])
end
end
2 changes: 1 addition & 1 deletion app/controllers/concerns/last_update_from_mernis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module LastUpdateFromMernis
extend ActiveSupport::Concern

def elapsed_time(resource)
elapsed_time = (Time.zone.now - resource.first.updated_at) / 1.day
elapsed_time = (Time.zone.now - resource.updated_at) / 1.day
redirect_with('wait') if elapsed_time.present? && elapsed_time < 7
end
end
38 changes: 29 additions & 9 deletions app/controllers/public_profile_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,46 @@

class PublicProfileController < ApplicationController
skip_before_action :authenticate_user!
before_action :set_employee, only: :show
before_action :check_identity
before_action :set_user, only: %i[show vcard]
before_action :set_employee, only: %i[show vcard]
before_action :check_identity, only: %i[show vcard]

def show; end

def index; end

def vcard
send_data vcard_content(@identity), type: 'text/vcard; charset=utf-8; header=present', filename: 'contact.vcf'
end

private

def set_user
@user = User.friendly.find(params[:id])
not_found unless @user
end

def set_employee
@employee = Employee.friendly.find(params[:id])
@employee = @user.employees.active.first
not_found unless @employee
end

def check_identity
identities = @employee.user.identities.formal
@identity = @user.identities.user_identity
not_found unless @identity
end

if identities.any?
@identity = identities.first
else
redirect_to root_path
end
def vcard_content(identity)
<<~VCARD
BEGIN:VCARD
VERSION:3.0
N:#{identity.last_name};#{identity.first_name};;;
FN:#{identity.first_name} #{identity.last_name}
ORG:Ondokuz Mayıs Üniversitesi
TITLE:#{identity.user.title}
TEL;TYPE=WORK,VOICE:+90 (362) 312-1919
EMAIL:#{identity.user.email}
END:VCARD
VCARD
end
end
7 changes: 7 additions & 0 deletions app/controllers/user/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class RegistrationsController < Devise::RegistrationsController

# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
before_action :update_slug, only: :update
after_action :update_password_change_time, only: :update

# GET /resource/sign_up
Expand Down Expand Up @@ -67,5 +68,11 @@ def update
def update_password_change_time
current_user.update!(password_changed_at: Time.zone.now)
end

def update_slug
# rubocop:disable Lint/UselessAssignment
slug = nil if params[:email].present?
# rubocop:enable Lint/UselessAssignment
end
end
end
6 changes: 4 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def index
end
end

def show; end
def show
@employees = @user.employees.includes(:title).order(active: :desc)
end

def new
@user = User.new
Expand All @@ -39,7 +41,7 @@ def destroy
private

def set_user
@user = User.find(params[:id])
@user = User.friendly.find(params[:id])
end

def set_identities
Expand Down
11 changes: 11 additions & 0 deletions app/helpers/date_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module DateHelper
def as_date(date = nil)
date&.strftime('%d.%m.%Y')
end

def as_date_and_time(date = nil)
date&.strftime('%d.%m.%Y - %H:%M')
end
end
Loading

0 comments on commit 6589569

Please sign in to comment.