c80_catoffers 0.1.0.5 → 0.1.0.6

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: e24a140e8e1791afd467b47c91cecce3fde43a05
4
- data.tar.gz: c1b606cceea2bc85671d82460c29f2ef4a45efe2
3
+ metadata.gz: 799acd02cc226c0ceea7ffb1d1ed099a55692f96
4
+ data.tar.gz: 9eef70870ee7a13a9822591d2baba9765f609b1e
5
5
  SHA512:
6
- metadata.gz: b2ecc4996ba2766dd631aeb4e1f33efc41267a2dea446c0ed09b05634af480e6ef13a29333a2c7cc2a8626661cc2fa506b340924d82bcc585e9624e676cc9efa
7
- data.tar.gz: efaa06b0777b51d3de73b07ff84eeda4e1e10b9401db560b28eb097c4fd1e951d05871996ff574fbf137752cc5389fcc67db69be223120dd4fc7acd9351aba94
6
+ metadata.gz: 8c2e7d24b5e14401b902899c70b89c7973f260288ed111231daff8036db00899ba7e1c957c6bd7047aee0ad8fc19ca901d3aed1fdcd80e5a3480da31604ee338
7
+ data.tar.gz: 6d78af6d91eb805b080e351b5f3c8b6ccfba55ff611333296801a294e915e4c5b9c5e590c4350f809c2ac67bb35c9defbf8082203d0821686ab4b4ea7f45703b
@@ -0,0 +1,34 @@
1
+ ActiveAdmin.register C80Catoffers::Price, as: 'Price' do
2
+
3
+ menu :label => 'Прайсы', # TODO_MY:: название пункта меню перенесести в параметры в базу
4
+ priority: 3,
5
+ parent: 'Услуги' # TODO_MY:: название пункта меню перенесести в параметры в базу
6
+
7
+ permit_params :title,
8
+ :file
9
+
10
+ batch_action :destroy, false
11
+
12
+ before_filter :skip_sidebar!, :only => :index
13
+
14
+ index do
15
+ column :title
16
+ column :file do |price|
17
+ link_to price.file, price.file.url, { :target => '_blank' }
18
+ end
19
+ actions
20
+ end
21
+
22
+ form(:html => {:multipart => true}) do |f|
23
+ f.inputs 'Свойства' do
24
+
25
+ f.input :title
26
+ f.input :file,
27
+ :as => :file,
28
+ :hint => f.object.file.url #f.template.asset_url(f.object.file.url)
29
+
30
+ end
31
+ f.actions
32
+ end
33
+
34
+ end
@@ -5,6 +5,8 @@ module C80Catoffers
5
5
 
6
6
  helper C80LazyImages::Engine.helpers
7
7
 
8
+ protect_from_forgery with: :exception
9
+
8
10
  def offers_guru
9
11
  respond_to do |format|
10
12
  format.js
@@ -3,6 +3,15 @@ module C80Catoffers
3
3
  module ModalHelper
4
4
 
5
5
  def _render_bs_modal(content='', title='')
6
+
7
+ # Если имеется загруженный прайс (в виде файла) - допишем к title ссылку на скачивание
8
+ if Price.all.count > 0
9
+ p = Price.first
10
+ file_url = p.file.url
11
+ file_ext = File.extname(file_url).split('.').join('')
12
+ title = "#{title} (<a href='#{file_url}' title='Откроется в новом окне' target='_blank'>скачать #{file_ext}</a>)"
13
+ end
14
+
6
15
  render :partial => 'c80_catoffers/bs_modal',
7
16
  :locals => {
8
17
  title: title,
@@ -0,0 +1,7 @@
1
+ module C80Catoffers
2
+
3
+ class Price < ActiveRecord::Base
4
+ mount_uploader :file, PriceUploader
5
+ end
6
+
7
+ end
@@ -0,0 +1,26 @@
1
+ module C80Catoffers
2
+
3
+ class PriceUploader < CarrierWave::Uploader::Base
4
+
5
+ storage :file
6
+
7
+ def filename
8
+ if original_filename
9
+ "price_#{secure_token(4)}.#{file.extension}"
10
+ end
11
+ end
12
+
13
+ protected
14
+ def secure_token(length=16)
15
+ var = :"@#{mounted_as}_secure_token"
16
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
17
+ end
18
+
19
+
20
+ def store_dir
21
+ 'uploads/prices'
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -4,13 +4,13 @@
4
4
  <div class="modal-content">
5
5
  <div class="modal-header">
6
6
  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
7
- <h4 class="modal-title" id="myModalLabel"><%= title %></h4>
7
+ <h4 class="modal-title" id="myModalLabel"><%= title.html_safe %></h4>
8
8
  </div>
9
9
  <div class="modal-body">
10
10
  <%= content.html_safe %>
11
11
  </div>
12
12
  <div class="modal-footer">
13
- <button type="button" class="btn btn-default" data-dismiss="modal"><%= close_label %></button>
13
+ <button type="button" class="btn btn-default" data-dismiss="modal"><%= close_label.html_safe %></button>
14
14
  <!--<button type="button" class="btn btn-primary">Save changes</button>-->
15
15
  </div>
16
16
  </div>
@@ -0,0 +1,10 @@
1
+ class CreateC80CatoffersPrices < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_catoffers_prices, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.string :file
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module C80Catoffers
2
- VERSION = '0.1.0.5'
2
+ VERSION = '0.1.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_catoffers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.5
4
+ version: 0.1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-15 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,6 +69,7 @@ files:
69
69
  - app/admin/c80_catoffers/csamples.rb
70
70
  - app/admin/c80_catoffers/csprops.rb
71
71
  - app/admin/c80_catoffers/offers.rb
72
+ - app/admin/c80_catoffers/prices.rb
72
73
  - app/admin/c80_catoffers/props.rb
73
74
  - app/assets/javascripts/c80_catoffers.js.coffee
74
75
  - app/assets/javascripts/c80_catoffers/offer_full_desc.js
@@ -97,9 +98,11 @@ files:
97
98
  - app/models/c80_catoffers/csprop.rb
98
99
  - app/models/c80_catoffers/offer.rb
99
100
  - app/models/c80_catoffers/ophoto.rb
101
+ - app/models/c80_catoffers/price.rb
100
102
  - app/models/c80_catoffers/prop.rb
101
103
  - app/uploaders/c80_catoffers/csphoto_uploader.rb
102
104
  - app/uploaders/c80_catoffers/ophoto_uploader.rb
105
+ - app/uploaders/c80_catoffers/price_uploader.rb
103
106
  - app/views/c80_catoffers/_bs_modal.html.erb
104
107
  - app/views/c80_catoffers/_csamples_widget.html.erb
105
108
  - app/views/c80_catoffers/_offer_full_desc.html.erb
@@ -132,6 +135,7 @@ files:
132
135
  - db/migrate/20161106191544_create_c80_catoffers_crows.rb
133
136
  - db/migrate/20161107115555_c80_catoffers_create_csprops.rb
134
137
  - db/migrate/20161107123333_c80_catoffers_create_join_table_csprops_csamples.rb
138
+ - db/migrate/20161213211414_create_c80_catoffers_prices.rb
135
139
  - db/seeds/c80_catoffers_01_fill_props.rb
136
140
  - db/seeds/c80_catoffers_02_fill_offers.rb
137
141
  - db/seeds/x02_fill_categories.rb