mail_manager 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.DS_Store +0 -0
- data/.gitignore +20 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +27 -0
- data/Guardfile +24 -0
- data/LICENSE.txt +22 -0
- data/MIT-LICENSE +20 -0
- data/Manifest.txt +141 -0
- data/Procfile +4 -0
- data/README +243 -0
- data/README.md +29 -0
- data/README.rdoc +3 -0
- data/Rakefile +33 -0
- data/app/.DS_Store +0 -0
- data/app/assets/javascripts/mail_manager/application.js +15 -0
- data/app/assets/stylesheets/mail_manager/application.css +13 -0
- data/app/controllers/mail_manager/application_controller.rb +4 -0
- data/app/controllers/mail_manager/base_controller.rb +22 -0
- data/app/controllers/mail_manager/bounces_controller.rb +32 -0
- data/app/controllers/mail_manager/contacts_controller.rb +75 -0
- data/app/controllers/mail_manager/mailing_lists_controller.rb +49 -0
- data/app/controllers/mail_manager/mailings_controller.rb +102 -0
- data/app/controllers/mail_manager/messages_controller.rb +30 -0
- data/app/controllers/mail_manager/subscriptions_controller.rb +104 -0
- data/app/helpers/mail_manager/application_helper.rb +4 -0
- data/app/helpers/mail_manager/subscriptions_helper.rb +8 -0
- data/app/models/.DS_Store +0 -0
- data/app/models/mail_manager.rb +12 -0
- data/app/models/mail_manager/bounce.rb +133 -0
- data/app/models/mail_manager/contact.rb +91 -0
- data/app/models/mail_manager/contactable_registry.rb +190 -0
- data/app/models/mail_manager/mailable_registry.rb +127 -0
- data/app/models/mail_manager/mailer.rb +267 -0
- data/app/models/mail_manager/mailing.rb +266 -0
- data/app/models/mail_manager/mailing_list.rb +36 -0
- data/app/models/mail_manager/message.rb +127 -0
- data/app/models/mail_manager/subscription.rb +126 -0
- data/app/models/mail_manager/test_message.rb +175 -0
- data/app/models/status_history.rb +60 -0
- data/app/views/layouts/mail_manager/application.html.erb +14 -0
- data/app/views/mail_manager/bounces/_email_parts.html.erb +30 -0
- data/app/views/mail_manager/bounces/index.html.erb +32 -0
- data/app/views/mail_manager/bounces/show.html.erb +38 -0
- data/app/views/mail_manager/contacts/_form.html.erb +27 -0
- data/app/views/mail_manager/contacts/double_opt_in.html.erb +1 -0
- data/app/views/mail_manager/contacts/edit.html.erb +12 -0
- data/app/views/mail_manager/contacts/index.html.erb +86 -0
- data/app/views/mail_manager/contacts/new.html.erb +9 -0
- data/app/views/mail_manager/contacts/show.html.erb +22 -0
- data/app/views/mail_manager/contacts/subscribe.html.erb +2 -0
- data/app/views/mail_manager/contacts/thank_you.html.erb +12 -0
- data/app/views/mail_manager/help/_available_email_substitutions.html.erb +5 -0
- data/app/views/mail_manager/mailer/double_opt_in.erb +6 -0
- data/app/views/mail_manager/mailer/unsubscribed.erb +5 -0
- data/app/views/mail_manager/mailer/unsubscribed.html.erb +5 -0
- data/app/views/mail_manager/mailing_lists/_form.html.erb +20 -0
- data/app/views/mail_manager/mailing_lists/edit.html.erb +13 -0
- data/app/views/mail_manager/mailing_lists/index.html.erb +39 -0
- data/app/views/mail_manager/mailing_lists/new.html.erb +9 -0
- data/app/views/mail_manager/mailing_lists/show.html.erb +13 -0
- data/app/views/mail_manager/mailings/_form.html.erb +81 -0
- data/app/views/mail_manager/mailings/edit.html.erb +12 -0
- data/app/views/mail_manager/mailings/index.html.erb +52 -0
- data/app/views/mail_manager/mailings/new.html.erb +9 -0
- data/app/views/mail_manager/mailings/show.html.erb +28 -0
- data/app/views/mail_manager/mailings/test.html.erb +12 -0
- data/app/views/mail_manager/messages/index.html.erb +37 -0
- data/app/views/mail_manager/subscriptions/_form.html.erb +37 -0
- data/app/views/mail_manager/subscriptions/_subscriptions.html.erb +13 -0
- data/app/views/mail_manager/subscriptions/edit.html.erb +11 -0
- data/app/views/mail_manager/subscriptions/index.html.erb +32 -0
- data/app/views/mail_manager/subscriptions/new.html.erb +9 -0
- data/app/views/mail_manager/subscriptions/show.html.erb +8 -0
- data/app/views/mail_manager/subscriptions/unsubscribe.html.erb +2 -0
- data/app/views/mail_manager/subscriptions/unsubscribe_by_email_address.html.erb +13 -0
- data/config/daemons.yml +5 -0
- data/config/routes.rb +43 -0
- data/db/migrate/001_mail_mgr_initial.rb +84 -0
- data/db/migrate/002_mail_mgr_create_contact.rb +60 -0
- data/db/migrate/003_mail_mgr_test_message.rb +23 -0
- data/db/migrate/004_add_deleted_at_to_mailing_lists.rb +15 -0
- data/db/migrate/005_contacts_deleted_at.rb +15 -0
- data/db/migrate/006_mail_mgr_mailing_list_add_defaults_to_active.rb +15 -0
- data/db/migrate/007_mail_mgr_message_add_from_email_address.rb +15 -0
- data/db/mlm_migrate/001_mlm_initial.rb +67 -0
- data/db/mlm_migrate/002_mailable_as_polymorphic.rb +27 -0
- data/db/mlm_migrate/003_contact_as_polymorphic.rb +64 -0
- data/db/mlm_migrate/004_bounce_mlm_mailing_id.rb +26 -0
- data/db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb +29 -0
- data/engine_plan.rb +13 -0
- data/features/bounce_management.feature +0 -0
- data/features/contact_management.feature +24 -0
- data/features/mailable.feature +23 -0
- data/features/mailing_management.feature +78 -0
- data/features/message.feature +11 -0
- data/features/step_definitions/email_steps.rb +50 -0
- data/features/step_definitions/mlm_steps.rb +11 -0
- data/features/step_definitions/pickle_steps.rb +41 -0
- data/features/step_definitions/webrat_steps.rb +115 -0
- data/features/subscription_management.feature +17 -0
- data/features/support/env.rb +31 -0
- data/features/support/paths.rb +44 -0
- data/lib/daemons/mail_manager.rb +38 -0
- data/lib/daemons/mail_manager_ctl +15 -0
- data/lib/deleteable.rb +50 -0
- data/lib/lock.rb +36 -0
- data/lib/mail_manager.rb +5 -0
- data/lib/mail_manager/config.rb +50 -0
- data/lib/mail_manager/engine.rb +43 -0
- data/lib/mail_manager/version.rb +3 -0
- data/lib/tasks/mail_manager.rake +143 -0
- data/lib/tasks/mail_manager_tasks.rake +4 -0
- data/lib/tasks/rspec.rake +165 -0
- data/lib/workers/mail_manager/bounce_job.rb +52 -0
- data/lib/workers/mail_manager/mailing_job.rb +30 -0
- data/lib/workers/mail_manager/message_job.rb +38 -0
- data/lib/workers/mail_manager/test_message_job.rb +37 -0
- data/mail_manager.gemspec +29 -0
- data/script/rails +8 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +47 -0
- data/spec/test_app/README.rdoc +261 -0
- data/spec/test_app/Rakefile +7 -0
- data/spec/test_app/app/assets/javascripts/application.js +15 -0
- data/spec/test_app/app/assets/javascripts/users.js +2 -0
- data/spec/test_app/app/assets/stylesheets/application.css +13 -0
- data/spec/test_app/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/test_app/app/assets/stylesheets/users.css +4 -0
- data/spec/test_app/app/controllers/application_controller.rb +3 -0
- data/spec/test_app/app/controllers/users_controller.rb +83 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/helpers/users_helper.rb +2 -0
- data/spec/test_app/app/models/user.rb +13 -0
- data/spec/test_app/app/views/layouts/application.html.erb +14 -0
- data/spec/test_app/app/views/users/_form.html.erb +33 -0
- data/spec/test_app/app/views/users/edit.html.erb +6 -0
- data/spec/test_app/app/views/users/index.html.erb +29 -0
- data/spec/test_app/app/views/users/new.html.erb +5 -0
- data/spec/test_app/app/views/users/show.html.erb +25 -0
- data/spec/test_app/config.ru +4 -0
- data/spec/test_app/config/application.rb +65 -0
- data/spec/test_app/config/boot.rb +10 -0
- data/spec/test_app/config/database.yml +25 -0
- data/spec/test_app/config/environment.rb +14 -0
- data/spec/test_app/config/environments/development.rb +37 -0
- data/spec/test_app/config/environments/production.rb +67 -0
- data/spec/test_app/config/environments/test.rb +37 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/inflections.rb +15 -0
- data/spec/test_app/config/initializers/mime_types.rb +5 -0
- data/spec/test_app/config/initializers/secret_token.rb +7 -0
- data/spec/test_app/config/initializers/session_store.rb +8 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/test_app/config/locales/en.yml +5 -0
- data/spec/test_app/config/lockable.yml +3 -0
- data/spec/test_app/config/mail_manager.yml +21 -0
- data/spec/test_app/config/routes.rb +7 -0
- data/spec/test_app/db/migrate/20131217101010_create_users.rb +13 -0
- data/spec/test_app/db/migrate/20131221064151_mail_mgr_initial.rb +84 -0
- data/spec/test_app/db/migrate/20131221064152_mail_mgr_create_contact.rb +60 -0
- data/spec/test_app/db/migrate/20131221064153_mail_mgr_test_message.rb +23 -0
- data/spec/test_app/db/migrate/20131221064154_add_deleted_at_to_mailing_lists.rb +15 -0
- data/spec/test_app/db/migrate/20131221064155_contacts_deleted_at.rb +15 -0
- data/spec/test_app/db/migrate/20131221064156_mail_mgr_mailing_list_add_defaults_to_active.rb +15 -0
- data/spec/test_app/db/migrate/20131221064157_mail_mgr_message_add_from_email_address.rb +15 -0
- data/spec/test_app/db/migrate/20131221072600_create_delayed_jobs.rb +22 -0
- data/spec/test_app/db/schema.rb +131 -0
- data/spec/test_app/db/structure.sql +31 -0
- data/spec/test_app/public/404.html +26 -0
- data/spec/test_app/public/422.html +26 -0
- data/spec/test_app/public/500.html +25 -0
- data/spec/test_app/public/favicon.ico +0 -0
- data/spec/test_app/script/delayed_job +5 -0
- data/spec/test_app/script/lockable +36 -0
- data/spec/test_app/script/rails +6 -0
- data/spec/test_app/spec/controllers/users_controller_spec.rb +160 -0
- data/spec/test_app/spec/factories/mailing_lists.rb +7 -0
- data/spec/test_app/spec/factories/mailings.rb +6 -0
- data/spec/test_app/spec/factories/original_factories.rb.txt +107 -0
- data/spec/test_app/spec/factories/users.rb +10 -0
- data/spec/test_app/spec/models/mail_manager/bounce_spec.rb +17 -0
- data/spec/test_app/spec/models/mail_manager/mailing_list_spec.rb +15 -0
- data/spec/test_app/spec/models/user_spec.rb +37 -0
- data/spec/test_app/spec/requests/users_spec.rb +11 -0
- data/spec/test_app/spec/routing/users_routing_spec.rb +35 -0
- data/spec/test_app/spec/support/database_cleaner.rb +23 -0
- data/spec/test_app/spec/support/files/bad_utf8_chars.eml +32 -0
- data/spec/test_app/spec/views/users/edit.html.erb_spec.rb +24 -0
- data/spec/test_app/spec/views/users/index.html.erb_spec.rb +29 -0
- data/spec/test_app/spec/views/users/new.html.erb_spec.rb +24 -0
- data/spec/test_app/spec/views/users/show.html.erb_spec.rb +21 -0
- data/zeus.json +22 -0
- metadata +424 -0
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MailManager
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mail_manager'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mail_manager
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'MailManager'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
32
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
33
|
+
task :default => :spec
|
data/app/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'dynamic_form'
|
2
|
+
class MailManager::BaseController < ApplicationController
|
3
|
+
layout MailManager.layout
|
4
|
+
helper_method :title, :use_show_for_resources?, :site_url
|
5
|
+
|
6
|
+
def title(value=nil)
|
7
|
+
@title = value if value.present?
|
8
|
+
@title
|
9
|
+
end
|
10
|
+
|
11
|
+
def use_show_for_resources?
|
12
|
+
MailManager.use_show_for_resources
|
13
|
+
rescue
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def site_url
|
18
|
+
MailManager.site_url
|
19
|
+
rescue
|
20
|
+
"#{default_url_options[:protocol]||'http'}://#{default_url_options[:domain]}"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MailManager
|
2
|
+
class BouncesController < BaseController
|
3
|
+
before_filter :find_bounce, :except => [:new, :create, :index]
|
4
|
+
before_filter :find_mailing
|
5
|
+
|
6
|
+
def index
|
7
|
+
params[:bounce] = Hash.new unless params[:bounce]
|
8
|
+
@mailings = Mailing.with_bounces(params[:bounce][:status])
|
9
|
+
@bounces = []
|
10
|
+
@bounces = Bounce.scoped
|
11
|
+
@bounces = @bounces.by_mailing_id(@mailing.id) if @mailing.present?
|
12
|
+
@bounces = @bounces.by_status(params[:bounce][:status]) if params[:bounce][:status].present?
|
13
|
+
@bounces = @bounces.paginate(:page => params[:page])
|
14
|
+
end
|
15
|
+
|
16
|
+
def show
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def find_bounce
|
22
|
+
@bounce = Bounce.find(params[:id])
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_mailing
|
26
|
+
return @mailing = Mailing.find_by_id(params[:mailing_id]) if params[:mailing_id]
|
27
|
+
return @mailing = @bounce.mailing if @bounce
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module MailManager
|
2
|
+
class ContactsController < BaseController
|
3
|
+
|
4
|
+
include DeleteableActions
|
5
|
+
|
6
|
+
def subscribe
|
7
|
+
if params[:contact].present? and params[:contact][:email_address].present?
|
8
|
+
@contact = MailManager::Contact.find_by_email_address(params[:contact][:email_address])
|
9
|
+
@contact = MailManager::Contact.new if @contact.nil?
|
10
|
+
@contact.update_attributes(params[:contact])
|
11
|
+
#check to see what list we subscribed to, if Austin local redirect, if San Antonio, redirect to their thank you page
|
12
|
+
end
|
13
|
+
|
14
|
+
if params[:redirect_url].present? #check to see if it came from SA
|
15
|
+
redirect_to params[:redirect_url]
|
16
|
+
else
|
17
|
+
redirect_to mail_manager.thank_you_path #uncomment after testing...
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def send_one_off_message
|
22
|
+
@contact = Contact.find(params[:id])
|
23
|
+
@mailing = Mailing.find(params[:mailing_id])
|
24
|
+
@mailing.send_one_off_message(@contact)
|
25
|
+
flash[:info] = "Test message sent to #{@contact.email_address_with_name}"
|
26
|
+
redirect_to mail_manager.contacts_path
|
27
|
+
end
|
28
|
+
|
29
|
+
def index
|
30
|
+
@mailing_list = MailingList.find_by_id(params[:mailing_list_id])
|
31
|
+
params[:status] ||= 'active'
|
32
|
+
@contacts = Contact.search(params).paginate(:page => params[:page], :per_page => params[:per_page])
|
33
|
+
end
|
34
|
+
|
35
|
+
def new
|
36
|
+
@contact = Contact.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def edit
|
40
|
+
find_contact
|
41
|
+
end
|
42
|
+
|
43
|
+
def create
|
44
|
+
@contact = Contact.new(params[:contact])
|
45
|
+
if @contact.save
|
46
|
+
flash[:notice] = 'Contact was successfully created.'
|
47
|
+
redirect_to(mail_manager.contacts_path)
|
48
|
+
else
|
49
|
+
render :action => "new"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def update
|
54
|
+
find_contact
|
55
|
+
if @contact.update_attributes(params[:contact])
|
56
|
+
flash[:notice] = 'Contact was successfully updated.'
|
57
|
+
redirect_to(mail_manager.contacts_path)
|
58
|
+
else
|
59
|
+
render :action => "edit"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def destroy
|
64
|
+
find_contact
|
65
|
+
@contact.delete
|
66
|
+
redirect_to(mail_manager.contacts_url)
|
67
|
+
end
|
68
|
+
|
69
|
+
protected
|
70
|
+
|
71
|
+
def find_contact
|
72
|
+
@contact = Contact.find(params[:id])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module MailManager
|
2
|
+
class MailingListsController < BaseController
|
3
|
+
before_filter :find_mailing_list, :except => [:new,:create,:index]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@mailing_lists = MailingList.active.order("name asc").paginate(:page => params[:page])
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@mailing_list = MailingList.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def edit
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@mailing_list = MailingList.new(params[:mailing_list])
|
21
|
+
if @mailing_list.save
|
22
|
+
flash[:notice] = 'MailingList was successfully created.'
|
23
|
+
redirect_to(mail_manager.mailing_lists_path)
|
24
|
+
else
|
25
|
+
render :action => "new"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
if @mailing_list.update_attributes(params[:mailing_list])
|
31
|
+
flash[:notice] = 'MailingList was successfully updated.'
|
32
|
+
redirect_to(mail_manager.mailing_lists_path)
|
33
|
+
else
|
34
|
+
render :action => "edit"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
@mailing_list.destroy
|
40
|
+
redirect_to(mail_manager.mailing_lists_url)
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def find_mailing_list
|
46
|
+
@mailing_list = MailingList.find(params[:id])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module MailManager
|
2
|
+
class MailingsController < BaseController
|
3
|
+
before_filter :find_mailing, :except => [:new,:create,:index]
|
4
|
+
before_filter :find_all_mailing_lists, :only => [:new,:create,:edit,:update]
|
5
|
+
before_filter :find_mailables, :only => [:new,:create,:edit,:update]
|
6
|
+
before_filter :get_mailables_for_select, :only => [:new,:create,:edit,:update]
|
7
|
+
|
8
|
+
def index
|
9
|
+
@mailings = Mailing.all.sort_by{|mailing| mailing.created_at}.reverse
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
@mailing = Mailing.new
|
17
|
+
@mailing.from_email_address = MailManager.default_from_email_address if MailManager.default_from_email_address
|
18
|
+
@mailing.scheduled_at = Time.now
|
19
|
+
@mailing.include_images = true
|
20
|
+
@mailing.mailing_lists = @all_mailing_lists
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
end
|
25
|
+
|
26
|
+
def test
|
27
|
+
end
|
28
|
+
|
29
|
+
def schedule
|
30
|
+
@mailing.schedule
|
31
|
+
redirect_to mail_manager.mailings_path
|
32
|
+
end
|
33
|
+
|
34
|
+
def cancel
|
35
|
+
@mailing.cancel
|
36
|
+
redirect_to mail_manager.mailings_path
|
37
|
+
end
|
38
|
+
|
39
|
+
def resume
|
40
|
+
@mailing.resume
|
41
|
+
redirect_to mail_manager.mailings_path
|
42
|
+
end
|
43
|
+
|
44
|
+
def pause
|
45
|
+
@mailing.pause
|
46
|
+
redirect_to mail_manager.mailings_path
|
47
|
+
end
|
48
|
+
|
49
|
+
def send_test
|
50
|
+
@mailing.send_test_message(params[:test_email_addresses])
|
51
|
+
flash[:notice] = "Test messages sent to #{params[:test_email_addresses]}."
|
52
|
+
redirect_to mail_manager.mailings_path
|
53
|
+
end
|
54
|
+
|
55
|
+
def create
|
56
|
+
@mailing = Mailing.new(params[:mailing])
|
57
|
+
if @mailing.save
|
58
|
+
flash[:notice] = 'Mailing was successfully created.'
|
59
|
+
redirect_to(mail_manager.mailings_path)
|
60
|
+
else
|
61
|
+
render :action => "new"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def update
|
66
|
+
if @mailing.update_attributes(params[:mailing])
|
67
|
+
@mailing.cancel
|
68
|
+
flash[:notice] = 'Mailing was successfully updated and set to pending. Be sure to reschedule your mailing.'
|
69
|
+
redirect_to(mail_manager.mailings_path)
|
70
|
+
else
|
71
|
+
render :action => "edit"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def destroy
|
76
|
+
@mailing.destroy
|
77
|
+
redirect_to(mail_manager.mailings_url)
|
78
|
+
end
|
79
|
+
|
80
|
+
protected
|
81
|
+
|
82
|
+
def find_mailing
|
83
|
+
@mailing = Mailing.find(params[:id])
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_all_mailing_lists
|
87
|
+
@all_mailing_lists = MailingList.active.find(:all, :order => "name asc")
|
88
|
+
end
|
89
|
+
|
90
|
+
def find_mailables
|
91
|
+
@mailables = MailableRegistry.find
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_mailables_for_select
|
95
|
+
#@mailables_for_select = [['Choose Mailable', @mailable.is_a?(Mailable) ?
|
96
|
+
# 'Mailable_new' : '']]+@mailables.collect{|mailable|
|
97
|
+
# [mailable.name,"#{mailable.class.name}_#{mailable.id}"]}
|
98
|
+
@mailables_for_select = @mailables.collect{|mailable|
|
99
|
+
[mailable.name,"#{mailable.class.name}_#{mailable.id}"]}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MailManager
|
2
|
+
class MessagesController < ApplicationController
|
3
|
+
layout 'admin'
|
4
|
+
before_filter :find_message, :except => [:new,:create,:index]
|
5
|
+
before_filter :find_mailing
|
6
|
+
|
7
|
+
def index
|
8
|
+
params[:message] = Hash.new unless params[:message]
|
9
|
+
params[:message][:status] = 'failed' if params[:message][:status].nil?
|
10
|
+
search_params = params[:message].merge(:mailing_id => params[:mailing_id])
|
11
|
+
@valid_statuses = Message.valid_statuses
|
12
|
+
@messages = Message.search(search_params).paginate(:page => params[:page])
|
13
|
+
end
|
14
|
+
|
15
|
+
def show
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def find_message
|
21
|
+
@message = Message.find(params[:id])
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_mailing
|
25
|
+
return @mailing = Mailing.find_by_id(params[:mailing_id]) if params[:mailing_id]
|
26
|
+
return @mailing = @message.message.try(:mailing) if @message
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module MailManager
|
2
|
+
class SubscriptionsController < BaseController
|
3
|
+
before_filter :find_subscription, :except => [:new,:create,:index,:unsubscribe,:unsubscribe_by_email_address]
|
4
|
+
before_filter :find_mailing_list
|
5
|
+
before_filter :find_contact, :except => [:new,:create,:index,:unsubscribe,:unsubscribe_by_email_address]
|
6
|
+
skip_before_filter :authorize, :only => [:unsubscribe,:unsubscribe_by_email_address]
|
7
|
+
|
8
|
+
def index
|
9
|
+
params[:search] = Hash.new unless params[:search]
|
10
|
+
search_params = params[:search].merge(:mailing_list_id => params[:mailing_list_id])
|
11
|
+
@valid_statuses = Subscription.valid_statuses
|
12
|
+
@subscriptions = Subscription.search(search_params).paginate(:all, :page => params[:page])
|
13
|
+
end
|
14
|
+
|
15
|
+
def unsubscribe
|
16
|
+
raise "Empty id for#{params[:guid]}" if params[:guid].blank?
|
17
|
+
if params[:guid] =~ /^test/
|
18
|
+
@message = TestMessage.find_by_guid(params[:guid])
|
19
|
+
@mailing_lists = ['Test Mailing List']
|
20
|
+
@contact = Contact.new(:first_name => 'Test', :last_name => 'Guy',
|
21
|
+
:email_address => @message.test_email_address)
|
22
|
+
else
|
23
|
+
unsubscribed_subscriptions = Subscription.unsubscribe_by_message_guid(params[:guid])
|
24
|
+
@mailing_lists = unsubscribed_subscriptions.reject{|subscription|
|
25
|
+
subscription.mailing_list.nil?}.collect{|subscription| subscription.mailing_list.name}
|
26
|
+
@contact = Message.find_by_guid(params[:guid]).try(:contact)
|
27
|
+
raise "Could not find your subscription. Please try unsubscribing with your email address." if @contact.nil?
|
28
|
+
end
|
29
|
+
render 'unsubscribe', :layout => 'layout'
|
30
|
+
rescue => e
|
31
|
+
Rails.logger.warn "Error unsubscribing: #{e.message}\n #{e.backtrace.join("\n ")}"
|
32
|
+
flash[:error] = e.message
|
33
|
+
redirect_to mail_manager.unsubscribe_by_email_address_path
|
34
|
+
end
|
35
|
+
|
36
|
+
def unsubscribe_by_email_address
|
37
|
+
unless params[:email_address].blank?
|
38
|
+
unsubscribed_subscriptions = Subscription.unsubscribe_by_email_address(params[:email_address])
|
39
|
+
@mailing_lists = unsubscribed_subscriptions.reject{|subscription|
|
40
|
+
subscription.mailing_list.nil?}.collect{|subscription| subscription.mailing_list.name}
|
41
|
+
@contact = Contact.new(:email_address => params[:email_address])
|
42
|
+
return render('unsubscribe', :layout => 'layout')
|
43
|
+
end
|
44
|
+
render :layout => 'layout'
|
45
|
+
end
|
46
|
+
|
47
|
+
def show
|
48
|
+
end
|
49
|
+
|
50
|
+
def new
|
51
|
+
@subscription = Subscription.new
|
52
|
+
@subscription.mailing_list = @mailing_list
|
53
|
+
@contact = @subscription
|
54
|
+
end
|
55
|
+
|
56
|
+
def edit
|
57
|
+
end
|
58
|
+
|
59
|
+
def create
|
60
|
+
@subscription = Subscription.new(params[:subscription])
|
61
|
+
@subscription.mailing_list_id = @mailing_list.id
|
62
|
+
if @subscription.save
|
63
|
+
flash[:notice] = 'Subscription was successfully created.'
|
64
|
+
return redirect_to(mail_manager.mailing_list_subscriptions_path(@mailing_list))
|
65
|
+
else
|
66
|
+
@contact = @subscription
|
67
|
+
render :action => "new"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def update
|
72
|
+
if @subscription.update_attributes(params[:subscription])
|
73
|
+
@subscription.change_status(params[:subscription][:status])
|
74
|
+
flash[:notice] = 'Subscription was successfully updated.'
|
75
|
+
redirect_to(mail_manager.mailing_list_subscriptions_path(@mailing_list))
|
76
|
+
else
|
77
|
+
render :action => "edit"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def destroy
|
82
|
+
@subscription.destroy
|
83
|
+
redirect_to(mail_manager.subscriptions_url)
|
84
|
+
end
|
85
|
+
|
86
|
+
protected
|
87
|
+
|
88
|
+
def find_subscription
|
89
|
+
@subscription = Subscription.find(params[:id])
|
90
|
+
end
|
91
|
+
|
92
|
+
def find_mailing_list
|
93
|
+
return @mailing_list = @subscription.mailing_list if @subscription
|
94
|
+
return @mailing_list = MailingList.find_by_id(params[:mailing_list_id]) if params[:mailing_list_id]
|
95
|
+
return @mailing_list = MailingList.find_by_id(params[:subscription][:mailing_list_id]) if
|
96
|
+
params[:subscription]
|
97
|
+
nil
|
98
|
+
end
|
99
|
+
|
100
|
+
def find_contact
|
101
|
+
@contact = @subscription.contact
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|