maily_herald-webui 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/.rspec +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +250 -0
- data/Guardfile +23 -0
- data/LICENSE +11 -0
- data/README.md +62 -0
- data/Rakefile +30 -0
- data/app/assets/images/maily_herald/.gitkeep +0 -0
- data/app/assets/images/maily_herald/webui/arrow-bottom.png +0 -0
- data/app/assets/images/maily_herald/webui/arrow-left.png +0 -0
- data/app/assets/images/maily_herald/webui/arrow-right.png +0 -0
- data/app/assets/images/maily_herald/webui/arrow-top.png +0 -0
- data/app/assets/images/maily_herald/webui/logo.svg +38 -0
- data/app/assets/images/maily_herald/webui/sprite-dropdown.png +0 -0
- data/app/assets/images/maily_herald/webui/sprite-form.png +0 -0
- data/app/assets/images/maily_herald/webui/sprite.png +0 -0
- data/app/assets/images/maily_herald/webui/user.png +0 -0
- data/app/assets/javascripts/maily_herald/webui/application.js +20 -0
- data/app/assets/javascripts/maily_herald/webui/dispatches.coffee +58 -0
- data/app/assets/javascripts/maily_herald/webui/webui.coffee +209 -0
- data/app/assets/stylesheets/maily_herald/webui/application.css +18 -0
- data/app/assets/stylesheets/maily_herald/webui/webui-bootstrap.scss +0 -0
- data/app/assets/stylesheets/maily_herald/webui/webui.sass +846 -0
- data/app/controllers/maily_herald/webui/application_controller.rb +19 -0
- data/app/controllers/maily_herald/webui/dashboard_controller.rb +65 -0
- data/app/controllers/maily_herald/webui/dispatches_controller.rb +42 -0
- data/app/controllers/maily_herald/webui/lists_controller.rb +69 -0
- data/app/controllers/maily_herald/webui/logs_controller.rb +20 -0
- data/app/controllers/maily_herald/webui/mailings_controller.rb +68 -0
- data/app/controllers/maily_herald/webui/one_time_mailings_controller.rb +32 -0
- data/app/controllers/maily_herald/webui/periodical_mailings_controller.rb +25 -0
- data/app/controllers/maily_herald/webui/resources_controller.rb +144 -0
- data/app/controllers/maily_herald/webui/sequence_mailings_controller.rb +43 -0
- data/app/controllers/maily_herald/webui/sequences_controller.rb +56 -0
- data/app/controllers/maily_herald/webui/sessions_controller.rb +11 -0
- data/app/controllers/maily_herald/webui/subscriptions_controller.rb +33 -0
- data/app/helpers/maily_herald/webui/application_helper.rb +157 -0
- data/app/helpers/maily_herald/webui/dispatches_helper.rb +18 -0
- data/app/helpers/maily_herald/webui/logs_helper.rb +37 -0
- data/app/helpers/maily_herald/webui/mailings_helper.rb +64 -0
- data/app/helpers/maily_herald/webui/sequence_mailings_helper.rb +13 -0
- data/app/helpers/maily_herald/webui/sequences_helper.rb +6 -0
- data/app/helpers/maily_herald/webui/subscribers_helper.rb +25 -0
- data/app/helpers/maily_herald/webui/subscriptions_helper.rb +11 -0
- data/app/helpers/maily_herald_helper.rb +151 -0
- data/app/views/layouts/maily_herald/webui/application.html.haml +58 -0
- data/app/views/layouts/maily_herald/webui/modal.html.haml +6 -0
- data/app/views/maily_herald/webui/dashboard/_log.html.haml +20 -0
- data/app/views/maily_herald/webui/dashboard/_log_list.html.haml +19 -0
- data/app/views/maily_herald/webui/dashboard/_logs.html.haml +15 -0
- data/app/views/maily_herald/webui/dashboard/index.html.haml +43 -0
- data/app/views/maily_herald/webui/dashboard/index.js.erb +15 -0
- data/app/views/maily_herald/webui/dispatches/_entities.html.haml +7 -0
- data/app/views/maily_herald/webui/dispatches/_logs.html.haml +4 -0
- data/app/views/maily_herald/webui/dispatches/_schedules.html.haml +4 -0
- data/app/views/maily_herald/webui/dispatches/_toggle.js.erb +1 -0
- data/app/views/maily_herald/webui/lists/_details.html.haml +14 -0
- data/app/views/maily_herald/webui/lists/_details_form.html.haml +14 -0
- data/app/views/maily_herald/webui/lists/_form.html.haml +1 -0
- data/app/views/maily_herald/webui/lists/_header.html.haml +13 -0
- data/app/views/maily_herald/webui/lists/_items.html.haml +24 -0
- data/app/views/maily_herald/webui/lists/_opt_outs.html.haml +7 -0
- data/app/views/maily_herald/webui/lists/_potential_subscribers.html.haml +7 -0
- data/app/views/maily_herald/webui/lists/_subscribers.html.haml +7 -0
- data/app/views/maily_herald/webui/lists/context_variables.html.haml +15 -0
- data/app/views/maily_herald/webui/lists/subscribe.js.erb +10 -0
- data/app/views/maily_herald/webui/lists/unsubscribe.js.erb +7 -0
- data/app/views/maily_herald/webui/logs/_items.html.haml +34 -0
- data/app/views/maily_herald/webui/logs/preview.html.haml +22 -0
- data/app/views/maily_herald/webui/mailings-old/_entity.html.haml +17 -0
- data/app/views/maily_herald/webui/mailings-old/_entity_list.html.haml +26 -0
- data/app/views/maily_herald/webui/mailings-old/_form.html.haml +32 -0
- data/app/views/maily_herald/webui/mailings-old/_print.html.haml +123 -0
- data/app/views/maily_herald/webui/mailings-old/create.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings-old/destroy.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings-old/edit.html.haml +16 -0
- data/app/views/maily_herald/webui/mailings-old/edit.js.erb +2 -0
- data/app/views/maily_herald/webui/mailings-old/index.html.haml +9 -0
- data/app/views/maily_herald/webui/mailings-old/index.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings-old/new.html.haml +16 -0
- data/app/views/maily_herald/webui/mailings-old/new.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings-old/preview.js.erb +2 -0
- data/app/views/maily_herald/webui/mailings-old/refresh_list.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings-old/show.html.haml +135 -0
- data/app/views/maily_herald/webui/mailings-old/show.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings-old/update.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings/_deliver.js.erb +1 -0
- data/app/views/maily_herald/webui/mailings/_details.html.haml +65 -0
- data/app/views/maily_herald/webui/mailings/_details_form.html.haml +39 -0
- data/app/views/maily_herald/webui/mailings/_form.html.haml +1 -0
- data/app/views/maily_herald/webui/mailings/_form_periodical.html.haml +2 -0
- data/app/views/maily_herald/webui/mailings/_form_sequence.html.haml +1 -0
- data/app/views/maily_herald/webui/mailings/_form_template_generic.html.haml +7 -0
- data/app/views/maily_herald/webui/mailings/_form_template_mailer.html.haml +4 -0
- data/app/views/maily_herald/webui/mailings/_header.html.haml +24 -0
- data/app/views/maily_herald/webui/mailings/_list.html.haml +27 -0
- data/app/views/maily_herald/webui/mailings/_template.html.haml +16 -0
- data/app/views/maily_herald/webui/mailings/_template_form.html.haml +7 -0
- data/app/views/maily_herald/webui/mailings/nav_secondary/_index.html.haml +3 -0
- data/app/views/maily_herald/webui/mailings/preview.html.haml +13 -0
- data/app/views/maily_herald/webui/mailings/update_form.js.erb +33 -0
- data/app/views/maily_herald/webui/resources/edit.js.erb +2 -0
- data/app/views/maily_herald/webui/resources/index.html.haml +11 -0
- data/app/views/maily_herald/webui/resources/index.js.erb +1 -0
- data/app/views/maily_herald/webui/resources/new.html.haml +5 -0
- data/app/views/maily_herald/webui/resources/show.html.haml +4 -0
- data/app/views/maily_herald/webui/resources/show.js.erb +3 -0
- data/app/views/maily_herald/webui/resources/update.js.erb +18 -0
- data/app/views/maily_herald/webui/sequences-old/_entity.html.haml +11 -0
- data/app/views/maily_herald/webui/sequences-old/_entity_list.html.haml +23 -0
- data/app/views/maily_herald/webui/sequences-old/_form.html.haml +17 -0
- data/app/views/maily_herald/webui/sequences-old/_log.html.haml +7 -0
- data/app/views/maily_herald/webui/sequences-old/_logs.html.haml +16 -0
- data/app/views/maily_herald/webui/sequences-old/_mailing.html.haml +4 -0
- data/app/views/maily_herald/webui/sequences-old/_mailing_list.html.haml +19 -0
- data/app/views/maily_herald/webui/sequences-old/edit.html.haml +14 -0
- data/app/views/maily_herald/webui/sequences-old/new.html.haml +13 -0
- data/app/views/maily_herald/webui/sequences-old/show.html.haml +122 -0
- data/app/views/maily_herald/webui/sequences-old/show.js.erb +2 -0
- data/app/views/maily_herald/webui/sequences-old/subscription.html.haml +79 -0
- data/app/views/maily_herald/webui/sequences/_details.html.haml +39 -0
- data/app/views/maily_herald/webui/sequences/_details_form.html.haml +27 -0
- data/app/views/maily_herald/webui/sequences/_form.html.haml +1 -0
- data/app/views/maily_herald/webui/sequences/_header.html.haml +11 -0
- data/app/views/maily_herald/webui/sequences/_list.html.haml +21 -0
- data/app/views/maily_herald/webui/sequences/_mailing_list.html.haml +21 -0
- data/app/views/maily_herald/webui/sequences/_mailings.html.haml +7 -0
- data/app/views/maily_herald/webui/sequences/update_form.js.erb +14 -0
- data/app/views/maily_herald/webui/shared/_context_attributes.html.haml +11 -0
- data/app/views/maily_herald/webui/subscribers/_item.html.haml +8 -0
- data/app/views/maily_herald/webui/subscribers/_list.html.haml +18 -0
- data/app/views/maily_herald/webui/subscription_groups/_form.html.haml +5 -0
- data/app/views/maily_herald/webui/subscription_groups/_subscription.html.haml +8 -0
- data/app/views/maily_herald/webui/subscription_groups/_subscription_list.html.haml +19 -0
- data/app/views/maily_herald/webui/subscription_groups/edit.html.haml +16 -0
- data/app/views/maily_herald/webui/subscription_groups/index.html.haml +35 -0
- data/app/views/maily_herald/webui/subscription_groups/new.html.haml +11 -0
- data/app/views/maily_herald/webui/subscription_groups/show.html.haml +42 -0
- data/app/views/maily_herald/webui/subscription_groups/show.js.erb +1 -0
- data/app/views/maily_herald/webui/subscriptions/show.html.haml +21 -0
- data/app/views/maily_herald/webui/subscriptions/toggle.js.erb +1 -0
- data/app/views/maily_herald/webui/webui/index.html.haml +136 -0
- data/app/views/maily_herald/webui/webui/show.html.haml +0 -0
- data/config/database.yml +5 -0
- data/config/initializers/smart_listing.rb +77 -0
- data/config/locales/en.yml +237 -0
- data/config/routes.rb +103 -0
- data/config/spring.rb +1 -0
- data/lib/maily_herald/webui.rb +15 -0
- data/lib/maily_herald/webui/breadcrumbs.rb +50 -0
- data/lib/maily_herald/webui/engine.rb +18 -0
- data/lib/maily_herald/webui/form_builder.rb +285 -0
- data/lib/maily_herald/webui/menu_manager.rb +66 -0
- data/lib/maily_herald/webui/version.rb +5 -0
- data/maily_herald-webui.gemspec +40 -0
- data/script/rails +8 -0
- data/spec/dummy/Guardfile +35 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/mailers/test_mailer.rb +11 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/user.rb +7 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/test_mailer/sample_mail.text.erb +1 -0
- data/spec/dummy/bin/rails +10 -0
- data/spec/dummy/bin/rake +7 -0
- data/spec/dummy/bin/rspec +7 -0
- data/spec/dummy/bin/spring +18 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +65 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +38 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/maily_herald.rb +101 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/locales/maily_herald.en.yml +28 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/migrate/20130723074347_create_users.rb +11 -0
- data/spec/dummy/db/migrate/20140804152249_create_maily_herald_tables.maily_herald.rb +68 -0
- data/spec/dummy/db/migrate/20140804152250_create_lists.maily_herald.rb +33 -0
- data/spec/dummy/db/schema.rb +79 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/lib/tasks/dummy.rb +8 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/spec_helper.rb +46 -0
- data/vendor/assets/fonts/maily_herald/webui/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.eot +0 -0
- data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.svg +1816 -0
- data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.ttf +0 -0
- data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.woff +0 -0
- data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.svg +520 -0
- data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.eot +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.svg +1825 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.ttf +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.woff +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.eot +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.svg +1825 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.ttf +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.woff +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.eot +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.svg +1825 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.ttf +0 -0
- data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.woff +0 -0
- data/vendor/assets/javascripts/maily_herald/webui/bootstrap-datepicker.js +1681 -0
- data/vendor/assets/javascripts/maily_herald/webui/bootstrap.min.js +6 -0
- data/vendor/assets/javascripts/maily_herald/webui/d3.v3.js +5 -0
- data/vendor/assets/javascripts/maily_herald/webui/rickshaw.js +4067 -0
- data/vendor/assets/stylesheets/maily_herald/webui/bootstrap-datepicker.css +786 -0
- data/vendor/assets/stylesheets/maily_herald/webui/bootstrap.min.css +5 -0
- data/vendor/assets/stylesheets/maily_herald/webui/font-awesome.min.css +4 -0
- data/vendor/assets/stylesheets/maily_herald/webui/rickshaw.css +355 -0
- metadata +564 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
module Webui
|
3
|
+
class ApplicationController < ActionController::Base
|
4
|
+
include MailyHerald::Webui::Breadcrumbs::ControllerExtensions
|
5
|
+
include MailyHerald::Webui::MenuManager::ControllerExtensions
|
6
|
+
|
7
|
+
helper SmartListing::Helper
|
8
|
+
helper_method :expert_mode?, :work_mode
|
9
|
+
|
10
|
+
def work_mode
|
11
|
+
session[:work_mode].try(:to_sym) || :regular
|
12
|
+
end
|
13
|
+
|
14
|
+
def expert_mode?
|
15
|
+
work_mode == :expert
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::DashboardController < Webui::ApplicationController
|
3
|
+
include SmartListing::Helper::ControllerExtensions
|
4
|
+
helper SmartListing::Helper
|
5
|
+
|
6
|
+
add_breadcrumb :label_dashboard, Proc.new{ lists_path }
|
7
|
+
set_menu_item :dashboard
|
8
|
+
|
9
|
+
def index
|
10
|
+
@period = case params[:period]
|
11
|
+
when "week"
|
12
|
+
1.week
|
13
|
+
when "6months"
|
14
|
+
6.months
|
15
|
+
when "year"
|
16
|
+
1.year
|
17
|
+
else #month
|
18
|
+
1.month
|
19
|
+
end
|
20
|
+
@time = Time.now
|
21
|
+
|
22
|
+
smart_listing_create(:logs, logs(:processed), :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "desc"})
|
23
|
+
smart_listing_create(:scheduled_logs, MailyHerald::Log.scheduled, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "asc"})
|
24
|
+
|
25
|
+
@total_count = MailyHerald::Log.count
|
26
|
+
@processed_count = logs(:processed).count
|
27
|
+
@delivered_count = logs(:delivered).count
|
28
|
+
@skipped_count = logs(:skipped).count
|
29
|
+
@failed_count = logs(:error).count
|
30
|
+
|
31
|
+
days = @period / 1.day
|
32
|
+
@delivered = {}
|
33
|
+
@failed = {}
|
34
|
+
@skipped = {}
|
35
|
+
|
36
|
+
for i in 0..days
|
37
|
+
@delivered[(@time - i.days).strftime("%Y-%m-%d")] = 0
|
38
|
+
@failed[(@time - i.days).strftime("%Y-%m-%d")] = 0
|
39
|
+
@skipped[(@time - i.days).strftime("%Y-%m-%d")] = 0
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
logs(:delivered).each do |l|
|
44
|
+
@delivered[l.processing_at.strftime("%Y-%m-%d")] ||= 0
|
45
|
+
@delivered[l.processing_at.strftime("%Y-%m-%d")] += 1
|
46
|
+
end
|
47
|
+
logs(:error).each do |l|
|
48
|
+
@failed[l.processing_at.strftime("%Y-%m-%d")] ||= 0
|
49
|
+
@failed[l.processing_at.strftime("%Y-%m-%d")] += 1
|
50
|
+
end
|
51
|
+
logs(:skipped).each do |l|
|
52
|
+
@skipped[l.processing_at.strftime("%Y-%m-%d")] ||= 0
|
53
|
+
@skipped[l.processing_at.strftime("%Y-%m-%d")] += 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def logs state, period = nil
|
60
|
+
period ||= @period
|
61
|
+
|
62
|
+
MailyHerald::Log.send(state).where("processing_at > (?)", @time - period)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::DispatchesController < Webui::ResourcesController
|
3
|
+
def index
|
4
|
+
super do |scope|
|
5
|
+
scope.not_archived
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def archived
|
10
|
+
self.class.superclass.instance_method(:index).bind(self).call do |scope|
|
11
|
+
scope.archived
|
12
|
+
end
|
13
|
+
|
14
|
+
render "index"
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_form
|
18
|
+
new
|
19
|
+
@item.attributes = item_params
|
20
|
+
end
|
21
|
+
|
22
|
+
def destroy
|
23
|
+
@item.archive!
|
24
|
+
|
25
|
+
render_containers ["details", "entities"]
|
26
|
+
render_update
|
27
|
+
end
|
28
|
+
|
29
|
+
def toggle
|
30
|
+
find_item
|
31
|
+
|
32
|
+
unless @item.enabled?
|
33
|
+
@item.enable!
|
34
|
+
else
|
35
|
+
@item.disable!
|
36
|
+
end
|
37
|
+
|
38
|
+
render_containers ["details", "entities"]
|
39
|
+
render_update
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::ListsController < Webui::ResourcesController
|
3
|
+
add_breadcrumb :label_list_plural, Proc.new{ lists_path }
|
4
|
+
set_menu_item :lists
|
5
|
+
|
6
|
+
def subscribe
|
7
|
+
find_item
|
8
|
+
|
9
|
+
@entity = @item.context.model.find params[:entity_id]
|
10
|
+
@item.subscribe! @entity
|
11
|
+
end
|
12
|
+
|
13
|
+
def unsubscribe
|
14
|
+
find_item
|
15
|
+
|
16
|
+
@entity = @item.context.model.find params[:entity_id]
|
17
|
+
@item.unsubscribe! @entity
|
18
|
+
end
|
19
|
+
|
20
|
+
def context_variables
|
21
|
+
@context = MailyHerald.context(params[:context])
|
22
|
+
|
23
|
+
render layout: "maily_herald/webui/modal"
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def resource_spec
|
29
|
+
@resource_spec ||= Webui::ResourcesController::Spec.new.tap do |spec|
|
30
|
+
spec.klass = MailyHerald::List
|
31
|
+
spec.scope = Rails::VERSION::MAJOR == 3 ? MailyHerald::List.scoped : MailyHerald::List.all
|
32
|
+
spec.filter_proc = Proc.new do |scope, query|
|
33
|
+
scope.where("name like ? or title like ?", "%#{query}%", "%#{query}%")
|
34
|
+
end
|
35
|
+
spec.items_partial = "items"
|
36
|
+
spec.params = [:name, :title]
|
37
|
+
spec.update_containers = {
|
38
|
+
"subscribers" => true,
|
39
|
+
"opt_outs" => true,
|
40
|
+
"potential_subscribers" => true
|
41
|
+
}
|
42
|
+
spec.containers_order = ["details", "subscribers", "opt_outs", "potential_subscribers"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def action_dependencies *containers
|
47
|
+
containers.flatten!
|
48
|
+
|
49
|
+
@list = @item
|
50
|
+
|
51
|
+
containers.each do |container|
|
52
|
+
case container
|
53
|
+
when "subscribers"
|
54
|
+
@subscribers = @item.subscribers
|
55
|
+
@subscribers = @subscribers.merge(@item.context.scope_like(params[:subscribers_filter])) if params[:subscribers_filter]
|
56
|
+
@subscribers = smart_listing_create(:subscribers, @subscribers, :partial => "maily_herald/webui/subscribers/list")
|
57
|
+
when "opt_outs"
|
58
|
+
@opt_outs = @item.opt_outs
|
59
|
+
@opt_outs = @opt_outs.merge(@item.context.scope_like(params[:opt_outs_filter])) if params[:opt_outs_filter]
|
60
|
+
@opt_outs = smart_listing_create(:opt_outs, @opt_outs, :partial => "maily_herald/webui/subscribers/list")
|
61
|
+
when "potential_subscribers"
|
62
|
+
@potential_subscribers = @item.potential_subscribers
|
63
|
+
@potential_subscribers = @potential_subscribers.merge(@item.context.scope_like(params[:potential_subscribers_filter])) if params[:potential_subscribers_filter]
|
64
|
+
@potential_subscribers = smart_listing_create(:potential_subscribers, @potential_subscribers, :partial => "maily_herald/webui/subscribers/list")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::LogsController < Webui::ResourcesController
|
3
|
+
add_breadcrumb :label_log_plural, Proc.new{ logs_path }
|
4
|
+
set_menu_item :logs
|
5
|
+
|
6
|
+
def preview
|
7
|
+
@log = MailyHerald::Log.find params[:id]
|
8
|
+
|
9
|
+
render layout: "maily_herald/webui/modal"
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def resource_spec
|
15
|
+
@resource_spec ||= Webui::ResourcesController::Spec.new.tap do |spec|
|
16
|
+
spec.klass = MailyHerald::Log
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::MailingsController < Webui::DispatchesController
|
3
|
+
def update
|
4
|
+
super
|
5
|
+
|
6
|
+
case edited_container
|
7
|
+
when "details"
|
8
|
+
render_containers ["details", "template"]
|
9
|
+
when "template"
|
10
|
+
render_containers "template"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def preview
|
15
|
+
find_item
|
16
|
+
|
17
|
+
@e = @item.list.context.scope.find(params[:entity_id])
|
18
|
+
@mail = @item.build_mail @e
|
19
|
+
|
20
|
+
render layout: "maily_herald/webui/modal"
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def set_resource_spec
|
26
|
+
Webui::ResourcesController::Spec.new.tap do |spec|
|
27
|
+
spec.klass = "MailyHerald::#{controller_name.classify}".constantize
|
28
|
+
if Rails::VERSION::MAJOR == 3
|
29
|
+
spec.scope = spec.klass.scoped
|
30
|
+
else
|
31
|
+
spec.scope = spec.klass.all
|
32
|
+
end
|
33
|
+
spec.filter_proc = Proc.new do |scope, query|
|
34
|
+
scope.where("name like ? or title like ?", "%#{query}%", "%#{query}%")
|
35
|
+
end
|
36
|
+
spec.items_partial = "maily_herald/webui/mailings/list"
|
37
|
+
spec.item_partial = "maily_herald/webui/mailings/mailing"
|
38
|
+
spec.params = [:title, :mailer_name, :list, :from, :conditions, :override_subscription, :subject, :template]
|
39
|
+
spec.update_containers = {
|
40
|
+
"template" => {editable: true},
|
41
|
+
"entities" => true,
|
42
|
+
"logs" => true
|
43
|
+
}
|
44
|
+
spec.containers_order = ["details", "template", "entities", "logs"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def action_dependencies *containers
|
49
|
+
containers.flatten!
|
50
|
+
|
51
|
+
@mailing = @item
|
52
|
+
@list = @mailing.list
|
53
|
+
|
54
|
+
containers.each do |container|
|
55
|
+
case container
|
56
|
+
when "logs"
|
57
|
+
@logs = smart_listing_create(:logs, @item.logs.processed, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "desc"})
|
58
|
+
when "entities"
|
59
|
+
@entities = @item.list.subscribers
|
60
|
+
@entities = @entities.merge(@item.list.context.scope_like(params[:entities_filter])) if params[:entities_filter]
|
61
|
+
@entities = smart_listing_create(:entities, @entities, :partial => "maily_herald/webui/subscribers/list")
|
62
|
+
else
|
63
|
+
yield(container) if block_given?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::OneTimeMailingsController < Webui::MailingsController
|
3
|
+
add_breadcrumb :label_one_time_mailing_plural, Proc.new{ one_time_mailings_path }
|
4
|
+
set_menu_item :one_time_mailings
|
5
|
+
|
6
|
+
def archived
|
7
|
+
add_breadcrumb view_context.tw("#{controller_name}.archived.label")
|
8
|
+
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def deliver
|
17
|
+
find_item
|
18
|
+
|
19
|
+
if params[:entity_id]
|
20
|
+
@e = @item.list.context.scope.find(params[:entity_id])
|
21
|
+
@item.deliver_to @e
|
22
|
+
|
23
|
+
render_containers ["logs"]
|
24
|
+
render_update
|
25
|
+
else
|
26
|
+
@item.run
|
27
|
+
head :ok
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::PeriodicalMailingsController < Webui::MailingsController
|
3
|
+
add_breadcrumb :label_periodical_mailing_plural, Proc.new{ periodical_mailings_path }
|
4
|
+
set_menu_item :periodical_mailings
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
def set_resource_spec
|
9
|
+
spec = super
|
10
|
+
spec.params.push(:start_at, :period_in_days)
|
11
|
+
spec.update_containers["schedules"] = true
|
12
|
+
spec.containers_order = ["details", "template", "entities", "schedules", "logs"]
|
13
|
+
spec
|
14
|
+
end
|
15
|
+
|
16
|
+
def action_dependencies *containers
|
17
|
+
super do |container|
|
18
|
+
case container
|
19
|
+
when "schedules"
|
20
|
+
@schedules = smart_listing_create(:schedules, @item.logs.scheduled, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "asc"})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
class Webui::ResourcesController < Webui::ApplicationController
|
3
|
+
include SmartListing::Helper::ControllerExtensions
|
4
|
+
helper SmartListing::Helper
|
5
|
+
|
6
|
+
helper_method :resource_spec
|
7
|
+
|
8
|
+
before_filter :find_item, :only => [:show, :edit, :update, :destroy]
|
9
|
+
|
10
|
+
class Spec
|
11
|
+
DEFAULT_CONTAINER = "details"
|
12
|
+
attr_accessor :klass, :scope, :filter_proc, :items_partial, :item_partial, :locale_prefix, :params, :containers_order
|
13
|
+
|
14
|
+
def filter scope, query
|
15
|
+
@filter_proc.call(scope, query)
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_containers
|
19
|
+
@update_containers ||= {
|
20
|
+
DEFAULT_CONTAINER => {editable: true}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
def update_containers= containers
|
24
|
+
update_containers.merge!(containers)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def index
|
29
|
+
scope = resource_spec.scope
|
30
|
+
scope = resource_spec.filter(scope, params[:filter]) if params[:filter]
|
31
|
+
|
32
|
+
if block_given?
|
33
|
+
scope = yield(scope)
|
34
|
+
end
|
35
|
+
|
36
|
+
@items = smart_listing_create(:items, scope, :partial => resource_spec.items_partial || "items")
|
37
|
+
end
|
38
|
+
|
39
|
+
def new
|
40
|
+
add_breadcrumb view_context.tw("#{controller_name}.new.label")
|
41
|
+
|
42
|
+
@item = resource_spec.klass.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def create
|
46
|
+
@item = resource_spec.klass.new
|
47
|
+
@item.attributes = item_params
|
48
|
+
|
49
|
+
yield(@item) if block_given?
|
50
|
+
|
51
|
+
if @item.save
|
52
|
+
redirect_to @item
|
53
|
+
else
|
54
|
+
puts @item.errors.to_yaml
|
55
|
+
add_breadcrumb view_context.tw("#{controller_name}.new.label", :action => :new)
|
56
|
+
render :action => :new
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def show
|
61
|
+
render_containers resource_spec.update_containers.keys
|
62
|
+
end
|
63
|
+
|
64
|
+
def edit
|
65
|
+
set_edited_container
|
66
|
+
end
|
67
|
+
|
68
|
+
def update
|
69
|
+
@item.update_attributes(item_params)
|
70
|
+
|
71
|
+
render_containers resource_spec.update_containers.keys
|
72
|
+
set_edited_container
|
73
|
+
end
|
74
|
+
|
75
|
+
def destroy
|
76
|
+
@item.destroy
|
77
|
+
|
78
|
+
flash[:notice] = "destroyed"
|
79
|
+
|
80
|
+
redirect_to :action => :index
|
81
|
+
end
|
82
|
+
|
83
|
+
protected
|
84
|
+
|
85
|
+
def resource_spec
|
86
|
+
@resource_spec ||= set_resource_spec
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
# Adds containers to list of containers to be updated (reloaded)
|
92
|
+
def render_containers containers, options = {}
|
93
|
+
containers = [*containers]
|
94
|
+
|
95
|
+
if options[:append]
|
96
|
+
@rendered_containers ||= []
|
97
|
+
@rendered_containers.concat(containers.flatten)
|
98
|
+
else
|
99
|
+
@rendered_containers = containers
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Sets main container which is editable
|
104
|
+
def set_edited_container name = nil
|
105
|
+
@edited_container = name || params[:edited_container] || Spec::DEFAULT_CONTAINER
|
106
|
+
end
|
107
|
+
def edited_container
|
108
|
+
@edited_container
|
109
|
+
end
|
110
|
+
|
111
|
+
# Renders update template from different action
|
112
|
+
def render_update
|
113
|
+
render action: "update"
|
114
|
+
end
|
115
|
+
|
116
|
+
# Collect container dependencies and render
|
117
|
+
def render(options = {}, locals = {}, &block)
|
118
|
+
collect_action_dependencies
|
119
|
+
super
|
120
|
+
end
|
121
|
+
|
122
|
+
def find_item
|
123
|
+
@item = resource_spec.klass.find params[:id]
|
124
|
+
end
|
125
|
+
|
126
|
+
# Run code required by rendered containers
|
127
|
+
def collect_action_dependencies
|
128
|
+
if @rendered_containers
|
129
|
+
begin
|
130
|
+
action_dependencies @rendered_containers
|
131
|
+
rescue NoMethodError
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def item_params
|
137
|
+
if Rails::VERSION::MAJOR == 3
|
138
|
+
params[:item]
|
139
|
+
else
|
140
|
+
params.require(:item).permit(*resource_spec.params)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|