fly_admin 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c77d4bfef9a60cbba77bf284fb516615d4739988
4
- data.tar.gz: ea265618ee342dfab5359b0e148f31fc449567d5
3
+ metadata.gz: fe790ccb88c3b854aaa5eb9ed37b9cb767615443
4
+ data.tar.gz: 6087c084c181e4fb08e862b4c26a874dc3a38078
5
5
  SHA512:
6
- metadata.gz: 57b734ff2b8ae61112eb10dd4ec9834b992535b6aaffda44a717cdc763f1fe9c5c906b6bff1b9fec9bc10cd0d751173fa9358f684b9257966060c8eae511cb89
7
- data.tar.gz: c9d0f7b26afea82b82faacfaadf52983fbd8d81636c0afbf0cd45c27c41b3207b33b29fb2f4bcb27040d934a5aa7d6aa27122bc1244d76e9aeeaf87c4bd366aa
6
+ metadata.gz: d925a5ed3de9b1ef130a2b88a32e270d8b221a609c94109d3f264e8eefb08186346432119364784d2902939b4c1ca7d0dd383b771e4765fb2d1739c976080129
7
+ data.tar.gz: 2fe7947394dfd4af2b481988559d9db6cb405ad6930333ffaaed392e717cf918ad384216342bdffa0d2d7c5d1976c1da1f7db65bd8ce84a6c2bf8092e1a61306
@@ -11,6 +11,10 @@
11
11
  margin: 10px !important;
12
12
  }
13
13
 
14
+ .margin-left-10 {
15
+ margin-left: 10px !important;
16
+ }
17
+
14
18
  .btn-for-link {
15
19
  padding: 6px 12px !important;
16
20
  }
@@ -154,7 +154,7 @@
154
154
  box-shadow: 0 0 2px #0a6aa1;
155
155
  }
156
156
  .vakata-context li > a.vakata-context-parent {
157
- background-image: url(<%= asset_path "data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw==" %>);
157
+ background-image: url(<%= asset_path "fly_admin/data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw==" %>);
158
158
  background-position: right center;
159
159
  background-repeat: no-repeat;
160
160
  }
@@ -232,7 +232,7 @@
232
232
  margin-right: -4px;
233
233
  }
234
234
  .vakata-context-rtl li > a.vakata-context-parent {
235
- background-image: url(<%= asset_path "data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7" %>);
235
+ background-image: url(<%= asset_path "fly_admin/data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7" %>);
236
236
  background-position: left center;
237
237
  background-repeat: no-repeat;
238
238
  }
@@ -358,7 +358,7 @@
358
358
  }
359
359
  #jstree-dnd.jstree-default .jstree-ok,
360
360
  #jstree-dnd.jstree-default .jstree-er {
361
- background-image: url(<%= asset_path "32px.png" %>);
361
+ background-image: url(<%= asset_path "fly_admin/32px.png" %>);
362
362
  background-repeat: no-repeat;
363
363
  background-color: transparent;
364
364
  }
@@ -374,7 +374,7 @@
374
374
  background-position: -39px -71px;
375
375
  }
376
376
  .jstree-default > .jstree-striped {
377
- background: url(<%= asset_path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAMAAAB/qqA+AAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMNAMM9s3UAAAAXSURBVHjajcEBAQAAAIKg/H/aCQZ70AUBjAATb6YPDgAAAABJRU5ErkJggg==" %>) left top repeat;
377
+ background: url(<%= asset_path "fly_admin/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAMAAAB/qqA+AAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMNAMM9s3UAAAAXSURBVHjajcEBAQAAAIKg/H/aCQZ70AUBjAATb6YPDgAAAABJRU5ErkJggg==" %>) left top repeat;
378
378
  }
379
379
  .jstree-default > .jstree-wholerow-ul .jstree-hovered,
380
380
  .jstree-default > .jstree-wholerow-ul .jstree-clicked {
@@ -428,7 +428,7 @@
428
428
  }
429
429
  .jstree-default .jstree-node,
430
430
  .jstree-default .jstree-icon {
431
- background-image: url(<%= asset_path "32px.png" %>);
431
+ background-image: url(<%= asset_path "fly_admin/32px.png" %>);
432
432
  }
433
433
  .jstree-default .jstree-node {
434
434
  background-position: -292px -4px;
@@ -490,7 +490,7 @@
490
490
  background-size: auto 48px;
491
491
  }
492
492
  .jstree-default.jstree-rtl .jstree-node {
493
- background-image: url(<%= asset_path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
493
+ background-image: url(<%= asset_path "fly_admin/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
494
494
  background-position: 100% 1px;
495
495
  background-repeat: repeat-y;
496
496
  }
@@ -522,16 +522,16 @@
522
522
  background-position: 0 0;
523
523
  }
524
524
  .jstree-default > .jstree-container-ul .jstree-loading > .jstree-ocl {
525
- background: url(<%= asset_path "throbber.gif" %>) center center no-repeat;
525
+ background: url(<%= asset_path "fly_admin/throbber.gif" %>) center center no-repeat;
526
526
  }
527
527
  .jstree-default .jstree-file {
528
- background: url(<%= asset_path "32px.png" %>) -100px -68px no-repeat;
528
+ background: url(<%= asset_path "fly_admin/32px.png" %>) -100px -68px no-repeat;
529
529
  }
530
530
  .jstree-default .jstree-folder {
531
- background: url(<%= asset_path "32px.png" %>) -260px -4px no-repeat;
531
+ background: url(<%= asset_path "fly_admin/32px.png" %>) -260px -4px no-repeat;
532
532
  }
533
533
  .jstree-default.jstree-rtl .jstree-node {
534
- background-image: url(<%= asset_path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
534
+ background-image: url(<%= asset_path "fly_admin/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
535
535
  }
536
536
  .jstree-default.jstree-rtl .jstree-last {
537
537
  background: transparent;
@@ -564,7 +564,7 @@
564
564
  }
565
565
  .jstree-default-small .jstree-node,
566
566
  .jstree-default-small .jstree-icon {
567
- background-image: url(<%= asset_path "32px.png" %>);
567
+ background-image: url(<%= asset_path "fly_admin/32px.png" %>);
568
568
  }
569
569
  .jstree-default-small .jstree-node {
570
570
  background-position: -295px -7px;
@@ -626,7 +626,7 @@
626
626
  background-size: auto 36px;
627
627
  }
628
628
  .jstree-default-small.jstree-rtl .jstree-node {
629
- background-image: url(<%= asset_path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
629
+ background-image: url(<%= asset_path "fly_admin/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
630
630
  background-position: 100% 1px;
631
631
  background-repeat: repeat-y;
632
632
  }
@@ -658,16 +658,16 @@
658
658
  background-position: 0 0;
659
659
  }
660
660
  .jstree-default-small > .jstree-container-ul .jstree-loading > .jstree-ocl {
661
- background: url(<%= asset_path "throbber.gif" %>) center center no-repeat;
661
+ background: url(<%= asset_path "fly_admin/throbber.gif" %>) center center no-repeat;
662
662
  }
663
663
  .jstree-default-small .jstree-file {
664
- background: url(<%= asset_path "32px.png" %>) -103px -71px no-repeat;
664
+ background: url(<%= asset_path "fly_admin/32px.png" %>) -103px -71px no-repeat;
665
665
  }
666
666
  .jstree-default-small .jstree-folder {
667
- background: url(<%= asset_path "32px.png" %>) -263px -7px no-repeat;
667
+ background: url(<%= asset_path "fly_admin/32px.png" %>) -263px -7px no-repeat;
668
668
  }
669
669
  .jstree-default-small.jstree-rtl .jstree-node {
670
- background-image: url(<%= asset_path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg==" %>);
670
+ background-image: url(<%= asset_path "fly_admin/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg==" %>);
671
671
  }
672
672
  .jstree-default-small.jstree-rtl .jstree-last {
673
673
  background: transparent;
@@ -700,7 +700,7 @@
700
700
  }
701
701
  .jstree-default-large .jstree-node,
702
702
  .jstree-default-large .jstree-icon {
703
- background-image: url(<%= asset_path "32px.png" %>);
703
+ background-image: url(<%= asset_path "fly_admin/32px.png" %>);
704
704
  }
705
705
  .jstree-default-large .jstree-node {
706
706
  background-position: -288px 0px;
@@ -762,7 +762,7 @@
762
762
  background-size: auto 64px;
763
763
  }
764
764
  .jstree-default-large.jstree-rtl .jstree-node {
765
- background-image: url(<%= asset_path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
765
+ background-image: url(<%= asset_path "fly_admin/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==" %>);
766
766
  background-position: 100% 1px;
767
767
  background-repeat: repeat-y;
768
768
  }
@@ -794,16 +794,16 @@
794
794
  background-position: 0 0;
795
795
  }
796
796
  .jstree-default-large > .jstree-container-ul .jstree-loading > .jstree-ocl {
797
- background: url(<%= asset_path "throbber.gif" %>) center center no-repeat;
797
+ background: url(<%= asset_path "fly_admin/throbber.gif" %>) center center no-repeat;
798
798
  }
799
799
  .jstree-default-large .jstree-file {
800
- background: url(<%= asset_path "32px.png" %>) -96px -64px no-repeat;
800
+ background: url(<%= asset_path "fly_admin/32px.png" %>) -96px -64px no-repeat;
801
801
  }
802
802
  .jstree-default-large .jstree-folder {
803
- background: url(<%= asset_path "32px.png" %>) -256px 0px no-repeat;
803
+ background: url(<%= asset_path "fly_admin/32px.png" %>) -256px 0px no-repeat;
804
804
  }
805
805
  .jstree-default-large.jstree-rtl .jstree-node {
806
- background-image: url( <%= asset_path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==" %>);
806
+ background-image: url( <%= asset_path "fly_admin/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==" %>);
807
807
  }
808
808
  .jstree-default-large.jstree-rtl .jstree-last {
809
809
  background: transparent;
@@ -816,7 +816,7 @@
816
816
  */
817
817
  }
818
818
  .jstree-default-responsive .jstree-icon {
819
- background-image: url(<%= asset_path "40px.png" %>);
819
+ background-image: url(<%= asset_path "fly_admin/40px.png" %>);
820
820
  }
821
821
  .jstree-default-responsive .jstree-node,
822
822
  .jstree-default-responsive .jstree-leaf > .jstree-ocl {
@@ -916,7 +916,7 @@
916
916
  .jstree-default-responsive .jstree-node > .jstree-ocl,
917
917
  .jstree-default-responsive .jstree-themeicon,
918
918
  .jstree-default-responsive .jstree-checkbox {
919
- background-image: url(<%= asset_path "40px.png" %>);
919
+ background-image: url(<%= asset_path "fly_admin/40px.png" %>);
920
920
  background-size: 120px 200px;
921
921
  }
922
922
  .jstree-default-responsive .jstree-node {
@@ -938,11 +938,11 @@
938
938
  background-position: 0 0;
939
939
  }
940
940
  .jstree-default-responsive .jstree-file {
941
- background: url(<%= asset_path "40px.png" %>) 0 -160px no-repeat;
941
+ background: url(<%= asset_path "fly_admin/40px.png" %>) 0 -160px no-repeat;
942
942
  background-size: 120px 200px;
943
943
  }
944
944
  .jstree-default-responsive .jstree-folder {
945
- background: url(<%= asset_path "40px.png" %>) -40px -40px no-repeat;
945
+ background: url(<%= asset_path "fly_admin/40px.png" %>) -40px -40px no-repeat;
946
946
  background-size: 120px 200px;
947
947
  }
948
948
  }
@@ -37,6 +37,7 @@ module FlyAdmin
37
37
  # PATCH/PUT /footers/1
38
38
  def update
39
39
  if @footer.update(footer_params)
40
+ @footer.local!
40
41
  clear_footer_cache
41
42
  redirect_to footers_url, notice: 'Тексты/Правилы были успешно изменены ⚒⚒⚒'
42
43
  else
@@ -0,0 +1,35 @@
1
+ module FlyAdmin
2
+ class SubscriptionsController < ActionController::Base
3
+ def start
4
+ get_cookie
5
+ if @customer_key.present?
6
+ # video can be in multiple categories , so save category_id
7
+ session[:video] = JSON.generate({ :id => params[:video_id], :category_id => params[:category_id], :season_id => params[:season_id] })
8
+ link = "http://#{@alias}/continue?key=#{@customer_key}"
9
+ redirect_to link
10
+ else
11
+ render nothing: true
12
+ end
13
+ end
14
+
15
+ def splash
16
+ begin
17
+ link = params[:back_url] + "?key=#{params[:customer_key]}"
18
+ redirect_to link
19
+ rescue Exception => e
20
+ SUBSCRIPTION_LOG.error "#{e.message}\n\t#{e.backtrace}"
21
+ render nothing: true
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def get_cookie
28
+ if session[:alias]
29
+ @alias = session[:alias]
30
+ @customer_key = session[:customer_key]
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -4,5 +4,19 @@ module FlyAdmin
4
4
  validates_presence_of :paysite_id, :country_id
5
5
  belongs_to :paysite
6
6
  belongs_to :country
7
+ state_machine :source_type, initial: 'local' do
8
+ event :bornpay do
9
+ transition any => 'bornpay'
10
+ end
11
+
12
+ event :imbs do
13
+ transition any => 'imbs'
14
+ end
15
+
16
+ # Если футер локальный, запросы к bornpay/imbs не делаем
17
+ event :local do
18
+ transition any => 'local'
19
+ end
20
+ end
7
21
  end
8
22
  end
@@ -10,8 +10,51 @@
10
10
  / This area used as dropdown edit box
11
11
  / end widget edit box
12
12
  / widget content
13
- .widget-body.no-padding
14
- = nested_form_for(category, :html => {:class => 'smart-form'}) do |f|
13
+ = nested_form_for(category, :html => {:class => 'smart-form', :multipart => true}) do |f|
14
+ - if category.errors.any?
15
+ - category.errors.full_messages.each do |msg|
16
+ = render 'layouts/error_flash_message', msg: msg
17
+ %section
18
+ .row
19
+ - if category.poster
20
+ .col-xs-3
21
+ = link_to category.poster_url do
22
+ = image_tag category.poster_url, size: '245x305', class: 'margin-left-10'
23
+ .col-xs-8
24
+ %label.textarea
25
+ = f.text_area :description, placeholder: 'Описание сериала', class: 'form-control ckeditor'
26
+ .row
27
+ %section.col.col-8
28
+ %label.input
29
+ = f.text_field :remote_poster_url, placeholder: 'Ссылка на постер', class: 'form-control input-sm margin-10'
30
+ %header
31
+ Дополнителная инфа
32
+ .row
33
+ %section.col.col-4
34
+ %label.input
35
+ = f.text_field :main_roles, placeholder: 'В главных ролях', class: 'margin-10 form-control input-sm'
36
+ %section.col.col-4
37
+ %label.input
38
+ = f.text_field :country, placeholder: 'Страна', class: 'margin-10 form-control input-sm'
39
+ %section.col.col-4
40
+ %label.input
41
+ = f.text_field :year, placeholder: 'Год', class: 'margin-10 form-control input-sm'
42
+ .row
43
+ %section.col.col-3
44
+ %lable.input
45
+ = f.text_field :scenario, placeholder: 'Сценарий', class: 'margin-10 form-control input-sm'
46
+ %section.col.col-3
47
+ %label.input
48
+ = f.text_field :director, placeholder: 'Режиссер', class: 'margin-10 form-control input-sm'
49
+ %section.col.col-3
50
+ %label.input
51
+ = f.text_field :time, placeholder: 'Время', class: 'margin-10 form-control input-sm'
52
+ %section.col.col-3
53
+ %label.input
54
+ = f.text_field :genre, placeholder: 'Жанр', class: 'margin-10 form-control input-sm'
55
+ %br
56
+ .widget-body.no-padding
57
+ %header Инфа о сезонах
15
58
  %table.table.table-bordered.margin-10.table-serials{style: 'width: 500px;'}
16
59
  %thead
17
60
  %tr
@@ -33,34 +76,40 @@
33
76
  = text_field_tag "name[#{locale}]", nil, class: 'input-xs', style: 'width: 90%;'
34
77
  %td
35
78
  = locale
36
-
37
79
  = link_to "Остальные языки для сериалов", "#", id: 'show-categories-inputs', class: 'margin-10 btn btn-for-link btn-link'
38
80
  = f.link_to_add 'Добавить сезон', :seasons, class: 'margin-10 btn btn-for-link btn-primary'
39
81
  = f.fields_for :seasons do |season_form|
40
82
  = season_form.hidden_field :id
41
- %table.table.table-bordered.margin-10{style: 'width: 500px;'}
42
- %thead
43
- %tr
44
- %th Название сезона
45
- %th на языке
46
- %tbody
47
- - categories_with_locales.each_with_index do |arr, index|
48
- - locale = arr[0]
49
- - title = arr[1]
83
+ .row
84
+ .col-xs-6
85
+ %table.table.table-bordered.margin-10{style: 'width: 500px;'}
86
+ %thead
87
+ %tr
88
+ %th Название сезона
89
+ %th на языке
90
+ %tbody
91
+ - categories_with_locales.each_with_index do |arr, index|
92
+ - locale = arr[0]
93
+ - title = arr[1]
50
94
 
51
- - if index >= 2
52
- - hide_class = "hidden-seasons-inputs"
95
+ - if index >= 2
96
+ - hide_class = "hidden-seasons-inputs"
53
97
 
54
- %tr{class: hide_class}
55
- %td
56
- - if season_form.object.persisted?
57
- = text_field_tag "#{season_form.object_name}[title][#{locale}]]", season_form.object.name_with_locale(locale), class: 'input-xs', style: 'width: 90%;'
58
- - else
59
- = text_field_tag "#{season_form.object_name}[title][#{locale}]]", nil, class: 'input-xs', style: 'width: 90%;'
60
- %td
61
- = locale
62
- = link_to "Остальные языки для сезонов", "#", class: 'show-seasons-inputs margin-10 btn btn-for-link btn-link'
63
- = season_form.link_to_remove 'Удалить сезон', class: 'margin-10 btn btn-for-link btn-danger'
64
-
98
+ %tr{class: hide_class}
99
+ %td
100
+ - if season_form.object.persisted?
101
+ = text_field_tag "#{season_form.object_name}[title][#{locale}]]", season_form.object.name_with_locale(locale), class: 'input-xs', style: 'width: 90%;'
102
+ - else
103
+ = text_field_tag "#{season_form.object_name}[title][#{locale}]]", nil, class: 'input-xs', style: 'width: 90%;'
104
+ %td
105
+ = locale
106
+ = link_to "Остальные языки для сезонов", "#", class: 'show-seasons-inputs margin-10 btn btn-for-link btn-link'
107
+ = season_form.link_to_remove 'Удалить сезон', class: 'margin-10 btn btn-for-link btn-danger'
108
+ .col-xs-4
109
+ %label.textarea
110
+ = season_form.text_field :remote_poster_url, placeholder: 'Ссылка на постер', class: 'form-control input-sm margin-10'
111
+ - if season_form.object.persisted?
112
+ = link_to season_form.object.poster_url do
113
+ = image_tag season_form.object.poster_url, size: '100x100', class: 'margin-left-10'
65
114
  %footer
66
- = f.submit 'Сохранить', class: 'btn btn-primary'
115
+ = f.submit 'Сохранить', class: 'btn btn-primary'
@@ -1,3 +1,9 @@
1
+ - if @footer.persisted? && @footer.source_type != 'local'
2
+ .alert.alert-danger.fade.in
3
+ %button.close{"data-dismiss" => "alert"}
4
+ x
5
+ %i.fa-fw.fa.fa-info
6
+ = "Внимание! Данный футер был получен из #{@footer.source_type} Поэтому, изменив его, он станет локальным и обновляться не будет!"
1
7
  #wid-id-8.jarviswidget{"data-widget-custombutton" => "false", "data-widget-editbutton" => "false", :id => "wid-id-0", 'data-widget-colorbutton' => true}
2
8
  %header
3
9
  %span.widget-icon
@@ -48,4 +54,4 @@
48
54
  %label.select
49
55
  = f.select :country_id, FlyAdmin::Country.all.collect { |c| [c.name,c.id] }, {}, {class: 'input-sm'}
50
56
  %footer
51
- = f.submit 'Сохранить', class: 'btn btn-primary'
57
+ = f.submit 'Сохранить', class: 'btn btn-primary'
@@ -31,6 +31,8 @@
31
31
  Страна
32
32
  %th
33
33
  Траффик
34
+ %th
35
+ Источник
34
36
  %th
35
37
  Опции
36
38
  %tbody
@@ -50,6 +52,8 @@
50
52
  = footer.country.try(:name)
51
53
  %td
52
54
  = footer.paysite.try(:name)
55
+ %td
56
+ = footer.source_type
53
57
  %td
54
58
  = link_to edit_footer_path(footer) do
55
59
  %i.fa.fa-edit.fa-2x
@@ -15,12 +15,7 @@
15
15
  %strong К сведению:
16
16
  = msg
17
17
  - when "error"
18
- .alert.alert-danger.fade.in
19
- %button.close{"data-dismiss" => "alert"}
20
- ×
21
- %i.fa-fw.fa.fa-times
22
- %strong Ошибка:
23
- = msg
18
+ = render 'layouts/error_flash_message', msg: msg
24
19
  - else
25
20
  .alert.alert-info.fade.in
26
21
  %button.close{"data-dismiss" => "alert"}
@@ -0,0 +1,5 @@
1
+ class AddSourceTypeToFlyAdminFooters < ActiveRecord::Migration
2
+ def change
3
+ add_column :fly_admin_footers, :source_type, :string, default: "local"
4
+ end
5
+ end
@@ -0,0 +1,66 @@
1
+ module FlyAdmin
2
+ class ConnectionApi
3
+
4
+ def self.check_user(user)
5
+ valid = true
6
+ begin
7
+ api_url = SiteConfig['wap_click_addr'] + "/api/check"
8
+ api_url = 'http://0.0.0.0:3000/api/check' if Rails.env.eql? 'development'
9
+ request = RestClient.get(api_url, :params => {:pass => user.customer_key})
10
+ hash = JSON.parse request
11
+ hash = hash.with_indifferent_access
12
+ VALIDATION_LOG.info "status for user #{user.id}: #{hash.inspect}"
13
+ valid = false unless hash[:status].eql? true
14
+ rescue Exception => e
15
+ VALIDATION_LOG.error "error check status for user #{user.id}: #{e.message}"
16
+ end
17
+ valid
18
+ end
19
+
20
+ def self.get_customer_params(params, request)
21
+ if ENV["RAILS_ENV"] == 'test' || ENV['TEST'].present? || Rails.env.eql?('test')
22
+ { key: 'fun_key', alias: 'imbs_domain.com', action_type: 'wap', 'status' => 'ok', country: 'az'}
23
+ else
24
+ url = SiteConfig['wap_click_addr'] + '/api/handle_customer'
25
+ # if Rails.env.eql? 'development'
26
+ # url = 'http://0.0.0.0:3000' + '/api/handle_customer'
27
+ # request.env['REMOTE_ADDR'] = '83.149.34.187'
28
+ # end
29
+ request_params = self.make_customer_request_params(request, params)
30
+ if ENV['TEST']
31
+ request_params[:remote_addr] = '83.149.9.19'
32
+ end
33
+ API_LOG.info "HTTP_USER_AGENT: #{request.env['HTTP_USER_AGENT']}"
34
+ API_LOG.info "URL TO IMBS: #{url}?#{request_params.to_query}"
35
+ begin
36
+ response = RestClient.get(url, :params => request_params)
37
+ API_LOG.info "RESPONSE FROM IMBS: #{response.inspect}"
38
+ out_hash = JSON.parse(response)
39
+ out_hash.with_indifferent_access
40
+ rescue Exception => e
41
+ API_LOG.error "response: #{response.inspect}"
42
+ {status: 'error'}
43
+ end
44
+ end
45
+ # end
46
+ end
47
+
48
+ def self.make_customer_request_params(request, params)
49
+ p = {}
50
+ p[:customer_key] = params[:key]
51
+ p[:sid] = params[:sid]
52
+ if p[:customer_key].blank?
53
+ p[:remote_addr] = request.env['REMOTE_ADDR']
54
+ p[:x_forwarded_for] = request.env['HTTP_X_FORWARDED_FOR']
55
+ end
56
+ p[:service_code] = SiteConfig['wc_service_code']
57
+
58
+ p = p.delete_if { |k,v| v.blank? }
59
+
60
+ concat = p[:customer_key].to_s + p[:sid].to_s + p[:remote_addr].to_s + p[:x_forwarded_for].to_s + p[:service_code].to_s + SiteConfig['wc_service_salt'].to_s
61
+ p[:hash] = Digest::MD5.hexdigest(concat)
62
+ p
63
+ end
64
+
65
+ end
66
+ end
@@ -8,14 +8,18 @@ module FlyAdmin
8
8
  def initialize
9
9
  @rails_cache = ActiveSupport::Cache::MemoryStore.new
10
10
  end
11
- # footer_ru_wap
12
- # page_en_mt
11
+ # Get footers like this
12
+ # footer_wap_ru
13
+ # Get pages (unsubscribe etc) like this
14
+ # page_mt_en
13
15
  def read(elem)
14
16
  text = @rails_cache.read(elem)
15
17
  expired_in = @rails_cache.read("#{elem}_expired_an")
16
18
 
17
19
  unless text
18
20
  text = check_footer(elem)
21
+ # Write to Rails cache like
22
+ # elem = content_wap_ru
19
23
  write_with_date(elem, text)
20
24
  else
21
25
  if Time.now > expired_in
@@ -47,7 +51,6 @@ module FlyAdmin
47
51
  @rails_cache.clear
48
52
  end
49
53
 
50
-
51
54
  def check_footer(elem)
52
55
  name, paysite, country = elem.split '_'
53
56
 
@@ -55,9 +58,29 @@ module FlyAdmin
55
58
  .joins(:country, :paysite)
56
59
  .where('fly_admin_countries.name = ? and fly_admin_paysites.name = ?', country, paysite).first
57
60
  # get footer from db , else get it content from url like this www.bornpay.com/footer/hsSDAasd.wap.ru.html
58
- # disable bornpay, use imbs in future
59
- footer ? footer.send(name) : ""
60
- #http_load(name, paysite, country)
61
+ FlyAdmin.api_type == 'bornpay' ? get_footer_from_bornpay(footer, name, paysite, country) : get_footer_from_imbs(footer, name, paysite, country)
62
+ end
63
+ def get_footer_from_bornpay(footer, name, paysite, country)
64
+ if footer && footer.local?
65
+ # Get from db
66
+ footer.send(name)
67
+ else
68
+ # Load from bornpay
69
+ footer_from_request = http_load(name, paysite, country)
70
+ # Save bornpay footer to db
71
+ save_footer_to_db(footer_from_request, name, paysite, country)
72
+ return footer_from_request
73
+ end
74
+ end
75
+
76
+ def get_footer_from_imbs(footer, name, paysite, country)
77
+ if footer
78
+ # Get from db
79
+ footer.send(name)
80
+ else
81
+ # Empty footer
82
+ ""
83
+ end
61
84
  end
62
85
 
63
86
  def http_load(name, paysite, country)
@@ -74,5 +97,28 @@ module FlyAdmin
74
97
  ""
75
98
  end
76
99
  end
100
+
101
+ def save_footer_to_db(footer_text, name, paysite, country)
102
+ if footer_text.present?
103
+ API_LOG.info "footer :#{footer_text}, name: #{name}, paysite: #{paysite}, country: #{country}"
104
+ country = Country.find_by_name(country)
105
+ paysite = Paysite.find_by_name(paysite)
106
+ case name
107
+ when 'content'
108
+ attributes = { 'content' => footer_text}
109
+ when 'unsubscription'
110
+ attributes = { 'unsubscription' => footer_text }
111
+ when 'offer'
112
+ attributes = { 'offer' => footer_text }
113
+ when 'terms'
114
+ attributes = { 'terms' => footer_text }
115
+ end
116
+ attributes.merge!('source_type' => FlyAdmin.api_type)
117
+ footer = FlyAdmin::Footer.find_or_create_by(country: country, paysite: paysite)
118
+ footer.assign_attributes(attributes)
119
+ footer.source_type = FlyAdmin.api_type
120
+ footer.save!
121
+ end
122
+ end
77
123
  end
78
124
  end
@@ -1,3 +1,3 @@
1
1
  module FlyAdmin
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/fly_admin.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "fly_admin/engine"
2
2
  require "fly_admin/page_cache"
3
+ require "fly_admin/connection_api"
3
4
  require "awesome_print"
4
5
  module FlyAdmin
5
6
  # See fly_admin_initializer.rb for more description
@@ -55,6 +55,33 @@ module FlyAdmin
55
55
  end
56
56
  end
57
57
 
58
+ def replace_state_machine_with_state_machines
59
+ gemfile_path = "#{Rails.root}/Gemfile"
60
+ gemfile = File.read(gemfile_path)
61
+ new_contents = gemfile.gsub(/gem "state_machine", :git => '.*'/, "gem 'state_machines-activerecord'")
62
+ new_contents.gsub!(/# using git.*295/, "")
63
+ File.open(gemfile_path, 'w') {|f| f.write(new_contents) }
64
+ ap "Running bundle install", :color => { :string => :green }
65
+ `bundle install`
66
+ end
67
+
68
+ def replace_connection_api
69
+ remove_file('lib/connection_api.rb')
70
+ controller_path = "#{Rails.root}/app/controllers/application_controller.rb"
71
+ controller_contents = File.read(controller_path)
72
+ controller_contents.gsub!(/ ConnectionApi/, " FlyAdmin::ConnectionApi")
73
+ File.open(controller_path, 'w') { |f| f.write(controller_contents) }
74
+ end
75
+
76
+ def replace_subscription_controller
77
+ remove_file('app/controllers/subscriptions_controller.rb')
78
+ routes_path = "#{Rails.root}/config/routes.rb"
79
+ routes_contents = File.read(routes_path)
80
+ routes_contents.gsub!(/"subscriptions#start"/,'"fly_admin/subscriptions#start"')
81
+ routes_contents.gsub!(/"subscriptions#splash"/, '"fly_admin/subscriptions#splash"')
82
+ File.open(routes_path, 'w') { |f| f.write(routes_contents) }
83
+ end
84
+
58
85
  private
59
86
  def engine_not_mounted?
60
87
  File.open("#{Rails.root}/config/routes.rb").each_line do |line|
@@ -27,7 +27,13 @@ namespace :fly_admin do
27
27
  desc 'Migrate existing footers'
28
28
  task :footers => :environment do
29
29
  Footer.all.each do |old_footer|
30
- attributes = old_footer.attributes.merge({"id" => nil, "created_at" => nil, "updated_at" => nil})
30
+ paysite_name = old_footer.paysite.name
31
+ country_name = old_footer.country.name
32
+
33
+ country_id = FlyAdmin::Country.find_by_name(country_name).id
34
+ paysite_id = FlyAdmin::Paysite.find_by_name(paysite_name).id
35
+
36
+ attributes = old_footer.attributes.merge({"id" => nil, "created_at" => nil, "updated_at" => nil, "source_type" => "local", "paysite_id" => paysite_id, "country_id" => country_id})
31
37
  FlyAdmin::Footer.create!(attributes)
32
38
  end
33
39
  ap "Migrating is successfull!", :color => { :string => :green }
@@ -5,4 +5,4 @@ Rails.application.config.assets.version = '1.0'
5
5
 
6
6
  # Precompile additional assets.
7
7
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
- # Rails.application.config.assets.precompile += %w( search.js )
8
+ Rails.application.config.assets.precompile += %w( .eot .svg .ttf .woff )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fly_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Korolev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-27 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mini_magick
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: sqlite3
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +104,8 @@ files:
90
104
  - MIT-LICENSE
91
105
  - README.rdoc
92
106
  - Rakefile
107
+ - app/assets/images/fly_admin/32px.png
108
+ - app/assets/images/fly_admin/40px.png
93
109
  - app/assets/images/fly_admin/ajax-loader.gif
94
110
  - app/assets/images/fly_admin/alpha.png
95
111
  - app/assets/images/fly_admin/avatars/1.png
@@ -903,6 +919,7 @@ files:
903
919
  - app/controllers/fly_admin/categories_controller.rb
904
920
  - app/controllers/fly_admin/footers_controller.rb
905
921
  - app/controllers/fly_admin/settings_controller.rb
922
+ - app/controllers/fly_admin/subscriptions_controller.rb
906
923
  - app/controllers/fly_admin/uploads_controller.rb
907
924
  - app/controllers/fly_admin/videos_controller.rb
908
925
  - app/helpers/fly_admin/application_helper.rb
@@ -946,7 +963,9 @@ files:
946
963
  - db/migrate/20150417075759_create_fly_admin_footers.rb
947
964
  - db/migrate/20150417142656_create_fly_admin_paysites.rb
948
965
  - db/migrate/20150417142744_create_fly_admin_countries.rb
966
+ - db/migrate/20150428102104_add_source_type_to_fly_admin_footers.rb
949
967
  - lib/fly_admin.rb
968
+ - lib/fly_admin/connection_api.rb
950
969
  - lib/fly_admin/engine.rb
951
970
  - lib/fly_admin/page_cache.rb
952
971
  - lib/fly_admin/railtie.rb