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.
Files changed (182) 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 -46
  179. data/app/helpers/ish_models/application_helper.rb +0 -4
  180. data/app/models/wco_email/message_template.rb +0 -6
  181. data/lib/tasks/ish_models_tasks.rake +0 -4
  182. /data/app/views/wco/{application/_alerts_notices.haml → _alerts_notices.haml} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 846e223319833c5b8082e5a4a025e9e19996bd49aa2f12eee713aa703a29f772
4
- data.tar.gz: a76155f4247d01d08d257dc8beff5677de93317d4fb26f713208c42a8f7f3b77
3
+ metadata.gz: dc9798da6c56049e09c45f4ceaf24521cbf168c3b79a53f756739947bdc51d8d
4
+ data.tar.gz: bc6e53e4ea0398992f8c91359ad2b7e28040606cfca1ba5dca811c65b9ea531d
5
5
  SHA512:
6
- metadata.gz: 9dfe93a9ee7efa81bc56d7acd16c1f226f4df418a79c69566abaa7298c73824330a0e38c2e9af7f51c8a9da605401639ef42bcecfd8e9c98726d877704e2de67
7
- data.tar.gz: d35193f9f49ab9a7a5f6abf6d9d4779d1df863b5f3a436dfcdfcc88a17985a9d2e8ae0f081da178e39dd9dc54b6e5b590038d842e13f09b8f8a29d3ada88250f
6
+ metadata.gz: cd8a42cdfa341ee867beeaaf81d37d190a91416feb6eb6f00b400a2e46bb2a2513a101c92e973e5c4b54ef2c57c747bddf740ca01498986701771bfb6286c9fc
7
+ data.tar.gz: f8b3d4a13c9a9a03fa61a572ddc4b351784c72f3c407803f80582fc43fa252e416bd9c7f5d98960b05cd18ac816709e058c9b983914a2c195c3712a55a432200
data/Rakefile CHANGED
@@ -1,15 +1,5 @@
1
- require "bundler/setup"
2
1
 
3
- load "rails/tasks/statistics.rake"
2
+ require_relative 'test/dummy/config/application'
4
3
 
5
- require "bundler/gem_tasks"
6
-
7
- require "rake/testtask"
8
-
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'test'
11
- t.pattern = 'test/**/*_test.rb'
12
- t.verbose = false
13
- end
14
-
15
- task default: :test
4
+ # Rails.application.initialize!
5
+ Rails.application.load_tasks
@@ -1,4 +1,6 @@
1
1
  //
2
+ //= link wco_models/application.css
2
3
  //= link_directory ../stylesheets/wco_models .css
3
4
  //
5
+
4
6
  console.log('Loaded wco_models/wco_models_manifest.js')
@@ -1,10 +1,48 @@
1
1
  //
2
- //= require vendor/test
3
- //= require vendor/jquery-3.3.1.min
4
- //= require vendor/popper-1.14.0.min
5
- //= require vendor/bootstrap-4.6.2.min
6
- //= require vendor/fontawesome-5.15.4.min
2
+ //= require rails-ujs
3
+ //
4
+ // // this was loaded twice causing issues - disabled for now.
5
+ // require vendor/test
6
+ // require vendor/jquery-3.3.1.min
7
+ // require vendor/popper-1.14.0.min
8
+ // require vendor/bootstrap-4.6.2.min
9
+ // require vendor/fontawesome-5.15.4.min
10
+ //
11
+ //= require vendor/jquery.iframe-transport
12
+ //= require vendor/jquery.ui.widget
13
+ //= require vendor/jquery.fileupload
14
+ //= require vendor/jquery-ui.min
7
15
  //
8
16
  //= require ./collapse-expand
17
+ //= require ./file_upload
18
+ //= require ./shared
9
19
  //
10
20
  console.log('Loaded wco/application.js')
21
+
22
+ $(function() {
23
+
24
+ if (!!$('body').select2) {
25
+ $('.select2').each(function() {
26
+ $( this ).select2({
27
+ width: '100%',
28
+ })
29
+ })
30
+ }
31
+
32
+ $('select[name="office_action_template[from_type]"]').on('change', (ev) => {
33
+ logg(ev.target.value, 'changed')
34
+
35
+ // let url = window.location.href;
36
+ // if (url.indexOf('?') > -1){
37
+ // url += `&from_type=${ev.target.value}`
38
+ // } else {
39
+ // url += `?from_type=${ev.target.value}`
40
+ // }
41
+ // window.location.href = url;
42
+
43
+ const parser = new URL(window.location);
44
+ parser.searchParams.set('from_type', ev.target.value);
45
+ window.location = parser.href;
46
+ })
47
+
48
+ }); // END
@@ -1,6 +1,7 @@
1
1
 
2
2
 
3
3
  $(function () {
4
+
4
5
  console.log('Loaded wco/collapse-expand.js')
5
6
 
6
7
  $(".collapse-expand").each(function() {
@@ -0,0 +1,32 @@
1
+
2
+ $(function () {
3
+
4
+ var fileuploadCount = 0
5
+ $('#fileupload').fileupload({
6
+ dataType: 'json',
7
+ success: function(ev) {
8
+ logg(ev, 'success')
9
+ ev = ev[0]
10
+ fileuploadCount += 1
11
+ var el = $('<div class="item" />')
12
+ var photosEl = $('#photos')
13
+ $('<div/>').html(fileuploadCount).appendTo(el)
14
+ $('<img/>').attr('src', ev.thumbnail_url).appendTo(el)
15
+ $('<div/>').html(ev.name).appendTo(el)
16
+ el.appendTo(photosEl)
17
+ },
18
+ error: function(err) {
19
+ logg(err, 'error')
20
+ err = err.responseJSON
21
+ fileuploadCount += 1
22
+ var el = $('<div class="item" />')
23
+ var errorsEl = $('.photos--multinew .errors')
24
+ $('<div/>').html(fileuploadCount).appendTo(el)
25
+ $('<div />').html(err.filename).appendTo(el)
26
+ $('<div />').html(err.message).appendTo(el)
27
+ el.appendTo(errorsEl)
28
+ },
29
+ });
30
+
31
+
32
+ })(); // END
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * Usage: logg(someObject, 'label')
4
+ *
5
+ * This development-grade logger can be used instead of console.log() with some advantages:
6
+ * * It encourages consistent labeling of logs. By labeling each log line, you can have dozens of log lines
7
+ * written per action, and still know which log line comes from where.
8
+ * The recommended label is the component name, or function name.
9
+ * * If the label is present, the logged object is placed in the window, allowing you to inspect it in the console. The
10
+ * label becomes the name of the object (stripped to [0-9a-zA-Z\-_] chars). If you're logging a function, you can execute it.
11
+ * If you log more than one thing, they can interact, allowing you to validate control flow.
12
+ * * the logger can be turned off by making this function simply return.
13
+ **/
14
+ function logg (a, b="", c=null) {
15
+ c = "string" === typeof c ? c : b.replace(/\W/g, "");
16
+ if (c.length > 0) {
17
+ window[c] = a;
18
+ }
19
+
20
+ console.log(`+++ ${b}:`, a); // eslint-disable-line no-console
21
+ };
22
+
@@ -5,16 +5,31 @@
5
5
  *= require_self
6
6
  **/
7
7
 
8
- /* body {
9
- &:before {
10
- content: 'wco_models/application.css';
11
- color: red;
8
+ .select2 {
9
+ min-width: 200px;
10
+ width: 100%;
11
+ }
12
+
13
+ .wco--alerts-notices {
14
+ border-bottom: 1px solid red;
15
+ }
16
+
17
+ .main-footer {
18
+ border-top: 1px solid red;
19
+ }
20
+
21
+ .main-header {
22
+ // border-bottom: 1px solid red;
23
+
24
+ li {
25
+ display: flex;
26
+
27
+ input[name='q'] {
28
+ width: 20px;
29
+ }
12
30
  }
13
- } */
31
+ }
14
32
 
15
- /* body {
16
- color: red;
17
- } */
18
33
 
19
34
  /* .min-w-100px {
20
35
  min-width: 100px;
@@ -17,7 +17,19 @@ textarea {
17
17
  }
18
18
 
19
19
  /* B */
20
+
21
+ .blue {
22
+ color: blue;
23
+ }
24
+
25
+ .border-right {
26
+ border-right: 1px solid red !important;
27
+ }
28
+
20
29
  table.bordered {
30
+ table-layout:fixed;
31
+ width: 100%;
32
+ word-wrap: break-word;
21
33
 
22
34
  border: 1px solid gray;
23
35
  border-bottom: 0;
@@ -32,36 +44,80 @@ table.bordered {
32
44
  border-top: 0;
33
45
  border-left: 0;
34
46
  }
35
-
47
+ .latest-at {
48
+ width: 100px;
49
+ }
50
+ .froms,
51
+ .leads {
52
+ width: 200px;
53
+ }
36
54
  }
37
55
 
38
56
  /* C */
39
57
 
40
58
  .code,
59
+ .mono,
41
60
  .monospace {
42
61
  font-family: monospace;
43
62
  font-size: 0.8em;
44
63
  }
64
+ textarea.monospace {
65
+ padding: 0.6em;
66
+ }
67
+
68
+
69
+ /* D */
70
+
71
+ .descr {
72
+ border: 1px solid red;
73
+ padding: 0.5em;
74
+ }
45
75
 
76
+ /* E */
77
+
78
+ .eg {
79
+ color: gray;
80
+ font-size: 0.8em;
81
+ }
46
82
 
47
83
  /* F */
84
+
48
85
  .flex-row {
49
86
  display: flex;
50
87
  }
88
+ .field_with_errors {
89
+ flex-grow: 1;
90
+ }
51
91
 
52
92
  /* G */
93
+
53
94
  .gray,
54
95
  .grey {
55
96
  color: grey;
56
97
  }
57
98
 
99
+ .green {
100
+ color: green;
101
+ }
102
+
103
+ /* H */
104
+ h5.title {
105
+ display: flex;
106
+ }
107
+
58
108
  /* M */
109
+
59
110
  .maxwidth {
60
111
  max-width: 1000px;
61
112
  margin: auto;
62
113
  }
63
114
 
115
+ .mini {
116
+ font-size: 0.8em;
117
+ }
118
+
64
119
  /* P */
120
+
65
121
  .padded {
66
122
  margin: 0.5em;
67
123
  }
@@ -1,5 +1,10 @@
1
1
 
2
2
  class Wco::ApplicationController < ActionController::Base
3
+ include Wco::ApplicationHelper
4
+
5
+ check_authorization
6
+
7
+ before_action :current_profile
3
8
 
4
9
  def home
5
10
  end
@@ -41,4 +46,8 @@ class Wco::ApplicationController < ActionController::Base
41
46
  flash[:notice] << str
42
47
  end
43
48
 
49
+ def my_truthy? which
50
+ ["1", "t", "T", "true"].include?( which )
51
+ end
52
+
44
53
  end
@@ -0,0 +1,143 @@
1
+
2
+ class Wco::GalleriesController < Wco::ApplicationController
3
+
4
+ # before_action :set_lists
5
+ before_action :set_gallery, only: %w| destroy edit j_show show update update_ordering |
6
+
7
+ # Alphabetized! : )
8
+
9
+ def create
10
+ # params[:gallery][:shared_profiles] ||= []
11
+ # params[:gallery][:shared_profiles].delete('')
12
+ # params[:gallery][:shared_profiles] = Wco::Profile.find params[:gallery][:shared_profiles]
13
+
14
+ @gallery = Wco::Gallery.new params[:gallery].permit!
15
+ # @gallery.user_profile = @current_profile
16
+ authorize! :create, @gallery
17
+
18
+ if @gallery.save
19
+ # Wco::GalleriesMailer.shared_galleries( params[:gallery][:shared_profiles], @gallery ).deliver
20
+ flash[:notice] = 'Success'
21
+ redirect_to edit_gallery_path(@gallery)
22
+ else
23
+ puts! @gallery.errors.messages
24
+ flash[:alert] = "Cannot create the gallery: #{@gallery.errors.full_messages.join(', ')}"
25
+ render :action => 'new'
26
+ end
27
+ end
28
+
29
+ def destroy
30
+ authorize! :destroy, @gallery
31
+ @gallery.delete
32
+ flash[:notice] = 'Marked the gallery deleted.'
33
+ redirect_to( request.referrer || galleries_path )
34
+ end
35
+
36
+ def edit
37
+ authorize! :edit, @gallery
38
+ end
39
+
40
+ def index
41
+ authorize! :index, Wco::Gallery
42
+ @page_title = 'Galleries'
43
+ @galleries = Wco::Gallery.all.order_by( :created_at => :desc )
44
+
45
+ if params[:q]
46
+ q = URI.decode(params[:q])
47
+ @galleries = @galleries.where({ :name => /#{q}/i })
48
+ end
49
+
50
+ @galleries = @galleries.page( params[:galleries_page] ).per( current_profile.per_page )
51
+
52
+ render "_index"
53
+ end
54
+
55
+ def j_show
56
+ authorize! :show, @gallery
57
+ respond_to do |format|
58
+ format.json do
59
+ jjj = {}
60
+ jjj[:photos] = @gallery.photos.map do |ph|
61
+ { :thumbnail_url => ph.photo.url( :thumb ),
62
+ :delete_type => 'DELETE',
63
+ :delete_url => photo_path(ph) }
64
+ end
65
+ render :json => jjj
66
+ end
67
+ end
68
+ end
69
+
70
+ def new
71
+ @gallery = Wco::Gallery.new
72
+ @page_title = 'New Gallery'
73
+ authorize! :new, @gallery
74
+ end
75
+
76
+ def shared_with_me
77
+ authorize! :index, Wco::Gallery
78
+ @page_title = 'Galleries Shared With Me'
79
+ @galleries = @current_profile.shared_galleries.unscoped.where( :is_trash => false
80
+ ).order_by( :created_at => :desc
81
+ ).page( params[:shared_galleries_page] ).per( 10 )
82
+ render params[:render_type]
83
+ end
84
+
85
+ def show
86
+ authorize! :show, @gallery
87
+ @photos = @gallery.photos.unscoped.where({ :is_trash => false }).order_by( ordering: :asc )
88
+ @deleted_photos = @gallery.photos.unscoped.where({ :is_trash => true }).order_by( ordering: :asc )
89
+ end
90
+
91
+ def update_ordering
92
+ authorize! :update, @gallery
93
+ out = []
94
+ params[:gallery][:sorted_photo_ids].each_with_index do |id, idx|
95
+ out.push Photo.find( id ).update_attribute( :ordering, idx )
96
+ end
97
+ flash[:notice] = "Outcomes: #{out}."
98
+ redirect_to action: 'show', id: @gallery.id
99
+ end
100
+
101
+ def update
102
+ authorize! :update, @gallery
103
+
104
+ old_shared_profile_ids = @gallery.shared_profiles.map(&:id)
105
+ if params[:gallery][:shared_profiles].present?
106
+ params[:gallery][:shared_profiles].delete('')
107
+ end
108
+ params[:gallery][:shared_profile_ids] = params[:gallery][:shared_profiles]
109
+ params[:gallery].delete :shared_profiles
110
+
111
+ flag = @gallery.update_attributes( params[:gallery].permit! )
112
+ if flag
113
+ if params[:gallery][:shared_profile_ids].present?
114
+ new_shared_profiles = Wco::Profile.find( params[:gallery][:shared_profile_ids]
115
+ ).select { |p| !old_shared_profile_ids.include?( p.id ) }
116
+ Wco::GalleriesMailer.shared_galleries( new_shared_profiles, @gallery ).deliver
117
+ end
118
+ flash[:notice] = 'Success.'
119
+ redirect_to edit_gallery_path(@gallery)
120
+ else
121
+ puts! @gallery.errors.messages, 'cannot save gallery'
122
+ flash[:alert] = 'No Luck. ' + @gallery.errors.messages.to_s
123
+ render :action => :edit
124
+ end
125
+ end
126
+
127
+ ##
128
+ ## private
129
+ ##
130
+ private
131
+
132
+ def set_gallery
133
+ begin
134
+ @gallery = Wco::Gallery.unscoped.find_by :slug => params[:id]
135
+ rescue
136
+ @gallery = Wco::Gallery.unscoped.find params[:id]
137
+ end
138
+ @page_title = "#{@gallery.name} Gallery"
139
+ @page_description = @gallery.subhead
140
+ end
141
+
142
+ end
143
+
@@ -0,0 +1,71 @@
1
+
2
+ class Wco::HeadlinesController < Wco::ApplicationController
3
+
4
+ before_action :set_lists
5
+
6
+ def create
7
+ params[:headline][:tag_ids].delete ''
8
+
9
+ @headline = Wco::Headline.new( params[:headline].permit! )
10
+ authorize! :create, @headline
11
+
12
+ @headline.date = Time.now.to_date
13
+
14
+ if @headline.save
15
+ flash_notice @headline
16
+ else
17
+ flash_alert @headline
18
+ end
19
+ redirect_to action: :index
20
+ end
21
+
22
+ def destroy
23
+ @headline = Wco::Headline.find params[:id]
24
+ authorize! :delete, @headline
25
+ @headline.delete
26
+ flash_notice "Probably ok"
27
+ redirect_to action: :index
28
+ end
29
+
30
+ def new
31
+ authorize! :new, Wco::Headline
32
+ end
33
+
34
+ def edit
35
+ @headline = Wco::Headline.find params[:id]
36
+ authorize! :edit, @headline
37
+ end
38
+
39
+ def index
40
+ @headlines = Wco::Headline.all
41
+ authorize! :index, Wco::Headline
42
+ render '_index'
43
+ end
44
+
45
+ def update
46
+ @headline = Wco::Headline.find params[:id]
47
+ authorize! :update, @headline
48
+
49
+ params[:headline][:tag_ids].delete ''
50
+
51
+ if @headline.update params[:headline].permit!
52
+ flash_notice @headline
53
+ else
54
+ flash_alert @headline
55
+ end
56
+ redirect_to action: :index
57
+ end
58
+
59
+ ##
60
+ ## private
61
+ ##
62
+ private
63
+
64
+ def set_lists
65
+ @sites_list = Wco::Site.list
66
+ @tags_list = Wco::Tag.list
67
+ end
68
+
69
+
70
+ end
71
+
@@ -0,0 +1,59 @@
1
+
2
+ class Wco::LeadsController < Wco::ApplicationController
3
+
4
+ before_action :set_lists
5
+
6
+ def index
7
+ authorize! :index, Wco::Lead
8
+ @leads = Wco::Lead.all
9
+
10
+ # if params[:q].present?
11
+ # @leads = @leads.where(" email LIKE ? or name LIKE ? ", "%#{params[:q]}%", "%#{params[:q]}%" )
12
+ # end
13
+
14
+ # if params[:q_tag_ids].present?
15
+ # carry = nil
16
+ # params[:q_tag_ids].each do |term_id|
17
+ # lts = LeadTag.where({ term_id: term_id }).map(&:lead_id)
18
+ # if carry
19
+ # carry = carry & lts
20
+ # else
21
+ # carry = lts
22
+ # end
23
+ # end
24
+ # @leads = Lead.where({ :id.in => carry })
25
+ # end
26
+
27
+ @leads = @leads.page( params[:leads_page ] ).per( current_profile.per_page )
28
+ end
29
+
30
+ def show
31
+ @lead = Wco::Lead.where({ id: params[:id] }).first
32
+ @lead ||= Wco::Lead.where({ email: params[:id] }).first
33
+ if !@lead
34
+ flash_alert "This lead does not exist"
35
+ redirect_to request.referrer
36
+ return
37
+ end
38
+ authorize! :show, @lead
39
+ # @schs = Sch.where( lead_id: @lead.id )
40
+ # @ctxs = Ctx.where( lead_id: @lead.id )
41
+ # @convs = Conv.find( Office::EmailConversationLead.where( lead_id: @lead.id ).map( &:email_conversation_id ) )
42
+ # @msgs = Msg.where( from: @lead.email )
43
+ # @galleries = @lead.galleries.page( params[:galleries_page] ).per( current_profile.per_page )
44
+ # @videos = @lead.videos.page( params[:videos_page] ).per( current_profile.per_page )
45
+ end
46
+
47
+ ##
48
+ ## private
49
+ ##
50
+ private
51
+
52
+ def set_lists
53
+ @email_campaigns_list = [[nil,nil]] + WcoEmail::Campaign.all.map { |c| [ c.slug, c.id ] }
54
+ @tags_list = Wco::Tag.list
55
+ end
56
+
57
+
58
+ end
59
+
@@ -0,0 +1,90 @@
1
+
2
+ Leadset = Wco::Leadset
3
+
4
+ class Wco::LeadsetsController < Wco::ApplicationController
5
+
6
+ before_action :set_lists
7
+
8
+ ## alphabetized : )
9
+
10
+ def create
11
+ @leadset = Leadset.new params[:leadset].permit!
12
+ authorize! :create, @leadset
13
+ if @leadset.save
14
+ flash[:notice] = "created leadset"
15
+ else
16
+ flash[:alert] = "Cannot create leadset: #{@leadset.errors.messages}"
17
+ end
18
+ redirect_to :action => 'index'
19
+ end
20
+
21
+ def destroy
22
+ leadsets = Leadset.find( params[:leadset_ids] )
23
+ @results = []
24
+ leadsets.each do |leadset|
25
+ @results.push leadset.discard
26
+ end
27
+ flash[:notice] = "Discard outcome: #{@results.inspect}."
28
+ redirect_to action: 'index'
29
+ end
30
+
31
+ def edit
32
+ @leadset = Leadset.find params[:id]
33
+ authorize! :edit, @leadset
34
+ end
35
+
36
+ def index
37
+ authorize! :index, Leadset
38
+ @leadsets = Leadset.all.includes(:leads)
39
+ if params[:q].present?
40
+ @leadsets = @leadsets.where(" company_url LIKE ? ", "%#{params[:q]}%" )
41
+ if @leadsets.length == 1
42
+ return redirect_to action: :show, id: @leadsets[0][:id]
43
+ end
44
+ end
45
+ @leadsets = @leadsets.page( params[:leadsets_page] ).per( current_profile.per_page )
46
+ end
47
+
48
+ def new
49
+ @new_leadset = Leadset.new
50
+ authorize! :new, @new_leadset
51
+ end
52
+
53
+ def show
54
+ @leadset = Leadset.find params[:id]
55
+ authorize! :show, @leadset
56
+
57
+ @email_contexts = {}
58
+ @leadset.leads.each do |lead|
59
+ @email_contexts[lead.email] = lead.email_contexts
60
+ end
61
+
62
+ @leads = @leadset.leads.page( params[:leads_page] ).per( current_profile.per_page )
63
+ @subscriptions = @leadset.subscriptions
64
+ @invoices = @leadset.invoices
65
+ end
66
+
67
+ def update
68
+ @leadset = Leadset.find params[:id]
69
+ authorize! :update, @leadset
70
+ if @leadset.update_attributes params[:leadset].permit!
71
+ flash[:notice] = 'Successfully updated leadset.'
72
+ else
73
+ flash[:alert] = "Cannot update leadset: #{@leadset.errors.messages}"
74
+ end
75
+ redirect_to :action => 'show', id: @leadset.id
76
+ end
77
+
78
+ ##
79
+ ## private
80
+ ##
81
+ private
82
+
83
+ def set_lists
84
+ @tags_list = Wco::Tag.list
85
+ @leads_list = Wco::Lead.all.map { |lead| [ lead.email, lead.id ] }
86
+ @templates_list = WcoEmail::EmailTemplate.all.map { |t| [ t.slug, t.id ] }
87
+ @email_campaigns_list = WcoEmail::Campaign.list
88
+ end
89
+
90
+ end