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 #424 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Sep 30, 2018
2 parents 450c625 + 6989b82 commit 2024040
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 67 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ GEM
arel (9.0.0)
ast (2.4.0)
aws-eventstream (1.0.1)
aws-partitions (1.104.0)
aws-sdk-core (3.27.1)
aws-partitions (1.105.0)
aws-sdk-core (3.28.0)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
Expand Down Expand Up @@ -154,7 +154,7 @@ GEM
i18n (1.1.0)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
image_processing (1.7.0)
image_processing (1.7.1)
mini_magick (~> 4.0)
ruby-vips (>= 2.0.13, < 3)
io-like (0.3.0)
Expand Down Expand Up @@ -254,9 +254,9 @@ GEM
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rollbar (2.17.0)
rollbar (2.18.0)
multi_json
rubocop (0.59.1)
rubocop (0.59.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
Expand Down
26 changes: 6 additions & 20 deletions app/controllers/public_profile_controller.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# frozen_string_literal: true

class PublicProfileController < ApplicationController
include PagyBackendWithHelpers

skip_before_action :authenticate_user!
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'
def index
@users = User.joins(:employees).search(params[:term])
end

def search
@users = User.joins(:identities).search(params[:word])
def vcard
send_data VcardBuilder.new(@identity), type: 'text/vcard; charset=utf-8; header=present', filename: 'contact.vcf'
end

private
Expand All @@ -33,18 +33,4 @@ def check_identity
@identity = @user.identities.user_identity
not_found if @identity.blank?
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: 4 additions & 3 deletions app/jobs/kps/identity_save_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ def perform(user, student_id = nil)

# callbacks
after_perform do |job|
response = @response.merge(student_id: @student_id)
formal_address = job.arguments.first.identities.formal
formal_address.present? ? formal_address.update(response) : formal_address.create(response)
response = @response.merge(student_id: @student_id, type: 'formal')
user = job.arguments.first
formal_identity = user.identities.user_identity
formal_identity.present? ? formal_identity.update(response) : user.identities.create(response)
end
end
end
20 changes: 20 additions & 0 deletions app/services/vcard_builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class VcardBuilder
def initialize(identity)
@identity = identity
end

def build_vcard
<<~VCARD
BEGIN:VCARD
VERSION:3.0
N:#{@identity.last_name};#{@identity.first_name};;;
FN:#{@identity.first_name} #{@identity.last_name}
ORG:#{Rails.application.config.tenant.name}
TITLE:#{@identity.user.title}
EMAIL:#{@identity.user.email}
END:VCARD
VCARD
end
end
2 changes: 1 addition & 1 deletion app/validators/duty_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def validate(record)
@duty = record
@duties = record.employee.user.duties.where.not(id: @duty.id)

date_validation if @duty.start_date.present? && @duty.end_date.present?
date_validation if @duty.start_date? && @duty.end_date?
restrict_duties if @duty.active?
end

Expand Down
2 changes: 1 addition & 1 deletion app/validators/position_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def validate(record)
@position = record
@positions = record.duty.employee.user.positions.where.not(id: @position.id)

date_validation if @position.start_date.present? && @position.end_date.present?
date_validation if @position.start_date? && @position.end_date?
restrict_positions if @position.active?
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
<div class="card-header special-header py-5">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-9 mx-auto">
<h3 class="text-white">Bir arama yapın</h3>
<%= form_tag profiles_search_path do |f| %>
<%= form_tag profiles_path, method: :get do |f| %>
<div class="input-group">
<%= text_field_tag :word, locals[:word], class: 'form-control', placeholder: 'Aramak istediğiniz isim, e-posta veya birim adı girin..', required: true, autocomplete: 'off' %>
<%= text_field_tag :term,
params[:term],
placeholder: 'Aramak istediğiniz isim, e-posta veya birim adı girin..',
required: true,
autocomplete: 'off',
class: 'form-control' %>
<span class="input-group-append">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i></button>
<%= submit_tag t('search'), class: 'btn btn-primary' %>
</span>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
27 changes: 26 additions & 1 deletion app/views/public_profile/index.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
<%= render 'form', locals: { word: '' } %>
<%= render 'search', locals: { term: params[:term] } %>

<% if params[:term] %>
<div class='col-sm-12'>
<div class='card'>
<div class="card-header">
<%= fa_icon 'search' %> <%= params[:term] %> için arama sonuçları
</div>
<div class="card-body">
<div class="col-sm-12">
<% if @users.any? %>
<div class="list-group">
<% @users.each do |user| %>
<%= link_to profiles_show_path(user.slug), class: 'list-group-item list-group-item-action' do %>
[<%= user.try(:title) %>] - <%= full_name(user.identities.user_identity) %>
<% end %>
<% end %>
</div>
<% else %>
<h2> Aradığınız kriterlere göre bir sonuç bulunamadı...</h2>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
25 changes: 0 additions & 25 deletions app/views/public_profile/search.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/references/languages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<td><%= language.name %></td>
<td><%= language.iso %></td>
<td>
<%= link_to_show(language_path(language)) %>
<%= link_to_edit(edit_language_path(language)) %>
<%= link_to_destroy(language) %>
</td>
Expand Down
4 changes: 2 additions & 2 deletions app/views/units/_search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="col-sm-12">
<div class="form-group">
<%= label_tag :term, t('smart_search') %>
<%= text_field_tag :term,
<%= text_field_tag :term,
params[:term],
placeholder: t('.smart_search_placeholder'),
class: 'form-control' %>
Expand All @@ -35,7 +35,7 @@
<div class="col-sm-3">
<div class="form-group">
<%= label_tag :duration, t('.duration') %>
<%= text_field_tag :duration,
<%= text_field_tag :duration,
params[:duration],
placeholder: "Öğretim Süresi (Yıl)",
class: 'form-control' %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/layouts/shared/sidebar_tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tr:
committee_units: Kurul/Komisyon Birimleri
committees: Kurullar/Komisyonlar
course_group_types: Ders Grup Türleri
course_management: Ders İşlemler
course_management: Ders İşlemleri
course_unit_groups: Ders Grupları
courses: Dersler
curriculums: Müfredatlar
Expand Down
4 changes: 1 addition & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
end

scope module: :student_management do
resources :prospective_students do
resources :prospective_students, only: %i[index show] do
get 'register', on: :member
end
end
Expand All @@ -53,9 +53,7 @@

# public profiles
get '/profiles', to: 'public_profile#index'
post '/profiles/search', to: 'public_profile#search'
get '/profiles/:id', to: 'public_profile#show', as: :profiles_show
get '/profiles/:id', to: 'public_profile#show'
get '/profiles/:id/vcard', to: 'public_profile#vcard', as: :profile_vcard

scope module: :studies do
Expand Down

0 comments on commit 2024040

Please sign in to comment.