Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
korotindev committed Oct 19, 2015
1 parent 3b0b7a4 commit 178acdf
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 19 deletions.
10 changes: 8 additions & 2 deletions app/controllers/web/remind_password_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ def create
end

def edit
@user_form = UserForm.find_with_model_by params.permit(:id, :token)
@user_form = UserForm.find_with_model_by! id: params[:id], token: params[:token]
end

def update

@user_form = UserForm.find_with_model_by! id: params[:id]
@user_form.submit params[:user]
if @user_form.save
redirect_to new_session_path
else
render :edit
end
end
end
5 changes: 5 additions & 0 deletions app/forms/application_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def find_with_model_by *args
self.new obj
end

def find_with_model_by! *args
obj = obj_class.find_by!(*args)
self.new obj
end

def new_with_model *args
obj = obj_class.new *args
active_form = self.new obj
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class User < ActiveRecord::Base
has_secure_password validations: false
has_secure_password

has_many :authentications, dependent: :destroy
has_many :article
Expand Down
16 changes: 11 additions & 5 deletions app/views/web/remind_password/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
- title
.container.mic-form-container
= render 'layouts/web/shared/errors', object: @user_form
= simple_form_for @user_form, url: { controller: :remind_password, action: :update } do |f|
= f.input :password, as: :password, required: true
= f.input :password_confirmation, as: :password, required: true
= f.button :submit, t('.register')
.row
.medium-6.small-12.columns.medium-push-3
%h3.title
= t('.title')
= render 'layouts/web/shared/errors', object: @user_form
= simple_form_for @user_form, url: { controller: :remind_password, action: :update } do |f|
= f.label t('.new_password'), required: true
= f.input :password, as: :password, required: true, label: false
= f.label t('.repeat_new_password'), required: true
= f.input :password_confirmation, as: :password, required: true, label: false
= f.button :submit, t('.update_password')
2 changes: 2 additions & 0 deletions app/views/web/remind_password/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.container.mic-form-container
.row
.medium-6.small-12.columns.medium-push-3
%h3.title
= t('.title')
- if @user_form.email.present?
%span.label.alert
%i.fa.fa-exclamation-circle
Expand Down
2 changes: 0 additions & 2 deletions app/views/web/users/account/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
= f.input :patronymic, as: :string
= f.input :last_name, as: :string
= f.input :email, as: :string
= f.input :password, as: :password_foundation
= f.input :motto, as: :string
= f.input :ticket, as: :string
= f.input :mobile_phone, as: :string
Expand Down Expand Up @@ -49,7 +48,6 @@
- unless @user.email.present?
= f.hint t('notifications.web.users.account.email.empty')
= f.input :email, as: :string, required: true
= f.input :password, as: :string
= f.button :submit, t('helpers.links.save')
- if !@user.is_member? || (@user.is_member? && @user.unavailable?)
- if @user.is_questionary?
Expand Down
5 changes: 5 additions & 0 deletions config/locales/ru/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ ru:
index:
title: Восстановление пароля
remind_password_error: Пользователь с указанным email не был найден или был удалён
edit:
title: Создание нового пароля
update_password: Обновить пароль
new_password: Новый пароль
repeat_new_password: Повторите новый пароль
pages:
shared:
not_found:
Expand Down
12 changes: 4 additions & 8 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ en:
error_notification:
default_message: "Please review the problems below:"
# Examples
# labels:
# defaults:
# password: 'Password'
# user:
# new:
# email: 'E-mail to sign in.'
# edit:
# email: 'E-mail.'
labels:
user:
edit:
password: 'Введите новый пароль'
# hints:
# defaults:
# username: 'User name to sign in.'
Expand Down
2 changes: 1 addition & 1 deletion lib/notifications/types/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Types

class Email
def self.to_send(params)
UserMailer.delay.send(params[:theme], params[:object], params[:user])
UserMailer.delay.send(params[:theme], params[:object], params[:user])
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/yaml/mail_messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ messages:
user:
after_create:
subject: 'Подтверждение адреса электронной почты'
remind_password:
subject: 'Восстановление утерянного пароля'
member:
after_create:
subject: 'Подтверждение адреса электронной почты'
Expand Down

0 comments on commit 178acdf

Please sign in to comment.