forked from openware/barong
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all logic from profile show to accounts show (close openware#449)
- Loading branch information
1 parent
3e66f25
commit d9b4a39
Showing
17 changed files
with
276 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountMailer < Devise::Mailer | ||
include SkipEmails | ||
|
||
def confirmation_instructions(record, token, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def reset_password_instructions(record, token, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def unlock_instructions(record, token, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def email_changed(record, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def password_change(record, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationMailer < ActionMailer::Base | ||
default from: 'from@example.com' | ||
include SkipEmails | ||
|
||
default from: ENV.fetch('SENDER_EMAIL', 'noreply@barong.io') | ||
layout 'mailer' | ||
|
||
def mail(options) | ||
send_email_if_enabled { super } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module SkipEmails | ||
extend ActiveSupport::Concern | ||
|
||
def send_email_if_enabled | ||
raise 'Block is required' unless block_given? | ||
|
||
if ENV['SKIP_EMAILS'] | ||
return Rails.logger.info 'Emails are skip. You need to use Event API to handle emails manually' | ||
end | ||
|
||
yield | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<div class="container"> | ||
<h4 class="text-center"> Profile </h4> | ||
<ul class="list-group"> | ||
<li class="list-group-item"> | ||
<b> E-mail: </b> | ||
<%= @account.email%> | ||
</li > | ||
<% if @profile %> | ||
<li class="list-group-item"> | ||
<b> First Name: </b> | ||
<%= @profile.first_name%> | ||
</li> | ||
|
||
<li class="list-group-item"> | ||
<b> Last Name: </b> | ||
<%= @profile.last_name%> | ||
</li> | ||
|
||
<li class="list-group-item"> | ||
<b> Address: </b> | ||
<%= @profile.address%> | ||
</li> | ||
|
||
<li class="list-group-item"> | ||
<b> Postcode: </b> | ||
<%= @profile.postcode%> | ||
</li> | ||
|
||
<li class="list-group-item"> | ||
<b> City: </b> | ||
<%= @profile.city%> | ||
</li> | ||
|
||
<li class="list-group-item"> | ||
<b> Country: </b> | ||
<%= @profile.country%> | ||
</li> | ||
|
||
<li class="list-group-item"> | ||
<b> State: </b> | ||
<div class="dropdown show"> | ||
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
<%= @profile.state.upcase_first %> | ||
</a> | ||
<div class="dropdown-menu"> | ||
<% Profile::STATES.each do |state|%> | ||
<%= link_to(state.upcase_first, change_state_admin_profile_path(@account.profile, state: state), method: :put, class: 'dropdown-item') unless @account.profile.state == state%> | ||
<% end %> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="list-group-item"> | ||
<%= link_to 'Edit', edit_admin_profile_path(@account.profile), class: 'btn btn-primary btn-sm' %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<br> | ||
<h4 class="text-center"> Phones </h4> | ||
<table class="table table-bordered table-striped table-hover table-sm text-center"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Country</th> | ||
<th>Number</th> | ||
<th>Vlidated at</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @phones.each do |phone| %> | ||
<tr> | ||
<td><%= phone.id %></td> | ||
<td><%= phone.country %></td> | ||
<td><%= phone.number %></td> | ||
<td><%= phone.validated_at %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<br> | ||
<h4 class="text-center"> Documents </h4> | ||
<table class="table table-bordered table-striped table-hover table-sm text-center"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Doc Photo</th> | ||
<th>Doc Name</th> | ||
<th>Doc Type</th> | ||
<th>Doc Number</th> | ||
<th>Doc Expire</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @documents.each do |document| %> | ||
<tr> | ||
<td><%= document.id %></td> | ||
<td><%= document.upload.present? ? link_to(image_tag(document.upload.url, width: '100', alt: 'Doc Preview'), asset_path(document.upload), target: '_blank') : ''%></td> | ||
<td><%= document.upload&.file&.filename%></td> | ||
<td><%= document.doc_type %></td> | ||
<td><%= document.doc_number %></td> | ||
<td><%= document.doc_expire %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<br> | ||
<%= link_to 'New Label', new_admin_account_label_path(@account.id), class: 'btn btn-success' %> | ||
<br> | ||
<h4 class="text-center"> Labels </h4> | ||
<table class="table table-bordered table-striped table-hover table-sm text-center"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Key</th> | ||
<th>Value</th> | ||
<th>Scope</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @labels.each do |label| %> | ||
<tr> | ||
<td><%= label.id %></td> | ||
<td><%= label.key %></td> | ||
<td><%= label.value %></td> | ||
<td><%= label.scope %></td> | ||
<td><%= link_to 'Edit', edit_admin_account_label_path(id: label.id, account_id: @account.id), class: 'btn btn-primary btn-sm' %></td> | ||
<td><%= link_to 'Delete', admin_account_label_path(id: label.id, account_id: @account.id), class: 'btn btn-danger btn-sm', method: :delete, data: {confirm: 'Are you sure?'} %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<%= form_with(model: [:admin, @account, @profile]) do |form| %> | ||
<% if profile.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(profile.errors.count, "error") %> prohibited this profile from being saved:</h2> | ||
|
||
<ul> | ||
<% profile.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
<%= form.label :first_name, class: 'control-label'%> | ||
<%= form.text_field :first_name, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :last_name, class: 'control-label'%> | ||
<%= form.text_field :last_name, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :dob, class: 'control-label'%> | ||
<%= form.text_field :dob, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :address, class: 'control-label'%> | ||
<%= form.text_field :address, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :postcode, class: 'control-label'%> | ||
<%= form.text_field :postcode, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :city, class: 'control-label'%> | ||
<%= form.text_field :city, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :country, class: 'control-label'%> | ||
<%= form.text_field :country, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.submit 'Submit', class: 'btn btn-primary' %> | ||
|
||
<br> | ||
<br> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="container"> | ||
<h1>Editing profile</h1> | ||
<%= render 'form', profile: @profile %> | ||
<br> | ||
</div> |
Oops, something went wrong.