wco_models 3.1.0.37 → 3.1.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -13
- data/app/assets/config/wco_models_manifest.js +2 -0
- data/app/assets/javascripts/wco/application.js +43 -5
- data/app/assets/javascripts/wco/collapse-expand.js +1 -0
- data/app/assets/javascripts/wco/file_upload.js +32 -0
- data/app/assets/javascripts/wco/shared.js +22 -0
- data/app/assets/stylesheets/wco/application.css +23 -8
- data/app/assets/stylesheets/wco/utils.scss +57 -1
- data/app/controllers/wco/application_controller.rb +9 -0
- data/app/controllers/wco/galleries_controller.rb +143 -0
- data/app/controllers/wco/headlines_controller.rb +71 -0
- data/app/controllers/wco/leads_controller.rb +59 -0
- data/app/controllers/wco/leadsets_controller.rb +90 -0
- data/app/controllers/wco/logs_controller.rb +64 -0
- data/app/controllers/wco/office_action_templates_controller.rb +80 -0
- data/app/controllers/wco/office_actions_controller.rb +71 -0
- data/app/controllers/wco/photos_controller.rb +78 -0
- data/app/controllers/wco/profiles_controller.rb +26 -0
- data/app/controllers/wco/publishers_controller.rb +60 -0
- data/app/controllers/wco/reports_controller.rb +75 -0
- data/app/controllers/wco/sites_controller.rb +52 -0
- data/app/controllers/wco/tags_controller.rb +57 -0
- data/app/helpers/wco/application_helper.rb +42 -0
- data/app/models/wco/asset.rb +26 -0
- data/app/models/wco/gallery.rb +3 -3
- data/app/models/wco/headline.rb +19 -0
- data/app/models/wco/invoice.rb +127 -0
- data/app/models/wco/lead.rb +42 -0
- data/app/models/wco/leadset.rb +8 -2
- data/app/models/wco/log.rb +18 -0
- data/app/models/wco/newsitem.rb +1 -0
- data/app/models/wco/office_action.rb +17 -18
- data/app/models/wco/office_action_template.rb +41 -0
- data/app/models/wco/office_action_template_tie.rb +20 -0
- data/app/models/wco/photo.rb +10 -8
- data/app/models/wco/price.rb +2 -0
- data/app/models/wco/product.rb +2 -0
- data/app/models/wco/profile.rb +1 -0
- data/app/models/wco/publisher.rb +68 -3
- data/app/models/wco/report.rb +48 -0
- data/app/models/wco/site.rb +12 -1
- data/app/models/wco/subscription.rb +1 -0
- data/app/models/wco/tag.rb +17 -4
- data/app/models/wco_email/campaign.rb +7 -11
- data/app/models/wco_email/context.rb +15 -14
- data/app/models/wco_email/conversation.rb +13 -27
- data/app/models/wco_email/{scheduled_email_action.rb → email_action.rb} +24 -20
- data/app/models/wco_email/email_action_template.rb +35 -0
- data/app/models/wco_email/email_filter.rb +9 -12
- data/app/models/wco_email/email_template.rb +124 -0
- data/app/models/wco_email/message.rb +228 -0
- data/app/models/wco_email/message_stub.rb +107 -0
- data/app/models/wco_email/obfuscated_redirect.rb +13 -0
- data/app/models/wco_email/unsubscribe.rb +19 -0
- data/app/models/wco_hosting/appliance.rb +1 -0
- data/app/models/wco_hosting/appliance_tmpl.rb +1 -0
- data/app/models/wco_hosting/domain.rb +1 -0
- data/app/models/wco_hosting/serverhost.rb +1 -0
- data/app/views/layouts/wco/application.haml +30 -17
- data/app/views/wco/_main_footer.haml +43 -0
- data/app/views/wco/_main_header.haml +37 -0
- data/app/views/wco/_main_header.haml-bk +109 -0
- data/app/views/wco/_paginate.haml +8 -0
- data/app/views/wco/_search.haml +8 -0
- data/app/views/wco/application/_debug.haml +0 -0
- data/app/views/wco/galleries/_form.haml +24 -0
- data/app/views/wco/galleries/_header.haml +8 -0
- data/app/views/wco/galleries/_index.haml +40 -0
- data/app/views/wco/galleries/_menu.haml-trash +10 -0
- data/app/views/wco/galleries/_menu_secondary.haml +12 -0
- data/app/views/wco/galleries/_thumbs.haml +9 -0
- data/app/views/wco/galleries/_title.haml +16 -0
- data/app/views/wco/galleries/edit.haml +6 -0
- data/app/views/wco/galleries/new.haml +6 -0
- data/app/views/wco/galleries/show.haml +43 -0
- data/app/views/wco/headlines/_form.haml +17 -0
- data/app/views/wco/headlines/_header.haml +6 -0
- data/app/views/wco/headlines/_index.haml +20 -0
- data/app/views/wco/headlines/edit.haml +6 -0
- data/app/views/wco/headlines/new.haml +2 -0
- data/app/views/wco/invoices/_form.haml-trash +29 -0
- data/app/views/wco/invoices/_header.haml +6 -0
- data/app/views/wco/invoices/_index_list.haml +13 -0
- data/app/views/wco/invoices/_index_table.haml +20 -0
- data/app/views/wco/invoices/index.haml +3 -0
- data/app/views/wco/invoices/new_pdf.haml +18 -0
- data/app/views/wco/invoices/new_stripe.haml +50 -0
- data/app/views/wco/invoices/show.haml +23 -0
- data/app/views/wco/kaminari/_first_page.html.erb +11 -0
- data/app/views/wco/kaminari/_gap.html.erb +8 -0
- data/app/views/wco/kaminari/_last_page.html.erb +11 -0
- data/app/views/wco/kaminari/_next_page.html.erb +11 -0
- data/app/views/wco/kaminari/_page.html.erb +13 -0
- data/app/views/wco/kaminari/_paginator.html.erb +25 -0
- data/app/views/wco/kaminari/_prev_page.html.erb +11 -0
- data/app/views/wco/leads/_form.haml +45 -0
- data/app/views/wco/leads/_form_import.haml +11 -0
- data/app/views/wco/leads/_header.haml +7 -0
- data/app/views/wco/leads/_index.haml +75 -0
- data/app/views/wco/leads/_index_rows.haml +11 -0
- data/app/views/wco/leads/edit.haml +22 -0
- data/app/views/wco/leads/index.haml +7 -0
- data/app/views/wco/leads/new.haml +9 -0
- data/app/views/wco/leads/show.haml +85 -0
- data/app/views/wco/leadsets/_form.haml +28 -0
- data/app/views/wco/leadsets/_header.haml +6 -0
- data/app/views/wco/leadsets/edit.haml +4 -0
- data/app/views/wco/leadsets/index.haml +45 -0
- data/app/views/wco/leadsets/index_dataTables.haml +33 -0
- data/app/views/wco/leadsets/new.haml +6 -0
- data/app/views/wco/leadsets/show.haml +52 -0
- data/app/views/wco/logs/_form.haml +17 -0
- data/app/views/wco/logs/_header.haml +6 -0
- data/app/views/wco/logs/_index.haml +23 -0
- data/app/views/wco/logs/edit.haml +6 -0
- data/app/views/wco/logs/new.haml +2 -0
- data/app/views/wco/office_action_templates/_form.haml +46 -0
- data/app/views/wco/office_action_templates/_header.haml +8 -0
- data/app/views/wco/office_action_templates/_ties.haml +18 -0
- data/app/views/wco/office_action_templates/edit.haml +6 -0
- data/app/views/wco/office_action_templates/index.haml +17 -0
- data/app/views/wco/office_action_templates/new.haml +5 -0
- data/app/views/wco/office_action_templates/show.haml +22 -0
- data/app/views/wco/office_actions/_form.haml +22 -0
- data/app/views/wco/office_actions/_header.haml +6 -0
- data/app/views/wco/office_actions/_index.haml +15 -0
- data/app/views/wco/office_actions/edit.haml +5 -0
- data/app/views/wco/office_actions/index.haml +10 -0
- data/app/views/wco/office_actions/new.haml +4 -0
- data/app/views/wco/office_actions/show.haml +5 -0
- data/app/views/wco/photos/_form.haml +0 -0
- data/app/views/wco/photos/_index_thumbs.haml +7 -0
- data/app/views/wco/photos/_meta.haml +7 -0
- data/app/views/wco/photos/_meta_manager.haml +7 -0
- data/app/views/wco/photos/_multinew.haml +6 -0
- data/app/views/wco/photos/index.haml +3 -0
- data/app/views/wco/photos/new.haml +0 -0
- data/app/views/wco/photos/show.haml +6 -0
- data/app/views/wco/photos/without_gallery.haml +11 -0
- data/app/views/wco/prices/_form.haml +1 -1
- data/app/views/wco/products/_header.haml +6 -0
- data/app/views/wco/publishers/_form.haml +28 -0
- data/app/views/wco/publishers/_header.haml +6 -0
- data/app/views/wco/publishers/edit.haml +4 -0
- data/app/views/wco/publishers/index.haml +37 -0
- data/app/views/wco/publishers/new.haml +4 -0
- data/app/views/wco/reports/_form.haml +28 -0
- data/app/views/wco/reports/_header.haml +14 -0
- data/app/views/wco/reports/edit.haml +4 -0
- data/app/views/wco/reports/index.haml +17 -0
- data/app/views/wco/reports/index_table.haml +17 -0
- data/app/views/wco/reports/new.haml +4 -0
- data/app/views/wco/reports/show.haml +8 -0
- data/app/views/wco/sites/_form.haml +21 -0
- data/app/views/wco/sites/_header.haml +6 -0
- data/app/views/wco/sites/edit.haml +4 -0
- data/app/views/wco/sites/index.haml +24 -0
- data/app/views/wco/sites/new.haml +4 -0
- data/app/views/wco/tags/_form.haml +10 -0
- data/app/views/wco/tags/_header.haml +6 -0
- data/app/views/wco/tags/_index.haml +10 -0
- data/app/views/wco/tags/_index_inline.haml +8 -0
- data/app/views/wco/tags/edit.haml +0 -0
- data/app/views/wco/tags/index.haml +9 -0
- data/app/views/wco/tags/new.haml +0 -0
- data/app/views/wco/tags/show.haml +15 -0
- data/config/routes.rb +42 -0
- data/lib/tasks/db_tasks.rake +13 -0
- data/lib/tasks/office_tasks.rake +36 -0
- data/lib/tasks/scrape_tasks.rake-trash +22 -0
- data/lib/wco/ai_writer.rb +55 -0
- data/lib/wco/engine.rb +0 -1
- data/lib/wco/office_worker.rb +4 -0
- data/lib/wco/scrape_wsj.rb +29 -0
- data/lib/wco/scrape_wsj_capy.rb +44 -0
- data/lib/wco_models.rb +15 -2
- metadata +241 -46
- data/app/helpers/ish_models/application_helper.rb +0 -4
- data/app/models/wco_email/message_template.rb +0 -6
- data/lib/tasks/ish_models_tasks.rake +0 -4
- /data/app/views/wco/{application/_alerts_notices.haml → _alerts_notices.haml} +0 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
class Wco::LogsController < Wco::ApplicationController
|
3
|
+
|
4
|
+
def bulkop
|
5
|
+
@logs = Wco::Log.find params[:ids]
|
6
|
+
authorize! :delete, @logs
|
7
|
+
case params[:verb]
|
8
|
+
when 'delete'
|
9
|
+
@logs.map &:delete
|
10
|
+
end
|
11
|
+
flash_notice "Probably ok"
|
12
|
+
redirect_to request.referrer
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@log = Wco::Log.new( params[:log].permit! )
|
17
|
+
authorize! :create, @log
|
18
|
+
|
19
|
+
if @log.save
|
20
|
+
flash_notice @log
|
21
|
+
else
|
22
|
+
flash_alert @log
|
23
|
+
end
|
24
|
+
redirect_to action: :index
|
25
|
+
end
|
26
|
+
|
27
|
+
def destroy
|
28
|
+
@log = Wco::Log.find params[:id]
|
29
|
+
authorize! :delete, @log
|
30
|
+
@log.delete
|
31
|
+
flash_notice "Probably ok"
|
32
|
+
redirect_to action: :index
|
33
|
+
end
|
34
|
+
|
35
|
+
def new
|
36
|
+
authorize! :new, Wco::Log
|
37
|
+
end
|
38
|
+
|
39
|
+
def edit
|
40
|
+
@log = Wco::Log.find params[:id]
|
41
|
+
authorize! :edit, @log
|
42
|
+
end
|
43
|
+
|
44
|
+
def index
|
45
|
+
authorize! :index, Wco::Log
|
46
|
+
@logs = Wco::Log.all.page( params[:logs_page] ).per( current_profile.per_page )
|
47
|
+
render '_index'
|
48
|
+
end
|
49
|
+
|
50
|
+
def update
|
51
|
+
@log = Wco::Log.find params[:id]
|
52
|
+
authorize! :update, @log
|
53
|
+
|
54
|
+
if @log.update params[:log].permit!
|
55
|
+
flash_notice @log
|
56
|
+
else
|
57
|
+
flash_alert @log
|
58
|
+
end
|
59
|
+
redirect_to action: :index
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
OAT = Wco::OfficeActionTemplate
|
3
|
+
OATT = Wco::OfficeActionTemplateTie
|
4
|
+
|
5
|
+
class Wco::OfficeActionTemplatesController < Wco::ApplicationController
|
6
|
+
|
7
|
+
before_action :set_lists
|
8
|
+
|
9
|
+
def edit
|
10
|
+
@oat = OAT.find params[:id]
|
11
|
+
@oat.ties.push Wco::OfficeActionTemplateTie.new
|
12
|
+
authorize! :edit, @oat
|
13
|
+
end
|
14
|
+
|
15
|
+
def index
|
16
|
+
authorize! :index, OAT
|
17
|
+
@oats = OAT.all
|
18
|
+
@new_oat = OAT.new
|
19
|
+
@new_oat.ties.push Wco::OfficeActionTemplateTie.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def new
|
23
|
+
@oat = OAT.new
|
24
|
+
@oat.ties.push Wco::OfficeActionTemplateTie.new
|
25
|
+
authorize! :new, @oat
|
26
|
+
end
|
27
|
+
|
28
|
+
def show
|
29
|
+
@oat = OAT.find params[:id]
|
30
|
+
authorize! :show, @oat
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
params[:oat][:ties_attributes].permit!
|
35
|
+
if params[:id]
|
36
|
+
@oat = OAT.find params[:id]
|
37
|
+
else
|
38
|
+
@oat = OAT.new
|
39
|
+
end
|
40
|
+
authorize! :upsert, @oat
|
41
|
+
|
42
|
+
if params[:oat][:ties_attributes]
|
43
|
+
params[:oat][:ties_attributes].each do |k, v|
|
44
|
+
if !v[:next_office_action_template_id].present?
|
45
|
+
params[:oat][:ties_attributes].delete( k )
|
46
|
+
end
|
47
|
+
if v[:to_delete] == "1"
|
48
|
+
OATT.find( v[:id] ).delete
|
49
|
+
params[:oat][:ties_attributes].delete( k )
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
if @oat.update params[:oat].permit!
|
55
|
+
flash_notice @oat
|
56
|
+
else
|
57
|
+
flash_alert @oat
|
58
|
+
end
|
59
|
+
redirect_to action: :index
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
## private
|
64
|
+
##
|
65
|
+
private
|
66
|
+
|
67
|
+
def set_lists
|
68
|
+
@from_types_list = [ nil, 'Wco::Gallery', 'Wco::Tag' ]
|
69
|
+
@from_type = params[:from_type]
|
70
|
+
@from_ids_list = []
|
71
|
+
if @from_type.present?
|
72
|
+
@from_ids_list = @from_type.constantize.list
|
73
|
+
end
|
74
|
+
@publishers_list = Wco::Publisher.list
|
75
|
+
|
76
|
+
@oats_list = OAT.list
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
|
2
|
+
OAT = Wco::OfficeActionTemplate
|
3
|
+
OA = Wco::OfficeAction
|
4
|
+
|
5
|
+
class Wco::OfficeActionsController < Wco::ApplicationController
|
6
|
+
|
7
|
+
before_action :set_lists
|
8
|
+
|
9
|
+
def create
|
10
|
+
@oa = OA.new params[:oa].permit!
|
11
|
+
authorize! :update, @oa
|
12
|
+
|
13
|
+
if @oa.save
|
14
|
+
flash_notice @oa
|
15
|
+
else
|
16
|
+
flash_alert @oa
|
17
|
+
end
|
18
|
+
redirect_to action: :index
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
@oa = OA.find params[:id]
|
23
|
+
authorize! :edit, @oa
|
24
|
+
end
|
25
|
+
|
26
|
+
def index
|
27
|
+
authorize! :index, OA
|
28
|
+
@oas = OA.all
|
29
|
+
end
|
30
|
+
|
31
|
+
def new
|
32
|
+
@oa = OA.new
|
33
|
+
authorize! :new, @oa
|
34
|
+
end
|
35
|
+
|
36
|
+
def show
|
37
|
+
@oa = OA.find params[:id]
|
38
|
+
authorize! :show, @oa
|
39
|
+
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
@oa = OA.find params[:id]
|
43
|
+
authorize! :update, @oa
|
44
|
+
|
45
|
+
if @oa.update params[:oa].permit!
|
46
|
+
flash_notice @oa
|
47
|
+
else
|
48
|
+
flash_alert @oa
|
49
|
+
end
|
50
|
+
redirect_to action: :index
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
## private
|
55
|
+
##
|
56
|
+
private
|
57
|
+
|
58
|
+
def set_lists
|
59
|
+
@from_types_list = [ nil, 'Wco::Gallery', 'Wco::Tag' ]
|
60
|
+
@from_type = params[:from_type]
|
61
|
+
@from_ids_list = []
|
62
|
+
if @from_type.present?
|
63
|
+
@from_ids_list = @from_type.constantize.list
|
64
|
+
end
|
65
|
+
@publishers_list = Wco::Publisher.list
|
66
|
+
|
67
|
+
@oats_list = OAT.list
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
class Wco::PhotosController < Wco::ApplicationController
|
3
|
+
|
4
|
+
# @TODO: this is bad? _vp_ 20170513
|
5
|
+
skip_authorization_check :only => [ :j_create ]
|
6
|
+
protect_from_forgery :except => [ :j_create]
|
7
|
+
|
8
|
+
## Alphabetized : )
|
9
|
+
|
10
|
+
def destroy
|
11
|
+
@photo = Wco::Photo.unscoped.find params[:id]
|
12
|
+
authorize! :destroy, @photo
|
13
|
+
@photo.gallery.touch if @photo.gallery
|
14
|
+
@photo.is_trash = true
|
15
|
+
flag = @photo.save
|
16
|
+
if flag
|
17
|
+
flash[:notice] = "Success"
|
18
|
+
else
|
19
|
+
flash[:alert] = "No luck: #{@photo.errors.messages}"
|
20
|
+
end
|
21
|
+
redirect_to request.referrer || root_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def index
|
25
|
+
authorize! :index, Wco::Photo
|
26
|
+
@photos = Wco::Photo.where( user_profile: @current_profile ).page( params[:photos_page] )
|
27
|
+
end
|
28
|
+
|
29
|
+
def j_create
|
30
|
+
if params[:slug]
|
31
|
+
gallery = Wco::Gallery.unscoped.where( :slug => params[:slug] ).first
|
32
|
+
gallery ||= Wco::Gallery.unscoped.find params[:slug]
|
33
|
+
elsif params[:gallery_id]
|
34
|
+
gallery = Wco::Gallery.unscoped.find( params[:gallery_id] )
|
35
|
+
gallery ||= Wco::Gallery.unscoped.where( :slug => params[:gallery_id] ).first
|
36
|
+
end
|
37
|
+
authorize! :create_photo, gallery
|
38
|
+
|
39
|
+
@photo = Wco::Photo.new params[:photo].permit!
|
40
|
+
@photo.is_public = true
|
41
|
+
@photo.gallery = gallery
|
42
|
+
|
43
|
+
@photo.gallery.touch
|
44
|
+
|
45
|
+
if @photo.save
|
46
|
+
j = {
|
47
|
+
:name => @photo.photo.original_filename,
|
48
|
+
:size => @photo.photo.size,
|
49
|
+
:url => @photo.photo.url( :large ),
|
50
|
+
:thumbnail_url => @photo.photo.url( :thumb ),
|
51
|
+
:delete_url => photo_path(@photo),
|
52
|
+
:delete_type => 'DELETE'
|
53
|
+
}
|
54
|
+
render :json => [ j ]
|
55
|
+
else
|
56
|
+
render :json => {
|
57
|
+
message: @photo.errors.full_messages.join(", "),
|
58
|
+
filename: @photo.photo.original_filename,
|
59
|
+
}, status: 400
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def new
|
64
|
+
authorize! :new, Wco::Photo
|
65
|
+
@photo = Wco::Photo.new
|
66
|
+
end
|
67
|
+
|
68
|
+
def show
|
69
|
+
@photo = Wco::Photo.unscoped.find params[:id]
|
70
|
+
authorize! :show, @photo
|
71
|
+
end
|
72
|
+
|
73
|
+
def without_gallery
|
74
|
+
@photos = Wco::Photo.unscoped.where( :gallery => nil, :is_trash => false )
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
class Wco::ProfilesController < Wco::ApplicationController
|
3
|
+
|
4
|
+
def update
|
5
|
+
@profile = Wco::Profile.find params[:id]
|
6
|
+
authorize! :update, @profile
|
7
|
+
|
8
|
+
# if params[:photo]
|
9
|
+
# photo = Photo.new :photo => params[:photo]
|
10
|
+
# @profile.profile_photo = photo
|
11
|
+
# end
|
12
|
+
|
13
|
+
flag = @profile.update params[:profile].permit!
|
14
|
+
if flag
|
15
|
+
flash_notice "Updated profile #{@profile.email}"
|
16
|
+
else
|
17
|
+
flash_alert "Cannot update profile: #{@profile.errors.full_messages}"
|
18
|
+
end
|
19
|
+
if params[:redirect_to]
|
20
|
+
redirect_to params[:redirect_to]
|
21
|
+
else
|
22
|
+
redirect_to request.referrer
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
# require 'httparty'
|
3
|
+
|
4
|
+
class Wco::PublishersController < Wco::ApplicationController
|
5
|
+
|
6
|
+
## Alphabetized : )
|
7
|
+
|
8
|
+
def create
|
9
|
+
@publisher = Wco::Publisher.new params[:publisher].permit!
|
10
|
+
authorize! :create, @publisher
|
11
|
+
if @publisher.save
|
12
|
+
flash_notice "Created publisher"
|
13
|
+
else
|
14
|
+
flash_alert "Cannot create publisher: #{@publisher.errors.messages}"
|
15
|
+
end
|
16
|
+
redirect_to action: 'index'
|
17
|
+
end
|
18
|
+
|
19
|
+
def do_run
|
20
|
+
@publisher = Wco::Publisher.find params[:id]
|
21
|
+
authorize! :do_run, @publisher
|
22
|
+
|
23
|
+
@publisher.do_run binding
|
24
|
+
|
25
|
+
flash_notice "Probably ok"
|
26
|
+
|
27
|
+
redirect_to action: 'index'
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit
|
31
|
+
@publisher = Wco::Publisher.find params[:id]
|
32
|
+
authorize! :edit, @publisher
|
33
|
+
@sites_list = Wco::Site.list
|
34
|
+
@galleries_list = Wco::Gallery.list
|
35
|
+
end
|
36
|
+
|
37
|
+
def index
|
38
|
+
authorize! :index, Wco::Publisher
|
39
|
+
@publishers = Wco::Publisher.all
|
40
|
+
end
|
41
|
+
|
42
|
+
def new
|
43
|
+
authorize! :new, Wco::Publisher
|
44
|
+
@new_publisher = Wco::Publisher.new
|
45
|
+
@sites_list = Wco::Site.list
|
46
|
+
@galleries_list = Wco::Gallery.list
|
47
|
+
end
|
48
|
+
|
49
|
+
def update
|
50
|
+
@publisher = Wco::Publisher.find params[:id]
|
51
|
+
authorize! :update, @publisher
|
52
|
+
if @publisher.update params[:publisher].permit!
|
53
|
+
flash_notice "Updated publisher"
|
54
|
+
else
|
55
|
+
flash_alert "Cannot update publisher: #{@publisher.errors.messages}"
|
56
|
+
end
|
57
|
+
redirect_to action: 'index'
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
class Wco::ReportsController < Wco::ApplicationController
|
3
|
+
|
4
|
+
before_action :set_lists
|
5
|
+
|
6
|
+
def create
|
7
|
+
params[:report][:tag_ids].delete ''
|
8
|
+
|
9
|
+
@report = Wco::Report.new params[:report].permit!
|
10
|
+
authorize! :create, @report
|
11
|
+
if @report.save
|
12
|
+
flash_notice "created report"
|
13
|
+
else
|
14
|
+
flash_alert "Cannot create report: #{@report.errors.messages}"
|
15
|
+
end
|
16
|
+
redirect_to action: 'index'
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
@report = Wco::Report.find params[:id]
|
21
|
+
authorize! :destroy, @report
|
22
|
+
if @report.destroy
|
23
|
+
flash_notice 'ok'
|
24
|
+
else
|
25
|
+
flash_alert 'No luck.'
|
26
|
+
end
|
27
|
+
redirect_to action: 'index'
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit
|
31
|
+
@report = Wco::Report.unscoped.find params[:id]
|
32
|
+
authorize! :edit, @report
|
33
|
+
end
|
34
|
+
|
35
|
+
def index
|
36
|
+
authorize! :index, Wco::Report
|
37
|
+
@reports = Wco::Report.all
|
38
|
+
if params[:deleted]
|
39
|
+
@reports = Wco::Report.unscoped.where( :deleted_at.ne => nil )
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def new
|
44
|
+
authorize! :new, Wco::Report
|
45
|
+
@new_report = Wco::Report.new
|
46
|
+
end
|
47
|
+
|
48
|
+
def show
|
49
|
+
@report = Wco::Report.unscoped.find params[:id]
|
50
|
+
authorize! :show, @report
|
51
|
+
end
|
52
|
+
|
53
|
+
def update
|
54
|
+
params[:report][:tag_ids].delete ''
|
55
|
+
|
56
|
+
@report = Wco::Report.unscoped.find params[:id]
|
57
|
+
authorize! :update, @report
|
58
|
+
if @report.update params[:report].permit!
|
59
|
+
flash_notice "updated report"
|
60
|
+
else
|
61
|
+
flash_alert "Cannot update report: #{@report.errors.messages}"
|
62
|
+
end
|
63
|
+
redirect_to action: 'index'
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
## private
|
68
|
+
##
|
69
|
+
private
|
70
|
+
|
71
|
+
def set_lists
|
72
|
+
@tags_list = Wco::Tag.list
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
class Wco::SitesController < Wco::ApplicationController
|
3
|
+
|
4
|
+
def create
|
5
|
+
@site = Wco::Site.new params[:site].permit!
|
6
|
+
authorize! :create, @site
|
7
|
+
if @site.save
|
8
|
+
flash_notice "created site"
|
9
|
+
else
|
10
|
+
flash_alert "Cannot create site: #{@site.errors.messages}"
|
11
|
+
end
|
12
|
+
redirect_to action: 'index'
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
@site = Wco::Site.find params[:id]
|
17
|
+
authorize! :destroy, @site
|
18
|
+
if @site.destroy
|
19
|
+
flash_notice 'ok'
|
20
|
+
else
|
21
|
+
flash_alert 'No luck.'
|
22
|
+
end
|
23
|
+
redirect_to action: 'index'
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit
|
27
|
+
@site = Wco::Site.find params[:id]
|
28
|
+
authorize! :edit, @site
|
29
|
+
end
|
30
|
+
|
31
|
+
def index
|
32
|
+
authorize! :index, Wco::Site
|
33
|
+
@sites = Wco::Site.all
|
34
|
+
end
|
35
|
+
|
36
|
+
def new
|
37
|
+
authorize! :new, Wco::Site
|
38
|
+
@new_site = Wco::Site.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
@site = Wco::Site.find params[:id]
|
43
|
+
authorize! :update, @site
|
44
|
+
if @site.update params[:site].permit!
|
45
|
+
flash_notice "updated site"
|
46
|
+
else
|
47
|
+
flash_alert "Cannot update site: #{@site.errors.messages}"
|
48
|
+
end
|
49
|
+
redirect_to action: 'index'
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
class Wco::TagsController < Wco::ApplicationController
|
3
|
+
|
4
|
+
def create
|
5
|
+
@tag = Wco::Tag.new params[:tag].permit!
|
6
|
+
authorize! :create, @tag
|
7
|
+
if @tag.save
|
8
|
+
flash_notice "created tag"
|
9
|
+
else
|
10
|
+
flash_alert "Cannot create tag: #{@tag.errors.messages}"
|
11
|
+
end
|
12
|
+
redirect_to action: 'index'
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
@tag = Wco::Tag.find params[:id]
|
17
|
+
authorize! :destroy, @tag
|
18
|
+
if @tag.destroy
|
19
|
+
flash_notice 'ok'
|
20
|
+
else
|
21
|
+
flash_alert 'No luck.'
|
22
|
+
end
|
23
|
+
redirect_to action: 'index'
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit
|
27
|
+
@tag = Wco::Tag.find params[:id]
|
28
|
+
authorize! :edit, @tag
|
29
|
+
end
|
30
|
+
|
31
|
+
def index
|
32
|
+
authorize! :index, Wco::Tag
|
33
|
+
@tags = Wco::Tag.all
|
34
|
+
end
|
35
|
+
|
36
|
+
def new
|
37
|
+
authorize! :new, Wco::Tag
|
38
|
+
@new_tag = Wco::Tag.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def show
|
42
|
+
@tag = Wco::Tag.find params[:id]
|
43
|
+
authorize! :show, @tag
|
44
|
+
end
|
45
|
+
|
46
|
+
def update
|
47
|
+
@tag = Wco::Tag.find params[:id]
|
48
|
+
authorize! :update, @tag
|
49
|
+
if @tag.update params[:tag].permit!
|
50
|
+
flash_notice "updated tag"
|
51
|
+
else
|
52
|
+
flash_alert "Cannot update tag: #{@tag.errors.messages}"
|
53
|
+
end
|
54
|
+
redirect_to action: 'index'
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
module Wco::ApplicationHelper
|
3
|
+
|
4
|
+
def my_truthy? which
|
5
|
+
["1", "t", "T", "true"].include?( which )
|
6
|
+
end
|
7
|
+
|
8
|
+
def obfuscate link
|
9
|
+
# puts! link, 'obfuscate helper' if DEBUG
|
10
|
+
obf = WcoEmail::ObfuscatedRedirect.find_or_create_by({ to: link })
|
11
|
+
return WcoEmail::Engine.routes.url_helpers.obf_url( obf.id, {
|
12
|
+
host: Rails.application.routes.default_url_options[:host],
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
def pretty_date date
|
17
|
+
# date.to_s[0, 10]
|
18
|
+
date&.strftime('%Y-%m-%d')
|
19
|
+
end
|
20
|
+
def pp_date a; pretty_date a; end
|
21
|
+
|
22
|
+
def pp_datetime date
|
23
|
+
date&.strftime('%Y-%m-%d %l:%M%P %z')
|
24
|
+
end
|
25
|
+
|
26
|
+
def pp_time date
|
27
|
+
return nil if !date
|
28
|
+
# return date.strftime('%l:%M%P %z')
|
29
|
+
return date.in_time_zone( Rails.application.config.time_zone ).strftime('%l:%M%P')
|
30
|
+
end
|
31
|
+
|
32
|
+
def pp_amount a
|
33
|
+
return '-' if !a
|
34
|
+
"$ #{'%.2f' % a}"
|
35
|
+
end
|
36
|
+
def pp_money a; pp_amount a; end
|
37
|
+
def pp_currency a; pp_amount a; end
|
38
|
+
def pp_percent a
|
39
|
+
"#{(a*100).round(2)}%"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
# require 'aws-sdk'
|
3
|
+
require 'mongoid_paperclip'
|
4
|
+
|
5
|
+
class Wco::Asset
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
include Mongoid::Paperclip
|
9
|
+
include Mongoid::Paranoia
|
10
|
+
include Wco::Utils
|
11
|
+
|
12
|
+
field :filename
|
13
|
+
|
14
|
+
belongs_to :email_message, class_name: 'WcoEmail::Message', optional: true
|
15
|
+
|
16
|
+
has_mongoid_attached_file :object,
|
17
|
+
:storage => :s3,
|
18
|
+
:s3_credentials => ::S3_CREDENTIALS,
|
19
|
+
:path => "assets/:id/:filename",
|
20
|
+
:s3_protocol => 'https',
|
21
|
+
:validate_media_type => false,
|
22
|
+
s3_region: ::S3_CREDENTIALS[:region]
|
23
|
+
|
24
|
+
do_not_validate_attachment_file_type :object
|
25
|
+
|
26
|
+
end
|
data/app/models/wco/gallery.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
class Wco::Gallery
|
3
3
|
include Mongoid::Document
|
4
4
|
include Mongoid::Timestamps
|
5
|
+
include Mongoid::Paranoia
|
5
6
|
# include Wco::PremiumItem
|
6
7
|
include Wco::Utils
|
7
8
|
store_in collection: 'wco_galleries'
|
@@ -43,14 +44,13 @@ class Wco::Gallery
|
|
43
44
|
[['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
|
44
45
|
end
|
45
46
|
|
46
|
-
# belongs_to :profile, class_name: 'Wco::Profile', inverse_of: :galleries
|
47
|
-
|
48
|
-
# has_many :newsitems, class_name: 'Wco::Newsitem'
|
49
47
|
has_many :photos, class_name: '::Wco::Photo', order: { weight: :asc }
|
50
48
|
|
51
49
|
def export_fields
|
52
50
|
%w| name subhead descr |
|
53
51
|
end
|
54
52
|
|
53
|
+
has_many :oats, class_name: 'Wco::OfficeActionTemplate'
|
54
|
+
|
55
55
|
end
|
56
56
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class Wco::Headline
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
include Mongoid::Paranoia
|
7
|
+
store_in collection: 'wco_content_headlines'
|
8
|
+
|
9
|
+
field :date
|
10
|
+
validates :date, presence: true
|
11
|
+
|
12
|
+
field :name
|
13
|
+
validates :name, presence: true, uniqueness: true
|
14
|
+
|
15
|
+
belongs_to :site, class_name: 'Wco::Site'
|
16
|
+
|
17
|
+
has_and_belongs_to_many :tags, class_name: 'Wco::Tag'
|
18
|
+
|
19
|
+
end
|