diff --git a/company/views.py b/company/views.py index 7bdf6c53..9e2370d5 100644 --- a/company/views.py +++ b/company/views.py @@ -35,6 +35,7 @@ class CompanySearchView(ListView): del queries['page'] context['queries'] = queries context['search_action'] = '/members/search/' + context['type'] = 'members search' return context @@ -48,6 +49,7 @@ class CompanyView(ExpoListView): def get_context_data(self, **kwargs): context = super(CompanyView, self).get_context_data(**kwargs) context['search_action'] = '/members/search/' + context['type'] = 'members search' return context class CompanyExposition(CompanyView): diff --git a/core/views.py b/core/views.py index b2864b24..e7e2c481 100644 --- a/core/views.py +++ b/core/views.py @@ -39,6 +39,7 @@ class EventSearchView(ListView): context['queries'] = queries context['search_action'] = '/events/search/' + return context class PlaceSearchView(ListView): @@ -66,6 +67,7 @@ class PlaceSearchView(ListView): del queries['page'] context['queries'] = queries context['search_action'] = '/places/search/' + context['type'] = 'places search' return context @@ -138,6 +140,7 @@ class PlaceListView(ListView): context['single_page'] = self.single_page context['search_form'] = self.search_form context['search_action'] = '/places/search/' + context['type'] = 'places search' return context class PlacePhotoView(PlaceListView): diff --git a/exposition/models.py b/exposition/models.py index 22033683..68ac5c5f 100644 --- a/exposition/models.py +++ b/exposition/models.py @@ -162,7 +162,7 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): theme = self.theme.all()[0] now = datetime.datetime.now() now = now.replace(day=now.day-1) - expositions = Exposition.objects.filter(theme__in=[theme], data_begin__gt=now).exclude(id=self.id) + expositions = Exposition.objects.filter(theme__in=[theme], data_begin__gt=now).exclude(id=self.id).order_by('data_begin') return expositions[:3] else: return [] diff --git a/media/imgs/cl-logo-3.png b/media/imgs/cl-logo-3.png new file mode 100644 index 00000000..3783a0d7 Binary files /dev/null and b/media/imgs/cl-logo-3.png differ diff --git a/media/import/.~lock.places_en.xlsx# b/media/import/.~lock.places_en.xlsx# index e499a320..59fbea56 100644 --- a/media/import/.~lock.places_en.xlsx# +++ b/media/import/.~lock.places_en.xlsx# @@ -1 +1 @@ -kotzilla ,kotzilla,kotzilla-Satellite-L300,27.05.2014 02:19,file:///home/kotzilla/.config/libreoffice/3; \ No newline at end of file +kotzilla ,kotzilla,kotzilla-Satellite-L300,27.05.2014 17:23,file:///home/kotzilla/.config/libreoffice/3; \ No newline at end of file diff --git a/media/import/.~lock.places_en123.xlsx# b/media/import/.~lock.places_en123.xlsx# new file mode 100644 index 00000000..59fbea56 --- /dev/null +++ b/media/import/.~lock.places_en123.xlsx# @@ -0,0 +1 @@ +kotzilla ,kotzilla,kotzilla-Satellite-L300,27.05.2014 17:23,file:///home/kotzilla/.config/libreoffice/3; \ No newline at end of file diff --git a/media/import/halls_en.xlsx b/media/import/halls_en.xlsx new file mode 100644 index 00000000..a7c4e2e4 Binary files /dev/null and b/media/import/halls_en.xlsx differ diff --git a/media/import/places_en.xlsx b/media/import/places_en123.xlsx similarity index 100% rename from media/import/places_en.xlsx rename to media/import/places_en123.xlsx diff --git a/place_exposition/management/commands/place_en.py b/place_exposition/management/commands/place_en.py index a0ae9d69..926e2de1 100644 --- a/place_exposition/management/commands/place_en.py +++ b/place_exposition/management/commands/place_en.py @@ -11,7 +11,7 @@ from django.conf import settings class Command(BaseCommand): def handle(self, *args, **options): - f = open(settings.MEDIA_ROOT+'/import/places_en.xlsx', 'r') + f = open(settings.MEDIA_ROOT+'/import/halls_en.xlsx', 'r') book = xlrd.open_workbook(file_contents=f.read()) @@ -21,6 +21,8 @@ class Command(BaseCommand): 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): # go through all rows in file if row_number > 0: @@ -31,6 +33,7 @@ class Command(BaseCommand): object = PlaceExposition.objects.language('en').get(id=int(row[0])) except: continue + methods = [] for col_number, cell in enumerate(row): # go through row cells # field name current cell @@ -39,6 +42,12 @@ class Command(BaseCommand): if setting is None: continue + + if setting.get('method'): + if cell != "": + methods.append({'func': setting['func'], 'value': cell, 'purpose': setting.get('purpose')}) + continue + field_name = setting['field'] func = setting.get('func') @@ -58,7 +67,23 @@ class Command(BaseCommand): # setattr(object, 'address', google_address(value)) setattr(object, field_name, value) - print(object.description) - object.save() - print('post save %s'% str(object)) + try: + object.save() + print('post save %s'% str(object)) + except: + continue + + for method in methods: + func = method['func'] + if method.get('purpose'): + try: + func(object, method['value'], method['purpose']) + except: + continue + else: + try: + func(object, method['value']) + except: + continue + diff --git a/place_exposition/models.py b/place_exposition/models.py index 9952ad42..a0121140 100644 --- a/place_exposition/models.py +++ b/place_exposition/models.py @@ -117,7 +117,9 @@ class PlaceExposition(TranslatableModel, ExpoMixin): def get_photos(self): photos = self.photos.all() - return photos + ph = self.files.filter(purpose='photo') + + return list(photos)+list(ph) def get_scheme(self): scheme = self.files.filter(purpose='scheme teritory') diff --git a/templates/client/base_catalog.html b/templates/client/base_catalog.html index db3c48e5..9a0a75d3 100644 --- a/templates/client/base_catalog.html +++ b/templates/client/base_catalog.html @@ -52,8 +52,7 @@
- - {% with search_form=search_form search_action=search_action%} + {% with search_form=search_form search_action=search_action type=type%} {% include 'client/includes/catalog_search.html' %} {% endwith %} diff --git a/templates/client/includes/catalog_search.html b/templates/client/includes/catalog_search.html index 08402a08..e978411b 100644 --- a/templates/client/includes/catalog_search.html +++ b/templates/client/includes/catalog_search.html @@ -3,7 +3,7 @@
-
{% trans 'поиск событий' %}
+
{% if type %}{{ type }}{% else %}{% trans 'поиск событий' %}{% endif %}
@@ -23,9 +23,9 @@
-
{% trans 'Тематика: ' %}Не важно
+ {% ifnotequal type 'places search' %}
{% trans 'Тематика: ' %}Не важно
{% endifnotequal %}
{% trans 'Место: ' %}Не важно
-
{% trans 'Период: ' %}Не важно
+ {% ifnotequal type 'places search' %}
{% trans 'Период: ' %}Не важно
{% endifnotequal %}