Подгружаемый блок с детальным описанием состава рейтинга -- готово
This commit is contained in:
@@ -85,6 +85,9 @@ urlpatterns = [
|
||||
# СРАВНЕНИЕ ОКОННЫХ НАБОРОВ
|
||||
re_path(r'^compare_sets/(?P<to_compare>[\s\S]+|.*)$', report1.compare_offers), # дубль для старых ссылок
|
||||
re_path(r'^compare_offers/(?P<to_compare>[\s\S]+|.*)$', report1.compare_offers),
|
||||
re_path(r'^specification_set/\d$', views.main_init), # заглушка (позже будет спецификация оконного набора)
|
||||
# отображение всех составлющих рейтинга
|
||||
re_path( r'^show_rating_components/(?P<win_set>\d+)$', report1.show_rating_components),
|
||||
|
||||
]
|
||||
|
||||
|
||||
20
oknardia/templates/report/show_rating_components.html
Executable file
20
oknardia/templates/report/show_rating_components.html
Executable file
@@ -0,0 +1,20 @@
|
||||
{# отображение рейтинга #}{% load static %}
|
||||
<table class="pop-tab" width="100%" style="border: none !important;">
|
||||
<tbody style="border: none !important;">
|
||||
<tr style="border: none !important; border-left: none !important;">
|
||||
<td style="border: none !important;">Услуги:</td>
|
||||
<td style="border: none !important;"><nobr><!-- НАЧАЛО звездочки рейтинга -->{% for Star in RATING_SERVIZ_STARS %}{% if Star == 0 %}<i class="glyphicon glyphicon-star-empty"></i>{% else %}<b class="glyphicon glyphicon-star"></b>{% endif %}{% endfor %}<!-- КОНЕЦ звездочки рейтинга НАЧАЛО бедж --> {% if RATING_SERVIZ > 0 %}<tt class="badge">{{ RATING_SERVIZ|stringformat:".2f" }}</tt>{% else %}<tt class="badge">не присвоен</tt>{% endif %}<!-- КОНЕЦ бедж --></nobr></td>
|
||||
</tr><tr style="border: none !important;">
|
||||
<td style="border: none !important;">Оконный профиль:</td>
|
||||
<td style="border: none !important;"><nobr><!-- НАЧАЛО звездочки рейтинга -->{% for Star in RATING_PVC_STARS %}{% if Star == 0 %}<i class="glyphicon glyphicon-star-empty"></i>{% else %}<b class="glyphicon glyphicon-star"></b>{% endif %}{% endfor %}<!-- КОНЕЦ звездочки рейтинга НАЧАЛО бедж --> {% if RATING_PVC > 0 %}<tt class="badge">{{ RATING_PVC|stringformat:".2f" }}</tt>{% else %}<tt class="badge">не присвоен</tt>{% endif %}<!-- КОНЕЦ бедж --></nobr></td>
|
||||
</tr><tr style="border: none !important;">
|
||||
<td style="border: none !important;">Стеклопакет:</td>
|
||||
<td style="border: none !important;"><nobr><!-- НАЧАЛО звездочки рейтинга -->{% for Star in RATING_GLAZ_STARS %}{% if Star == 0 %}<i class="glyphicon glyphicon-star-empty"></i>{% else %}<b class="glyphicon glyphicon-star"></b>{% endif %}{% endfor %}<!-- КОНЕЦ звездочки рейтинга НАЧАЛО бедж --> {% if RATING_GLAZ > 0 %}<tt class="badge">{{ RATING_GLAZ|stringformat:".2f" }}</tt>{% else %}<tt class="badge">не присвоен</tt>{% endif %}<!-- КОНЕЦ бедж --></nobr></td>
|
||||
</tr><tr style="border: none !important;">
|
||||
<td style="border: none !important;">От пользователей:</td>
|
||||
<td style="border: none !important;"><nobr><!-- НАЧАЛО звездочки рейтинга -->{% for Star in RATING_OFFER_STARS %}{% if Star == 0 %}<i class="glyphicon glyphicon-star-empty"></i>{% else %}<b class="glyphicon glyphicon-star"></b>{% endif %}{% endfor %}<!-- КОНЕЦ звездочки рейтинга НАЧАЛО бедж --> {% if RATING_OFFER > 0 %}<tt class="badge">{{ RATING_OFFER|stringformat:".2f" }}</tt>{% else %}<tt class="badge">не присвоен</tt>{% endif %}<!-- КОНЕЦ бедж --></nobr></td>
|
||||
</tr><tr style="border: none !important;">
|
||||
<td colspan="2" style="background:ghostwhite;padding:1ex;border: none !important;"><small>В базе {{ NUM_OFFERS }}. Обновление цен {{ DATA_OFFER_UPDATE }}.<!-- Время исполнения: {{ ticks|stringformat:".4f" }}--></small></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -275,7 +275,8 @@ def compare_offers(request: HttpRequest, to_compare: str = "1,2") -> HttpRespons
|
||||
or profile_num_cameras == min_i_profile_cameras or max_i_profile_cameras - min_i_profile_cameras < 0.001:
|
||||
profile_num_cameras_color = None
|
||||
else:
|
||||
color_ratio = (profile_num_cameras-min_i_profile_cameras)/(max_i_profile_cameras-min_i_profile_cameras)
|
||||
color_ratio = (profile_num_cameras - min_i_profile_cameras) / (
|
||||
max_i_profile_cameras - min_i_profile_cameras)
|
||||
profile_num_cameras_color = f"#{255 - int(color_ratio * 128):02x}ff{255 - int(color_ratio * 128):02x}"
|
||||
# построим массив "цветов" для рейтинга "Контуров уплотнения" (чем больше, тем лучше)
|
||||
if max_f_profile_seals == ini_max or min_f_profile_seals == ini_min or i.fProfileSeals <= 0 \
|
||||
@@ -335,7 +336,6 @@ def compare_offers(request: HttpRequest, to_compare: str = "1,2") -> HttpRespons
|
||||
else:
|
||||
color_ratio = (i.iProfileHeight - min_i_profile_height) / (max_i_profile_height - min_i_profile_height)
|
||||
profile_height_color = f"#{127 + int(color_ratio * 128):02x}ff{127 + int(color_ratio * 128):02x}"
|
||||
print(profile_height_color)
|
||||
# построим массив "цветов" для рейтинга "Камер стеклопакета" (чем больше, тем лучше)
|
||||
if max_i_glazing_cameras_n == ini_max or min_i_profile_height == ini_min \
|
||||
or i.iGlazingCamerasN == min_i_glazing_cameras_n \
|
||||
@@ -479,7 +479,8 @@ def compare_offers(request: HttpRequest, to_compare: str = "1,2") -> HttpRespons
|
||||
"GLAZING_LIGHT_REFLECTION": i.sGlazingLightReflectance, # Коэффициент светоотражения внешний/внутренний
|
||||
"GLAZING_PASSING_SUN": i.fGlazingPassingSun, # Коэффициент солнцепропускания стеклопакета
|
||||
"GLAZING_PASSING_SUN_COLOR": glazing_passing_sun_color, # Коэффициент солнцепропускания ЦВЕТ
|
||||
"GLAZING_REFLECTION_AND_ABSORPTION": i.sGlazingReflectionAndAbsorptionOfHeat, # Коэффициент теплоотражения/теплопоглощения стеклопакета
|
||||
"GLAZING_REFLECTION_AND_ABSORPTION": i.sGlazingReflectionAndAbsorptionOfHeat,
|
||||
# Коэффициент теплоотражения/теплопоглощения стеклопакета
|
||||
"GLAZING_TONING": i.sGlazingToning, # Тонирование стеклопакета
|
||||
"URL_W_DEL": list2_del.replace(f",{i.id},", ",")[1:-1] # Тонирование стеклопакета
|
||||
})
|
||||
@@ -542,3 +543,58 @@ def compare_offers(request: HttpRequest, to_compare: str = "1,2") -> HttpRespons
|
||||
})
|
||||
return render(request, "report/report_compare_set.html", to_template)
|
||||
|
||||
|
||||
def show_rating_components(request: HttpRequest, win_set: str = "1") -> HttpResponse:
|
||||
""" Показать состав рейтинга оконного предложения (компоненты рейтинга)
|
||||
|
||||
:param request: HttpRequest -- входящий http-запрос
|
||||
:param win_set: str -- id оконного набора, для которого показать состав рейтинга
|
||||
:return: HttpResponse --
|
||||
"""
|
||||
time_start = time.time()
|
||||
to_template = {}
|
||||
try:
|
||||
win_set = int(win_set)
|
||||
except ValueError:
|
||||
win_set = 1
|
||||
q = SetKit.objects.raw(
|
||||
f"SELECT oknardia_pvcprofiles.fProfileRating, oknardia_glazing.fGlazingRating,"
|
||||
f" oknardia_setkit.fSetRating, oknardia_setkit.id, MAX(oknardia_priceoffer.dOfferModify) AS dPriceModify,"
|
||||
f" COUNT(oknardia_priceoffer.id) AS NumOffer, AVG(oknardia_priceoffer.fOfferRating) AS fOfferRatingAvg "
|
||||
f"FROM oknardia_setkit"
|
||||
f" INNER JOIN oknardia_glazing"
|
||||
f" ON oknardia_setkit.kSet2Glazing_id = oknardia_glazing.id"
|
||||
f" INNER JOIN oknardia_pvcprofiles"
|
||||
f" ON oknardia_setkit.kSet2PVCprofiles_id = oknardia_pvcprofiles.id"
|
||||
f" INNER JOIN oknardia_priceoffer"
|
||||
f" ON oknardia_priceoffer.kOffer2SetKit_id = oknardia_setkit.id "
|
||||
f"WHERE oknardia_setkit.id = {win_set} "
|
||||
f"GROUP BY oknardia_pvcprofiles.fProfileRating,"
|
||||
f" oknardia_glazing.fGlazingRating,"
|
||||
f" oknardia_setkit.fSetRating,"
|
||||
f" oknardia_setkit.id;")
|
||||
raring_list = list(q)
|
||||
f_rating_service = raring_list[0].fSetRating - RARING_WEIGHT_PVC_PROFILE_IN_SET * normalize(
|
||||
raring_list[0].fProfileRating, val_max=RARING_PVC_PROFILE_MAX
|
||||
)
|
||||
f_rating_service -= RARING_WEIGHT_GLAZING_IN_SET * normalize(raring_list[0].fGlazingRating,
|
||||
val_max=RARING_GLAZING_MAX)
|
||||
f_rating_service = normalize(f_rating_service,
|
||||
val_max=RARING_SET_MAX-RARING_WEIGHT_PVC_PROFILE_IN_SET-RARING_WEIGHT_GLAZING_IN_SET)
|
||||
f_rating_service *= RARING_SET_MAX
|
||||
to_template.update({'RATING_SERVIZ': f_rating_service,
|
||||
'RATING_SERVIZ_STARS': get_rating_set_for_stars(f_rating_service),
|
||||
'RATING_GLAZ': raring_list[0].fGlazingRating,
|
||||
'RATING_GLAZ_STARS': get_rating_set_for_stars(raring_list[0].fGlazingRating),
|
||||
'RATING_PVC': raring_list[0].fProfileRating,
|
||||
'RATING_PVC_STARS': get_rating_set_for_stars(raring_list[0].fProfileRating),
|
||||
'RATING_OFFER': raring_list[0].fOfferRatingAvg,
|
||||
'RATING_OFFER_STARS': get_rating_set_for_stars(raring_list[0].fOfferRatingAvg),
|
||||
'DATA_OFFER_UPDATE': pytils.dt.distance_of_time_in_words(
|
||||
int(django.utils.dateformat.format(raring_list[0].dPriceModify, 'U')), accuracy=2),
|
||||
'NUM_OFFERS': pytils.numeral.get_plural(raring_list[0].NumOffer,
|
||||
"коммерческое предложение, коммерческих предложения,"
|
||||
" коммерческих предложений"),
|
||||
'TEST': win_set,
|
||||
'ticks': float(time.time() - time_start)})
|
||||
return render(request, "report/show_rating_components.html", to_template)
|
||||
|
||||
Reference in New Issue
Block a user