c80_contest 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +87 -6
  4. data/app/admin/c80_contest/bids.rb +1 -1
  5. data/app/admin/c80_contest/settings.rb +129 -0
  6. data/app/assets/images/c80_contest/lo.gif +0 -0
  7. data/app/assets/stylesheets/c80_contest/backend/settings_page.scss +32 -0
  8. data/app/assets/stylesheets/c80_contest/frontend/bid_form.scss +85 -0
  9. data/app/assets/stylesheets/c80_contest/frontend/lo.scss +14 -0
  10. data/app/assets/stylesheets/lib/fileinput/fileinput.scss +1 -1
  11. data/app/controllers/c80_contest/application_controller.rb +13 -0
  12. data/app/controllers/c80_contest/bid_controller.rb +1 -2
  13. data/app/controllers/c80_contest/pages_controller.rb +21 -0
  14. data/app/helpers/c80_contest/application_helper.rb +42 -14
  15. data/app/helpers/c80_contest/mailer_helper.rb +22 -0
  16. data/app/mailers/c80_contest/bid_mailer.rb +25 -0
  17. data/app/models/c80_contest/setting.rb +21 -1
  18. data/app/uploaders/c80_contest/button_photo_uploader.rb +32 -0
  19. data/app/views/c80_contest/pages/rules_page.html.erb +7 -0
  20. data/app/views/c80_contest/shared/_banner_button.html.erb +3 -0
  21. data/app/views/c80_contest/shared/_bid_form.html.erb +1 -0
  22. data/c80_contest.gemspec +1 -1
  23. data/config/routes.rb +1 -0
  24. data/db/migrate/20170512114103_add_c80_contest_admin_labels_to_settings.rb +6 -0
  25. data/db/migrate/20170512170504_add_c80_contest_mail_from_to_settings.rb +6 -0
  26. data/db/migrate/20170518165005_add_c80_contest_is_active_to_settings.rb +5 -0
  27. data/db/migrate/20170518191906_add_c80_contest_button_photo_to_settings.rb +5 -0
  28. data/db/seeds/c80_contest_fill_settings.rb +5 -0
  29. data/lib/c80_contest/version.rb +1 -1
  30. data/lib/c80_contest.rb +1 -0
  31. metadata +18 -7
  32. data/app/assets/images/c80_contest/.keep +0 -0
  33. data/app/assets/images/loading-sm.gif +0 -0
  34. data/app/assets/images/loading.gif +0 -0
  35. data/app/assets/stylesheets/c80_contest/frontend/foo.scss +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37ec190a34b844e42cfeafee62ab0d88e3b73617
4
- data.tar.gz: 421a35c9f17885da1f6d193b4d3b276418a53fd3
3
+ metadata.gz: 83d252fc69b885e1bc70a92464817b20cdc39d1a
4
+ data.tar.gz: cb5a10d7604d9fb1fa3b604a2143584d5a13d5d6
5
5
  SHA512:
6
- metadata.gz: 1798ce875d29f544941336bcf2ed976d5fad978bd7e8dab13f90f3657b926bcbc3e064f175af1bbb9d236acf75db272386e562eff5e18a22fb819e84bd6bdcfc
7
- data.tar.gz: 9dad4584a8b24168c0f29b23a4d563886d365e89d3909355fa736ea3c3e0a0a1bc8c10cdf424990d61585ec6e4b3c0d3e759bcfbe764c8959be95ab83060d670
6
+ metadata.gz: 12a31fc40295304bf3c8e7a566940ae0b39db400e99cc77da75832eee90ce0dd90fab1e8dce37e3e8ccd7567fe97186b2e0e9ec43a0eac476e00912682c1f453
7
+ data.tar.gz: 392a997ee618f89c34040c73666e91e654ec1712b427ca62a5d8add90d582a96b3defaad01283aa9a5c550c4f4a1eb37666f7b6dff9ef2d9843052302617df82
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.0
4
+ - 2.2.0
5
5
  before_install: gem install bundler -v 1.15.0.pre.3
data/README.md CHANGED
@@ -6,22 +6,33 @@
6
6
  Добавляет на сайт функционал для проведения конкурса типа "пришли фотографию чека - участвуй в конкурсе по розыгрышу 500 литров бензина".
7
7
  Содержит:
8
8
 
9
- * форму отправки: фото чека, поля для ввода имени и телефона
10
- * страницу в ActiveAdmin
11
- * виджет типа "слайдер-карусель" на ActiveAdmin dashboard
9
+ * форму отправки: фото чека, поля для ввода имени и телефона. Форма
10
+ защищена (по мере возможности) от спама: она запрашивается только тогда,
11
+ когда пользователь кликнул по нужной кнопке - приходит в виде строки,
12
+ превращается в html (с помощью `jQuery`) и помещается на страницу.
13
+
14
+ * страницу в ActiveAdmin с настройками и таблицей заявок
15
+
16
+ Сообщения уходят на почту админу (в настройках можно указать почтовый адрес).
12
17
 
13
18
  ## Dependencies
14
19
 
15
20
  * rails (`::Rails::Engine`)
16
- * activeadmin
17
- * bootstrap
18
- * bootstrap/modal
21
+ * activeadmin (backend)
22
+ * ckeditor (backend)
23
+ * bootstrap (frontend)
24
+ * bootstrap/modal (frontend)
25
+ * c80: modal forms (frontend)
26
+ * remote multipart form (frontend)
19
27
 
20
28
  ## Installation
21
29
 
22
30
  Add this line to your application's Gemfile:
23
31
 
24
32
  ```ruby
33
+ gem 'remotipart'
34
+ gem 'c80_modal_forms'
35
+
25
36
  gem 'c80_contest'
26
37
  ```
27
38
 
@@ -29,4 +40,74 @@ And then execute:
29
40
 
30
41
  $ bundle
31
42
 
43
+ application.js:
44
+
45
+ //= require bootstrap/modal
46
+ //= require bootstrap/transitions
47
+ //= require jquery.remotipart
48
+ //= require c80_modal_forms
49
+
50
+ //= require c80_contest
51
+
52
+ application.scss:
53
+
54
+ @import 'c80_contest';
55
+
56
+ application_controller.rb:
57
+
58
+ helper C80Contest::Engine.helpers
59
+
60
+ routes.rb:
61
+
62
+ mount C80Contest::Engine => '/'
63
+
32
64
  ## Usage
65
+
66
+ ### Settings
67
+
68
+ В админке появляется пункт меню 'Розыгрыш', в котором содержатся
69
+ два подпункта: собственно, заявки от посетителей сайта и настройки
70
+ модуля. Модуль можно выключить - тогда всё исчезнет с сайта, что
71
+ касается розыгрыша, и код менять при этом не нужно. Там же в настройках
72
+ можно менять другие параметры модуля.
73
+
74
+ ### Helpers
75
+
76
+ * `render_banner_button` - отрисует кнопку, по которой можно кликнуть,
77
+ чтобы получить с сервера форму, которую можно заполнить.
78
+
79
+ ### Прелоадер
80
+
81
+ Это то, что видно после клика по кнопке до тех пор,
82
+ пока не получен ответ от сервера (с формой, которую можно заполнить).
83
+
84
+ Кастомизируется с помощью css вида:
85
+
86
+ ```css
87
+ /* этот прелоадер ложится поверх картинки-кнопки,
88
+ закрывая её всю полупрозрачным чёрным, а по-центру
89
+ этого поля расположен анимированный гиф. */
90
+
91
+ /* С помощью width/height подгоняем под конкретный размер картинки,
92
+ которую надо накрыть. */
93
+
94
+ /* т.к. js уже позиционировал див с помощью top/left -
95
+ в css корректируем местонах. с помощью margin.
96
+ */
97
+
98
+ div#lo {
99
+ width: 965px;
100
+ height: 160px;
101
+ background-size: 10%;
102
+ background-color: rgba(0,0,0,0.3);
103
+ margin-top: -65px;
104
+ margin-left: 60px;
105
+ }
106
+ ```
107
+
108
+ # TODO
109
+
110
+ * [ ] Проверить, удаляются ли окна из html, когда их закрываем или когда они сами исчезают
111
+ * [ ] Вывести в настройки размер кнопки-картинки, использовать их в uploader-е и в css прелоадера
112
+ * [ ] Дописать тесты
113
+ * [ ] Допилить Readme
@@ -2,7 +2,7 @@ ActiveAdmin.register C80Contest::Bid, :as => 'Bid' do
2
2
 
3
3
  if ActiveRecord::Base.connection.table_exists?('c80_contest_settings')
4
4
  menu :parent => C80Contest::Setting.first.admin_label_menu,
5
- :label => C80Contest::Setting.first.admin_label_menu if C80Contest::Setting.first.present?
5
+ :label => C80Contest::Setting.first.admin_label_bids if C80Contest::Setting.first.present?
6
6
  end
7
7
 
8
8
  config.sort_order = 'created_at_desc'
@@ -0,0 +1,129 @@
1
+ if defined?(ActiveAdmin)
2
+ ActiveAdmin.register C80Contest::Setting do
3
+
4
+ if ActiveRecord::Base.connection.table_exists?('c80_contest_settings')
5
+ menu :parent => C80Contest::Setting.first.admin_label_menu,
6
+ :label => C80Contest::Setting.first.admin_label_settings if C80Contest::Setting.first.present?
7
+ end
8
+
9
+ # noinspection RubyResolve
10
+ before_filter :skip_sidebar!, :only => :index
11
+
12
+ controller do
13
+
14
+ def update
15
+ setting = C80Contest::Setting.find(params[:id])
16
+ permitted_params[:setting].each_key do |k|
17
+ if k == 'button_photo'
18
+ # byebug
19
+ # noinspection RubyResolve
20
+ setting.button_photo = permitted_params[:setting][k]
21
+ setting.save!
22
+ else
23
+ setting.update_column(k, permitted_params[:setting][k])
24
+ end
25
+ end
26
+ # noinspection RailsParamDefResolve
27
+ redirect_to :action => :index
28
+ end
29
+
30
+ def permitted_params
31
+ params.permit(
32
+ :utf8, :_method, :authenticity_token, :commit, :id,
33
+ :setting => [
34
+ :form_title,
35
+ :form_label_name,
36
+ :form_label_phone,
37
+ :form_label_photo,
38
+ :form_label_button_send,
39
+ :form_label_button_sending,
40
+ :rules,
41
+ :ok_text,
42
+ :ok_text_title,
43
+ :message_letter_subj,
44
+ :message_text,
45
+ :admin_label_menu,
46
+ :admin_label_settings,
47
+ :admin_label_bids,
48
+ :mail_from,
49
+ :mail_to,
50
+ :is_active,
51
+ :button_photo
52
+ ]
53
+ )
54
+ end
55
+ end
56
+
57
+ index do
58
+ column do |s|
59
+ a = ''
60
+ s.attribute_names.sort.each do |n|
61
+ next if n =~ /message_text|created_at|updated_at|id/
62
+ sn = s[n]
63
+
64
+ # особым образом выведем фотку
65
+ if n == 'button_photo'
66
+ if s[n].nil?
67
+ sn = '<картинка баннера не загружена>'
68
+ else
69
+ sn = "<img src='#{# noinspection RubyResolve
70
+ s.button_photo.url}'/>"
71
+ end
72
+ end
73
+
74
+ # особым образом выведем правила
75
+ if n == 'rules' && sn.present?
76
+ tmp = ActionView::Base.full_sanitizer.sanitize(sn)
77
+
78
+ t = tmp.gsub("\n",'')
79
+ s = t unless t.nil?
80
+
81
+ t = s.gsub("\t",' ')
82
+ s = t unless t.nil?
83
+
84
+ t = s.gsub("\r",'')
85
+ s = t unless t.nil?
86
+
87
+ t = s.gsub(/&\w+;/,'*')
88
+ s = t unless t.nil?
89
+
90
+ ah = "<a href='/rules_page' target='_blank' style='text-decoration: underline;'>Просмотреть</a>"
91
+ sn = "#{tmp[0..129]}... <em style='color:#2b2b2b;'>(знаков с пробелами: ~#{s.size})</em> #{ah}"
92
+ end
93
+
94
+ a += "<li><em>#{n}:</em>#{sn}</li>"
95
+ end
96
+ "<ul>#{a}</ul>".html_safe
97
+ end
98
+
99
+ actions
100
+ end
101
+
102
+ form(:html => {:multipart => true}) do |f|
103
+ f.inputs do
104
+ f.input :is_active
105
+ f.input :form_title
106
+ f.input :form_label_name
107
+ f.input :form_label_phone
108
+ f.input :form_label_photo
109
+ f.input :form_label_button_send
110
+ f.input :form_label_button_sending
111
+ # noinspection RubyResolve
112
+ f.input :button_photo, :hint => "#{image_tag(f.object.button_photo.url)}".html_safe
113
+ f.input :rules, :as => :ckeditor
114
+ f.input :ok_text
115
+ f.input :ok_text_title
116
+ f.input :mail_from
117
+ f.input :mail_to
118
+ f.input :message_letter_subj
119
+ f.input :message_text, :input_html => {:rows => 3, :class => 'code_area'}
120
+
121
+ f.input :admin_label_menu
122
+ f.input :admin_label_settings
123
+ f.input :admin_label_bids
124
+ end
125
+ f.actions
126
+ end
127
+
128
+ end
129
+ end
@@ -0,0 +1,32 @@
1
+ body.admin_c80_contest_settings {
2
+
3
+ #titlebar_right .action_items {
4
+ display: none;
5
+ }
6
+
7
+ .table_tools {
8
+ display: none;
9
+ }
10
+
11
+ a.view_link {
12
+ display: none;
13
+ }
14
+ a.delete_link {
15
+ display: none;
16
+ }
17
+
18
+ .blank_slate_container {
19
+ opacity: 0;
20
+ }
21
+
22
+ ul {
23
+ white-space: nowrap;
24
+ em {
25
+ font-weight: bold;
26
+ display: inline-block;
27
+ width: 200px;
28
+ }
29
+
30
+ }
31
+
32
+ }
@@ -0,0 +1,85 @@
1
+ div#bid_form {
2
+
3
+ .modal-content {
4
+
5
+ .modal-header {
6
+
7
+ h4 {
8
+ }
9
+
10
+ a.medium {
11
+ display: block;
12
+ margin: 0 auto;
13
+ text-align: center;
14
+ color: white;
15
+ font-size: 16px;
16
+ text-decoration: underline;
17
+ /*font-family: "DinCondProBold";*/
18
+ }
19
+
20
+ button.close {
21
+ }
22
+
23
+ }
24
+
25
+ .modal-body {
26
+ label.control-label {
27
+ }
28
+
29
+ .form-control {
30
+
31
+ /*стилизуем bootstrap fileinput*/
32
+ &.kv-fileinput-caption {
33
+
34
+ /*в этом блоке живёт имя файла и иконка слева*/
35
+ div.file-caption-name {
36
+ overflow: visible;
37
+ height: 28px;
38
+ margin-top: 8px;
39
+ margin-left: 6px;
40
+
41
+ /*иконку чуть отодвинем влево*/
42
+ i.glyphicon {
43
+ left: -6px;
44
+ color: #337ab7;
45
+ }
46
+
47
+ }
48
+ }
49
+
50
+ }
51
+
52
+ .input-group-btn {
53
+
54
+ /*скроем кнопку "загрузить" плагина fileinput*/
55
+ .fileinput-upload-button {
56
+ display: none;
57
+ }
58
+
59
+ /*кнопки "удалить" и "browse" подгоним по высоте к полю, где живёт имя файла*/
60
+ .btn {
61
+ }
62
+
63
+ }
64
+
65
+ /*у плагина fileinput картинку-предпросмотр ограничим по ширине*/
66
+ .kv-file-content {
67
+ img.file-preview-image {
68
+ width: auto !important;
69
+ height: auto !important;
70
+ max-width: 625px;
71
+ }
72
+ }
73
+
74
+ div.actions {
75
+ label.control-label {
76
+ display: none;
77
+ }
78
+ input.btn {
79
+
80
+ }
81
+ }
82
+ }
83
+
84
+ }
85
+ }
@@ -0,0 +1,14 @@
1
+ #lo {
2
+ position: absolute;
3
+ width: 50px;
4
+ height: 17px;
5
+ background: transparent url(image_path('c80_contest/lo.gif')) no-repeat 50% 50%;
6
+ z-index: 120;
7
+ transition: visibility 1s, opacity 0.5s linear;
8
+
9
+ &.invis {
10
+ visibility: hidden;
11
+ opacity: 0;
12
+ }
13
+
14
+ }
@@ -109,7 +109,7 @@
109
109
  }
110
110
 
111
111
  .kv-file-content {
112
- height: 170px;
112
+ height: auto;
113
113
  }
114
114
 
115
115
  .file-thumbnail-footer {
@@ -1,5 +1,18 @@
1
1
  module C80Contest
2
2
  class ApplicationController < ActionController::Base
3
3
  protect_from_forgery with: :exception
4
+
5
+ # noinspection RubyResolve
6
+ before_filter :check_is_active
7
+
8
+ private
9
+
10
+ def check_is_active
11
+ # noinspection RubyResolve
12
+ unless Setting.first.is_active
13
+ render :plain => 'none'
14
+ end
15
+ end
16
+
4
17
  end
5
18
  end
@@ -8,8 +8,7 @@ module C80Contest
8
8
 
9
9
  # noinspection RubyResolve
10
10
  format.js
11
- settings = Setting.first
12
- # MessageOrderMailer.send_mess(m, settings.message_letter_subj).deliver
11
+ BidMailer.send_letter(m).deliver#_now
13
12
  else
14
13
  # noinspection RubyResolve
15
14
  format.js { render json: m.errors, status: :unprocessable_entity }
@@ -0,0 +1,21 @@
1
+ module C80Contest
2
+ class PagesController < ::ApplicationController
3
+
4
+ # noinspection RubyResolve
5
+ before_filter :check_is_active
6
+
7
+ def rules_page
8
+ @rules = Setting.first.rules
9
+ end
10
+
11
+ private
12
+
13
+ def check_is_active
14
+ # noinspection RubyResolve
15
+ unless Setting.first.is_active
16
+ render :plain => 'none'
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -1,25 +1,53 @@
1
1
  module C80Contest
2
2
  module ApplicationHelper
3
3
 
4
- def render_bid_form(bid)
4
+ # такое тоже бывает, после того, как создал PagesController
5
+ def root_url
6
+ '/'
7
+ end
5
8
 
6
- settings = Setting.first
9
+ def render_bid_form(bid)
10
+ # noinspection RubyResolve
11
+ if settings.is_active
12
+ render :partial => 'c80_contest/shared/bid_form',
13
+ :locals => {
14
+ bid: bid,
15
+ settings: settings
16
+ }
17
+ else
18
+ render :plain => ''
19
+ end
20
+ end
7
21
 
8
- render :partial => 'c80_contest/shared/bid_form',
9
- :locals => {
10
- bid: bid,
11
- settings: settings
12
- }
22
+ def render_ok_message
23
+ # noinspection RubyResolve
24
+ if settings.is_active
25
+ render :partial => 'c80_contest/shared/ok_message',
26
+ :locals => {
27
+ ok_text: settings.ok_text,
28
+ ok_text_title: settings.ok_text_title
29
+ }
30
+ else
31
+ render :plain => ''
32
+ end
33
+ end
13
34
 
35
+ def render_banner_button
36
+ # noinspection RubyResolve
37
+ if settings.is_active
38
+ render :partial => 'c80_contest/shared/banner_button',
39
+ :locals => {
40
+ img_url: settings.button_photo.url
41
+ }
42
+ else
43
+ render :plain => ''
44
+ end
14
45
  end
15
46
 
16
- def render_ok_message
17
- settings = Setting.first
18
- render :partial => 'c80_contest/shared/ok_message',
19
- :locals => {
20
- ok_text: settings.ok_text,
21
- ok_text_title: settings.ok_text_title
22
- }
47
+ private
48
+
49
+ def settings
50
+ @settings ||= Setting.first
23
51
  end
24
52
 
25
53
  end
@@ -0,0 +1,22 @@
1
+ module C80Contest
2
+ module MailerHelper
3
+ def format_message(bid)
4
+
5
+ # noinspection RubyResolve
6
+ m = Setting.first.message_text
7
+
8
+ tmp = m.gsub!('{title}',bid.title)
9
+ m = tmp unless tmp.nil?
10
+
11
+ tmp = m.gsub!('{phone}',bid.phone)
12
+ m = tmp unless tmp.nil?
13
+
14
+ tmp = m.gsub!('{bid_id}',bid.id.to_s)
15
+ m = tmp unless tmp.nil?
16
+
17
+ tmp = m.gsub!('{photo_url}',bid.photo.url.to_s)
18
+ m = tmp unless tmp.nil?
19
+ m
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module C80Contest
2
+ class BidMailer < ActionMailer::Base
3
+
4
+ include C80Contest::MailerHelper
5
+
6
+ default from: Proc.new { Setting.first.mail_from },
7
+ to: Proc.new { Setting.first.mail_to }
8
+
9
+ def send_letter(bid)
10
+
11
+ subj = Setting.first.message_letter_subj
12
+
13
+ # Rails.logger.debug "<BidMailer.send_letter> subj: #{subj}, #{bid.as_json}"
14
+ @message = format_message(bid)
15
+
16
+ # puts '<BidMailer.send_letter> Отправляем сообщение.'
17
+ mail(subject: subj) do |format|
18
+ format.html { render inline: '<%= @message.html_safe %>'}
19
+ end
20
+
21
+ #puts "#{SiteProps.first.mail_to}"
22
+ end
23
+
24
+ end
25
+ end
@@ -1,6 +1,8 @@
1
1
  module C80Contest
2
2
  class Setting < ActiveRecord::Base
3
3
 
4
+ mount_uploader :button_photo, C80Contest::ButtonPhotoUploader
5
+
4
6
  validates :form_title,
5
7
  :presence => true,
6
8
  :length => { :in => 5..125 }
@@ -39,7 +41,7 @@ module C80Contest
39
41
 
40
42
  validates :rules,
41
43
  # :presence => true,
42
- :length => { :in => 0..1000 }
44
+ :length => { :in => 0..10000 }
43
45
 
44
46
  validates :message_letter_subj,
45
47
  :presence => true,
@@ -49,5 +51,23 @@ module C80Contest
49
51
  :presence => true,
50
52
  :length => { :in => 20..499 }
51
53
 
54
+ validates :admin_label_settings,
55
+ :presence => true,
56
+ :length => { in: 5..20 }
57
+
58
+ validates :admin_label_bids,
59
+ :presence => true,
60
+ :length => { in: 5..20 }
61
+
62
+ validates :mail_from,
63
+ :presence => true,
64
+ :length => { in: 5..40 },
65
+ :format => { with: /\A([a-z0-9_.-]+)@([a-z0-9-]+)\.[a-z.]+\z/ }
66
+
67
+ validates :mail_to,
68
+ :presence => true,
69
+ :length => { in: 5..40 },
70
+ :format => { with: /\A([a-z0-9_.-]+)@([a-z0-9-]+)\.[a-z.]+\z/ }
71
+
52
72
  end
53
73
  end
@@ -0,0 +1,32 @@
1
+ module C80Contest
2
+
3
+ class ButtonPhotoUploader < ::CarrierWave::Uploader::Base
4
+
5
+ include ::CarrierWave::MiniMagick
6
+
7
+ storage :file
8
+ process :resize_to_limit => [965, 965]
9
+
10
+ version :thumb do
11
+ process :resize_to_fit => [500,500]
12
+ end
13
+
14
+ def store_dir
15
+ 'uploads/buttons/'
16
+ end
17
+
18
+ def filename
19
+ if original_filename
20
+ "button_#{secure_token(4)}.#{file.extension}"
21
+ end
22
+ end
23
+
24
+ protected
25
+ def secure_token(length=16)
26
+ var = :"@#{mounted_as}_secure_token"
27
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,7 @@
1
+ <div class="center-block rules-page-btn">
2
+ <%= render_banner_button %>
3
+ </div>
4
+ <div class="center-block rules-page">
5
+ <%= # noinspection RubyResolve
6
+ @rules.html_safe if @rules.present? %>
7
+ </div>
@@ -0,0 +1,3 @@
1
+ <%# C80Contest::ApplicationHelper: render_banner_button %>
2
+ <%= # noinspection RubyResolve
3
+ link_to image_tag(img_url), '#', :class => 'c80_contest_invoking_btn' %>
@@ -8,6 +8,7 @@
8
8
  <div class="modal-header">
9
9
  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
10
10
  <h4 class="modal-title medium" id="myModalLabel"><%= settings.form_title %></h4>
11
+ <%= link_to 'Подробные условия акции', '/rules_page', :class => 'medium', :target => :blank %>
11
12
  </div>
12
13
  <div class="modal-body regular">
13
14
 
data/c80_contest.gemspec CHANGED
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency 'bootstrap-sass', '>= 3.3.5.1'
40
40
  spec.add_development_dependency 'sass-rails', '>= 5.0.4'
41
41
  spec.add_development_dependency 'c80_modal_forms', '~> 0.1.0.1'
42
- spec.add_development_dependency 'byebug', '~> 9.0.6'
42
+ spec.add_dependency 'byebug', '~> 9.0.6'
43
43
 
44
44
  # spec.add_development_dependency 'combustion', '~> 0.6.0'
45
45
 
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  C80Contest::Engine.routes.draw do
2
2
  match '/give_me_bid_form', :to => 'site#give_me_form', :via => :post, :defaults => { :format => 'js' }
3
3
  match '/make_bid', :to => 'bid#make_bid', :via => :post, :defaults => { :format => 'js' }
4
+ match '/rules_page', :to => 'pages#rules_page', :via => :get
4
5
  end
@@ -0,0 +1,6 @@
1
+ class AddC80ContestAdminLabelsToSettings < ActiveRecord::Migration
2
+ def change
3
+ add_column :c80_contest_settings, :admin_label_settings, :string
4
+ add_column :c80_contest_settings, :admin_label_bids, :string
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddC80ContestMailFromToSettings < ActiveRecord::Migration
2
+ def change
3
+ add_column :c80_contest_settings, :mail_from, :string
4
+ add_column :c80_contest_settings, :mail_to, :string
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddC80ContestIsActiveToSettings < ActiveRecord::Migration
2
+ def change
3
+ add_column :c80_contest_settings, :is_active, :boolean
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddC80ContestButtonPhotoToSettings < ActiveRecord::Migration
2
+ def change
3
+ add_column :c80_contest_settings, :button_photo, :string
4
+ end
5
+ end
@@ -11,8 +11,13 @@ C80Contest::Setting.create!({
11
11
  :ok_text => 'Ваша заявка принята',
12
12
  :ok_text_title => 'Ваша заявка отправлена',
13
13
  :admin_label_menu => 'Розыгрыш',
14
+ :admin_label_bids => 'Заявки',
15
+ :admin_label_settings => 'Настройки',
14
16
  :rules => 'Акция проводится с 18 мая по 18 июня. В розыгрыше участвуют чеки на покупки, совершённые в цетре "7авто".',
15
17
  :message_letter_subj => 'Заявка на участие',
18
+ :mail_from => 'robot@mail.ru',
19
+ :mail_to => 'admin@mail.ru',
20
+ :is_active => true,
16
21
  :message_text => ' • Имя: {name}<br>' +
17
22
  ' • Номер телефона: {phone}<br>' +
18
23
  ' • Фото чека: <br>' +
@@ -1,3 +1,3 @@
1
1
  module C80Contest
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/c80_contest.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'c80_contest/version'
2
2
  require 'c80_contest/engine'
3
+ require 'byebug'
3
4
 
4
5
  module C80Contest
5
6
  def self.table_name_prefix
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_contest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-12 00:00:00.000000000 Z
11
+ date: 2017-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -241,7 +241,7 @@ dependencies:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
243
  version: 9.0.6
244
- type: :development
244
+ type: :runtime
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
@@ -268,9 +268,8 @@ files:
268
268
  - README.rdoc
269
269
  - Rakefile
270
270
  - app/admin/c80_contest/bids.rb
271
- - app/assets/images/c80_contest/.keep
272
- - app/assets/images/loading-sm.gif
273
- - app/assets/images/loading.gif
271
+ - app/admin/c80_contest/settings.rb
272
+ - app/assets/images/c80_contest/lo.gif
274
273
  - app/assets/javascripts/c80_contest.js.coffee
275
274
  - app/assets/javascripts/c80_contest/frontend/ajax_bid_form.js
276
275
  - app/assets/javascripts/lib/fileinput/fileinput.js
@@ -279,18 +278,26 @@ files:
279
278
  - app/assets/javascripts/lib/fileinput/themes/gly/theme.js
280
279
  - app/assets/stylesheets/c80_contest.scss
281
280
  - app/assets/stylesheets/c80_contest/backend/bid_page.scss
282
- - app/assets/stylesheets/c80_contest/frontend/foo.scss
281
+ - app/assets/stylesheets/c80_contest/backend/settings_page.scss
282
+ - app/assets/stylesheets/c80_contest/frontend/bid_form.scss
283
+ - app/assets/stylesheets/c80_contest/frontend/lo.scss
283
284
  - app/assets/stylesheets/c80_contest_active_admin.scss
284
285
  - app/assets/stylesheets/lib/fileinput/fileinput.scss
285
286
  - app/assets/stylesheets/lib/fileinput/themes/explorer/theme.scss
286
287
  - app/controllers/c80_contest/application_controller.rb
287
288
  - app/controllers/c80_contest/bid_controller.rb
289
+ - app/controllers/c80_contest/pages_controller.rb
288
290
  - app/controllers/c80_contest/site_controller.rb
289
291
  - app/helpers/c80_contest/application_helper.rb
292
+ - app/helpers/c80_contest/mailer_helper.rb
293
+ - app/mailers/c80_contest/bid_mailer.rb
290
294
  - app/models/c80_contest/bid.rb
291
295
  - app/models/c80_contest/setting.rb
292
296
  - app/uploaders/c80_contest/bid_photo_uploader.rb
297
+ - app/uploaders/c80_contest/button_photo_uploader.rb
293
298
  - app/views/c80_contest/bid/make_bid.js.erb
299
+ - app/views/c80_contest/pages/rules_page.html.erb
300
+ - app/views/c80_contest/shared/_banner_button.html.erb
294
301
  - app/views/c80_contest/shared/_bid_form.html.erb
295
302
  - app/views/c80_contest/shared/_ok_message.html.erb
296
303
  - app/views/c80_contest/site/give_me_form.js.erb
@@ -303,6 +310,10 @@ files:
303
310
  - create_base.rb
304
311
  - db/migrate/20170510124400_create_c80_contest_bids.rb
305
312
  - db/migrate/20170511145501_create_c80_contest_settings.rb
313
+ - db/migrate/20170512114103_add_c80_contest_admin_labels_to_settings.rb
314
+ - db/migrate/20170512170504_add_c80_contest_mail_from_to_settings.rb
315
+ - db/migrate/20170518165005_add_c80_contest_is_active_to_settings.rb
316
+ - db/migrate/20170518191906_add_c80_contest_button_photo_to_settings.rb
306
317
  - db/seeds/c80_contest_fill_settings.rb
307
318
  - lib/c80_contest.rb
308
319
  - lib/c80_contest/engine.rb
File without changes
Binary file
Binary file
File without changes