Merge branch 'master' into new_mailchimp_integration
Esse commit está contido em:
@@ -82,22 +82,22 @@ class Contribution < ActiveRecord::Base
|
||||
|
||||
def update_user_billing_info
|
||||
user.update_attributes({
|
||||
address_street: address_street || user.address_street,
|
||||
address_number: address_number || user.address_number,
|
||||
address_neighbourhood: address_neighbourhood || user.address_neighbourhood,
|
||||
address_zip_code: address_zip_code || user.address_zip_code,
|
||||
address_city: address_city || user.address_city,
|
||||
address_state: address_state || user.address_state,
|
||||
phone_number: address_phone_number || user.phone_number,
|
||||
cpf: payer_document || user.cpf
|
||||
address_street: (address_street.present? ? address_street : user.address_street),
|
||||
address_number: (address_number.present? ? address_number : user.address_number),
|
||||
address_neighbourhood: (address_neighbourhood.present? ? address_neighbourhood : user.address_neighbourhood),
|
||||
address_zip_code: (address_zip_code.present? ? address_zip_code : user.address_zip_code),
|
||||
address_city: (address_city.present? ? address_city : user.address_city),
|
||||
address_state: (address_state.present? ? address_state : user.address_state),
|
||||
phone_number: (address_phone_number.present? ? address_phone_number : user.phone_number),
|
||||
cpf: (payer_document.present? ? payer_document : user.cpf)
|
||||
})
|
||||
end
|
||||
|
||||
def notify_to_contributor(template_name)
|
||||
def notify_to_contributor(template_name, options = {})
|
||||
Notification.notify_once(template_name,
|
||||
self.user,
|
||||
{ contribution_id: self.id },
|
||||
contribution: self
|
||||
{ contribution: self }.merge!(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
+11
-1
@@ -209,11 +209,21 @@ class Project < ActiveRecord::Base
|
||||
Notification.notify_once(
|
||||
template_name,
|
||||
self.user,
|
||||
{ project_id: self.id },
|
||||
{ project_id: self.id, channel_id: self.last_channel.try(:id) },
|
||||
{ project: self }.merge!(params)
|
||||
)
|
||||
end
|
||||
|
||||
def notify_to_backoffice(template_name, options = {}, backoffice_user = User.find_by(email: CatarseSettings[:email_payments]))
|
||||
if backoffice_user
|
||||
Notification.notify_once(template_name,
|
||||
backoffice_user,
|
||||
{ project_id: self.id, channel_id: self.last_channel.try(:id) },
|
||||
{ project: self, channel: self.last_channel }.merge!(options)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def self.between_dates(attribute, starts_at, ends_at)
|
||||
return scoped unless starts_at.present? && ends_at.present?
|
||||
|
||||
@@ -12,19 +12,10 @@ class ProjectObserver < ActiveRecord::Observer
|
||||
end
|
||||
|
||||
def from_draft_to_in_analysis(project)
|
||||
if (user = project.new_draft_recipient)
|
||||
Notification.notify_once(
|
||||
project.notification_type(:new_draft_project),
|
||||
user,
|
||||
{project_id: project.id, channel_id: project.last_channel.try(:id)},
|
||||
{
|
||||
project: project,
|
||||
channel: project.last_channel,
|
||||
origin_email: project.user.email,
|
||||
origin_name: project.user.display_name
|
||||
}
|
||||
)
|
||||
end
|
||||
project.notify_to_backoffice(:new_draft_project, {
|
||||
origin_email: project.user.email,
|
||||
origin_name: project.user.display_name
|
||||
}, project.new_draft_recipient)
|
||||
|
||||
deliver_default_notification_for(project, :in_analysis_project)
|
||||
|
||||
@@ -32,42 +23,18 @@ class ProjectObserver < ActiveRecord::Observer
|
||||
end
|
||||
|
||||
def from_online_to_waiting_funds(project)
|
||||
Notification.notify_once(
|
||||
:project_in_wainting_funds,
|
||||
project.user,
|
||||
{project_id: project.id},
|
||||
{
|
||||
project: project,
|
||||
origin_email: CatarseSettings[:email_projects]
|
||||
}
|
||||
)
|
||||
project.notify_owner(:project_in_wainting_funds, { origin_email: CatarseSettings[:email_projects] })
|
||||
end
|
||||
|
||||
def from_waiting_funds_to_successful(project)
|
||||
Notification.notify_once(
|
||||
:project_success,
|
||||
project.user,
|
||||
{project_id: project.id},
|
||||
{
|
||||
project: project,
|
||||
origin_email: CatarseSettings[:email_projects]
|
||||
}
|
||||
)
|
||||
project.notify_owner(:project_success, origin_email: CatarseSettings[:email_projects])
|
||||
|
||||
notify_admin_that_project_reached_deadline(project)
|
||||
notify_users(project)
|
||||
end
|
||||
|
||||
def notify_admin_that_project_reached_deadline(project)
|
||||
if (user = User.where(email: ::CatarseSettings[:email_payments]).first)
|
||||
Notification.notify_once(
|
||||
:adm_project_deadline,
|
||||
user,
|
||||
{project_id: project.id},
|
||||
project: project,
|
||||
origin_email: CatarseSettings[:email_system],
|
||||
project: project
|
||||
)
|
||||
end
|
||||
project.notify_to_backoffice(:adm_project_deadline, { origin_email: CatarseSettings[:email_system] })
|
||||
end
|
||||
|
||||
def from_in_analysis_to_rejected(project)
|
||||
@@ -94,23 +61,10 @@ class ProjectObserver < ActiveRecord::Observer
|
||||
notify_users(project)
|
||||
|
||||
project.contributions.with_state('waiting_confirmation').each do |contribution|
|
||||
Notification.notify_once(
|
||||
:pending_contribution_project_unsuccessful,
|
||||
contribution.user,
|
||||
{contribution_id: contribution.id},
|
||||
{contribution: contribution, project: project }
|
||||
)
|
||||
contribution.notify_to_contributor(:pending_contribution_project_unsuccessful, { project: project })
|
||||
end
|
||||
|
||||
Notification.notify_once(
|
||||
:project_unsuccessful,
|
||||
project.user,
|
||||
{project_id: project.id, user_id: project.user.id},
|
||||
{
|
||||
project: project,
|
||||
origin_email: CatarseSettings[:email_projects]
|
||||
}
|
||||
)
|
||||
project.notify_owner(:project_unsuccessful, { origin_email: CatarseSettings[:email_projects] })
|
||||
end
|
||||
|
||||
def from_waiting_funds_to_failed(project)
|
||||
@@ -121,13 +75,9 @@ class ProjectObserver < ActiveRecord::Observer
|
||||
def notify_users(project)
|
||||
project.contributions.with_state('confirmed').each do |contribution|
|
||||
unless contribution.notified_finish
|
||||
Notification.notify_once(
|
||||
(project.successful? ? :contribution_project_successful : :contribution_project_unsuccessful),
|
||||
contribution.user,
|
||||
{contribution_id: contribution.id},
|
||||
contribution: contribution,
|
||||
project: project,
|
||||
)
|
||||
template_name = (project.successful? ? :contribution_project_successful : :contribution_project_unsuccessful)
|
||||
|
||||
contribution.notify_to_contributor(template_name, { project: project })
|
||||
contribution.update_attributes({ notified_finish: true })
|
||||
end
|
||||
end
|
||||
@@ -136,16 +86,12 @@ class ProjectObserver < ActiveRecord::Observer
|
||||
private
|
||||
|
||||
def deliver_default_notification_for(project, notification_type)
|
||||
Notification.notify_once(
|
||||
project.notification_type(notification_type),
|
||||
project.user,
|
||||
{project_id: project.id, channel_id: project.last_channel.try(:id)},
|
||||
{
|
||||
project: project,
|
||||
channel: project.last_channel,
|
||||
origin_email: project.last_channel.try(:email) || CatarseSettings[:email_projects],
|
||||
origin_name: project.last_channel.try(:name) || CatarseSettings[:company_name]
|
||||
}
|
||||
)
|
||||
template_name = project.notification_type(notification_type)
|
||||
|
||||
project.notify_owner(template_name, {
|
||||
channel: project.last_channel,
|
||||
origin_email: project.last_channel.try(:email) || CatarseSettings[:email_projects],
|
||||
origin_name: project.last_channel.try(:name) || CatarseSettings[:company_name]
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,16 +12,16 @@ class ChannelPartnerUploader < ImageUploader
|
||||
|
||||
version :medium do
|
||||
process resize_to_fill: [370,320]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
|
||||
version :thumb do
|
||||
process resize_to_fill: [220,172]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
|
||||
version :thumb_small, from_version: :project_thumb do
|
||||
process resize_to_fill: [85,67]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,5 +21,5 @@ class ImageUploader < CarrierWave::Uploader::Base
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
|
||||
process quality: 60
|
||||
process quality: 80
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class ProfileUploader < ImageUploader
|
||||
|
||||
version :curator_thumb do
|
||||
process resize_to_fill: [195,120]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,18 +12,18 @@ class ProjectUploader < ImageUploader
|
||||
|
||||
version :project_thumb do
|
||||
process resize_to_fill: [220,172]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
|
||||
version :project_thumb_small, from_version: :project_thumb do
|
||||
process resize_to_fill: [85,67]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
|
||||
#facebook requires a minimum thumb size
|
||||
version :project_thumb_facebook do
|
||||
process resize_to_fill: [512,400]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ class UserUploader < ImageUploader
|
||||
|
||||
version :thumb_avatar do
|
||||
process resize_to_fill: [119,121]
|
||||
process convert: :png
|
||||
process convert: :jpg
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -165,7 +165,7 @@ describe Contribution do
|
||||
end
|
||||
|
||||
context "when cpf on contributions is null" do
|
||||
let(:contribution) { create(:contribution, payer_document: nil) }
|
||||
let(:contribution) { create(:contribution, payer_document: '') }
|
||||
let(:user) { contribution.user }
|
||||
|
||||
before do
|
||||
|
||||
@@ -331,7 +331,7 @@ describe Project do
|
||||
|
||||
it "should create notification for all projects that is expiring" do
|
||||
Notification.should_receive(:notify_once).
|
||||
with(:verify_moip_account, @p.user, {project_id: @p.id}, {project: @p, origin_email: CatarseSettings[:email_payments]})
|
||||
with(:verify_moip_account, @p.user, {project_id: @p.id, channel_id: @p.last_channel.try(:id)}, {project: @p, origin_email: CatarseSettings[:email_payments]})
|
||||
Project.send_verify_moip_account_notification
|
||||
end
|
||||
end
|
||||
@@ -345,7 +345,7 @@ describe Project do
|
||||
|
||||
it "should create notification for all inactive drafts" do
|
||||
Notification.should_receive(:notify_once).
|
||||
with(:inactive_draft, @p.user, {project_id: @p.id}, {project: @p})
|
||||
with(:inactive_draft, @p.user, {project_id: @p.id, channel_id: @p.last_channel.try(:id)}, {project: @p})
|
||||
Project.send_inactive_drafts_notification
|
||||
end
|
||||
end
|
||||
|
||||
@@ -114,7 +114,7 @@ describe ProjectObserver do
|
||||
Notification.should_receive(:notify_once).with(
|
||||
:project_in_wainting_funds,
|
||||
project.user,
|
||||
{project_id: project.id},
|
||||
{project_id: project.id, channel_id: project.last_channel.try(:id)},
|
||||
{
|
||||
project: project,
|
||||
origin_email: CatarseSettings[:email_projects]
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário