Form and controller method to mark members as deleted

This commit is contained in:
Brenda Wallace
2017-05-20 22:01:20 +12:00
parent 18c02bf33b
commit e2fe04a44b
4 changed files with 23 additions and 2 deletions

View File

@@ -72,7 +72,9 @@ class ApplicationController < ActionController::Base
# email settings
:show_email, :newsletter, :send_notification_email, :send_planting_reminder,
# update password
:current_password)
:current_password,
# is the account deleted
:deleted)
end
end

View File

@@ -54,6 +54,11 @@ class MembersController < ApplicationController
end
end
def destroy
@member.update!(deleted: true)
redirect_to root_path
end
def view_follows
@member = Member.confirmed.find(params[:login_name])
@follows = @member.followed.paginate(page: params[:page])

View File

@@ -40,5 +40,6 @@ end
# check if we need the current password to update fields
def needs_password?(member, params)
params[:member][:password].present? ||
params[:member][:password_confirmation].present?
params[:member][:password_confirmation].present? ||
params[:member][:deleted].present?
end

View File

@@ -0,0 +1,13 @@
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f|
%br/
= devise_error_messages!
.form-group
= f.label :current_password, "Password required to delete", class: 'control-label col-md-2'
.col-md-4
= f.password_field :current_password, :class => 'form-control', id: 'current_pw_for_delete'
.form-group
.form-actions.col-md-offset-2.col-md-8
= f.submit "Delete", class: 'btn btn-primary'
=f.hidden_field(:deleted, value: true)