c80_news_tz 0.1.1.15 → 0.1.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/admin/c80_news_tz/spots.rb +43 -0
- data/app/models/c80_news_tz/rubric.rb +27 -0
- data/app/models/c80_news_tz/spot.rb +6 -0
- data/db/migrate/20160307075757_create_spots.rb +10 -0
- data/db/migrate/20160307075858_create_join_table_rubrics_spots.rb +12 -0
- data/lib/c80_news_tz/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26125a7e49af2991e638979c7f5df740775831e0
|
4
|
+
data.tar.gz: 83f7bfa87b315b1b215a044f4c9d689d428515d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2f6a42ab356be29fd8fa9b75aafc8a96cf727d7afcf1c6d0421ea8af926e6c029a3b4700f9a17629d38c0ed7ea772c426a090d7b9ceb0895ba4c428c5108725
|
7
|
+
data.tar.gz: f2b136bb79682ea4698995a5af228371851fdbf52f8c62e6e129c007ccf9912f7c9afe259390e78dc0326f6f615070aab97d9063f26f22fc4f62da77e5de1042
|
@@ -0,0 +1,43 @@
|
|
1
|
+
ActiveAdmin.register C80NewsTz::Spot, :as => 'Spot' do
|
2
|
+
|
3
|
+
menu :label => "Рубрики на главной", :parent => 'Содержимое сайта'
|
4
|
+
|
5
|
+
before_filter :skip_sidebar!, :only => :index
|
6
|
+
|
7
|
+
permit_params :rubric_ids => []
|
8
|
+
|
9
|
+
config.sort_order = 'id_asc'
|
10
|
+
|
11
|
+
index do
|
12
|
+
id_column
|
13
|
+
column :title
|
14
|
+
|
15
|
+
column :rubrics do |loc|
|
16
|
+
# нарисуем список
|
17
|
+
list_items = ((loc.rubrics.map { |p|
|
18
|
+
"<li>• #{ p.title } <a href='/rubrics/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/rubrics/#{p.slug}/edit'>[edit]</a> </li>"
|
19
|
+
}).join("")).html_safe
|
20
|
+
|
21
|
+
"<ul>#{list_items}</ul>".html_safe
|
22
|
+
end
|
23
|
+
|
24
|
+
actions
|
25
|
+
end
|
26
|
+
|
27
|
+
form(:html => {:multipart => true}) do |f|
|
28
|
+
f.inputs "Свойства" do
|
29
|
+
f.input :title
|
30
|
+
|
31
|
+
f.input :rubrics,
|
32
|
+
:as => :select,
|
33
|
+
:input_html => {:multiple => false},
|
34
|
+
:include_blank => true,
|
35
|
+
:member_label => Proc.new { |p|
|
36
|
+
p.title
|
37
|
+
}
|
38
|
+
|
39
|
+
end
|
40
|
+
f.actions
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "babosa"
|
2
2
|
module C80NewsTz
|
3
3
|
class Rubric < ActiveRecord::Base
|
4
|
+
has_and_belongs_to_many :spots, :join_table => 'c80_news_tz_rubrics_spots'
|
5
|
+
|
4
6
|
validates_with RubricValidator
|
5
7
|
|
6
8
|
extend FriendlyId
|
@@ -21,5 +23,30 @@ module C80NewsTz
|
|
21
23
|
# name_changed? || super
|
22
24
|
end
|
23
25
|
|
26
|
+
# выдать массив рубрик, которые должны выводиться на главной
|
27
|
+
def self.select_all_in_spots
|
28
|
+
s = "
|
29
|
+
SELECT
|
30
|
+
`c80_news_tz_rubrics`.*,
|
31
|
+
`c80_news_tz_spots`.`id` AS `spot_id`
|
32
|
+
FROM `c80_news_tz_rubrics`
|
33
|
+
INNER JOIN `c80_news_tz_rubrics_spots` ON `c80_news_tz_rubrics_spots`.`rubric_id` = `c80_news_tz_rubrics`.`id`
|
34
|
+
INNER JOIN `c80_news_tz_spots` ON `c80_news_tz_spots`.`id` = `c80_news_tz_rubrics_spots`.`spot_id`
|
35
|
+
ORDER BY `spot_id`;
|
36
|
+
"
|
37
|
+
result = self.find_by_sql(s)
|
38
|
+
result
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# выдать публикации из этой рубрики
|
43
|
+
def pubs(lim = nil)
|
44
|
+
if lim.nil?
|
45
|
+
C80NewsTz::Fact.joins(:rubrics).where(:c80_news_tz_rubrics => {:title => self.title})
|
46
|
+
else
|
47
|
+
C80NewsTz::Fact.joins(:rubrics).where(:c80_news_tz_rubrics => {:title => self.title}).limit(lim)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
24
51
|
end
|
25
52
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateJoinTableRubricsSpots < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :c80_news_tz_rubrics_spots, :id => false do |t|
|
4
|
+
t.integer :rubric_id, :null => false
|
5
|
+
t.integer :spot_id, :null => false
|
6
|
+
end
|
7
|
+
|
8
|
+
# Add table index
|
9
|
+
add_index :c80_news_tz_rubrics_spots, [:rubric_id, :spot_id], :unique => true
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
data/lib/c80_news_tz/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c80_news_tz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.
|
4
|
+
version: 0.1.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C80609A
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- app/admin/c80_news_tz/locations.rb
|
101
101
|
- app/admin/c80_news_tz/notices.rb
|
102
102
|
- app/admin/c80_news_tz/rubrics.rb
|
103
|
+
- app/admin/c80_news_tz/spots.rb
|
103
104
|
- app/assets/images/c80_news_tz/.keep
|
104
105
|
- app/assets/javascripts/c80_news_tz/application.js.coffee
|
105
106
|
- app/assets/javascripts/c80_news_tz/backend.js.coffee
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- app/models/c80_news_tz/prop.rb
|
132
133
|
- app/models/c80_news_tz/rubric.rb
|
133
134
|
- app/models/c80_news_tz/rubric_validator.rb
|
135
|
+
- app/models/c80_news_tz/spot.rb
|
134
136
|
- app/uploaders/c80_news_tz/clogo_uploader.rb
|
135
137
|
- app/uploaders/c80_news_tz/cphoto_uploader.rb
|
136
138
|
- app/uploaders/c80_news_tz/fphoto_uploader.rb
|
@@ -166,6 +168,8 @@ files:
|
|
166
168
|
- db/migrate/20160227121416_create_nphotos.rb
|
167
169
|
- db/migrate/20160304145554_create_locations.rb
|
168
170
|
- db/migrate/20160304145555_create_join_table_facts_locations.rb
|
171
|
+
- db/migrate/20160307075757_create_spots.rb
|
172
|
+
- db/migrate/20160307075858_create_join_table_rubrics_spots.rb
|
169
173
|
- db/seeds/19_fill_news_props.rb.example
|
170
174
|
- db/seeds/20_fill_rubrics.rb.example
|
171
175
|
- db/seeds/21_fill_facts.rb.example
|