wordjelly-auth 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/auth/application.js +1 -1
  3. data/app/controllers/auth/application_controller.rb +6 -0
  4. data/app/controllers/auth/concerns/devise_concern.rb +1 -1
  5. data/app/controllers/auth/concerns/work/communication_controller_concern.rb +82 -0
  6. data/app/controllers/auth/concerns/work/instruction_controller_concern.rb +6 -1
  7. data/app/controllers/auth/endpoints_controller.rb +41 -24
  8. data/app/controllers/auth/images_controller.rb +0 -4
  9. data/app/controllers/auth/profiles_controller.rb +2 -13
  10. data/app/controllers/auth/work/communications_controller.rb +18 -0
  11. data/app/controllers/auth/work/work_controller.rb +43 -0
  12. data/app/jobs/notification_job.rb +17 -0
  13. data/app/mailers/auth/send_mail.rb +15 -0
  14. data/app/models/auth/concerns/chief_model_concern.rb +4 -0
  15. data/app/models/auth/concerns/shopping/product_concern.rb +5 -3
  16. data/app/models/auth/concerns/user_concern.rb +2 -6
  17. data/app/models/auth/endpoint.rb +26 -3
  18. data/app/models/auth/image.rb +5 -0
  19. data/app/models/auth/work/communication.rb +109 -0
  20. data/app/models/auth/work/cycle.rb +8 -14
  21. data/app/models/auth/work/instruction.rb +1 -0
  22. data/app/models/auth/work/minute.rb +75 -52
  23. data/app/views/auth/images/_form.html.erb +1 -1
  24. data/app/views/auth/images/_image_concern.html.erb +3 -3
  25. data/app/views/auth/send_mail/send.html.erb +1 -0
  26. data/app/views/auth/shopping/products/show/_summary.html.erb +12 -0
  27. data/app/views/auth/work/communications/_form.html.erb +57 -0
  28. data/app/views/auth/work/instructions/_form.html.erb +7 -1
  29. data/app/views/auth/work/instructions/_image.html.erb +5 -0
  30. data/app/views/auth/work/instructions/new.html.erb +1 -0
  31. data/app/views/auth/work/instructions/show.html.erb +1 -0
  32. data/app/views/layouts/send_mail.html.erb +5 -0
  33. data/lib/auth/engine.rb +34 -4
  34. data/lib/auth/rails/routes.rb +11 -11
  35. data/lib/auth/version.rb +1 -1
  36. data/spec/dummy/app/assets/javascripts/application.js +0 -2
  37. data/spec/dummy/app/assets/javascripts/images.js +9 -19
  38. data/spec/dummy/app/assets/time_hashes.json +1 -1
  39. data/spec/dummy/app/views/layouts/application.html.erb +0 -1
  40. data/spec/dummy/app/views/new/notification.text.erb +1 -1
  41. data/spec/dummy/app/views/worms/new.html.erb +3 -0
  42. data/spec/dummy/config/cloudinary.yml +6 -6
  43. data/spec/dummy/config/initializers/preinitializer.rb +1 -4
  44. data/spec/models/auth/work/minute_spec.rb +43 -34
  45. data/spec/requests/user/amazon_sns_request_spec.rb +34 -2
  46. data/spec/support/work_support.rb +133 -0
  47. metadata +13 -2
@@ -22,5 +22,6 @@ class Auth::Work::Instruction
22
22
 
23
23
  embeds_many :links, :class_name => "Auth::Work::Link"
24
24
  embeds_many :bullets, :class_name => "Auth::Work::Bullet"
25
+ embeds_many :communications, :class_name => "Auth::Work::Communication", :as => :instruction_communications
25
26
 
26
27
  end
@@ -246,72 +246,95 @@ class Auth::Work::Minute
246
246
 
247
247
 
248
248
 
249
- ## okay first do what can be predictable done.
250
- ## that means the partials in the views.
251
- ## go for it.
252
-
253
- ## match where [cycle is a and cycle is primary] OR [cycle is b and cycle is primary, cycle is c and cycle is primary] present.
254
- ## then unwind the cycles
255
- ## so now we know that all these cycles even if they don't be primary, still belong to a minute with a primary
256
- ## now match only the useful cycles
257
- ## group by minutes
258
- ## add a field that combines the size of the avialable cycles + the distance from now
259
- ## sort by that.
260
- ## @param[Array] cycle_requirements_array : {cycle_id , worker_requirements :{"type" : number}, entity_requirements: {"type" : number}}
249
+
250
+ ## @param[Hash] cycles : {cycle_id => cycle}
261
251
  ## @param[Hash] transport_information : {distance : , coordinates :}
262
252
  ## lets get the edit out of the way first.
263
- def find_applicable_minute(cycle_requirements_array)
264
- ## go to elasticsearch for this ?
265
- ## ?
266
- aggregations = [
267
- {
268
- "cycles" => {
269
- "$elemMatch" => {
253
+ def self.find_applicable_minutes(cycles,transport_information={})
254
+ query_clause = {
255
+ "$match" => {
256
+ "$and" => [
257
+ {
270
258
  "$or" =>
271
- [
259
+ [
272
260
 
273
- ]
274
- }
275
- }
276
- },
277
- {
278
- "$unwind" => "$cycles"
279
- },
280
- {
281
- ## keep all cycles, dont enforce the belongs_to_minute at this level.
282
- ## just cycle_type and workers and entities
283
- ## since we want to include the 30 min rolling slots as well.
284
- ## we are only keeping the cycles which have the required type.
285
- ## and we can match again,
286
- "$match" => {
287
- "cycles.cycle_type" => {
288
- "$in" => "all_the_cycles"
261
+ ]
262
+ },
263
+ {
264
+ "cycles" => {
265
+ "$elemMatch" => {
266
+ "$or" => [
267
+ ]
268
+ }
269
+ }
289
270
  }
290
- }
271
+ ]
291
272
  }
292
- ]
273
+ }
293
274
 
275
+ ## that will be one api out of the way.
276
+ ## next is also medicine.
294
277
 
278
+ ## after this will be the aggregate phase.
295
279
 
296
- cycle_requirements_array.each do |req|
297
- aggregations[0]["cycles"]["$elemMatch"]["$or"] << {
298
- "cycle_type" => req["cycle_type"],
299
- "workers_available.#{req['workers_count'] - 1}" => {
300
- "$exists" => true
301
- },
302
- "entities_available.#{req['entities_count'] - 1}" => {
303
- "$exists" => true
304
- },
305
- "belongs_to_minute" => true
280
+ combined_requirements = {}
281
+ individual_requirements = []
282
+ cycles.keys.each do |cycle_id|
283
+ cycle = cycles[cycle_id]
284
+ cycle_clause = {
285
+ "$and" =>
286
+ [
287
+
288
+ ]
306
289
  }
290
+
291
+ cycle_clause["$and"] << {
292
+ "capacity" => cycle.capacity
293
+ }
294
+
295
+ ## does the cycle have some kind of type ?
296
+ cycle_clause["$and"] << {
297
+ "cycle_type" => cycle.cycle_type
298
+ }
299
+
300
+ query_clause["$match"]["$and"][1]["cycles"]["$elemMatch"]["$or"] << cycle_clause
301
+
302
+
303
+ cycle_clause_for_entity_types = {
304
+
305
+ }
306
+
307
+ cycle.requirements.keys.each do |k|
308
+ combined_requirements[k] = 0 unless combined_requirements[k]
309
+ combined_requirements[k]+= cycle.requirements[k]
310
+ cycle_clause_for_entity_types["entity_types.#{k}"] =
311
+ {
312
+ "$gte" => cycle.requirements[k]
313
+ }
314
+
315
+ end
316
+
317
+
318
+ query_clause["$match"]["$and"][0]["$or"] << cycle_clause_for_entity_types
319
+
307
320
  end
308
321
 
309
- ## we are going to get minutes that have at the minimum one of the cycles as belonging to the given minute.
322
+ =begin
323
+ query_clause = [{
324
+ "$match" => {
325
+ "time" => {
326
+ "$exists" => true
327
+ }
328
+ }
329
+ }]
330
+ =end
331
+ puts "this is the generated query clause => "
332
+ puts JSON.pretty_generate(query_clause)
333
+
334
+
335
+ Auth::Work::Minute.collection.aggregate([query_clause])
310
336
 
311
- ## now we are going to unwind the cycles,
312
- ## keep only those which satisfy these conditions.
313
337
 
314
- ## we take a look at other cycles which will be affected only if that cycle, is not already booked, otherwise it doesnt make any difference at all.
315
338
 
316
339
  end
317
340
 
@@ -4,8 +4,8 @@
4
4
 
5
5
  the parent id and class
6
6
 
7
+ <!-- here we add the recaptcha if it says so in the configuration -->
7
8
 
8
-
9
9
  <%= f.hidden_field :parent_id, :value => @model.parent_id %>
10
10
 
11
11
  <%= f.hidden_field :parent_class, :value => @model.parent_class %>
@@ -1,4 +1,4 @@
1
- <div id="image_id"><%= BSON::ObjectId.new.to_s %></div>
2
- <div id="parent_id"><%= @model.id.to_s %></div>
3
- <div id="parent_class"><%= @model.class.name.to_s %></div>
1
+ <div id="image_id" style="display:none;"><%= BSON::ObjectId.new.to_s %></div>
2
+ <div id="parent_id" style="display:none;"><%= @model.id.to_s %></div>
3
+ <div id="parent_class" style="display:none;"><%= @model.class.name.to_s %></div>
4
4
  <div id="upload_widget_opener"></div>
@@ -0,0 +1 @@
1
+ hi this is the email.
@@ -16,5 +16,17 @@
16
16
  <span class="m-20-left"><%= Auth.configuration.currency %> <%= product.price %>/-</span>
17
17
  </div>
18
18
  </li>
19
+ <li class="collection-item">
20
+ <div>
21
+ <i class="material-icons icon-align green-text">create</i>
22
+ <span class="m-20-left"><%= link_to "Edit Product", edit_product_path(product.id.to_s) %></span>
23
+ </div>
24
+ </li>
25
+ <li class="collection-item">
26
+ <div>
27
+ <i class="material-icons icon-align blue-text">note_add</i>
28
+ <span class="m-20-left"><%= link_to "Add New Instruction", new_instruction_path(:product_id => product.id.to_s) %></span>
29
+ </div>
30
+ </li>
19
31
  </ul>
20
32
  </div>
@@ -0,0 +1,57 @@
1
+ <%= form_for(@auth_work_communication, as: "communication", url: @auth_work_communication.new_record? ? communications_path : communication_path(:id => @auth_work_communication.id.to_s), method: @auth_work_communication.new_record? ? :post : :put) do |f| %>
2
+ <div class="form_fields">
3
+ <div id="email_options">
4
+ <h5>E-Mail Options</h5>
5
+ <%= f.check_box :send_email,{},true,false %>
6
+ <%= f.label :send_email %>
7
+
8
+ <%= f.text_field :email_template_path %>
9
+ <%= f.label :email_template_path %>
10
+ </div>
11
+
12
+ <div class="divider"> </div>
13
+
14
+ <div id="repeat_options">
15
+ <h5>Repeat Options</h5>
16
+ <%= f.select :repeat,@auth_work_communication.repeat_options,{include_blank: true} %>
17
+
18
+ <%= f.number_field :repeat_times %>
19
+ <%= f.label :repeat_times %>
20
+
21
+ <%= f.text_field :method_to_determine_communication_timing %>
22
+ <%= f.label :method_to_determine_communication_timing %>
23
+
24
+ </div>
25
+
26
+ <div class="divider"></div>
27
+
28
+ <div id="general_options">
29
+
30
+ <%= f.text_field :method_to_determine_recipients %>
31
+ <%= f.label :method_to_determine_recipients %>
32
+
33
+
34
+ <% if @auth_work_communication.cycle_id %>
35
+ <%=
36
+ hidden_field_tag :cycle_id, @auth_work_communication.cycle_id.to_s
37
+ %>
38
+ <% end %>
39
+
40
+ <% if @auth_work_communication.instruction_id %>
41
+ <%=
42
+ hidden_field_tag :instruction_id, @auth_work_communication.instruction_id.to_s %>
43
+ %>
44
+ <% end %>
45
+
46
+ </div>
47
+
48
+ </div>
49
+ <div class="actions">
50
+ <%= f.submit %>
51
+ </div>
52
+ <% end %>
53
+
54
+ <!-- now in order to get this to render, first i need to fix instruction -->
55
+ <!-- then will create some product, and inside that have to give buttons to make instructions and also bullets -->
56
+ <!-- so let me first add , the add instruction to the product -->
57
+ <!-- also let me first do the image upload integration also -->
@@ -1,4 +1,4 @@
1
- <%= form_for(@auth_work_instruction, as: "instruction", url: instruction_path, method: :put) do |f| %>
1
+ <%= form_for(@auth_work_instruction, as: "instruction", url: @auth_work_instruction.new_record? ? instructions_path : instruction_path(:id => @auth_work_instruction.id), method: @auth_work_instruction.new_record? ? :post : :put) do |f| %>
2
2
  <div class="form_fields">
3
3
  <%=
4
4
  f.text_field :title
@@ -9,6 +9,12 @@
9
9
  <%=
10
10
  hidden_field_tag :product_id, @auth_shopping_product.id.to_s
11
11
  %>
12
+ <% if @auth_work_instruction.new_record? %>
13
+ <h6>In order to upload images / videos you need to first save this record</h6>
14
+ <% else %>
15
+ <% @model = @auth_work_instruction %>
16
+ <%= render :partial => "auth/images/image_concern.html.erb" %>
17
+ <% end %>
12
18
  </div>
13
19
  <div class="actions">
14
20
  <%= f.submit %>
@@ -0,0 +1,5 @@
1
+ <% if instruction.images.size > 0 %>
2
+ <img src="<%= instruction.images.first.get_url %>" class="circle" height="30px" width="35px" />
3
+ <% else %>
4
+ <img src="/assets/placeholder.png" alt="" class="circle" height="30px" width="35px">
5
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form.html.erb" %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "show", locals: {instruction: @auth_work_instruction, product: @auth_shopping_product} %>
@@ -0,0 +1,5 @@
1
+ <html>
2
+ <body>
3
+ <%= yield %>
4
+ </body>
5
+ </html>
data/lib/auth/engine.rb CHANGED
@@ -84,10 +84,16 @@ module Auth
84
84
  attr_accessor :instruction_controller
85
85
  attr_accessor :bullet_class
86
86
  attr_accessor :bullet_controller
87
+ attr_accessor :communication_class
88
+ attr_accessor :communication_controller
87
89
  ## the class used in the user_concern, to send emails.
88
90
  ## should inherit from Auth::Notifier.
89
91
  ## the class used to send the notification
90
92
  attr_accessor :mailer_class
93
+
94
+ ## the new mailer class being used in Auth::Work::Notification.
95
+ attr_accessor :new_mailer_class
96
+ attr_accessor :mail_from
91
97
 
92
98
  ## the queue adapter for the delayed jobs
93
99
  ## @used in OtpJob
@@ -185,6 +191,9 @@ module Auth
185
191
 
186
192
  attr_accessor :image_class
187
193
  attr_accessor :image_controller
194
+ ## basically does not apply if the user is signed in.
195
+ ## otherwise will apply.
196
+ attr_accessor :protect_image_with_recaptcha
188
197
 
189
198
 
190
199
  #######################################################
@@ -204,6 +213,12 @@ module Auth
204
213
 
205
214
  attr_accessor :endpoint_controller
206
215
 
216
+ attr_accessor :cycle_class
217
+
218
+ attr_accessor :cycle_controller
219
+
220
+
221
+
207
222
  def initialize
208
223
 
209
224
 
@@ -309,8 +324,8 @@ module Auth
309
324
  @notification_class = nil
310
325
  @notification_response_class = nil
311
326
 
312
-
313
-
327
+ @new_mailer_class = "Auth::SendMail"
328
+ @mail_from = "bhargav.r.raut@gmail.com"
314
329
 
315
330
  ###############################################################
316
331
  ##
@@ -319,7 +334,7 @@ module Auth
319
334
  ###############################################################
320
335
  @queue_adapter = "shoryuken"
321
336
 
322
-
337
+ ## command :
323
338
  ####################################################
324
339
  ##
325
340
  ##
@@ -415,7 +430,7 @@ module Auth
415
430
  ########################################################
416
431
  @image_class = "Auth::Image"
417
432
  @image_controller = "auth/images"
418
-
433
+ @protect_image_with_recaptcha = true
419
434
 
420
435
  ########################################################
421
436
  ##
@@ -429,12 +444,27 @@ module Auth
429
444
  ########################################################
430
445
  ##
431
446
  ## ENDPOINT CLASS.
447
+ ## for amazon and aws notifications.
432
448
  ##
433
449
  ########################################################
434
450
  @endpoint_class = "Auth::Endpoint"
435
451
  @endpoint_controller = "auth/endpoints"
436
452
 
437
453
 
454
+ ########################################################
455
+ ##
456
+ ##
457
+ ## WORK CLASSES
458
+ ##
459
+ ##
460
+ ########################################################
461
+ @communication_controller = "auth/work/communications"
462
+ @communication_class = "Auth::Work::Communication"
463
+
464
+ @cycle_controller = "auth/work/cycles"
465
+ @cycle_class = "Auth::Work::Cycle"
466
+
467
+
438
468
  end
439
469
  end
440
470
 
@@ -16,7 +16,7 @@ module ActionDispatch::Routing
16
16
  end
17
17
  end
18
18
 
19
- puts "scope path is: #{scope_path}"
19
+ #puts "scope path is: #{scope_path}"
20
20
  scope_path
21
21
 
22
22
  end
@@ -38,7 +38,7 @@ module ActionDispatch::Routing
38
38
  Auth.configuration.send("#{model}_class").underscore.pluralize.scan(/(?<scope_path>.+?)\/(?<collection>[A-Za-z_]+)$/) do
39
39
  collection = Regexp.last_match[:collection]
40
40
  end
41
- puts "collection is :#{collection}"
41
+ #puts "collection is :#{collection}"
42
42
  collection
43
43
  end
44
44
 
@@ -121,7 +121,10 @@ module ActionDispatch::Routing
121
121
  end
122
122
 
123
123
 
124
- ["cart_item","cart","payment","product","discount","image","bullet","instruction"].each do |model|
124
+ ["cart_item","cart","payment","product","discount","image","bullet","instruction","communication"].each do |model|
125
+
126
+ ## establish a communication controller, model, views and engine constants with defaults.
127
+
125
128
 
126
129
  if Auth.configuration.send("#{model}_controller")
127
130
 
@@ -132,13 +135,7 @@ module ActionDispatch::Routing
132
135
 
133
136
  if collection
134
137
 
135
- ## what about the route for this ?
136
-
137
-
138
-
139
- ## okay so what and how much longer ?
140
- ## probably till night.
141
- ##
138
+
142
139
  if model == "bullet"
143
140
 
144
141
  resources collection.to_sym, controller: controller_name, path: "/auth/work/bullets"
@@ -147,6 +144,9 @@ module ActionDispatch::Routing
147
144
 
148
145
  resources collection.to_sym, controller: controller_name, path: "/auth/work/instructions"
149
146
 
147
+ elsif model == "communication"
148
+
149
+ resources collection.to_sym, controller: controller_name, path: "/auth/work/communications"
150
150
  else
151
151
  scope :path => scope_path, :as => as_prefix do
152
152
 
@@ -228,7 +228,7 @@ module ActionDispatch::Routing
228
228
  common_callback_path = Auth::OmniAuth::Path.common_callback_path(provider)
229
229
 
230
230
  if !Rails.application.routes.url_helpers.method_defined?("#{provider}_omniauth_authorize_path".to_sym)
231
- puts "calling route for provider: #{provider}"
231
+ #puts "calling route for provider: #{provider}"
232
232
  match "#{omniauth_request_path}", controller: omniauth_ctrl, action: "passthru", via: [:get,:post], as: "#{provider}_omniauth_authorize"
233
233
  end
234
234
 
data/lib/auth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Auth
2
- VERSION = "1.1.7"
2
+ VERSION = "1.1.8"
3
3
  end
@@ -14,5 +14,3 @@
14
14
  //= require images
15
15
  //= require_tree .
16
16
 
17
-
18
-
@@ -1,21 +1,3 @@
1
- $(document).ready(function(){
2
-
3
- if($.fn.cloudinary_fileupload !== undefined) {
4
- $("input.cloudinary-fileupload[type=file]").cloudinary_fileupload();
5
- console.log("cloudinary is defined");
6
- }
7
- else{
8
- console.log("cloudinary is undefined");
9
- }
10
-
11
-
12
- $('#upload_widget_opener').cloudinary_upload_widget(
13
- { cloud_name: "doohavoda", api_key:"779116626984783", upload_signature: generateSignature,
14
- public_id: $("#image_id").text()},
15
- function(error, result) { console.log(error, result) });
16
-
17
- });
18
-
19
1
  var generateSignature = function(callback, params_to_sign){
20
2
  params_to_sign["_id"] = $("#image_id").text();
21
3
  params_to_sign["parent_id"] = $("#parent_id").text();
@@ -33,4 +15,12 @@ var generateSignature = function(callback, params_to_sign){
33
15
  callback(signature); },
34
16
  error : function(xhr, status, error) { console.log(xhr, status, error); }
35
17
  });
36
- }
18
+ }
19
+
20
+
21
+ document.addEventListener("turbolinks:load", function() {
22
+ $('#upload_widget_opener').cloudinary_upload_widget(
23
+ { cloud_name: "doohavoda", api_key:"393369625566631", upload_signature: generateSignature,
24
+ public_id: $("#image_id").text()},
25
+ function(error, result) { console.log(error, result) });
26
+ })