diff --git a/exposition/management/commands/exposition_load.py b/exposition/management/commands/exposition_load.py index 0195584f..2e3a9b2a 100644 --- a/exposition/management/commands/exposition_load.py +++ b/exposition/management/commands/exposition_load.py @@ -14,19 +14,20 @@ F = settings.MEDIA_ROOT+'/import/exp.xlsx' LA_FILE = settings.MEDIA_ROOT+'/import/expo_la.xlsx' NA_EU_ASIA_FILE = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa.xls' +NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls' class Command(BaseCommand): def handle(self, *args, **options): - f = open(NA_EU_ASIA_FILE, 'r') + f = open(NA_EU_ASIA_FILE2, 'r') book = xlrd.open_workbook(file_contents=f.read()) 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]] - for row_number, row in enumerate(row_list[1:]): - print(row_number) + for row_number, row in enumerate(row_list[344:400]): + #print(row_number) if row[0] != '': # in first column ids @@ -76,11 +77,11 @@ class Command(BaseCommand): pass else: setattr(object, field_name, value) - #object.save() + + object.save() print('post save %s'% str(object)) - """ for method in methods: func = method['func'] if method.get('purpose'): @@ -90,4 +91,3 @@ class Command(BaseCommand): continue else: func(object, method['value']) - """ \ No newline at end of file diff --git a/exposition/models.py b/exposition/models.py index 4d54b967..e815ae55 100644 --- a/exposition/models.py +++ b/exposition/models.py @@ -32,7 +32,7 @@ BIT_AUDIENCE = (('experts', _(u'Специалисты')), ('experts and consume ('general public', _(u'Широкая публика'))) -CURRENCY = ('RUB', 'USD', 'EUR', 'RMB', 'GBP') +CURRENCY = ('RUB', 'USD', 'EUR', 'RMB', 'GBP', 'AED', 'SGD', 'TRY', 'CZK', 'CHF', 'SEK', 'LKR') # check if table exist and create flags if true flags = [str(item.id) for item in Service.objects.all()] if db_table_exists('service_service') else [] diff --git a/import_xls/excel_settings.py b/import_xls/excel_settings.py index a6f19251..0473b787 100644 --- a/import_xls/excel_settings.py +++ b/import_xls/excel_settings.py @@ -332,7 +332,7 @@ event_sett = { 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'city_id', 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}, diff --git a/import_xls/utils.py b/import_xls/utils.py index 0cf02daa..807202c8 100644 --- a/import_xls/utils.py +++ b/import_xls/utils.py @@ -51,7 +51,7 @@ def to_city(value, lang, country): # except IndexError if no found city = City.objects.filter(translations__name=value, country=country)[0] # print(city) - return city + return city.id except IndexError: print('---------------------') print(value.encode('utf8')) diff --git a/place_exposition/management/commands/place_exposition_load.py b/place_exposition/management/commands/place_exposition_load.py index b47945e8..c2f889e8 100644 --- a/place_exposition/management/commands/place_exposition_load.py +++ b/place_exposition/management/commands/place_exposition_load.py @@ -1,19 +1,22 @@ # -*- coding: utf-8 -*- from django.core.management.base import BaseCommand, CommandError +import xlrd from place_exposition.models import PlaceExposition -import xlrd, xlwt from import_xls.excel_settings import import_settings, place_exp_sett from django.conf import settings -from import_xls.import_forms import google_address + +PLACE_FILE = settings.MEDIA_ROOT+'/import/places.xlsx' class Command(BaseCommand): def handle(self, *args, **options): - f = open(settings.MEDIA_ROOT+'/import/places_ru.xlsx', 'r') + f = open(PLACE_FILE, 'r') book = xlrd.open_workbook(file_contents=f.read()) 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]] + existing = 0 + for row_number, row in enumerate(row_list): # go through all rows in file if row_number > 0: @@ -23,6 +26,7 @@ class Command(BaseCommand): try: object = PlaceExposition.objects.language('ru').get(id=int(row[0])) + existing += 1 except ValueError: object = PlaceExposition() object.translate('ru') @@ -30,6 +34,7 @@ class Command(BaseCommand): except PlaceExposition.DoesNotExist: object = PlaceExposition(id= int(row[0])) object.translate('ru') + existing += 1 else: # if id blank - its a new place object = PlaceExposition @@ -69,7 +74,7 @@ class Command(BaseCommand): # setattr(object, 'address', google_address(value)) setattr(object, field_name, value) - object.save() + #object.save() print('post save %s'% str(object)) """ try: @@ -82,7 +87,7 @@ class Command(BaseCommand): #object.url = url #object.save() """ - + """ for method in methods: func = method['func'] if method.get('purpose'): @@ -96,4 +101,6 @@ class Command(BaseCommand): except: continue + """ + print(existing) diff --git a/templates/client/base_catalog.html b/templates/client/base_catalog.html index 7b85c67e..3d9b4709 100644 --- a/templates/client/base_catalog.html +++ b/templates/client/base_catalog.html @@ -38,7 +38,8 @@ {% endblock %} - + {% include 'client/includes/side_confs.html' %} +
{% include 'client/includes/news.html' %} {% block aside_vk %} diff --git a/templates/client/includes/header.html b/templates/client/includes/header.html index ce23d413..c06b77bf 100644 --- a/templates/client/includes/header.html +++ b/templates/client/includes/header.html @@ -79,7 +79,6 @@