From f9dc583cb44da36ff5411f93d3a5f0d74164ebbf Mon Sep 17 00:00:00 2001 From: Kotiuk Nazarii Date: Fri, 14 Aug 2015 11:23:31 +0300 Subject: [PATCH] Remove bugs --- exposition/views.py | 8 ++++- import_xls/import_forms.py | 9 ++--- import_xls/utils.py | 13 +++++-- templates/admin/base.html | 6 ++-- .../admin/conference/conference_list.html | 36 ++++++++++++------- templates/admin/exposition/exposition.html | 6 ---- templates/admin/import templates/log.html | 1 - templates/admin/includes/admin_nav.html | 1 + templates/client/blank.html | 2 ++ .../conference/conference_object.html | 15 ++++---- .../exposition/exposition_object.html | 14 ++++---- 11 files changed, 64 insertions(+), 47 deletions(-) diff --git a/exposition/views.py b/exposition/views.py index f5c8f113..48b55b3b 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -294,7 +294,7 @@ MONTHES = settings.MONTHES class ExpoCatalog(MetadataMixin, ListView): model = Exposition paginate_by = settings.CLIENT_PAGINATION - template_name = 'exposition/catalog.html' + template_name = 'client/exposition/catalog.html' search_form = ExpositionSearchForm filter_object = None year = None @@ -445,6 +445,12 @@ class ExpoTagCatalog(ExpoCatalog): self.filter_object = tag return qs + def get_context_data(self, **kwargs): + context = super(ExpoTagCatalog, self).get_context_data(**kwargs) + tag = self.kwargs['tag'] + context['theme_for_filter'] = tag.theme + return context + class ExpoVisitors(MetadataMixin, ListView): paginate_by = settings.CLIENT_PAGINATION diff --git a/import_xls/import_forms.py b/import_xls/import_forms.py index 7d390652..8554605c 100644 --- a/import_xls/import_forms.py +++ b/import_xls/import_forms.py @@ -288,13 +288,13 @@ class ImportEventForm(ImportForm): if row[0] != '': # in first column id try: - obj = self.model.objects.language(lang).get(id=int(row[0])) + obj = model.objects.language(lang).get(id=int(row[0])) except ValueError: - obj = self.model() + obj = model() obj.translate(lang) - except self.model.DoesNotExist: - obj = self.model(id= int(row[0])) + except model.DoesNotExist: + obj = model(id= int(row[0])) obj.translate(lang) else: # if id blank - its a new event @@ -359,6 +359,7 @@ class ImportEventForm(ImportForm): except Exception: setattr(obj, 'place_alt', cell) if not obj.url: + a = obj.name obj.url = translit_with_separator(obj.name) obj.is_published = True try: diff --git a/import_xls/utils.py b/import_xls/utils.py index 334f9608..8efe455c 100644 --- a/import_xls/utils.py +++ b/import_xls/utils.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- import urllib2 import time, xlrd +import os +from PIL import Image from django.conf import settings from django.utils import translation from hvad.utils import get_translation_aware_manager @@ -134,6 +136,7 @@ def to_periodic(value): def to_audience(value, model=Exposition): if value: + translation.activate('ru') l = value.split(', ') if l: new_list = [] @@ -190,9 +193,9 @@ def save_logo(obj, path): return None try: - response = urllib2.urlopen(url, timeout=15) + response = urllib2.urlopen(url, timeout=5) except: - return None + return u'Превышено время ожидания' with open(download_to,'wb') as f: try: @@ -202,6 +205,12 @@ def save_logo(obj, path): # can be timeout return u'Превышено время ожидания' + try: + # check if image + im=Image.open(download_to) + except IOError: + os.remove(download_to) + return u'Неправильный формат логотипа' obj.logo = logo_path + alt_name try: obj.save() diff --git a/templates/admin/base.html b/templates/admin/base.html index a6b935ce..55d78941 100644 --- a/templates/admin/base.html +++ b/templates/admin/base.html @@ -31,9 +31,9 @@ {# The fav icon #} -{# datetimepicker #} - - + {# datetimepicker #} + + {% block scripts %} diff --git a/templates/admin/conference/conference_list.html b/templates/admin/conference/conference_list.html index 327f4a31..5bc54f8b 100644 --- a/templates/admin/conference/conference_list.html +++ b/templates/admin/conference/conference_list.html @@ -7,6 +7,17 @@ {% endblock %} +{% block styles %} + +td a{ + float:left; + margin: 0 10px 10px 0 +} + + +{% endblock %} + + {% block body %}
@@ -32,6 +43,7 @@ + @@ -41,31 +53,29 @@ {% for item in object_list %} + - - - - - diff --git a/templates/admin/exposition/exposition.html b/templates/admin/exposition/exposition.html index a6953917..3b2be57b 100644 --- a/templates/admin/exposition/exposition.html +++ b/templates/admin/exposition/exposition.html @@ -22,12 +22,6 @@ {# selects #} - {# datepicker #} - - - - - diff --git a/templates/admin/import templates/log.html b/templates/admin/import templates/log.html index cbda5e24..80256163 100644 --- a/templates/admin/import templates/log.html +++ b/templates/admin/import templates/log.html @@ -38,7 +38,6 @@ Displays lists of all cities in the table {% endfor %}
id Название Дата начала  
{{ item.id }} {{ item.name }} {{ item.data_begin }} + Отключить - + Включить + + + Изменить + + + на сайте - - - Изменить + + Удалить - - Удалить - -
- Добавить город
{% include 'admin/includes/admin_pagination.html' with page_obj=objects %} diff --git a/templates/admin/includes/admin_nav.html b/templates/admin/includes/admin_nav.html index 51a37be8..7f1ec5ed 100644 --- a/templates/admin/includes/admin_nav.html +++ b/templates/admin/includes/admin_nav.html @@ -12,6 +12,7 @@
  • Импорт
  • Экспорт
  • +
  • Архив логов
  • diff --git a/templates/client/blank.html b/templates/client/blank.html index ebc89246..169d8388 100644 --- a/templates/client/blank.html +++ b/templates/client/blank.html @@ -22,6 +22,8 @@ This template include basic anf main styles and js files, {% include 'includes/meta.html' %} + + diff --git a/templates/client/includes/conference/conference_object.html b/templates/client/includes/conference/conference_object.html index ca037581..96128573 100644 --- a/templates/client/includes/conference/conference_object.html +++ b/templates/client/includes/conference/conference_object.html @@ -165,15 +165,12 @@ {% endif %} {% endif %} - {% if event.place_alt %} - {% if not event.place %} -
    {% trans 'Место проведения' %}:
    -
    - {{ event.place_alt }} -
    - {% endif %} - - {% endif %} + {% if not event.place %} +
    {% trans 'Место проведения' %}:
    +
    + {{ event.country.name }} , {{ event.city.name }}{% if event.place_alt %} , {{ event.place_alt }}{% endif %} +
    + {% endif %} {% if event.web_page %}
    {% trans 'Веб-сайт' %}:
    diff --git a/templates/client/includes/exposition/exposition_object.html b/templates/client/includes/exposition/exposition_object.html index 377d18cd..adccea4e 100644 --- a/templates/client/includes/exposition/exposition_object.html +++ b/templates/client/includes/exposition/exposition_object.html @@ -169,15 +169,13 @@ {% endif %} {% endif %} - {% if exposition.place_alt %} - {% if not exposition.place %} -
    {% trans 'Место проведения' %}:
    -
    - {{ exposition.place_alt }} -
    - {% endif %} + {% if not exposition.place %} +
    {% trans 'Место проведения' %}:
    +
    + {{ exposition.country.name }} , {{ exposition.city.name }}{% if exposition.place_alt %} , {{ exposition.place_alt }}{% endif %} +
    + {% endif %} - {% endif %} {% if exposition.web_page %}
    {% trans 'Веб-сайт' %}: