wco_models 3.1.0.36 → 3.1.0.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -13
  3. data/app/assets/config/wco_models_manifest.js +2 -0
  4. data/app/assets/javascripts/wco/application.js +43 -5
  5. data/app/assets/javascripts/wco/collapse-expand.js +1 -0
  6. data/app/assets/javascripts/wco/file_upload.js +32 -0
  7. data/app/assets/javascripts/wco/shared.js +22 -0
  8. data/app/assets/stylesheets/wco/application.css +23 -8
  9. data/app/assets/stylesheets/wco/utils.scss +57 -1
  10. data/app/controllers/wco/application_controller.rb +9 -0
  11. data/app/controllers/wco/galleries_controller.rb +143 -0
  12. data/app/controllers/wco/headlines_controller.rb +71 -0
  13. data/app/controllers/wco/leads_controller.rb +59 -0
  14. data/app/controllers/wco/leadsets_controller.rb +90 -0
  15. data/app/controllers/wco/logs_controller.rb +64 -0
  16. data/app/controllers/wco/office_action_templates_controller.rb +80 -0
  17. data/app/controllers/wco/office_actions_controller.rb +71 -0
  18. data/app/controllers/wco/photos_controller.rb +78 -0
  19. data/app/controllers/wco/profiles_controller.rb +26 -0
  20. data/app/controllers/wco/publishers_controller.rb +60 -0
  21. data/app/controllers/wco/reports_controller.rb +75 -0
  22. data/app/controllers/wco/sites_controller.rb +52 -0
  23. data/app/controllers/wco/tags_controller.rb +57 -0
  24. data/app/helpers/wco/application_helper.rb +42 -0
  25. data/app/models/wco/asset.rb +26 -0
  26. data/app/models/wco/gallery.rb +3 -3
  27. data/app/models/wco/headline.rb +19 -0
  28. data/app/models/wco/invoice.rb +127 -0
  29. data/app/models/wco/lead.rb +42 -0
  30. data/app/models/wco/leadset.rb +8 -2
  31. data/app/models/wco/log.rb +18 -0
  32. data/app/models/wco/newsitem.rb +1 -0
  33. data/app/models/wco/office_action.rb +17 -18
  34. data/app/models/wco/office_action_template.rb +41 -0
  35. data/app/models/wco/office_action_template_tie.rb +20 -0
  36. data/app/models/wco/photo.rb +10 -8
  37. data/app/models/wco/price.rb +2 -0
  38. data/app/models/wco/product.rb +2 -0
  39. data/app/models/wco/profile.rb +1 -0
  40. data/app/models/wco/publisher.rb +68 -3
  41. data/app/models/wco/report.rb +48 -0
  42. data/app/models/wco/site.rb +12 -1
  43. data/app/models/wco/subscription.rb +1 -0
  44. data/app/models/wco/tag.rb +17 -4
  45. data/app/models/wco_email/campaign.rb +7 -11
  46. data/app/models/wco_email/context.rb +15 -14
  47. data/app/models/wco_email/conversation.rb +13 -27
  48. data/app/models/wco_email/{scheduled_email_action.rb → email_action.rb} +24 -20
  49. data/app/models/wco_email/email_action_template.rb +35 -0
  50. data/app/models/wco_email/email_filter.rb +9 -12
  51. data/app/models/wco_email/email_template.rb +124 -0
  52. data/app/models/wco_email/message.rb +228 -0
  53. data/app/models/wco_email/message_stub.rb +107 -0
  54. data/app/models/wco_email/obfuscated_redirect.rb +13 -0
  55. data/app/models/wco_email/unsubscribe.rb +19 -0
  56. data/app/models/wco_hosting/appliance.rb +1 -0
  57. data/app/models/wco_hosting/appliance_tmpl.rb +1 -0
  58. data/app/models/wco_hosting/domain.rb +1 -0
  59. data/app/models/wco_hosting/serverhost.rb +1 -0
  60. data/app/views/layouts/wco/application.haml +30 -17
  61. data/app/views/wco/_main_footer.haml +43 -0
  62. data/app/views/wco/_main_header.haml +37 -0
  63. data/app/views/wco/_main_header.haml-bk +109 -0
  64. data/app/views/wco/_paginate.haml +8 -0
  65. data/app/views/wco/_search.haml +8 -0
  66. data/app/views/wco/application/_debug.haml +0 -0
  67. data/app/views/wco/galleries/_form.haml +24 -0
  68. data/app/views/wco/galleries/_header.haml +8 -0
  69. data/app/views/wco/galleries/_index.haml +40 -0
  70. data/app/views/wco/galleries/_menu.haml-trash +10 -0
  71. data/app/views/wco/galleries/_menu_secondary.haml +12 -0
  72. data/app/views/wco/galleries/_thumbs.haml +9 -0
  73. data/app/views/wco/galleries/_title.haml +16 -0
  74. data/app/views/wco/galleries/edit.haml +6 -0
  75. data/app/views/wco/galleries/new.haml +6 -0
  76. data/app/views/wco/galleries/show.haml +43 -0
  77. data/app/views/wco/headlines/_form.haml +17 -0
  78. data/app/views/wco/headlines/_header.haml +6 -0
  79. data/app/views/wco/headlines/_index.haml +20 -0
  80. data/app/views/wco/headlines/edit.haml +6 -0
  81. data/app/views/wco/headlines/new.haml +2 -0
  82. data/app/views/wco/invoices/_form.haml-trash +29 -0
  83. data/app/views/wco/invoices/_header.haml +6 -0
  84. data/app/views/wco/invoices/_index_list.haml +13 -0
  85. data/app/views/wco/invoices/_index_table.haml +20 -0
  86. data/app/views/wco/invoices/index.haml +3 -0
  87. data/app/views/wco/invoices/new_pdf.haml +18 -0
  88. data/app/views/wco/invoices/new_stripe.haml +50 -0
  89. data/app/views/wco/invoices/show.haml +23 -0
  90. data/app/views/wco/kaminari/_first_page.html.erb +11 -0
  91. data/app/views/wco/kaminari/_gap.html.erb +8 -0
  92. data/app/views/wco/kaminari/_last_page.html.erb +11 -0
  93. data/app/views/wco/kaminari/_next_page.html.erb +11 -0
  94. data/app/views/wco/kaminari/_page.html.erb +13 -0
  95. data/app/views/wco/kaminari/_paginator.html.erb +25 -0
  96. data/app/views/wco/kaminari/_prev_page.html.erb +11 -0
  97. data/app/views/wco/leads/_form.haml +45 -0
  98. data/app/views/wco/leads/_form_import.haml +11 -0
  99. data/app/views/wco/leads/_header.haml +7 -0
  100. data/app/views/wco/leads/_index.haml +75 -0
  101. data/app/views/wco/leads/_index_rows.haml +11 -0
  102. data/app/views/wco/leads/edit.haml +22 -0
  103. data/app/views/wco/leads/index.haml +7 -0
  104. data/app/views/wco/leads/new.haml +9 -0
  105. data/app/views/wco/leads/show.haml +85 -0
  106. data/app/views/wco/leadsets/_form.haml +28 -0
  107. data/app/views/wco/leadsets/_header.haml +6 -0
  108. data/app/views/wco/leadsets/edit.haml +4 -0
  109. data/app/views/wco/leadsets/index.haml +45 -0
  110. data/app/views/wco/leadsets/index_dataTables.haml +33 -0
  111. data/app/views/wco/leadsets/new.haml +6 -0
  112. data/app/views/wco/leadsets/show.haml +52 -0
  113. data/app/views/wco/logs/_form.haml +17 -0
  114. data/app/views/wco/logs/_header.haml +6 -0
  115. data/app/views/wco/logs/_index.haml +23 -0
  116. data/app/views/wco/logs/edit.haml +6 -0
  117. data/app/views/wco/logs/new.haml +2 -0
  118. data/app/views/wco/office_action_templates/_form.haml +46 -0
  119. data/app/views/wco/office_action_templates/_header.haml +8 -0
  120. data/app/views/wco/office_action_templates/_ties.haml +18 -0
  121. data/app/views/wco/office_action_templates/edit.haml +6 -0
  122. data/app/views/wco/office_action_templates/index.haml +17 -0
  123. data/app/views/wco/office_action_templates/new.haml +5 -0
  124. data/app/views/wco/office_action_templates/show.haml +22 -0
  125. data/app/views/wco/office_actions/_form.haml +22 -0
  126. data/app/views/wco/office_actions/_header.haml +6 -0
  127. data/app/views/wco/office_actions/_index.haml +15 -0
  128. data/app/views/wco/office_actions/edit.haml +5 -0
  129. data/app/views/wco/office_actions/index.haml +10 -0
  130. data/app/views/wco/office_actions/new.haml +4 -0
  131. data/app/views/wco/office_actions/show.haml +5 -0
  132. data/app/views/wco/photos/_form.haml +0 -0
  133. data/app/views/wco/photos/_index_thumbs.haml +7 -0
  134. data/app/views/wco/photos/_meta.haml +7 -0
  135. data/app/views/wco/photos/_meta_manager.haml +7 -0
  136. data/app/views/wco/photos/_multinew.haml +6 -0
  137. data/app/views/wco/photos/index.haml +3 -0
  138. data/app/views/wco/photos/new.haml +0 -0
  139. data/app/views/wco/photos/show.haml +6 -0
  140. data/app/views/wco/photos/without_gallery.haml +11 -0
  141. data/app/views/wco/prices/_form.haml +1 -1
  142. data/app/views/wco/products/_header.haml +6 -0
  143. data/app/views/wco/publishers/_form.haml +28 -0
  144. data/app/views/wco/publishers/_header.haml +6 -0
  145. data/app/views/wco/publishers/edit.haml +4 -0
  146. data/app/views/wco/publishers/index.haml +37 -0
  147. data/app/views/wco/publishers/new.haml +4 -0
  148. data/app/views/wco/reports/_form.haml +28 -0
  149. data/app/views/wco/reports/_header.haml +14 -0
  150. data/app/views/wco/reports/edit.haml +4 -0
  151. data/app/views/wco/reports/index.haml +17 -0
  152. data/app/views/wco/reports/index_table.haml +17 -0
  153. data/app/views/wco/reports/new.haml +4 -0
  154. data/app/views/wco/reports/show.haml +8 -0
  155. data/app/views/wco/sites/_form.haml +21 -0
  156. data/app/views/wco/sites/_header.haml +6 -0
  157. data/app/views/wco/sites/edit.haml +4 -0
  158. data/app/views/wco/sites/index.haml +24 -0
  159. data/app/views/wco/sites/new.haml +4 -0
  160. data/app/views/wco/tags/_form.haml +10 -0
  161. data/app/views/wco/tags/_header.haml +6 -0
  162. data/app/views/wco/tags/_index.haml +10 -0
  163. data/app/views/wco/tags/_index_inline.haml +8 -0
  164. data/app/views/wco/tags/edit.haml +0 -0
  165. data/app/views/wco/tags/index.haml +9 -0
  166. data/app/views/wco/tags/new.haml +0 -0
  167. data/app/views/wco/tags/show.haml +15 -0
  168. data/config/routes.rb +42 -0
  169. data/lib/tasks/db_tasks.rake +13 -0
  170. data/lib/tasks/office_tasks.rake +36 -0
  171. data/lib/tasks/scrape_tasks.rake-trash +22 -0
  172. data/lib/wco/ai_writer.rb +55 -0
  173. data/lib/wco/engine.rb +0 -1
  174. data/lib/wco/office_worker.rb +4 -0
  175. data/lib/wco/scrape_wsj.rb +29 -0
  176. data/lib/wco/scrape_wsj_capy.rb +44 -0
  177. data/lib/wco_models.rb +15 -2
  178. metadata +241 -47
  179. data/app/helpers/ish_models/application_helper.rb +0 -4
  180. data/app/models/wco/premium_tier.rb +0 -13
  181. data/app/models/wco_email/message_template.rb +0 -6
  182. data/lib/tasks/ish_models_tasks.rake +0 -4
  183. /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
@@ -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