remotes/origin/1203
Nazar Kotyuk 12 years ago
parent 0f59cf26dd
commit 76534b1895
  1. 293
      exposition/management/commands/exposition_load.py
  2. 3
      functions/custom_views.py
  3. 16
      import_xls/excel_settings.py
  4. BIN
      media/imgs/149.jpeg
  5. BIN
      media/imgs/Atlantic City In-Water Power Boat Show.JPG
  6. BIN
      media/imgs/Automechanika 2012.jpeg
  7. BIN
      media/imgs/Bio 2014.png
  8. BIN
      media/imgs/CEF Summer Chengdu 2014.jpeg
  9. BIN
      media/imgs/CWIEME Berlin.jpeg
  10. BIN
      media/imgs/CeBIT India.jpeg
  11. BIN
      media/imgs/Cloud World Forum.1.JPG
  12. BIN
      media/imgs/Cloud World Forum.2.JPG
  13. BIN
      media/imgs/Cloud World Forum.3.JPG
  14. BIN
      media/imgs/Cloud World Forum.JPG
  15. BIN
      media/imgs/Coffee Fest Portland.JPG
  16. BIN
      media/imgs/Construct India.1.png
  17. BIN
      media/imgs/Construct India.2.png
  18. BIN
      media/imgs/Construct India.3.png
  19. BIN
      media/imgs/Construct India.png
  20. BIN
      media/imgs/EMS World Expo.JPG
  21. BIN
      media/imgs/Ecoc2014.JPG
  22. BIN
      media/imgs/FIMI2014.png
  23. BIN
      media/imgs/Fastener Fair India.1.png
  24. BIN
      media/imgs/Fastener Fair India.2.png
  25. BIN
      media/imgs/Fastener Fair India.3.png
  26. BIN
      media/imgs/Fastener Fair India.png
  27. BIN
      media/imgs/Fatex.jpeg
  28. BIN
      media/imgs/Fine-Food-India.1.png
  29. BIN
      media/imgs/Fine-Food-India.2.png
  30. BIN
      media/imgs/Fine-Food-India.3.png
  31. BIN
      media/imgs/Fine-Food-India.png
  32. BIN
      media/imgs/FlowEx China 2014.jpeg
  33. BIN
      media/imgs/GLEE_Logo_RGB_Square.png
  34. BIN
      media/imgs/Great Tennessee Air Show.1.png
  35. BIN
      media/imgs/Great Tennessee Air Show.2.png
  36. BIN
      media/imgs/Great Tennessee Air Show.3.png
  37. BIN
      media/imgs/Great Tennessee Air Show.png
  38. BIN
      media/imgs/Guangzhou International Lighting Exhibition 2012.jpeg
  39. BIN
      media/imgs/HOGA.png
  40. BIN
      media/imgs/Hong Kong Food Expo.1.jpeg
  41. BIN
      media/imgs/Hong Kong Food Expo.2.jpeg
  42. BIN
      media/imgs/Hong Kong Food Expo.3.jpeg
  43. BIN
      media/imgs/Hong Kong Food Expo.jpeg
  44. BIN
      media/imgs/hm13_logo_en_col.png
  45. BIN
      media/imgs/logo_cosmoprof.png
  46. BIN
      media/import/expositions_ru.xlsx
  47. 2
      templates/client/includes/menu.html
  48. 2
      templates/client/includes/place_object.html
  49. 4
      templates/client/includes/show_date_block.html

@ -4,10 +4,281 @@ from city.models import City
from country.models import Country
from exposition.models import Exposition
import xlrd, xlwt
from import_xls.excel_settings import event_sett
#from import_xls.excel_settings import event_sett
from django.conf import settings
from import_xls.import_forms import google_address
def to_int(val):
"""
Reverse function to get_int
return None if value isnt integer
"""
try:
return int(val)
except ValueError:
return None
def to_country(value):
try:
#query = get_translation_aware_manager(Country)
#country = query.filter(name=value)[0]
country = Country.objects.filter(translations__name=value)[0]
return country
except IndexError:
return None
def to_city(value, lang, country):
try:
# get city by name
#objects = get_translation_aware_manager(City)
# except IndexError if no found
city = City.objects.filter(translations__name=value, country=country)[0]
return city
except IndexError:
return None
from theme.models import Theme, Tag
def to_theme(obj, value):
if isinstance(value, float) or isinstance(value, int):
if (value - int(value) > 0):
value = str(value)
else:
value = str(int(value))
theme_ids = value.split('.')
else:
theme_ids = value.split(',')
theme_objects = []
for id in theme_ids:
try:
theme = Theme.objects.language('ru').get(id=int(id))
theme_objects.append(theme)
obj.theme.add(theme)
except Theme.DoesNotExist, ValueError:
pass
return theme_objects
from hvad.utils import get_translation_aware_manager
def to_tag(obj,value):
if value == [""]:
return None
names = value.split(',')
tags = []
for name in names:
objects = get_translation_aware_manager(Tag)
tag = objects.filter(name=name)
#tag = Tag.objects.language('ru').filter(transations__name=name)
if tag:
tags.append(tag[0])
obj.tag.add(tag[0])
else:
continue
return tags
import time
def to_date(value):
if not value:
return None
if isinstance(value, unicode) or isinstance(value, str):
t = time.strptime(value, "%d.%m.%Y")
if isinstance(value, float):
t = xlrd.xldate_as_tuple(value, 0)+(0,0,0)
return time.strftime("%Y-%m-%d", t)
def to_currency(value):
if value=='USD':
return value
if value=='EUR':
return value
if value=='RUB':
return 'RUB'
return 'USD'
from django.core.validators import validate_email, URLValidator
def to_url(url):
validate = URLValidator()
try:
validate(url)
except:
return ''
return url
def to_email(email):
try:
validate_email(email)
except:
return ''
return email
from file.models import FileModel
import urllib2
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from functions.files import get_alternative_filename
def save_logo(obj, value, purpose):
"""
if not obj.id:
return None
"""
urls = value.split(';')
for url in urls:
if url[0]!=('/'):
url = '/'+url
url = 'http://www.expomap.ru'+url
file_name = url.split('/')[-1]
alt_name = get_alternative_filename(settings.MEDIA_ROOT+'imgs/', file_name)
download_to = settings.MEDIA_ROOT+'imgs/'+alt_name
try:
response = urllib2.urlopen(url, timeout=3)
except:
continue
with open(download_to,'wb') as f:
f.write(response.read())
f.close()
file_name ='imgs/'+alt_name
content_type = ContentType.objects.get_for_model(obj)
file = FileModel(file_path=file_name, file_type='JPG', purpose=purpose,
content_type=content_type, object_id=obj.id)
file.save()
from place_exposition.models import EXPOSITION_TYPE
def to_type(value):
for t in EXPOSITION_TYPE:
if value == t[1]:
return t[0]
return 'Exposition complex'
def to_phone(value):
if value:
if isinstance(value, float) or isinstance(value, int):
return value
else:
deduct = ('-','(',')','.',' ', '+')
for elem in deduct:
value = value.replace(elem, '')
value = to_int(value)
return value
from place_exposition.models import PlaceExposition
def to_place(value):
try:
place = PlaceExposition.objects.get(id=value)
return place
except:
return None
from exposition.models import BIT_AUDIENCE
def to_audience(value, model=Exposition):
if value:
l = value.split(', ')
aud = {'Trade visitors':'experts', 'Trade visitors and Public':'experts and consumers',
'General public': 'general public'}
if l:
new_list = []
for value in l:
for item1, item2 in BIT_AUDIENCE:
if aud.get(value) == item2:
new_list.append(item1)
if new_list:
return reduce(lambda x,y: x|y, (getattr(model.audience, item) for item in new_list))
return 0
def to_periodic(value):
per = {'Оnce a year': 1.0, 'Every 2 years':0.5, 'Twice a year':2.0}
return per.get(value, 0)
from organiser.models import Organiser
def to_organiser(obj, value):
org = Organiser.objects.filter(translations__name=value)
if org:
obj.organiser.add(org[0])
else:
org = Organiser()
org.translate('ru')
org.name = value
org.save()
event_sett = {
u'ID':{u'field': u'id', u'func': to_int},
u'Название':{u'field': u'name', u'func': unicode},
u'Краткое описание':{u'field': u'main_title', u'func': unicode},
u'Дата начала:(YYYY-MM-DD)':{u'field': u'data_begin', u'func': to_date},
u'Дата окончания:(YYYY-MM-DD)':{u'field': u'data_end', u'func': to_date},
u'Страна':{u'field': u'country', u'func': to_country},
u'Город':{u'field': u'city', u'func': to_city, 'extra_values': 'country'},
u'Место проведения':{u'field': u'place', u'func': to_place},#####
u'ID Тематики':{u'field': u'theme', u'func': to_theme, u'method': True},
u'Теги':{u'field': u'tag', u'func': to_tag, u'method': True},
u'Организатор №1':{u'field': u'organiser', u'func': to_organiser, u'method': True},####
u'Организатор №2':{u'field': u'organiser', u'func': to_organiser, u'method': True},####
u'Описание события':{u'field': u'description', u'func': unicode},
u'Периодичность':{u'field': u'periodic', u'func': to_periodic},
u'Аудитория':{u'field': u'audience', u'func': to_audience},
u'Логотип':{u'field': u'logo', u'func': save_logo, u'method': True, u'purpose': 'logo'},
u'Официальный веб-сайт':{u'field': u'web_page', u'func': to_url},
u'Экспонируемые продукты':{u'field': u'products', u'func': unicode},
u'Время работы':{u'field': u'time', u'func': unicode},
u'Валюта':{u'field': u'currency', u'func': to_currency},
#
u'Посетители_билет (1 день)':{u'field': u'price_day', u'func': to_int},
u'Посетители_билет (все дни)':{u'field': u'price_all', u'func': to_int},
#u'Условия':{u'field': u'periodic', u'func': unicode},
u'Посетители_билет (1 день)(на стойке)':{u'field': u'price_day_bar', u'func': to_int},##??
u'Посетители_билет (все дни)(на стойке)':{u'field': u'price_all_bar', u'func': to_int},##??
#u'Условия':{u'field': u'periodic', u'func': unicode},##??
#u'Примечание':{u'field': u'periodic', u'func': unicode},
u'Каталог':{u'field': u'price_catalog', u'func': to_int},
u'Налог включен':{u'field': u'tax', u'func': bool},
u'Год основания':{u'field': u'foundation_year', u'func': to_int},
#u'Данные за год':{u'field': u'periodic', u'func': to_int},
u'Посетители':{u'field': u'visitors', u'func': to_int},
u'Участники':{u'field': u'members', u'func': to_int},
#u'Страны':{u'field': u'periodic', u'func': unicode},##??
u'Площадь':{u'field': u'periodic', u'func': to_int},
u'Min_Raw кв.м.':{u'field': u'min_closed_area', u'func': to_int},
u'Max_Raw кв.м.':{u'field': u'max_closed_area', u'func': to_int},
u'Min_Pack кв.м.':{u'field': u'min_closed_equipped_area', u'func': to_int},
u'Max_Pack кв.м.':{u'field': u'max_closed_equipped_area', u'func': to_int},
u'Открытая площадь':{u'field': u'max_open_area', u'func': to_int},
u'Мин. Площадь кв.м.':{u'field': u'min_open_area', u'func': to_int},
u'Регистрационный взнос':{u'field': u'registration_payment', u'func': to_int},
#u'Примечание':{u'field': u'periodic', u'func': unicode},
u'Крайний срок подачи заявки':{u'field': u'application_deadline', u'func': to_date},
u'UFI':{u'field': u'quality_label', u'func': bool, },##
u'РСВЯ':{u'field': u'quality_label', u'func': bool},##
u'EXPORATING':{u'field': u'quality_label', u'func': bool},##
u'Отменена':{u'field': u'canceled', u'func': bool},
u'ExpoHIT':{u'field': u'expohit', u'func': bool},
#u'Фото':{u'field': u'photo', u'func': save_photo, u'method': True},
}
class Command(BaseCommand):
def handle(self, *args, **options):
@ -17,7 +288,7 @@ class Command(BaseCommand):
sheet = book.sheet_by_index(0)
row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)]
labels = [label for label in row_list[0]]
print(len(row_list))
for row_number, row in enumerate(row_list):
@ -46,6 +317,7 @@ class Command(BaseCommand):
methods = []
flag = False
for col_number, cell in enumerate(row):
# go through row cells
# field name current cell
label = labels[col_number]
@ -82,9 +354,19 @@ class Command(BaseCommand):
print('error city')
flag = True
continue
setattr(object, field_name, value)
if not field_name=='quality_label':
setattr(object, field_name, value)
else:
if value:
if setting.get('l') == 'ufi':
object.quality_label.ufi = True
if setting.get('l') == 'rsva':
object.quality_label.rsva = True
if setting.get('l') == 'exporating':
object.quality_label.exporating = True
object.currency = 'USD'
if not flag:
try:
print('pre save %s'% str(object))
@ -96,7 +378,6 @@ class Command(BaseCommand):
else:
print('bad city')
for method in methods:
func = method['func']
if method.get('purpose'):
@ -108,4 +389,4 @@ class Command(BaseCommand):
try:
func(object, method['value'])
except:
continue
continue

@ -284,7 +284,8 @@ class ExpoListView(ExpoMixin, ListView):
self.params = params
return query
return query.order_by('data_begin')
def get_context_data(self, **kwargs):
context = super(ExpoListView, self).get_context_data(**kwargs)

@ -528,22 +528,6 @@ event_sett = {
u'Фото':{u'field': u'photo', u'func': save_photo, u'method': True},
#
}
import_settings={

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

@ -16,7 +16,7 @@
<ul class="s-menu">
<li><a href="#">{% trans 'о нас' %}</a></li>
<li><a href="#">{% trans 'партнеры' %}</a></li>
<li><a href="#">{% trans 'реклама' %}</a></li>
<li><a href="/advertising/">{% trans 'реклама' %}</a></li>
<li><a href="#">{% trans 'сервис' %}</a></li>
<li><a href="#">{% trans 'для партнеров' %}</a></li>
<li><a href="#">{% trans 'контакты' %}</a></li>

@ -95,7 +95,9 @@
<div id="ps-photo-gallery" class="ps-photo-gallery swiper-container">
<ul class="swiper-wrapper">
{% for photo in place.get_photos %}
{% if forloop.counter < 5 %}
<li class="swiper-slide"><img src="{{ photo.file_path.url }}" alt="" /></li>
{% endif %}
{% endfor %}
</ul>
<div class="re-controls">

@ -1,3 +1,5 @@
{% load i18n %}
{% if obj.data_begin|timesince:obj.data_end > "4 week" %}
{{ obj.data_begin|date:"F" }}
{% else %}
@ -6,7 +8,7 @@
{% else %}
{% if obj.data_end %}
c {{ obj.data_begin|date:"j" }} по {{ obj.data_end }}
{% trans 'с' %} {{ obj.data_begin|date:"j" }} {% trans 'по' %} {{ obj.data_end }}
{% else %}
{{ obj.data_begin }}
{% endif %}

Loading…
Cancel
Save