diff --git a/Gemfile.lock b/Gemfile.lock index e1d6f0115..bf66a2fd4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) diff --git a/app/controllers/public_profile_controller.rb b/app/controllers/public_profile_controller.rb index 8209392fc..f651a8d46 100644 --- a/app/controllers/public_profile_controller.rb +++ b/app/controllers/public_profile_controller.rb @@ -1,6 +1,8 @@ # 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] @@ -8,14 +10,12 @@ class PublicProfileController < ApplicationController 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 @@ -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 diff --git a/app/jobs/kps/identity_save_job.rb b/app/jobs/kps/identity_save_job.rb index ed3cfa00e..462ac0ff6 100644 --- a/app/jobs/kps/identity_save_job.rb +++ b/app/jobs/kps/identity_save_job.rb @@ -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 diff --git a/app/services/vcard_builder.rb b/app/services/vcard_builder.rb new file mode 100644 index 000000000..8041a51c1 --- /dev/null +++ b/app/services/vcard_builder.rb @@ -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 diff --git a/app/validators/duty_validator.rb b/app/validators/duty_validator.rb index fdc2bab71..6cc691da1 100644 --- a/app/validators/duty_validator.rb +++ b/app/validators/duty_validator.rb @@ -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 diff --git a/app/validators/position_validator.rb b/app/validators/position_validator.rb index 60d6318e4..08df87804 100644 --- a/app/validators/position_validator.rb +++ b/app/validators/position_validator.rb @@ -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 diff --git a/app/views/public_profile/_form.html.erb b/app/views/public_profile/_search.html.erb similarity index 56% rename from app/views/public_profile/_form.html.erb rename to app/views/public_profile/_search.html.erb index bc61c9a67..9d90f29a4 100644 --- a/app/views/public_profile/_form.html.erb +++ b/app/views/public_profile/_search.html.erb @@ -12,15 +12,20 @@