Skip to content

Commit

Permalink
new field contacts in resume
Browse files Browse the repository at this point in the history
  • Loading branch information
usernaimandrey committed Mar 31, 2023
1 parent 683ded5 commit d5a26b1
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 19 deletions.
19 changes: 18 additions & 1 deletion app/forms/web/account/resume_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@ class Web::Account::ResumeForm < Resume

validates :direction_list, direction_list: true

attrs = %i[name hexlet_url github_url contact summary skills_description awards_description english_fluency city relocation skill_list direction_list]
attrs = %i[
name
hexlet_url
github_url
contact
contact_email
contact_phone
contact_telegram summary
skills_description
summary
awards_description
english_fluency
city
relocation
skill_list
direction_list
]

nested_attrs = {
educations_attributes: %i[description begin_date end_date current _destroy id],
works_attributes: %i[company position description begin_date end_date current _destroy id]
Expand Down
16 changes: 15 additions & 1 deletion app/forms/web/admin/resume_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@
class Web::Admin::ResumeForm < Resume
include ActiveFormModel

attrs = %i[state_event name hexlet_url github_url contact summary skills_description awards_description english_fluency]
attrs = %i[
state_event
name
hexlet_url
github_url
contact
contact_email
contact_phone
contact_telegram
summary
skills_description
awards_description
english_fluency
]

nested_attrs = {
educations_attributes: %i[description begin_date end_date current _destroy id],
works_attributes: %i[company position description begin_date end_date current _destroy id]
Expand Down
4 changes: 4 additions & 0 deletions app/models/resume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class Resume < ApplicationRecord
validates :github_url, presence: true
validates :summary, presence: true, length: { minimum: 200 }
validates :skills_description, presence: true
validates :contact_email, 'valid_email_2/email': true
# TODO: В будущем для валидации номеров телефона надо подключить гем
validates :contact_phone, format: { with: /\A((\d{1}|\+\d{1})[- ]?)?(\(?\d{3}\)?[- ]?)?[\d\- ]{7,10}$\z/ },
if: -> { contact_phone.present? }

belongs_to :user
has_many :answers, inverse_of: :resume, dependent: :destroy
Expand Down
15 changes: 15 additions & 0 deletions app/views/web/resumes/_information.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@
.col-sm-9
= link_to @resume.github_url, @resume.github_url, target: '_blank', rel: :noopener
- if @resume.contact
.row.mt-3.mb-4
.col-sm-3
b = han('resume', 'contact_phone')
.col-sm-9
= @resume.contact_phone
.row.mt-3.mb-4
.col-sm-3
b = han('resume', 'contact_email')
.col-sm-9
= @resume.contact_email
.row.mt-3.mb-4
.col-sm-3
b = han('resume', 'contact_telegram')
.col-sm-9
= @resume.contact_telegram
.row.mt-3.mb-4
.col-sm-3
b = han('resume', 'contact')
Expand Down
6 changes: 6 additions & 0 deletions app/views/web/shared/_resume_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
= f.input :hexlet_url
.mb-3
= f.input :github_url
.mb-3
= f.input :contact_phone
.mb-3
= f.input :contact_email
.mb-3
= f.input :contact_telegram
.mb-3
= f.input :contact
.mb-3
Expand Down
19 changes: 12 additions & 7 deletions config/locales/en.activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ en:
vacancy:
publish: Publish
archive: Archive
# errors:
# models:
# resume/answer/like:
# attributes:
# user:
# answer_owner: Нельзя лайкнуть свой ответ :)
attributes:
resume/answer:
content: Answer
Expand Down Expand Up @@ -104,7 +98,10 @@ en:
summary: Description
hexlet_url: Hexlet
github_url: GitHub
contact: Contact information
contact: Additional contacts
contact_phone: Phone
contact_email: Email
contact_telegram: Telegram
english_fluency: Languages
skills_description: Skills
awards_description: Awards, Certificates
Expand All @@ -114,3 +111,11 @@ en:
state/archived: Archived
skill_list: Skill tags
direction_list: Direction
errors:
models:
resume:
attributes:
contact_email:
invalid: is not in the correct format
contact_phone:
invalid: is not in the correct format
19 changes: 12 additions & 7 deletions config/locales/ru.activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ ru:
vacancy:
publish: Опубликовать
archive: Архивировать
# errors:
# models:
# resume/answer/like:
# attributes:
# user:
# answer_owner: Нельзя лайкнуть свой ответ :)

models:
resume: Резюме
Expand Down Expand Up @@ -81,7 +75,10 @@ ru:
relocation: Готовность к релокации
hexlet_url: Hexlet
github_url: GitHub
contact: Контакт
contact: Дополнительные контакты
contact_phone: Телефон
contact_email: Почта
contact_telegram: Телеграм
english_fluency: Владение английским
skills_description: Навыки
awards_description: Награды, Сертификаты
Expand Down Expand Up @@ -115,3 +112,11 @@ ru:
content: Комментарий
answer/comment:
content: Комментарий
errors:
models:
resume:
attributes:
contact_email:
invalid: имеет не верный формат
contact_phone:
invalid: имеет неверное формат
5 changes: 4 additions & 1 deletion config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ en:
relocation: Specify whether you're ready to relocate
hexlet_url: "link to your Hexlet account: https://ru.hexlet.io/u/mokevnin"
github_url: "link to your GitHub account: https://github.com/mokevnin"
contact: "Email address, phone number"
contact: Here you can specify additional contacts - for example, links to social networks
contact_phone: "Your phone: +1 935 555 55 55"
contact_email: "Your email: example@test.com"
contact_telegram: "Your Telegram: https://tlgg.ru/Kiril or @Kiril"
name: PHP programmer, Android developer, ...
skills_description: PHP, Vim, AWS, Agile metodologies
awards_description: Participation in competitions, hackathons and other specialized events. Courses.
Expand Down
5 changes: 4 additions & 1 deletion config/locales/simple_form.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ ru:
relocation: Укажите вашу готовность к релокации
hexlet_url: 'Ссылка на профиль: https://ru.hexlet.io/u/mokevnin'
github_url: 'Ссылка на профиль: https://github.com/mokevnin'
contact: 'Предпочитаемый способ связи (емайл, линкедин, телеграмм и т.п.)'
contact: Здесь можно указать дополнительные контакты - например ссылки на социальные сети
contact_phone: "Ваш телефон: +7 906 777 77 77"
contact_email: "Ваша почта email@example.ru"
contact_telegram: 'Ваш телеграм: https://tlgg.ru/Kiril или @Kiril'
name: PHP-программист, Android-разработчик, ...
skills_description: Знаю PHP, пользуюсь Vim, Работал с AWS
awards_description: Участие в олимпиадах, хакатонах, других профильных мероприятиях. Курсы.
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20230330191106_add_new_fields_to_resume.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddNewFieldsToResume < ActiveRecord::Migration[7.0]
def change
add_column :resumes, :contact_phone, :string
add_column :resumes, :contact_email, :string
add_column :resumes, :contact_telegram, :string
end
end
5 changes: 4 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_02_21_221505) do
ActiveRecord::Schema[7.0].define(version: 2023_03_30_191106) do
create_table "countries", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
Expand Down Expand Up @@ -149,6 +149,9 @@
t.string "locale"
t.string "city"
t.string "relocation"
t.string "contact_phone"
t.string "contact_email"
t.string "contact_telegram"
t.index ["user_id"], name: "index_resumes_on_user_id"
end

Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/resumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ DEFAULTS: &DEFAULTS
hexlet_url: https://ru.hexlet.io/u/$LABEL
github_url: https://github.com/$LABEL
contact: $LABEL@email.com
contact_phone: +7 999 999 99 99
contact_telegram: '@$LABEL'
name: Resume Name $LABEL
english_fluency: fluent
skills_description: <%= Faker::Lorem.paragraph %>
Expand Down

0 comments on commit d5a26b1

Please sign in to comment.