-
Notifications
You must be signed in to change notification settings - Fork 69
mail notification to origin and destination when transfer is done #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,16 @@ | ||
class PaymentNotifier < ActionMailer::Base | ||
default from: "\"TimeOverflow\" <info@timeoverflow.org>" | ||
|
||
# @param username [String] username of the destination account | ||
# @param time [String] | ||
def transfer_source(user, username_destination, time) | ||
mail(to: "#{user.email}", subject: default_i18n_subject(time: time, username_destination: username_destination), body: 'SI') | ||
end | ||
|
||
# @param username [String] username of the source account | ||
# @param time [String] | ||
def transfer_destination(user, username_source, time) | ||
# Todo: Send with destination locale | ||
mail(to: "#{user.email}", subject: default_i18n_subject(time: time, username_source: username_source), body: 'SI') | ||
end | ||
end |
This file contains hidden or 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,30 @@ | ||
class TransferCreator | ||
|
||
def initialize(source:, destination:, amount:, reason:, post_id:) | ||
@source = source | ||
@destination = destination | ||
@amount = amount | ||
@reason = reason | ||
@post_id = post_id | ||
end | ||
|
||
attr_reader :transfer | ||
|
||
def create! | ||
@transfer = Transfer.new( | ||
source: @source, | ||
destination: @destination, | ||
amount: @amount, | ||
reason: @reason, | ||
post_id: @post_id | ||
) | ||
@transfer.save! && notify_by_email | ||
end | ||
|
||
def notify_by_email | ||
# mail notificación pago | ||
#Todo: check accountable as organization | ||
PaymentNotifier.transfer_source(@source.accountable.user, @destination.accountable.display_name_with_uid, @transfer.amount.to_f/3600).deliver_now | ||
PaymentNotifier.transfer_destination(@destination.accountable.user, @source.accountable.display_name_with_uid, @transfer.amount.to_f/3600).deliver_now | ||
end | ||
end |
This file contains hidden or 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,10 +1,16 @@ | ||
ca: | ||
mailers_globals: | ||
footer: | ||
text: "%{organization_name} en" | ||
text: "%{organization_name} a" | ||
|
||
organization_notifier: | ||
recent_posts: | ||
subject: Boletín semanal | ||
text1: "Últimas ofertas publicadas:" | ||
text2: "Últimas demandas publicadas:" | ||
subject: "Butlletí setmanal" | ||
text1: "Darreres ofertes publicades:" | ||
text2: "Darreres demandes publicades:" | ||
|
||
payment_notifier: | ||
transfer_source: | ||
subject: "Has pagat %{time} hores a %{username_destination}" | ||
transfer_destination: | ||
subject: "Has rebut %{time} hores de %{username_source}" |
This file contains hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
class TimeFormatter | ||
def mdash | ||
raw "—" | ||
end | ||
|
||
def seconds_to_h_m(seconds) | ||
sign = seconds <=> 0 | ||
if sign.try :nonzero? | ||
minutes, _seconds = seconds.abs.divmod(60) | ||
hours, minutes = minutes.divmod(60) | ||
raw format("%s%d:%02d", ("-" if sign < 0), hours, minutes) | ||
else | ||
mdash | ||
end | ||
end | ||
end |
This file contains hidden or 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,27 @@ | ||
require 'spec_helper' | ||
|
||
describe TransferCreator do | ||
describe '#create!' do | ||
let(:jordi_member) { Fabricate(:member) } | ||
let(:organization) { member.organization } | ||
let(:paco_member) { Fabricate(:member, organization: organization) } | ||
let(:jordi) { jordi_member.user } | ||
let(:paco) { paco_member.user } | ||
let(:amount) { 3 } | ||
let(:post) { double(Post, id: 666) } | ||
|
||
subject do | ||
described_class.new( | ||
source: jordi, | ||
destination: paco, | ||
amount: amount, | ||
reason: reason, | ||
post_id: post.id | ||
).create! | ||
end | ||
|
||
it 'Creates a new Transfer' do | ||
expect(subject).to be true | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Que es
mdash
? No lo veo definido en ningun sitio.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esto... copy paste de /helpers/application_helper.rb función
seconds_to_hm(seconds)
😬 me falto tampien copy paste deThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vas a necesitar
raw
tambien me temo.... y creo que es cosa de vistas...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ademas, no dupliques codigo. Muevelo y usa en todos sitios la clase esa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me temo que estás haciendo de Ruby aquí. Si no me equivoco
#strftime
hace esto ya http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/DateTime.html#method-i-strftime