|
|
|
|
@ -59,6 +59,7 @@ field_settings = [ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_int(val): |
|
|
|
|
""" |
|
|
|
|
Reverse function to get_int |
|
|
|
|
@ -81,7 +82,7 @@ def to_country(value): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from city.models import City |
|
|
|
|
def to_city(value, lang=None, country=None): |
|
|
|
|
def to_city(value, lang, country): |
|
|
|
|
try: |
|
|
|
|
# get city by name |
|
|
|
|
objects = get_translation_aware_manager(City) |
|
|
|
|
@ -91,18 +92,12 @@ def to_city(value, lang=None, country=None): |
|
|
|
|
except IndexError: |
|
|
|
|
# not found |
|
|
|
|
# try to create new city |
|
|
|
|
city = City() |
|
|
|
|
city = City(country=country) |
|
|
|
|
city.translate(lang) |
|
|
|
|
city.name = value |
|
|
|
|
city.save() |
|
|
|
|
return city |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AUDIENCE1 = ((None,'Не выбрано'), |
|
|
|
|
('experts', 'Специалисты'), |
|
|
|
|
('experts and consumers', 'Специалисты и потребители'), |
|
|
|
|
('general public', 'Широкая публика')) |
|
|
|
|
return city |
|
|
|
|
|
|
|
|
|
def to_audience(value): |
|
|
|
|
try: |
|
|
|
|
@ -113,40 +108,73 @@ def to_audience(value): |
|
|
|
|
elif value == 'Широкая публика': |
|
|
|
|
return 'general public' |
|
|
|
|
else: |
|
|
|
|
return '' |
|
|
|
|
return 'None' |
|
|
|
|
except: |
|
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cell(field_name, value, lang=None): |
|
|
|
|
return 'None' |
|
|
|
|
|
|
|
|
|
import_settings={ |
|
|
|
|
'name': {'func': str, }, |
|
|
|
|
'url': {'func': str}, |
|
|
|
|
'data_begin': {'func': str}, |
|
|
|
|
'data_end': {'func': str}, |
|
|
|
|
'main_title': {'func': str}, |
|
|
|
|
'description': {'func': str}, |
|
|
|
|
'audience': {'func': to_audience}, |
|
|
|
|
'country': {'func': to_country}, |
|
|
|
|
'city': {'func': to_city, 'extra_values': 'country'}, |
|
|
|
|
'periodic': {'func': str}, |
|
|
|
|
'web_page': {'func': str}, |
|
|
|
|
'time': {'func': str}, |
|
|
|
|
'products': {'func': str}, |
|
|
|
|
'foundation_year': {'func': to_int}, |
|
|
|
|
'tax': {'func': bool}, |
|
|
|
|
'currency': {'func': str}, |
|
|
|
|
'max_price': {'func': to_int}, |
|
|
|
|
'min_price': {'func': to_int}, |
|
|
|
|
'registration_payment': {'func': to_int}, |
|
|
|
|
'min_closed_area': {'func': to_int}, |
|
|
|
|
'max_closed_area': {'func': to_int}, |
|
|
|
|
'min_closed_equipped_area': {'func': to_int}, |
|
|
|
|
'max_closed)equipped_area': {'func': to_int}, |
|
|
|
|
'min_open_area': {'func': to_int}, |
|
|
|
|
'max_open_area': {'func': to_int}, |
|
|
|
|
'min_area': {'func': to_int}, |
|
|
|
|
'max_area': {'func': to_int}, |
|
|
|
|
'is_published': {'func': bool}, |
|
|
|
|
'canceled_by_administrator': {'func': bool} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
def get_cell(field_name): |
|
|
|
|
return {#'id': int(value), |
|
|
|
|
'url': str(value), |
|
|
|
|
'name': str(value), |
|
|
|
|
'data_begin': str(value), |
|
|
|
|
'data_end': str(value), |
|
|
|
|
'main_title': str(value), |
|
|
|
|
'description': str(value), |
|
|
|
|
'audience': to_audience(value), |
|
|
|
|
'country': to_country(value), |
|
|
|
|
'city': to_city(value, lang=lang), |
|
|
|
|
'url': str, |
|
|
|
|
'name': str, |
|
|
|
|
'data_begin': str, |
|
|
|
|
'data_end': str, |
|
|
|
|
'main_title': str, |
|
|
|
|
'description': str, |
|
|
|
|
'audience': to_audience, |
|
|
|
|
'country': to_country, |
|
|
|
|
'city': to_city, |
|
|
|
|
#'periodic': str(value), |
|
|
|
|
'web_page': str(value), |
|
|
|
|
'time': str(value), |
|
|
|
|
'products': str(value), |
|
|
|
|
'foundation_year': to_int(value), |
|
|
|
|
'tax': bool(value), |
|
|
|
|
'currency': str(value), |
|
|
|
|
'max_price': to_int(value), |
|
|
|
|
'min_price': to_int(value), |
|
|
|
|
'registration_payment': to_int(value), |
|
|
|
|
'min_closed_area': to_int(value), |
|
|
|
|
'max_closed_area': to_int(value), |
|
|
|
|
'min_closed_equipped_area': to_int(value), |
|
|
|
|
'max_closed_equipped_area': to_int(value), |
|
|
|
|
'min_open_area': to_int(value), |
|
|
|
|
'max_open_area': to_int(value), |
|
|
|
|
'min_area': to_int(value), |
|
|
|
|
'max_area': to_int(value), |
|
|
|
|
'is_published': bool(value), |
|
|
|
|
'canceled_by_administrator': bool(value) |
|
|
|
|
'web_page': str, |
|
|
|
|
'time': str, |
|
|
|
|
'products': str, |
|
|
|
|
'foundation_year': to_int, |
|
|
|
|
'tax': bool, |
|
|
|
|
'currency': str, |
|
|
|
|
'max_price': to_int, |
|
|
|
|
'min_price': to_int, |
|
|
|
|
'registration_payment': to_int, |
|
|
|
|
'min_closed_area': to_int, |
|
|
|
|
'max_closed_area': to_int, |
|
|
|
|
'min_closed_equipped_area': to_int, |
|
|
|
|
'max_closed_equipped_area': to_int, |
|
|
|
|
'min_open_area': to_int, |
|
|
|
|
'max_open_area': to_int, |
|
|
|
|
'min_area': to_int, |
|
|
|
|
'max_area': to_int, |
|
|
|
|
'is_published': bool, |
|
|
|
|
'canceled_by_administrator': bool |
|
|
|
|
}.get(field_name) |
|
|
|
|
""" |