c80_estate 0.1.0.33 → 0.1.0.34
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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/admin/c80_estate/areas.rb +29 -8
- data/app/models/c80_estate/area.rb +84 -25
- data/app/models/c80_estate/property.rb +1 -0
- data/app/views/c80_estate/shared/properties/_single_property_on_page.html.erb +12 -10
- data/lib/c80_estate/version.rb +1 -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: 832f4348a9023325a7bbb127efb6c10234eb27b8
|
|
4
|
+
data.tar.gz: a716de7341084ea34df0bf2d2b71f7e70c6fd723
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 273b0fd67f31a3b0d1fa0f5e8ce3ccab77996ceb10546154149cf31fa9ceb27677c8b2c5fd262bc3494dee098a1527309e3c637df71c645492e0624d29e21667
|
|
7
|
+
data.tar.gz: 8b3c499e0e165c338bde6113941723e4477a934cabb5be9b28035dd2100ccd0d53876f3f3dde10aa81b8c025d8396ab37fefe59e18c4043a9377ce289d71bbb5
|
data/README.md
CHANGED
|
@@ -46,6 +46,29 @@ ActiveAdmin.register C80Estate::Area, as: 'Area' do
|
|
|
46
46
|
|
|
47
47
|
config.clear_action_items!
|
|
48
48
|
|
|
49
|
+
controller do
|
|
50
|
+
|
|
51
|
+
def scoped_collection
|
|
52
|
+
|
|
53
|
+
# [X] 1. оптимизируем выдачу на index, согласно
|
|
54
|
+
# http://activeadmin.info/docs/2-resource-customization.html#customizing-resource-retrieval
|
|
55
|
+
# https://github.com/activeadmin/activeadmin/commit/f8ef8ca7f9ce6dc70a4761d6269477f0dff448ec
|
|
56
|
+
# http://www.rubydoc.info/gems/activeadmin/file/docs/2-resource-customization.md
|
|
57
|
+
|
|
58
|
+
# [ ]2. решаем задачу с "чужими незанятыми" и "чужими занятыми".
|
|
59
|
+
# * http://stackoverflow.com/a/23788089
|
|
60
|
+
# способ реализации с дописанным кастомным where
|
|
61
|
+
# super.where(account_id: account.id).order(:date_sent)
|
|
62
|
+
|
|
63
|
+
# включаем atypes и properties.logos: http://stackoverflow.com/a/24397716
|
|
64
|
+
C80Estate::Area
|
|
65
|
+
.includes(:astatuses, :atype, property: :plogos) ##[1]
|
|
66
|
+
.all_except_busy_alien(current_admin_user)
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
49
72
|
action_item :new_model, :only => :index do
|
|
50
73
|
if current_admin_user.can_create_areas?
|
|
51
74
|
link_to I18n.t("active_admin.new_model"), '/admin/areas/new', method: :get
|
|
@@ -72,6 +95,8 @@ ActiveAdmin.register C80Estate::Area, as: 'Area' do
|
|
|
72
95
|
|
|
73
96
|
config.sort_order = 'id_asc'
|
|
74
97
|
|
|
98
|
+
# before_filter :skip_sidebar!, :only => :index
|
|
99
|
+
|
|
75
100
|
filter :atype_id,
|
|
76
101
|
:label => 'Тип площади',
|
|
77
102
|
:as => :select,
|
|
@@ -141,14 +166,15 @@ ActiveAdmin.register C80Estate::Area, as: 'Area' do
|
|
|
141
166
|
scope "All", :all_areas
|
|
142
167
|
scope "Free", :free_areas
|
|
143
168
|
scope "Busy", :busy_areas
|
|
169
|
+
# scope 'My', :my_areas
|
|
144
170
|
|
|
145
171
|
index do
|
|
146
|
-
selectable_column
|
|
172
|
+
# selectable_column
|
|
147
173
|
column :title do |area|
|
|
148
174
|
link_to area.title, "/admin/areas/#{area.id}", title: I18n.t("active_admin.view")
|
|
149
175
|
end
|
|
150
176
|
column :atype do |area|
|
|
151
|
-
area.
|
|
177
|
+
area.atype.title
|
|
152
178
|
end
|
|
153
179
|
column '<abbr title="За м.кв. в месяц">Цена м.кв.</abbr>'.html_safe do |area|
|
|
154
180
|
"#{area.price_value.to_s(:rounded, :precision => 2)} руб"
|
|
@@ -168,8 +194,7 @@ ActiveAdmin.register C80Estate::Area, as: 'Area' do
|
|
|
168
194
|
column :property do |area|
|
|
169
195
|
"<div class='image_vertical properties_index_logo'>
|
|
170
196
|
<span></span><a href='/admin/areas?utf8=✓&q%5Bproperty_id_eq%5D=#{area.property.id}&commit=Фильтровать&order=id_asc'><img src='#{image_path(area.property.logo_path)}'>
|
|
171
|
-
</div><span class='properties_index_logo_title'>#{area.
|
|
172
|
-
|
|
197
|
+
</div><span class='properties_index_logo_title'>#{area.property.title}</span></a>".html_safe
|
|
173
198
|
end
|
|
174
199
|
column :astatuses do |area|
|
|
175
200
|
"<span class='status_#{area.astatus_tag}'>#{area.astatus_title}</span>".html_safe
|
|
@@ -177,10 +202,6 @@ ActiveAdmin.register C80Estate::Area, as: 'Area' do
|
|
|
177
202
|
column :assigned_person do |area|
|
|
178
203
|
area.property.assigned_person_title
|
|
179
204
|
end
|
|
180
|
-
# actions
|
|
181
|
-
# column '' do |area|
|
|
182
|
-
# link_to I18n.t("active_admin.view"), "/admin/areas/#{area.id}", class: 'member_link'
|
|
183
|
-
# end
|
|
184
205
|
column '' do |area|
|
|
185
206
|
if current_admin_user.can_edit_area?(area)
|
|
186
207
|
link_to I18n.t("active_admin.edit"), "/admin/areas/#{area.id}/edit", class: 'member_link'
|
|
@@ -42,6 +42,13 @@ module C80Estate
|
|
|
42
42
|
self.joins(:astatuses).where(:c80_estate_astatuses => {tag: 'free'})
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# def self.my_areas
|
|
46
|
+
# self.joins(:property)
|
|
47
|
+
# .where(:c80_estate_properties => {assigned_person_id: current_admin_user.id})
|
|
48
|
+
# end
|
|
49
|
+
|
|
50
|
+
# scope :my_areas, lambda { |t| t.joins(:property).where(:c80_estate_properties => {assigned_person_id: current_admin_user.id}) }
|
|
51
|
+
|
|
45
52
|
# посчитает кол-во свободных метров
|
|
46
53
|
def self.free_areas_sq
|
|
47
54
|
Rails.logger.debug "<Area.free_areas_sq>"
|
|
@@ -188,50 +195,99 @@ module C80Estate
|
|
|
188
195
|
self.where(:atype_id => atype_id)
|
|
189
196
|
end
|
|
190
197
|
|
|
198
|
+
# Не отображать "чужие" занятые площади (для менеждеров) (задача №1748)
|
|
199
|
+
def self.all_except_busy_alien(admin_user)
|
|
200
|
+
if admin_user.can_view_statistics?
|
|
201
|
+
# админам покажем всё
|
|
202
|
+
self.all
|
|
203
|
+
else
|
|
204
|
+
|
|
205
|
+
# http://stackoverflow.com/questions/9540801/combine-two-activerecordrelation-objects
|
|
206
|
+
# двумя независимыми запросами получим мои площади и немои свободные площади, сложим их, и отдадим
|
|
207
|
+
|
|
208
|
+
=begin
|
|
209
|
+
# ВАРИАНТ 1
|
|
210
|
+
|
|
211
|
+
# извлечём немои свободные площади
|
|
212
|
+
# этот код я написал, смотря на уже существующий where_assigned_person_id
|
|
213
|
+
not_my_free_areas = self.free_areas
|
|
214
|
+
.joins(:property)
|
|
215
|
+
.where.not(:c80_estate_properties => {assigned_person_id: admin_user.id})
|
|
216
|
+
|
|
217
|
+
# извлечём все мои площади
|
|
218
|
+
all_my_areas = self.joins(:property)
|
|
219
|
+
.where(:c80_estate_properties => {assigned_person_id: admin_user.id})
|
|
220
|
+
|
|
221
|
+
# это вернёт только то, что находится в ПЕРЕСЕЧЕНИИ результатов, а нужен union
|
|
222
|
+
not_my_free_areas.merge(all_my_areas)
|
|
223
|
+
=end
|
|
224
|
+
|
|
225
|
+
=begin
|
|
226
|
+
# ВАРИАНТ 2
|
|
227
|
+
# http://stackoverflow.com/a/28358592
|
|
228
|
+
# User.where(
|
|
229
|
+
# User.arel_table[:first_name].eq('Tobias').or(
|
|
230
|
+
# User.arel_table[:last_name].eq('Fünke')
|
|
231
|
+
# )
|
|
232
|
+
# )
|
|
233
|
+
=end
|
|
234
|
+
|
|
235
|
+
=begin
|
|
236
|
+
# ВАРИАНТ 3
|
|
237
|
+
# http://stackoverflow.com/a/31528499
|
|
238
|
+
# first_name_relation = User.where(:first_name => 'Tobias') # ActiveRecord::Relation
|
|
239
|
+
# last_name_relation = User.where(:last_name => 'Fünke') # ActiveRecord::Relation
|
|
240
|
+
#
|
|
241
|
+
# all_name_relations = User.none
|
|
242
|
+
# first_name_relation.each do |ar|
|
|
243
|
+
# all_name_relations.new(ar)
|
|
244
|
+
# end
|
|
245
|
+
# last_name_relation.each do |ar|
|
|
246
|
+
# all_name_relations.new(ar)
|
|
247
|
+
# end
|
|
248
|
+
=end
|
|
249
|
+
|
|
250
|
+
# попробуем 3-й вариант
|
|
251
|
+
not_my_free_areas = self.free_areas
|
|
252
|
+
.joins(:property)
|
|
253
|
+
.where.not(:c80_estate_properties => {assigned_person_id: admin_user.id})
|
|
254
|
+
|
|
255
|
+
all_my_areas = self.joins(:property)
|
|
256
|
+
.where(:c80_estate_properties => {assigned_person_id: admin_user.id})
|
|
257
|
+
|
|
258
|
+
all_my_areas.union(not_my_free_areas)
|
|
259
|
+
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
191
263
|
def has_astatus?
|
|
192
264
|
errors.add_to_base 'Укажите статус площади' if self.astatuses.blank?
|
|
193
265
|
end
|
|
194
266
|
|
|
267
|
+
# --------
|
|
268
|
+
|
|
195
269
|
def atype_title
|
|
196
|
-
|
|
197
|
-
if atype.present?
|
|
198
|
-
res = atype.title
|
|
199
|
-
end
|
|
200
|
-
res
|
|
270
|
+
atype.title
|
|
201
271
|
end
|
|
202
272
|
|
|
203
273
|
def property_title
|
|
204
|
-
|
|
205
|
-
if property.present?
|
|
206
|
-
res = property.title
|
|
207
|
-
end
|
|
208
|
-
res
|
|
274
|
+
property.title
|
|
209
275
|
end
|
|
210
276
|
|
|
211
277
|
def astatus_title
|
|
212
|
-
|
|
213
|
-
if astatuses.count > 0
|
|
214
|
-
res = astatuses.first.title
|
|
215
|
-
end
|
|
216
|
-
res
|
|
278
|
+
astatuses.first.title
|
|
217
279
|
end
|
|
218
280
|
|
|
219
281
|
def astatus_id
|
|
220
|
-
|
|
221
|
-
if astatuses.count > 0
|
|
222
|
-
res = astatuses.first.id
|
|
223
|
-
end
|
|
224
|
-
res
|
|
282
|
+
astatuses.first.id
|
|
225
283
|
end
|
|
226
284
|
|
|
227
285
|
def astatus_tag
|
|
228
|
-
|
|
229
|
-
if astatuses.count > 0
|
|
230
|
-
res = astatuses.first.tag
|
|
231
|
-
end
|
|
232
|
-
res
|
|
286
|
+
astatuses.first.tag
|
|
233
287
|
end
|
|
234
288
|
|
|
289
|
+
# --------
|
|
290
|
+
|
|
235
291
|
def is_free?
|
|
236
292
|
astatus_tag == 'free'
|
|
237
293
|
end
|
|
@@ -261,6 +317,7 @@ module C80Estate
|
|
|
261
317
|
end
|
|
262
318
|
|
|
263
319
|
# выдать цену за м.кв. в месяц
|
|
320
|
+
# TODO_MY:: добавить модели Area столбец price_value и before_update метод, который высчитывал бы значение
|
|
264
321
|
def price_value
|
|
265
322
|
|
|
266
323
|
res = 0.0
|
|
@@ -298,6 +355,7 @@ module C80Estate
|
|
|
298
355
|
res
|
|
299
356
|
end
|
|
300
357
|
|
|
358
|
+
# TODO_MY:: добавить модели Area столбец square_value и before_update метод, который высчитывал бы значение
|
|
301
359
|
def square_value
|
|
302
360
|
res = 0.0
|
|
303
361
|
p = item_props.where(:prop_name_id => 9)
|
|
@@ -308,6 +366,7 @@ module C80Estate
|
|
|
308
366
|
res
|
|
309
367
|
end
|
|
310
368
|
|
|
369
|
+
# TODO_MY:: добавить модели Area столбец power_price_value и before_update метод, который высчитывал бы значение
|
|
311
370
|
def power_price_value
|
|
312
371
|
price_value * 1.0 * square_value
|
|
313
372
|
end
|
|
@@ -166,6 +166,7 @@ module C80Estate
|
|
|
166
166
|
res
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
+
# TODO:: при построении индексной таблицы из 100 строк происходит 100 запросов к базе типа COUNT(*). Добавить before_update метод и поле logo_path и вычислять путь к лого в before update
|
|
169
170
|
def logo_path
|
|
170
171
|
url = 'property_default_logo.png'
|
|
171
172
|
if plogos.count > 0
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<div class="clearfix">
|
|
8
8
|
<div id="div_main_show_area" class="clearfix">
|
|
9
9
|
<%= link_to image_tag('w227x182px.gif',
|
|
10
|
-
:alt=>item_title,
|
|
10
|
+
:alt => item_title,
|
|
11
11
|
:data => {:original => image_path(@item.main_image_url)},
|
|
12
12
|
:class => 'lazy'),
|
|
13
13
|
image_path(@item.main_image_url),
|
|
@@ -37,15 +37,17 @@
|
|
|
37
37
|
<%= ph_render_tech_props(@item) %>
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
</div>
|
|
40
|
+
<% if current_admin_user.can_edit_property?(@item) %>
|
|
41
|
+
<div id="div_all_areas_table" class="wrap_collapse">
|
|
42
|
+
<button type="button" class="btn" data-toggle="collapse" data-target="#iid">
|
|
43
|
+
<span class="fa fa-chevron-right"></span>
|
|
44
|
+
Площади объекта <%= @item.title %> (<%= @item.areas.count %>)
|
|
45
|
+
</button>
|
|
46
|
+
<div class="collapse" id="iid">
|
|
47
|
+
<%= ph_render_areas_table(@item) %>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<% end %>
|
|
49
51
|
|
|
50
52
|
<div id="related_items" class="hidden">
|
|
51
53
|
<%# smiph_render_related_items(@item) %>
|
data/lib/c80_estate/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: c80_estate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0.
|
|
4
|
+
version: 0.1.0.34
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- C80609A
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-08-
|
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|