kirgudu_base 0.0.23 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/kirgudu_base/application_controller.rb +775 -766
- data/app/controllers/kirgudu_base/security/authentications_controller.rb +389 -390
- data/app/views/kirgudu_base/admin/medialoot/layouts/application.html.erb +3 -3
- data/app/views/kirgudu_base/admin/zapanel/layouts/application.html.erb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ada44845151cb638bdff9d72359de28fc3ef4212
|
4
|
+
data.tar.gz: 682f789c5de778ee0a5c3f8e45345879f0cdc2ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88926b030fd37398d89863be78837000b23fe027ccdf379c702ab778f4612937b0ca91c90b095287d0886c1c12460faa6e446cb9832d4669228810ff1572e265
|
7
|
+
data.tar.gz: c6397005b78fa7c681abe004b8a8a48de1cbf61cb60bead76c66279be33ee9037ed4fedc84d83b0dc4c6a8d31a6d6a89106620792922dabb0a733b0dbbaaf1e8
|
@@ -1,804 +1,813 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
module KirguduBase
|
3
|
-
|
3
|
+
class ApplicationController < ActionController::Base
|
4
4
|
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
########################################################################################
|
7
|
+
############################## Extending Controller ####################################
|
8
|
+
########################################################################################
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
# DynamicPages Helper
|
11
|
+
extend ::KirguduBase::Controllers::DynamicPages::Class
|
12
|
+
include ::KirguduBase::Controllers::DynamicPages::Instance
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
# DynamicTransactions Helper
|
15
|
+
extend ::KirguduBase::Controllers::DynamicTransactions
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
# ObligatoryFilters Helper
|
18
|
+
extend ::KirguduBase::Controllers::ObligatoryFilters
|
19
19
|
|
20
20
|
|
21
|
+
include ::KirguduBase::UrlHelper
|
22
|
+
include ::KirguduBase::BreadcrumbsHelper
|
23
|
+
include ::KirguduBase::ApplicationHelper
|
21
24
|
|
22
|
-
include ::KirguduBase::UrlHelper
|
23
|
-
include ::KirguduBase::BreadcrumbsHelper
|
24
|
-
include ::KirguduBase::ApplicationHelper
|
25
25
|
|
26
|
+
########################################################################################
|
27
|
+
######################### Before&After Actions ###############################
|
28
|
+
########################################################################################
|
26
29
|
|
27
|
-
########################################################################################
|
28
|
-
######################### Before&After Actions ###############################
|
29
|
-
########################################################################################
|
30
30
|
|
31
|
+
before_action :request_started # first filter of request
|
32
|
+
before_action :initialize_global_variables
|
31
33
|
|
32
|
-
before_action :request_started # first filter of request
|
33
|
-
before_action :initialize_global_variables
|
34
34
|
|
35
|
+
after_action :request_finished # last filter of request
|
35
36
|
|
36
|
-
|
37
|
+
########################################################################################
|
38
|
+
############################## Views Paths ###################################
|
39
|
+
########################################################################################
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
# template path
|
42
|
+
kb_template_path "kirgudu_base/admin/zapanel"
|
43
|
+
# layout view pathes
|
44
|
+
kb_views_paths_layout "layouts/application"
|
45
|
+
# action views pathes
|
46
|
+
kb_views_paths_dashboard "common/dashboard"
|
47
|
+
kb_views_paths_index "common/index"
|
48
|
+
kb_views_paths_new "common/new"
|
49
|
+
kb_views_paths_edit "common/edit"
|
50
|
+
kb_views_paths_delete "common/delete"
|
51
|
+
kb_views_paths_show "common/show"
|
52
|
+
kb_views_paths_management "/common/management"
|
53
|
+
kb_views_paths_sorting "/common/sorting"
|
54
|
+
# common views pathes
|
55
|
+
kb_views_paths_entry_not_found "shared/entry_not_found"
|
56
|
+
kb_views_paths_404_page "shared/page_404"
|
41
57
|
|
42
|
-
# template path
|
43
|
-
kb_template_path "kirgudu_base/admin/zapanel"
|
44
|
-
# layout view pathes
|
45
|
-
kb_views_paths_layout "layouts/application"
|
46
|
-
# action views pathes
|
47
|
-
kb_views_paths_dashboard "common/dashboard"
|
48
|
-
kb_views_paths_index "common/index"
|
49
|
-
kb_views_paths_new "common/new"
|
50
|
-
kb_views_paths_edit "common/edit"
|
51
|
-
kb_views_paths_delete "common/delete"
|
52
|
-
kb_views_paths_show "common/show"
|
53
|
-
kb_views_paths_management "/common/management"
|
54
|
-
kb_views_paths_sorting "/common/sorting"
|
55
|
-
# common views pathes
|
56
|
-
kb_views_paths_entry_not_found "shared/entry_not_found"
|
57
|
-
kb_views_paths_404_page "shared/page_404"
|
58
58
|
|
59
|
+
def page_for_default_redirection_after_login
|
59
60
|
|
61
|
+
end
|
60
62
|
|
61
63
|
|
64
|
+
def set_content_type
|
65
|
+
content_type = case params[:format]
|
66
|
+
when "json"
|
67
|
+
"application/json"
|
68
|
+
when "xml"
|
69
|
+
"text/xml"
|
70
|
+
end
|
71
|
+
self.headers["Content-Type"] = content_type if content_type
|
72
|
+
end
|
62
73
|
|
63
74
|
|
75
|
+
def entry_class
|
76
|
+
self.class.get_kb_entry_class
|
77
|
+
end
|
64
78
|
|
65
|
-
def page_for_default_redirection_after_login
|
66
79
|
|
67
|
-
|
80
|
+
#########################################################################################################################
|
81
|
+
###################################### Breadcrumbs ###############################################
|
82
|
+
#########################################################################################################################
|
68
83
|
|
69
84
|
|
70
|
-
|
71
|
-
|
72
|
-
when "json"
|
73
|
-
"application/json"
|
74
|
-
when "xml"
|
75
|
-
"text/xml"
|
76
|
-
end
|
77
|
-
self.headers["Content-Type"] = content_type if content_type
|
78
|
-
end
|
85
|
+
def render *args
|
86
|
+
self.render_breadcrumbs
|
79
87
|
|
88
|
+
#raise "BreadCrumbs: #{self.create_breadcrumbs}"
|
80
89
|
|
90
|
+
super
|
91
|
+
end
|
81
92
|
|
82
|
-
def entry_class
|
83
|
-
self.class.get_kb_entry_class
|
84
|
-
end
|
85
93
|
|
94
|
+
def render_breadcrumbs
|
95
|
+
#if self.class.respond_to?(:dashboard_controller_class_name)
|
96
|
+
# if self.class.to_s == self.class.dashboard_controller_class_name.to_s
|
97
|
+
# add_new_breadcrumb(I18n.t("#{self.class.dashboard_controller_class_name.to_i18n}.index.title"))
|
98
|
+
# else
|
99
|
+
# add_new_breadcrumb(I18n.t("#{self.class.dashboard_controller_class_name.to_i18n}.index.title"), self.class.dashboard_controller_class_name.to_route_path)
|
100
|
+
# end
|
101
|
+
#end
|
102
|
+
end
|
86
103
|
|
104
|
+
def add_new_breadcrumb(label, path = nil)
|
105
|
+
self.kb_breadcrumbs << {label: label, url: path}
|
106
|
+
end
|
87
107
|
|
88
108
|
|
109
|
+
def prepare_breadcrumbs
|
110
|
+
#string_logger.info("BREADCRUMBS: #{breadcrumbs}")
|
111
|
+
end
|
89
112
|
|
90
|
-
|
91
|
-
|
92
|
-
|
113
|
+
def kb_breadcrumbs
|
114
|
+
@kb_breadcrumbs ||= []
|
115
|
+
end
|
93
116
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
#
|
672
|
-
#
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
#
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
#
|
707
|
-
#
|
708
|
-
#
|
709
|
-
|
710
|
-
#
|
711
|
-
#
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
#
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
def debugger_after_action
|
792
|
-
|
793
|
-
end
|
794
|
-
|
795
|
-
|
796
|
-
def request_started
|
797
|
-
|
798
|
-
end
|
799
|
-
|
800
|
-
def request_finished
|
801
|
-
|
802
|
-
end
|
803
|
-
end
|
117
|
+
def breadcrumbs_length
|
118
|
+
self.kb_breadcrumbs.length
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
#########################################################################################################################
|
123
|
+
############################# I18n String Generator Methods #####################################
|
124
|
+
#########################################################################################################################
|
125
|
+
|
126
|
+
def self.to_i18n
|
127
|
+
::ChupakabraTools::ClassHelper.controller_class_to_i18n(self)
|
128
|
+
end
|
129
|
+
|
130
|
+
def to_i18n
|
131
|
+
self.class.to_i18n
|
132
|
+
end
|
133
|
+
|
134
|
+
#########################################################################################################################
|
135
|
+
############################### Routes Generator Methods ########################################
|
136
|
+
#########################################################################################################################
|
137
|
+
|
138
|
+
def self.to_route_path
|
139
|
+
::ChupakabraTools::ClassHelper.controller_full_path_underscore(self)
|
140
|
+
end
|
141
|
+
|
142
|
+
def to_route_path
|
143
|
+
self.class.to_route_path
|
144
|
+
end
|
145
|
+
|
146
|
+
#########################################################################################################################
|
147
|
+
############################### Routes Generator Methods ########################################
|
148
|
+
#########################################################################################################################
|
149
|
+
|
150
|
+
def self.to_url_for(action, options = {})
|
151
|
+
options ||= {}
|
152
|
+
options.merge!(
|
153
|
+
only_path: true,
|
154
|
+
controller: self.to_route_path,
|
155
|
+
action: action
|
156
|
+
)
|
157
|
+
Rails.application.routes.url_helpers.url_for(options)
|
158
|
+
end
|
159
|
+
|
160
|
+
def to_url_for(action = nil, options = {})
|
161
|
+
self.class.to_url_for(action, options)
|
162
|
+
end
|
163
|
+
|
164
|
+
#########################################################################################################################
|
165
|
+
#################################### Routes Injection ############################################
|
166
|
+
#########################################################################################################################
|
167
|
+
|
168
|
+
|
169
|
+
#########################################################################################################################
|
170
|
+
##################################### Strong Parameters ###########################################
|
171
|
+
#########################################################################################################################
|
172
|
+
|
173
|
+
|
174
|
+
def class_strong_params(form)
|
175
|
+
prms = []
|
176
|
+
if form.properties
|
177
|
+
form.properties.each_pair do |key, property|
|
178
|
+
unless property.read_only == :true
|
179
|
+
prms << property.name
|
180
|
+
end
|
181
|
+
end
|
182
|
+
elsif form.elements
|
183
|
+
form.elements.each do |element|
|
184
|
+
if element.is_a?(::KiruguduBase::DynamicPages::FormProperty)
|
185
|
+
unless element.read_only == :true
|
186
|
+
prms << element.name
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
#raise "#{self.entry_class.for_form_params}"
|
193
|
+
#raise "#{prms.to_s}"
|
194
|
+
params.require(self.entry_class.for_form_params).permit(prms)
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
#########################################################################################################################
|
199
|
+
################################### Filters #########################################
|
200
|
+
#########################################################################################################################
|
201
|
+
|
202
|
+
def get_filters_for_list(list, source)
|
203
|
+
result = {}
|
204
|
+
if list
|
205
|
+
list.filters.each do |filter|
|
206
|
+
source_value = source[filter.name]
|
207
|
+
if [:autocomplete, :autocomplete_with_id, :text_edit, :select, :chosen_select].include?(filter.input_type)
|
208
|
+
if source_value
|
209
|
+
source_value.strip!
|
210
|
+
source_value = nil if source_value.blank?
|
211
|
+
end
|
212
|
+
end
|
213
|
+
result[filter.name] = source_value if source_value
|
214
|
+
end if list.filters
|
215
|
+
|
216
|
+
result[:page] = source[:page].to_i rescue nil
|
217
|
+
result[:per_page] = source[:per_page] rescue nil
|
218
|
+
end
|
219
|
+
result
|
220
|
+
end
|
221
|
+
|
222
|
+
|
223
|
+
#########################################################################################################################
|
224
|
+
################################## Class Hierarchy Methods ########################################
|
225
|
+
#########################################################################################################################
|
226
|
+
|
227
|
+
def get_class_hierarchy
|
228
|
+
self.class.get_class_hierarchy
|
229
|
+
end
|
230
|
+
|
231
|
+
def self.get_class_hierarchy
|
232
|
+
::ChupakabraTools::ClassHelper.get_controller_hierarchy(self)
|
233
|
+
end
|
234
|
+
|
235
|
+
def get_class_variable(name)
|
236
|
+
self.class.get_class_variable(name)
|
237
|
+
end
|
238
|
+
|
239
|
+
def self.get_method_latest_result(method_name, *method_args)
|
240
|
+
method_result = nil
|
241
|
+
self.get_class_hierarchy.each do |controller_class|
|
242
|
+
method_result = controller_class.send(method_name, *method_args) if controller_class.respond_to?(method_name)
|
243
|
+
return method_result if method_result
|
244
|
+
end
|
245
|
+
method_result
|
246
|
+
end
|
247
|
+
|
248
|
+
#########################################################################################################################
|
249
|
+
################################### Dynamic Transactions #########################################
|
250
|
+
#########################################################################################################################
|
251
|
+
|
252
|
+
def process_transaction_injections(entry, action, flow_position, filter_params, options = {})
|
253
|
+
options ||= {}
|
254
|
+
|
255
|
+
transaction_is_ok = true
|
256
|
+
|
257
|
+
classes_to_process = self.get_class_hierarchy
|
258
|
+
classes_to_process.each do |controller_klass|
|
259
|
+
if controller_klass.respond_to?(:get_kb_transaction_injections)
|
260
|
+
available_injections = controller_klass.get_kb_transaction_injections(action, flow_position)
|
261
|
+
available_injections.each do |injection|
|
262
|
+
#raise "Processing Transaction Injection. Class: #{controller_klass.to_s}, Injection: #{injection.to_json}"
|
263
|
+
if self.send(injection.method, entry, filter_params, options) == false
|
264
|
+
transaction_is_ok &= false
|
265
|
+
end
|
266
|
+
end if available_injections
|
267
|
+
end
|
268
|
+
end
|
269
|
+
transaction_is_ok
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
#########################################################################################################################
|
274
|
+
###################################### Locale Methods #############################################
|
275
|
+
#########################################################################################################################
|
276
|
+
|
277
|
+
|
278
|
+
def set_i18n_locale_from_params
|
279
|
+
if params[:locale]
|
280
|
+
if I18n.available_locales.include?(params[:locale].to_sym)
|
281
|
+
I18n.locale = params[:locale]
|
282
|
+
session[:locale] = params[:locale]
|
283
|
+
cookies.permanent[:locale_set] = params[:locale]
|
284
|
+
else
|
285
|
+
if session[:locale]
|
286
|
+
#params[:locale] = session[:locale]
|
287
|
+
#I18n.locale = session[:locale]
|
288
|
+
#locale_redirect(session[:locale])
|
289
|
+
#redirect_to request.url #, notice: "Translation \"#{params[:locale]}\" not available."
|
290
|
+
#@string_logger.error flash.now[:notice]
|
291
|
+
redirect_to url_for(locale: session[:locale])
|
292
|
+
elsif cookies[:locale_set]
|
293
|
+
session[:locale] = cookies[:locale_set]
|
294
|
+
params[:locale] = cookies[:locale_set]
|
295
|
+
I18n.locale = cookies[:locale_set]
|
296
|
+
#locale_redirect(session[:locale])
|
297
|
+
else
|
298
|
+
locale = get_best_locale
|
299
|
+
params[:locale] = locale
|
300
|
+
session[:locale] = locale
|
301
|
+
cookies.permanent[:locale_set] = locale
|
302
|
+
I18n.locale = locale
|
303
|
+
#locale_redirect(I18n.locale)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
elsif session[:locale]
|
307
|
+
redirect_to url_for(locale: session[:locale])
|
308
|
+
elsif cookies[:locale_set]
|
309
|
+
redirect_to url_for(locale: cookies[:locale_set])
|
310
|
+
else
|
311
|
+
redirect_to url_for(locale: get_best_locale)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
#def default_url_options
|
316
|
+
# {locale: I18n.locale}
|
317
|
+
#end
|
318
|
+
|
319
|
+
def check_locale_parameter
|
320
|
+
if session[:locale]
|
321
|
+
#if params[:locale]
|
322
|
+
if I18n.available_locales.include?(params[:locale].to_sym)
|
323
|
+
if params[:locale] != session[:locale]
|
324
|
+
session[:locale] = params[:locale]
|
325
|
+
I18n.locale = params[:locale]
|
326
|
+
else
|
327
|
+
I18n.locale = session[:locale]
|
328
|
+
end
|
329
|
+
else
|
330
|
+
I18n.locale = session[:locale]
|
331
|
+
#redirect_to home_path, notice: :wrong_locale #"Translation \"#{params[:locale]}\" not available yet."
|
332
|
+
end
|
333
|
+
else
|
334
|
+
I18n.locale = session[:locale]
|
335
|
+
#redirect_to request.url, locale: I18n.locale
|
336
|
+
end
|
337
|
+
#else
|
338
|
+
# session[:locale] = I18n.locale
|
339
|
+
#end
|
340
|
+
end
|
341
|
+
|
342
|
+
def get_best_locale
|
343
|
+
locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first.to_sym
|
344
|
+
if I18n.available_locales.include?(locale)
|
345
|
+
locale
|
346
|
+
else
|
347
|
+
I18n.default_locale
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
|
352
|
+
def prepare_applications_data
|
353
|
+
|
354
|
+
end
|
355
|
+
|
356
|
+
|
357
|
+
#########################################################################################################################
|
358
|
+
##################################### Global Variables ############################################
|
359
|
+
#########################################################################################################################
|
360
|
+
|
361
|
+
# called in before_action in ::KirguduBase::ApplicationController
|
362
|
+
def initialize_global_variables
|
363
|
+
|
364
|
+
@template_path = self.class.get_method_latest_result(:get_kb_template)
|
365
|
+
|
366
|
+
@settings_manager = ::KirguduBase::Settings::SettingsManager.new
|
367
|
+
|
368
|
+
default_host_to_set = request.host
|
369
|
+
default_host_to_set += ":#{request.port}" if request.port && request.port != 80
|
370
|
+
|
371
|
+
Rails.application.routes.default_url_options[:host] = default_host_to_set
|
372
|
+
|
373
|
+
if Rails.env.development?
|
374
|
+
I18n.locale = :ru
|
375
|
+
end
|
376
|
+
|
377
|
+
WillPaginate.per_page = 20
|
378
|
+
end
|
379
|
+
|
380
|
+
#########################################################################################################################
|
381
|
+
#################################### Current User To Override ############################################
|
382
|
+
#########################################################################################################################
|
383
|
+
|
384
|
+
# method for Ability
|
385
|
+
def current_user
|
386
|
+
@current_user
|
387
|
+
end
|
388
|
+
|
389
|
+
def current_user= value
|
390
|
+
@current_user = value
|
391
|
+
end
|
392
|
+
|
393
|
+
def current_user_symbol
|
394
|
+
:user_id
|
395
|
+
end
|
396
|
+
|
397
|
+
#########################################################################################################################
|
398
|
+
####################################### Current User ##############################################
|
399
|
+
#########################################################################################################################
|
400
|
+
|
401
|
+
|
402
|
+
def current_user_set_info(user, remember_me = nil)
|
403
|
+
#logger.info("USER is ::KirguduBase::Security::User") if user && user.is_a?(::KirguduBase::Security::User)
|
404
|
+
self.current_user = user
|
405
|
+
self.session[self.current_user_symbol] = user.id
|
406
|
+
self.session[:"#{self.current_user_symbol}_expire"] = DateTime.now.utc + 1.day
|
407
|
+
self.session[:"#{self.current_user_symbol}_remember_me"] = remember_me
|
408
|
+
#logger.info("Session[:user_id]=#{self.session[:user_id]}")
|
409
|
+
end
|
410
|
+
|
411
|
+
def current_user_clear_info
|
412
|
+
self.current_user = nil
|
413
|
+
self.session[self.current_user_symbol] = nil
|
414
|
+
self.session[:"#{self.current_user_symbol}_expire"] = DateTime.now.utc - 1.day
|
415
|
+
self.session[:"#{self.current_user_symbol}_remember_me"] = false
|
416
|
+
end
|
417
|
+
|
418
|
+
def current_user_query_db(user_id)
|
419
|
+
::KirguduBase::Security::User.where(id: user_id).first if user_id
|
420
|
+
end
|
421
|
+
|
422
|
+
def authenticate_user
|
423
|
+
time_now = DateTime.now.utc
|
424
|
+
user_remember_me = self.session[:"#{self.current_user_symbol}_remember_me"]
|
425
|
+
slided_expire_time = time_now + (user_remember_me ? 2.weeks : 1.day)
|
426
|
+
user_session_expire = self.session[:"#{self.current_user_symbol}_expire"] || slided_expire_time
|
427
|
+
user_id = self.session[self.current_user_symbol]
|
428
|
+
|
429
|
+
if user_session_expire < time_now
|
430
|
+
logger.info("User Session Expired. Expire At: #{user_session_expire}")
|
431
|
+
#raise "Session Expired #{user_session_expire}, #{self.session[:"#{self.current_user_symbol}_expire"]}"
|
432
|
+
self.current_user_clear_info
|
433
|
+
else
|
434
|
+
if user_id
|
435
|
+
logger.info("User ID: #{user_id}")
|
436
|
+
logger.info("Slided Expire At: #{slided_expire_time}")
|
437
|
+
self.current_user = self.current_user_query_db(user_id)
|
438
|
+
self.session[:"#{self.current_user_symbol}_expire"] = slided_expire_time
|
439
|
+
else
|
440
|
+
logger.info("User ID is null")
|
441
|
+
self.current_user_clear_info
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
logger.info("Current User is null") if self.current_user.nil?
|
446
|
+
logger.info("Current User: #{self.current_user.full_name}") unless self.current_user.nil?
|
447
|
+
|
448
|
+
|
449
|
+
if self.current_user.nil? || self.current_user.deletion_status_id != ::ChupakabraTools::DeletionStatus.id_by_tag(:actual)
|
450
|
+
logger.info("1Current User is null") if self.current_user.nil?
|
451
|
+
#logger.info("1Current User deletion_status_id: #{::ChupakabraTools::DeletionStatus[self.current_user.deletion_status_id]}") unless self.current_user.deletion_status_id == ::ChupakabraTools::DeletionStatus.id_by_tag(:actual)
|
452
|
+
self.current_user_clear_info
|
453
|
+
self.session[:return_to] = request.url
|
454
|
+
respond_to do |format|
|
455
|
+
format.json { render_json_need_authentication }
|
456
|
+
format.html { redirect_to self.get_url_to_redirect_for_authentication }
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
logger.info("User Authentications is Complete")
|
461
|
+
logger.info("Current User is null") if self.current_user.nil?
|
462
|
+
#logger.info("Current User deletion_status_id: #{::ChupakabraTools::DeletionStatus[self.current_user.deletion_status_id]}") unless ::ChupakabraTools::DeletionStatus.id_by_tag(:actual)
|
463
|
+
logger.info("Current User: #{self.current_user.full_name}") unless self.current_user.nil?
|
464
|
+
end
|
465
|
+
|
466
|
+
def get_url_to_redirect_for_authentication
|
467
|
+
auth_controller = ::KirguduBase.authentications_controller
|
468
|
+
raise "Put in 'intializers' value for 'KirguduBase.authentications_controller' or override 'get_url_to_redirect_for_authentication' method" unless auth_controller
|
469
|
+
|
470
|
+
if auth_controller.is_a?(String)
|
471
|
+
auth_controller = eval(auth_controller)
|
472
|
+
end
|
473
|
+
auth_controller.to_url_for(:login)
|
474
|
+
end
|
475
|
+
|
476
|
+
def get_url_for_login( options = {})
|
477
|
+
self.get_kirgudu_base_authentication_controller_setting.to_url_for(:login, options)
|
478
|
+
end
|
479
|
+
def get_url_for_logout( options = {})
|
480
|
+
self.get_kirgudu_base_authentication_controller_setting.to_url_for(:logout, options)
|
481
|
+
end
|
482
|
+
|
483
|
+
def get_url_for_restore_password_code(options = {})
|
484
|
+
self.get_kirgudu_base_authentication_controller_setting.to_url_for(:restore_password_code, options)
|
485
|
+
end
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
def get_kirgudu_base_authentication_controller_setting
|
490
|
+
auth_controller = ::KirguduBase.authentications_controller
|
491
|
+
raise "Add 'KirguduBase.authentications_controller' to /initializers/kirgudu_base.rb' method" unless auth_controller
|
492
|
+
auth_controller = eval(auth_controller) if auth_controller.is_a?(String)
|
493
|
+
auth_controller
|
494
|
+
end
|
495
|
+
|
496
|
+
|
497
|
+
##############################################################################################
|
498
|
+
##################################### Views Paths #######################################
|
499
|
+
##############################################################################################
|
500
|
+
|
501
|
+
def get_template_path
|
502
|
+
self.class.get_method_latest_result(:get_kb_template);
|
503
|
+
end
|
504
|
+
|
505
|
+
def get_view_path(view_name, include_template = true)
|
506
|
+
view_path = self.class.get_method_latest_result(:get_kb_view_path, view_name)
|
507
|
+
view_path ||= self.get_view_default_path(view_name)
|
508
|
+
template_path = ""
|
509
|
+
template_path = self.get_template_path if include_template
|
510
|
+
|
511
|
+
include_template ? "#{template_path}/#{view_path}" : "#{view_path}"
|
512
|
+
end
|
513
|
+
|
514
|
+
def get_layout_path(include_template = true)
|
515
|
+
self.get_view_path(:layout, include_template)
|
516
|
+
end
|
517
|
+
|
518
|
+
def get_view_default_path(view_name)
|
519
|
+
defaults = {
|
520
|
+
layout: "layouts/application",
|
521
|
+
page_404: "shared/page_404",
|
522
|
+
entry_not_found: "shared/entry_not_found",
|
523
|
+
index: "common/index",
|
524
|
+
new: "common/new",
|
525
|
+
edit: "common/edit",
|
526
|
+
delete: "common/delete",
|
527
|
+
show: "common/show",
|
528
|
+
management: "common/management",
|
529
|
+
sorting: "common/sorting",
|
530
|
+
dashboard: "common/dashboard"
|
531
|
+
}
|
532
|
+
defaults[view_name]
|
533
|
+
end
|
534
|
+
|
535
|
+
|
536
|
+
##############################################################################################
|
537
|
+
############################################# #######################################
|
538
|
+
##############################################################################################
|
539
|
+
|
540
|
+
def string_logger
|
541
|
+
@string_logger
|
542
|
+
end
|
543
|
+
|
544
|
+
def string_logger= value
|
545
|
+
@string_logger = value
|
546
|
+
end
|
547
|
+
|
548
|
+
##############################################################################################
|
549
|
+
############################################# #######################################
|
550
|
+
##############################################################################################
|
551
|
+
|
552
|
+
|
553
|
+
def update_url_with_ajax_referer_url
|
554
|
+
if params[:current_url]
|
555
|
+
begin
|
556
|
+
p_current_url = URI.parse(params[:current_url])
|
557
|
+
p_query = CGI.parse(p_current_url.query)
|
558
|
+
|
559
|
+
#string_logger.info("Current URL: #{p_current_url}")
|
560
|
+
#string_logger.info("Current URL QUERY : #{p_query}")
|
561
|
+
|
562
|
+
params[:page] = p_query["page"].first if p_query["page"]
|
563
|
+
params[:status_id] = p_query["status_id"].first if p_query["status_id"]
|
564
|
+
params[:website_id] = p_query["website_id"].first if p_query["website_id"] and params[:website_id].nil?
|
565
|
+
|
566
|
+
#string_logger.info("Params After Loading from Current URL: #{params}")
|
567
|
+
end
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
|
572
|
+
def system_logging_init
|
573
|
+
#@logging_options = Hash.new
|
574
|
+
#
|
575
|
+
#@logging_options[:status] = @settings_manager.get("SystemZone::Logging::Status")
|
576
|
+
#unless @logging_options[:status]
|
577
|
+
# @logging_options[:status] = false
|
578
|
+
#end
|
579
|
+
#@logging_options[:level] = @settings_manager.get("SystemZone::Logging::Level")
|
580
|
+
#unless @logging_options[:level]
|
581
|
+
# @logging_options[:level] = ::SystemZone::Logging::Event::LEVEL_SYSTEM
|
582
|
+
#end
|
583
|
+
#
|
584
|
+
#if @logging_options[:status] == true
|
585
|
+
# @logging_request = ::SystemZone::Logging::Request.new
|
586
|
+
# @logging_request.ip = request.remote_ip
|
587
|
+
# @logging_request.serve_id = 1 #FIX: change in future to identify servers
|
588
|
+
# @logging_request.session_id = request.session[:session_id] ? request.session[:session_id] : ''
|
589
|
+
# @logging_request.controller_name = controller_path
|
590
|
+
# @logging_request.action_name = self.action_name
|
591
|
+
# @logging_request.http_method = request.method
|
592
|
+
# @logging_request.params = params.to_json
|
593
|
+
# @logging_request.agent = request.env["HTTP_USER_AGENT"]
|
594
|
+
# @logging_request.os = http_request_retrieve_operating_system(request.env["HTTP_USER_AGENT"])
|
595
|
+
# #@logging_request.screen = request.env["HTTP_USER_AGENT"]
|
596
|
+
# @logging_request.referer_url = request.referer
|
597
|
+
# @logging_request.url = request.referer
|
598
|
+
# @logging_request.user_id = @current_user.id if @current_user && @current_user.id
|
599
|
+
# @logging_request.client_id = current_client.id if current_client && current_client.id
|
600
|
+
# @logging_request.save
|
601
|
+
#end
|
602
|
+
|
603
|
+
end
|
604
|
+
|
605
|
+
def system_logging_write_event(source, level_id, message)
|
606
|
+
#if @logging_options[:status] == true && @logging_request && (level_id == ::SystemZone::Logging::Event::LEVEL_SYSTEM || level_id <= @logging_options[:level])
|
607
|
+
# current_event = ::SystemZone::Logging::Event.new
|
608
|
+
# current_event.request = @logging_request
|
609
|
+
# current_event.source = source && !source.blank? ? source : self.action_name
|
610
|
+
# current_event.level_id = level_id
|
611
|
+
# current_event.message = message
|
612
|
+
# current_event.save
|
613
|
+
#end
|
614
|
+
end
|
615
|
+
|
616
|
+
|
617
|
+
def fake_counter_iterate(counter_name)
|
618
|
+
#counter_data = {}
|
619
|
+
#counter_data[:total_name] = "Fake::Counter::Total::#{counter_name}"
|
620
|
+
#counter_data[:quantity_per_period_name] = "Fake::Counter::#{counter_name}::QuantityPerPeriod"
|
621
|
+
#counter_data[:period_type_name] = "Fake::Counter::#{counter_name}::PeriodType"
|
622
|
+
#counter_data[:initial_seed_name] = "Fake::Counter::#{counter_name}::InitialSeed"
|
623
|
+
#
|
624
|
+
#counter_data[:local_timezone] = ActiveSupport::TimeZone.new("Moscow")
|
625
|
+
#counter_data[:local_today] = Time.now.in_time_zone(counter_data[:local_timezone]).to_date
|
626
|
+
#counter_data[:local_now] = Time.now.in_time_zone(counter_data[:local_timezone])
|
627
|
+
#
|
628
|
+
##getting or setting number_of_orders_per_period
|
629
|
+
#counter_data[:total] = @settings_manager.get(counter_data[:total_name])
|
630
|
+
#unless counter_data[:total]
|
631
|
+
# counter_data[:total] = 846
|
632
|
+
# create_option(counter_data[:total_name], counter_data[:total], value_type: "integer")
|
633
|
+
#end
|
634
|
+
#
|
635
|
+
##getting or setting number_of_orders_per_period
|
636
|
+
#counter_data[:quantity_per_period] = @settings_manager.get(counter_data[:quantity_per_period_name])
|
637
|
+
#counter_data[:quantity_per_period] = 63 unless counter_data[:quantity_per_period]
|
638
|
+
##getting or setting counter_data[:period_type]
|
639
|
+
#counter_data[:period_type] = @settings_manager.get(counter_data[:period_type_name])
|
640
|
+
#counter_data[:period_type] = "day" unless counter_data[:period_type]
|
641
|
+
##getting or setting counter_data[:initial_seed]
|
642
|
+
#counter_data[:initial_seed] = @settings_manager.get(counter_data[:initial_seed_name])
|
643
|
+
#counter_data[:initial_seed] = 7 unless counter_data[:initial_seed]
|
644
|
+
#
|
645
|
+
#
|
646
|
+
## searchiung for period_counter in OrderCounter
|
647
|
+
#period_counter = get_period_counter(counter_data[:local_now], counter_data[:period_type])
|
648
|
+
#
|
649
|
+
#
|
650
|
+
## string_logger.info("*****************************************************************")
|
651
|
+
## string_logger.info("Total Counter (before): #{total_counter}") if total_counter
|
652
|
+
## string_logger.info("Day Counter (before): #{day_counter}") if day_counter
|
653
|
+
#
|
654
|
+
#ActiveRecord::Base.transaction do
|
655
|
+
# unless period_counter
|
656
|
+
# # period_counter not found so New period_counter created
|
657
|
+
# period_counter = ::SystemZone::Fakes::Counter.new
|
658
|
+
# # calculating period_start and period_end Time
|
659
|
+
# if counter_data[:period_type] == "day"
|
660
|
+
# period_counter.start_at = counter_data[:local_now].beginning_of_day
|
661
|
+
# period_counter.finish_at = counter_data[:local_now].end_of_day
|
662
|
+
# elsif counter_data[:period_type] == "week"
|
663
|
+
# period_counter.start_at = counter_data[:local_now].beginning_of_week
|
664
|
+
# period_counter.finish_at = counter_data[:local_now].end_of_week
|
665
|
+
# elsif counter_data[:period_type] == "month"
|
666
|
+
# period_counter.start_at = counter_data[:local_now].beginning_of_month
|
667
|
+
# period_counter.finish_at = counter_data[:local_now].end_of_month
|
668
|
+
# elsif counter_data[:period_type] == "year"
|
669
|
+
# period_counter.start_at = counter_data[:local_now].beginning_of_year
|
670
|
+
# period_counter.finish_at = counter_data[:local_now].end_of_year
|
671
|
+
# else
|
672
|
+
# period_counter.start_at = counter_data[:local_now].beginning_of_day
|
673
|
+
# period_counter.finish_at = counter_data[:local_now].end_of_day
|
674
|
+
# end
|
675
|
+
# # initializing period_counter values
|
676
|
+
# period_counter.fake_initial = rand(counter_data[:initial_seed])
|
677
|
+
# period_counter.fake_max = counter_data[:quantity_per_period]
|
678
|
+
# period_counter.fake_value = period_counter.fake_initial
|
679
|
+
# period_counter.real_value = period_counter.fake_initial
|
680
|
+
# # calculate period in seconds for current period
|
681
|
+
# period_in_seconds = (period_counter.period_end - period_counter.period_start).round
|
682
|
+
# # calculate iteration period in seconds keeping in mind that we have fake_value_initial
|
683
|
+
# iteration_period_in_seconds = (period_in_seconds / (counter_data[:quantity_per_period] - period_counter.fake_value_initial)).round
|
684
|
+
# # calculating number of iteration from period start to now
|
685
|
+
# number_of_iteration_by_now = ((counter_data[:local_now] - period_counter.period_start).round/iteration_period_in_seconds).round
|
686
|
+
# #adding number_of_iteration_by_now to fake_value
|
687
|
+
# period_counter.fake_value += number_of_iteration_by_now
|
688
|
+
# period_counter.real_value += number_of_iteration_by_now
|
689
|
+
# # initializing next_iteration_date
|
690
|
+
# next_iteration_date = period_counter.period_start + number_of_iteration_by_now * iteration_period_in_seconds
|
691
|
+
# # increasing number_of_iteration_by_now by 1 while next_iteration_date < counter_data[:local_now]
|
692
|
+
# begin
|
693
|
+
# number_of_iteration_by_now += 1
|
694
|
+
# #period_counter.fake_value += 1
|
695
|
+
# #period_counter.real_value += 1
|
696
|
+
# next_iteration_date = period_counter.period_start + number_of_iteration_by_now * iteration_period_in_seconds
|
697
|
+
# end while next_iteration_date < counter_data[:local_now]
|
698
|
+
# #setting net_iteration_date
|
699
|
+
# period_counter.next_iteration_date = next_iteration_date
|
700
|
+
# counter_data[:total] += period_counter.real_value
|
701
|
+
# set_option_value(counter_data[:total_name], counter_data[:total])
|
702
|
+
# end
|
703
|
+
# if period_counter.next_iteration_date < counter_data[:local_now]
|
704
|
+
# #string_logger.info("*****************************************************************")
|
705
|
+
# #string_logger.info("*****************************************************************")
|
706
|
+
# #string_logger.info("Increasing Current OrderCounter")
|
707
|
+
# #string_logger.info("*****************************************************************")
|
708
|
+
# #string_logger.info("Fake Value: #{period_counter.fake_value}")
|
709
|
+
# #string_logger.info("Real Value: #{period_counter.real_value}")
|
710
|
+
# # calculate period in seconds for current period
|
711
|
+
# period_in_seconds = (period_counter.period_end - period_counter.period_start).round
|
712
|
+
# #string_logger.info("Period (in seconds): #{period_in_seconds}")
|
713
|
+
# # calculate iteration period in seconds keeping in mind that we have fake_value_initial
|
714
|
+
# iteration_period_in_seconds = (period_in_seconds / (counter_data[:quantity_per_period] - period_counter.fake_value_initial)).round
|
715
|
+
# #string_logger.info("Iteration Period (in seconds): #{iteration_period_in_seconds}")
|
716
|
+
# # calculating number of iteration from period start to now
|
717
|
+
# number_of_iteration_by_now = ((counter_data[:local_now] - period_counter.period_start).round/iteration_period_in_seconds).round
|
718
|
+
# #string_logger.info("Number of Iterations by Now: #{number_of_iteration_by_now}")
|
719
|
+
# #adding difference between number_of_iteration_by_now and fake_value to fake_value
|
720
|
+
# iteration_difference_by_now = number_of_iteration_by_now - period_counter.fake_value
|
721
|
+
# #string_logger.info("Iterations To Add (difference): #{iteration_difference_by_now}")
|
722
|
+
# if iteration_difference_by_now > 0
|
723
|
+
# period_counter.fake_value += iteration_difference_by_now
|
724
|
+
# period_counter.real_value += iteration_difference_by_now
|
725
|
+
# #increasing total counter
|
726
|
+
# counter_data[:total] += iteration_difference_by_now
|
727
|
+
# set_option_value(counter_data[:total_name], counter_data[:total])
|
728
|
+
#
|
729
|
+
# #string_logger.info("Fake Value (with difference): #{period_counter.fake_value}")
|
730
|
+
# #string_logger.info("Real Value (with difference): #{period_counter.real_value}")
|
731
|
+
# # initializing next_iteration_date
|
732
|
+
# next_iteration_date = period_counter.period_start + number_of_iteration_by_now * iteration_period_in_seconds
|
733
|
+
# #string_logger.info("Next Iteration Date: #{next_iteration_date.in_time_zone(counter_data[:local_timezone])}")
|
734
|
+
# # increasing number_of_iteration_by_now by 1 while next_iteration_date < counter_data[:local_now]
|
735
|
+
# begin
|
736
|
+
# #string_logger.info("Iterrating for next iteration date")
|
737
|
+
# number_of_iteration_by_now += 1
|
738
|
+
# #period_counter.fake_value += 1
|
739
|
+
# #period_counter.real_value += 1
|
740
|
+
# next_iteration_date = period_counter.period_start + number_of_iteration_by_now * iteration_period_in_seconds
|
741
|
+
# end while next_iteration_date < counter_data[:local_now]
|
742
|
+
# #setting net_iteration_date
|
743
|
+
# period_counter.next_iteration_date = next_iteration_date
|
744
|
+
# #string_logger.info("*****************************************************************")
|
745
|
+
# #string_logger.info("*****************************************************************")
|
746
|
+
# end
|
747
|
+
# end
|
748
|
+
# #saving period_counter
|
749
|
+
# period_counter.save
|
750
|
+
#end # end of transaction
|
751
|
+
#
|
752
|
+
#counter_result = {}
|
753
|
+
#counter_result[:total] = counter_data[:total]
|
754
|
+
#counter_result[:by_period] = period_counter.fake_value
|
755
|
+
#
|
756
|
+
## string_logger.info("Total Counter: #{counter_result[:total]}")
|
757
|
+
## string_logger.info("Day Counter: #{counter_result[:by_period]}")
|
758
|
+
#counter_result
|
759
|
+
end
|
760
|
+
|
761
|
+
|
762
|
+
def render_page_e404
|
763
|
+
respond_to do |format|
|
764
|
+
format.html { render :template => 'layouts/404', :status => 404 }
|
765
|
+
format.all { render :nothing => true, :status => "404" }
|
766
|
+
end
|
767
|
+
end
|
768
|
+
|
769
|
+
#rescue_from ActiveRecord::RecordNotFound , :with => :e404
|
770
|
+
|
771
|
+
# rescue_from ActiveRecord::RecordInvalid , :with => :e404
|
772
|
+
|
773
|
+
#rescue_from ActionController::RoutingError , :with => :e404
|
774
|
+
|
775
|
+
#rescue_from ActiveRecord::ActiveRecordError , :with => :e404
|
776
|
+
|
777
|
+
#rescue_from ArgumentError , :with => :e404
|
778
|
+
|
779
|
+
#rescue_from Exception, :with => :e404
|
780
|
+
|
781
|
+
|
782
|
+
#rescue_from CanCan::AccessDenied do |exception|
|
783
|
+
# respond_to do |format|
|
784
|
+
# format.html { render :template => '/shared/access_denied.html.erb', :status => 404 }
|
785
|
+
# format.all { render :nothing => true, :status => "404" }
|
786
|
+
# end
|
787
|
+
#end
|
788
|
+
|
789
|
+
|
790
|
+
# ***********************************************************************************************
|
791
|
+
# ************************************** PRIVATE METHODS ****************************************
|
792
|
+
# ***********************************************************************************************
|
793
|
+
private
|
794
|
+
|
795
|
+
|
796
|
+
def debugger_before_action
|
797
|
+
|
798
|
+
end
|
799
|
+
|
800
|
+
def debugger_after_action
|
801
|
+
|
802
|
+
end
|
803
|
+
|
804
|
+
|
805
|
+
def request_started
|
806
|
+
|
807
|
+
end
|
808
|
+
|
809
|
+
def request_finished
|
810
|
+
|
811
|
+
end
|
812
|
+
end
|
804
813
|
end
|