Skip to content

Commit

Permalink
Remove questionnaire fields from person forms
Browse files Browse the repository at this point in the history
  • Loading branch information
mpugach committed Dec 24, 2023
1 parent 6e84be6 commit 14d5ff2
Show file tree
Hide file tree
Showing 21 changed files with 11 additions and 154 deletions.
6 changes: 3 additions & 3 deletions app/controllers/people_controller.rb
Expand Up @@ -117,9 +117,9 @@ def show_photo
class PersonParams
def self.filter(params)
params.require(:person).permit(
:birthday, :education, :email, :friends_to_be_with, :gender, :marital_status,
:middle_name, :name, :photo, :photo_cache, :diploma_name, :favorite_lectors,
:surname, :work, telephones_attributes: %i[id phone _destroy]
:birthday, :email, :gender,
:middle_name, :name, :photo, :photo_cache, :diploma_name,
:surname, telephones_attributes: %i[id phone _destroy]
)
end
end
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/users/registrations_controller.rb
Expand Up @@ -6,9 +6,8 @@ class RegistrationsController < Devise::RegistrationsController
before_action :sanitize_account_update, only: :update

PERMITTED_PARAMS = [
:name, :surname, :middle_name, :gender, :photo, :photo_cache, :diploma_name, :favorite_lectors,
:birthday, :education, :work, :marital_status,
:friends_to_be_with, { telephones_attributes: %i[id phone _destroy] }
:name, :surname, :middle_name, :gender, :photo, :photo_cache, :diploma_name,
:birthday, { telephones_attributes: %i[id phone _destroy] }
].freeze

def new
Expand Down
5 changes: 1 addition & 4 deletions app/models/person.rb
@@ -1,9 +1,6 @@
class Person < ApplicationRecord
include Ilikable

# TODO: use enums here since we run rails 4.1
MARITAL_STATUSES = %i[single in_relationship married divorced widowed].freeze

class SymbolWrapper
def self.load(string)
string.try(:to_sym)
Expand Down Expand Up @@ -60,7 +57,7 @@ def self.dump(symbol)
validates :password, length: { in: 6..128, unless: :skip_password_validation }, on: :create
validates :password, length: { in: 6..128 }, allow_blank: true, on: :update
validates :privacy_agreement, acceptance: { accept: 'yes', unless: :skip_password_validation }, on: :create
validates :telephones, :birthday, :marital_status, presence: true
validates :telephones, :birthday, presence: true

validate :check_photo_dimensions
validate :validate_age
Expand Down
6 changes: 0 additions & 6 deletions app/views/people/_form.html.haml
Expand Up @@ -8,19 +8,13 @@
= f.input :photo_cache, as: :hidden
= f.input :email, autofocus: true
= f.input :diploma_name
= f.input :favorite_lectors
= f.input :name
= f.input :middle_name
= f.input :surname
= render 'shared/nested_telephones', f: f
= f.input :gender, collection: [[:male, true], [:female, false]],
label_method: lambda { |element| t("simple_form.options.person.gender.#{element.first}") }
= f.input :marital_status, collection: Person::MARITAL_STATUSES,
label_method: lambda { |element| t("simple_form.options.person.marital_status.#{element.first}") }
= f.input :birthday, as: :string, input_html: { type: 'date', value: date_value(f.object.birthday) }
= f.input :friends_to_be_with
= f.input :education
= f.input :work

.form-actions
= f.button :submit
25 changes: 0 additions & 25 deletions app/views/people/show.html.haml
Expand Up @@ -27,11 +27,6 @@
.col-xs-12
= link_to t('links.crop_photo'), crop_image_path(@person.id), class: 'btn btn-default'
.col-xs-12.col-sm-8
.row
.col-xs-4.col-sm-3
Favorite lectors:
.col-xs-8.col-sm-9
= @person.favorite_lectors
.row
.col-xs-4.col-sm-3
Registration time:
Expand Down Expand Up @@ -120,32 +115,12 @@
Email:
.col-xs-8.col-sm-9
= mail_to @person.email
.row
.col-xs-4.col-sm-3
Marital status:
.col-xs-8.col-sm-9
= @person.marital_status
.row
.col-xs-4.col-sm-3
Friends to be with:
.col-xs-8.col-sm-9
= @person.friends_to_be_with
- @person.telephones.each_with_index do |telephone, index|
.row
.col-xs-4.col-sm-3
Telephone #{index + 1}:
.col-xs-8.col-sm-9
= telephone.phone
.row
.col-xs-4.col-sm-3
Education:
.col-xs-8.col-sm-9
= @person.education
.row
.col-xs-4.col-sm-3
Work:
.col-xs-8.col-sm-9
= @person.work

.row
.col-xs-12.vert-offset-top-1#pending_docs
Expand Down
6 changes: 0 additions & 6 deletions app/views/users/registrations/edit.html.haml
Expand Up @@ -28,23 +28,17 @@
%p
Currently waiting confirmation for: #{resource.unconfirmed_email}
= f.input :diploma_name
= f.input :favorite_lectors
= f.input :name
= f.input :middle_name
= f.input :surname
.col-xs-12
.row
.col-xs-12.col-sm-6
= f.input :birthday, as: :string, input_html: { type: 'date', value: date_value(f.object.birthday) }
= f.input :education
= f.input :marital_status, collection: Person::MARITAL_STATUSES,
label_method: lambda { |element| t("simple_form.options.person.marital_status.#{element.first}") }
= f.input :friends_to_be_with
= render 'shared/nested_telephones', f: f
.col-xs-12.col-sm-6
= f.input :gender, collection: [[:male, true], [:female, false]],
label_method: lambda { |element| t("simple_form.options.person.gender.#{element.first}") }
= f.input :work
= f.input :password, autocomplete: 'off'
= f.input :password_confirmation
= f.input :current_password
Expand Down
6 changes: 0 additions & 6 deletions app/views/users/registrations/new.html.haml
Expand Up @@ -22,19 +22,13 @@
= f.input :name
= f.input :middle_name
= f.input :surname
= f.input :education
= f.input :marital_status, collection: Person::MARITAL_STATUSES,
label_method: lambda { |element| t("simple_form.options.person.marital_status.#{element.first}") }
= render 'shared/nested_telephones', f: f
.col-xs-12.col-sm-6
= f.input :diploma_name
= f.input :favorite_lectors
= f.input :gender, collection: [[:male, true], [:female, false]],
label_method: lambda { |element| t("simple_form.options.person.gender.#{element.first}") }
= f.input :password
= f.input :password_confirmation
= f.input :work
= f.input :friends_to_be_with

.row.form-actions
.col-xs-12.text-center
Expand Down
10 changes: 0 additions & 10 deletions config/locales/active_record.ru.yml
Expand Up @@ -49,19 +49,15 @@ ru:
birthday: 'День рождения'
current_password: 'Текущий пароль'
diploma_name: 'Имя для диплома'
education: 'Образование'
email: 'Электронная почта'
favorite_lectors: 'Любимые лекторы'
gender: 'Пол'
marital_status: 'Семейное положение'
middle_name: 'Отчество'
name: 'Имя'
password_confirmation: 'Подтверждение'
password: 'Пароль'
photo: 'Фотография'
privacy_agreement: 'Соглашение на обработку персональных данных'
surname: 'Фамилия'
work: 'Работа'
program:
title_uk: 'Название на украинском'
title_ru: 'Название на русском'
Expand Down Expand Up @@ -124,12 +120,8 @@ ru:
current_password:
blank: 'должен быть заполнен'
invalid: 'не правильный'
favorite_lectors:
blank: 'укажите пожалуйста'
gender:
inclusion: 'должен быть выбран'
marital_status:
blank: 'должно быть выбрано'
password:
too_long: 'слишком длинный (максимум %{count} символов)'
too_short: 'слишком короткий (минимум %{count} символов)'
Expand All @@ -142,8 +134,6 @@ ru:
surname:
blank: 'должна быть заполнена'
too_long: 'слишком длинная (максимум %{count} символов)'
work:
blank: 'должна быть заполнена'
program:
attributes:
manager:
Expand Down
12 changes: 0 additions & 12 deletions config/locales/active_record.uk.yml
Expand Up @@ -49,19 +49,15 @@ uk:
birthday: 'День народження'
current_password: 'Поточний пароль'
diploma_name: "І'мя для диплому"
education: 'Освіта'
email: 'Електронна пошта'
favorite_lectors: 'Улюблені лектори'
gender: 'Стать'
marital_status: 'Сімейний стан'
middle_name: 'По батькові'
name: "Ім'я"
password_confirmation: 'Підтвердження'
password: 'Пароль'
photo: 'Фотографія'
privacy_agreement: 'Згода на обробку персональних даних'
surname: 'Прізвище'
work: 'Робота'
program:
title_uk: 'Назва українською'
title_ru: 'Назва російською'
Expand Down Expand Up @@ -129,21 +125,15 @@ uk:
attributes:
birthday:
over_16_years_old: 'вибачте Вам повинно виконатися 16 повних років'
education:
blank: 'повинна бути заповнена'
current_password:
blank: 'повинен бути заповненим'
invalid: 'не вірний'
favorite_lectors:
blank: 'вкажіть будь ласка'
email:
blank: 'повинна бути заповнена'
invalid: 'повинна відповідати формату «pryklad@example.com»'
taken: 'зайнята. Можливо Ви вже зареєстровані, спробуйте <a href="/password/new">відновити пароль</a>'
gender:
inclusion: 'повинна бути обрана'
marital_status:
blank: 'повинен бути обраний'
password:
too_long: 'занадто довигий (максимум %{count} символів)'
too_short: 'занадто короткий (мінімум %{count} символів)'
Expand All @@ -153,8 +143,6 @@ uk:
size: 'повинна бути не меньше 150*200 пікселів'
privacy_agreement:
accepted: 'повинна бути прийнята'
work:
blank: 'повинна бути заповнена'
program:
attributes:
title_uk:
Expand Down
15 changes: 0 additions & 15 deletions config/locales/simple_form.ru.yml
Expand Up @@ -12,12 +12,6 @@ ru:
gender:
male: 'Мужской'
female: 'Женский'
marital_status:
single: 'нет отношений'
in_relationship: 'в отношениях/гражданском браке'
married: 'женат/замужем'
divorced: 'разведен/разведена'
widowed: 'вдовец/вдова'
program:
visible:
visible: 'Да'
Expand All @@ -30,12 +24,8 @@ ru:
birthday: 'День рождения'
current_password: 'Текущий пароль'
diploma_name: 'Имя для печати на дипломах и сертификатах на украинском (оставьте пустым, если совпадает с именем и фамилией)'
education: 'Специальность'
email: 'Электронная почта'
favorite_lectors: 'Имена лекторов, которых Вам нравится слушать больше всего'
friends_to_be_with: 'Друзья в Академии'
gender: 'Пол'
marital_status: 'Семейное положение'
middle_name: 'Отчество'
name: 'Имя'
notify_schedules: 'Мое расписание'
Expand All @@ -44,16 +34,13 @@ ru:
phone: 'Телефон'
photo: 'Фотография на студенческий билет'
surname: 'Фамилия'
work: 'Профессия'
placeholders:
person:
email: 'test@example.com'
name: 'Антон'
middle_name: 'Иванович'
surname: 'Петренко'
birthday: '31.02.1980'
education: 'Инженер компьютерних систем, экономист'
work: 'Тестировщик, вэб програмист, менеджер'
new:
password: '******'
password_confirmation: '******'
Expand All @@ -65,7 +52,5 @@ ru:
birthday: 'В Акадении могут учиться только с 16 лет'
password: 'Оставьте пустым, если не хотите менять'
current_password: 'Введите Ваш текущий пароль, чтобы подтвердить изменения'
friends_to_be_with: 'если Вы пришли в Академию вместе с друзьями, укажите их имена через запятую, чтобы быть с ними в одной группе'
new:
birthday: 'В Акадении могут учиться только с 16 лет'
friends_to_be_with: 'если Вы пришли в Академию вместе с друзьями, укажите их имена через запятую, чтобы быть с ними в одной группе'
15 changes: 0 additions & 15 deletions config/locales/simple_form.uk.yml
Expand Up @@ -12,12 +12,6 @@ uk:
gender:
male: 'Чоловіча'
female: 'Жіноча'
marital_status:
single: 'немає відносин'
in_relationship: 'у відносинах/цивільному шлюбі'
married: 'одружений/заміжня'
divorced: 'розлучений/розлучена'
widowed: 'вдівець/вдова'
program:
visible:
visible: 'Так'
Expand All @@ -30,12 +24,8 @@ uk:
birthday: 'День народження'
current_password: 'Поточний пароль'
diploma_name: "Ім'я для друку на дипломах та сертифікатах (залиште пустим, якщо відповідає імені та призвищу)"
education: 'Спеціальність'
email: 'Електронна пошта'
favorite_lectors: 'Імена лекторів, яких Вам подобається слухати найбільше'
friends_to_be_with: 'Друзі в Академії'
gender: 'Стать'
marital_status: 'Сімейний стан'
middle_name: 'По батькові'
name: "Ім'я"
notify_schedules: 'Мій розклад'
Expand All @@ -44,16 +34,13 @@ uk:
phone: 'Телефон'
photo: 'Фотографія на студентський квиток'
surname: 'Прізвище'
work: 'Професія'
placeholders:
person:
email: 'test@example.com'
name: 'Антон'
middle_name: 'Іванович'
surname: 'Петренко'
birthday: '31.02.1980'
education: "Інженер з комп'ютерних систем, економіст"
work: 'Тестувальник, веб програміст, менеджер'
new:
password: '******'
password_confirmation: '******'
Expand All @@ -65,7 +52,5 @@ uk:
birthday: 'В Академії можна навчатися тільки з 16 років'
password: 'Залиште пустим, якщо не хочете змінювати'
current_password: 'Введіть Ваш поточний пароль, щоб підтвердити зміни'
friends_to_be_with: 'якщо Ви прийшли до Академії разом з друзями, вкажіть іх імена через кому, щоб бути з ними у одній группі'
new:
birthday: 'В Академії можна навчатися тільки з 16 років'
friends_to_be_with: 'якщо Ви прийшли до Академії разом з друзями, вкажіть іх імена через кому, щоб бути з ними у одній группі'
4 changes: 1 addition & 3 deletions lib/tasks/export_for_service.rake
Expand Up @@ -22,9 +22,7 @@ namespace :academic do
sheet.add_row([
name_for_card(person),
person.student_profile.try(:academic_groups).try(:map, &:title).try(:join, ', '),
person.telephones.map(&:phone).join(', '),
person.work,
person.education
person.telephones.map(&:phone).join(', ')
])

print PROGRESS_ELEMENT
Expand Down
10 changes: 4 additions & 6 deletions spec/controllers/people_controller_spec.rb
Expand Up @@ -211,7 +211,7 @@
Given(:person) { create :person }

def update_model(attributes = nil)
person.favorite_lectors = 'Какой-то текст'
person.middle_name = 'Какой-то текст'

attributes ||= person.attributes.merge(skip_password_validation: true)

Expand All @@ -222,19 +222,19 @@ def update_model(attributes = nil)

context 'on success' do
context 'field chenged' do
Then { expect { update_model }.to change { person[:favorite_lectors] }.to('Какой-то текст') }
Then { expect { update_model }.to change { person[:middle_name] }.to('Какой-то текст') }
end

context 'receives .update_attributes' do
Then do
expect_any_instance_of(Person).to receive(:update).with(
ActionController::Parameters.new(
'favorite_lectors' => 'params',
'middle_name' => 'params',
'skip_password_validation' => true
).permit!
)

update_model('favorite_lectors' => 'params')
update_model('middle_name' => 'params')
end
end

Expand Down Expand Up @@ -263,8 +263,6 @@ def update_model(attributes = nil)
email: 'ssd@pamho.yes',
gender: true,
birthday: 7200.days.ago.to_date,
education: 'Брахмачарьи ашрам',
work: 'ББТ',
telephones_attributes: [
id: nil,
phone: '+380 50 111 2233'
Expand Down

0 comments on commit 14d5ff2

Please sign in to comment.