|
|
|
|
@ -15,16 +15,27 @@ register = template.Library() |
|
|
|
|
|
|
|
|
|
@register.inclusion_tag('templatetags/contractor_indicator.html', takes_context=True) |
|
|
|
|
def contractor_indicator(context, contractor): |
|
|
|
|
fields = ['avatar', 'cro', 'first_name', 'gender', |
|
|
|
|
fields = ['avatar', 'first_name', 'gender', |
|
|
|
|
'last_name', 'patronym', 'phone', |
|
|
|
|
'skype', 'website', 'location'] |
|
|
|
|
'skype', 'website', 'location', |
|
|
|
|
'contractor_specializations', 'contractor_building_classifications', 'contractor_construction_types', |
|
|
|
|
'contractor_resume__text'] |
|
|
|
|
|
|
|
|
|
indicator_sum = 0 |
|
|
|
|
for f in fields: |
|
|
|
|
if hasattr(contractor, f) and getattr(contractor, f): |
|
|
|
|
try: |
|
|
|
|
if not getattr(contractor, f).all(): |
|
|
|
|
continue |
|
|
|
|
except AttributeError: |
|
|
|
|
pass |
|
|
|
|
indicator_sum += 1 |
|
|
|
|
|
|
|
|
|
# Если в резюме > 100 символов - считаем его заполненным |
|
|
|
|
if len(getattr(contractor, 'contractor_resume').text) > 100: |
|
|
|
|
indicator_sum += 1 |
|
|
|
|
|
|
|
|
|
current_indicator = math.ceil(math.ceil(100 / len(fields)) * indicator_sum) |
|
|
|
|
current_indicator = math.ceil(math.ceil(100 / len(fields) * indicator_sum)) |
|
|
|
|
current_indicator_px = math.ceil(current_indicator / 2) |
|
|
|
|
return { |
|
|
|
|
'current_indicator': current_indicator, |
|
|
|
|
|