Tickets. 16.02.2015

remotes/origin/1203
Назар Котюк 11 years ago
parent 3a23d56b40
commit 30abcf8da6
  1. 57
      exposition/management/commands/expo_organiser.py
  2. 74
      exposition/management/commands/fix_logo.py
  3. 2
      import_xls/excel_settings.py
  4. 1
      organiser/models.py
  5. 2
      place_exposition/admin.py
  6. 2
      place_exposition/forms.py
  7. 2
      proj/views.py
  8. 8
      settings/admin.py
  9. 8
      settings/forms.py
  10. 10
      templates/client/includes/exposition/exposition_object.html
  11. 14
      templates/client/includes/exposition/price.html
  12. 10
      templates/client/includes/exposition/search_result.html
  13. 38
      templates/client/includes/index/main_date_block.html
  14. 64
      templates/client/includes/index/main_events.html
  15. 84
      templates/client/index.html

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
import xlrd
from django.core.management.base import BaseCommand
from django.conf import settings
from functions.form_check import translit_with_separator
from exposition.models import Exposition
from organiser.models import Organiser
CHINA_FILE = settings.MEDIA_ROOT+'/import/expo_china_ru.xlsx'
GERMANY_FILE = settings.MEDIA_ROOT+'/import/expo_germany_ru.xlsx'
# 391 row not imported(same url)
ITALY_FILE = settings.MEDIA_ROOT+'/import/expo_italy_ru.xlsx'
# moscow 3 exps
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(GERMANY_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]]
for row_number, row in enumerate(row_list[1:]):
exp_url = translit_with_separator(row[2])
try:
exp = Exposition.objects.get(url=exp_url)
except Exposition.DoesNotExist:
continue
cell1 = row[11].split(';')
cell2 = row[12].split(';')
orgs = [item.strip() for item in cell1+cell2 if item]
exp.organiser.clear()
for org in orgs:
url = translit_with_separator(org)
try:
organiser = Organiser.objects.get(url=url)
except Organiser.DoesNotExist:
organiser = Organiser(url=url)
organiser.translate('ru')
organiser.name = org
organiser.save()
if not exp.organiser.filter(url=organiser.url).exists():
exp.organiser.add(organiser)
print(exp)

@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
import xlrd
import urllib2
from django.core.management.base import BaseCommand
from django.conf import settings
from functions.form_check import translit_with_separator
from functions.files import get_alternative_filename
from exposition.models import Exposition
from organiser.models import Organiser
CHINA_FILE = settings.MEDIA_ROOT+'/import/expo_china_ru.xlsx'
GERMANY_FILE = settings.MEDIA_ROOT+'/import/expo_germany_ru.xlsx'
# 391 row not imported(same url)
ITALY_FILE = settings.MEDIA_ROOT+'/import/expo_italy_ru.xlsx'
# moscow 3 exps
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_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:]):
exp_url = translit_with_separator(row[2])
try:
exp = Exposition.objects.get(url=exp_url)
except Exposition.DoesNotExist:
continue
if row[16] =='' or row[16].startswith('http') or row[16].startswith('https') or row[16].startswith('/') or row[16].startswith('../'):
continue
path = row[16]
file_name = path.split('/')[-1]
logo_path = exp.logo.field.upload_to
full_path = settings.MEDIA_ROOT + logo_path
alt_name = get_alternative_filename(full_path, file_name)
download_to = full_path+alt_name
url = 'http://expomap.ru/' + path
try:
response = urllib2.urlopen(url, timeout=15)
except:
continue
with open(download_to,'wb') as f:
try:
f.write(response.read())
f.close()
except:
# can be timeout
continue
exp.logo = logo_path + alt_name
try:
exp.save()
print(exp)
except:
print('logo exception. logo: %s'%exp.logo)
continue

@ -372,7 +372,7 @@ event_sett = {
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'min_stand_size', u'func': to_int},
u'Регистрационный взнос':{u'field': u'registration_payment', u'func': to_int},
u'Примечание по участии':{u'field': u'participation_note', u'func': unicode},
u'Крайний срок подачи заявки':{u'field': u'application_deadline', u'func': to_date},

@ -75,6 +75,7 @@ class Organiser(TranslatableModel):
#fields saves information about creating and changing model
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
active = models.NullBooleanField(default=0)
def __unicode__(self):
return self.lazy_translation_getter('name', self.pk)

@ -296,12 +296,12 @@ def edit_hall(request, place_url, hall_id):
form.save(place, hall_id)
return HttpResponseRedirect('/admin/place_exposition/%s/'%place.url)
else:
data = {'capacity': hall.capacity, 'number': hall.number}
for code, name in settings.LANGUAGES:
trans_obj = Hall._meta.translations_model.objects.get(language_code = code, master__id=hall.id) #access to translated fields
data['name_%s'%code] = trans_obj.name
form = HallForm(initial=data)
context = {'form': form, 'languages': settings.LANGUAGES}
context.update(csrf(request))

@ -310,8 +310,8 @@ class HallForm(forms.Form):
hall.capacity = data['capacity']
hall.number = data['number']
hall.place_exposition = place_exposition
hall.save()
fill_with_signal(Hall, hall, data)
hall.save()
return hall

@ -34,7 +34,7 @@ class MainPageView(TemplateView):
def get_context_data(self, **kwargs):
context = super(MainPageView, self).get_context_data(**kwargs)
events = Exposition.objects.all().order_by('-main_page')[:5]
events = Exposition.objects.filter(main_page__gt=0)
exposition_themes = Theme.objects.order_by('-main_page').filter(types=Theme.types.exposition)[:6]
conference_themes = Theme.objects.order_by('-main_page').filter(types=Theme.types.conference)[:6]
seminar_themes = Theme.objects.order_by('-main_page').filter(types=Theme.types.seminar)[:6]

@ -60,10 +60,10 @@ import datetime
def main_page(request):
now = datetime.datetime.now()
expositions = Exposition.objects.filter(main_page__gt=0, data_begin__gte=now)
conferences = Conference.objects.filter(main_page__gt=0, data_begin__gte=now)
seminars = Seminar.objects.filter(main_page__gt=0, data_begin__gte=now)
webinars = Webinar.objects.filter(main_page__gt=0, data_begin__gte=now)
expositions = Exposition.objects.filter(main_page__gt=0)
conferences = Conference.objects.filter(main_page__gt=0)
seminars = Seminar.objects.filter(main_page__gt=0)
webinars = Webinar.objects.filter(main_page__gt=0)
events = {'expositions':expositions, 'conferences': conferences,
'seminars':seminars, 'webinars': webinars}

@ -82,20 +82,20 @@ class MainPageEvent(forms.Form):
super(MainPageEvent, self).__init__(*args, **kwargs)
now = datetime.datetime.now
self.fields['expositions' ] = forms.ModelMultipleChoiceField(
queryset=Exposition.objects.filter(data_begin__gte=now),
queryset=Exposition.objects.all(),
required=False
)
self.fields['conferences' ] = forms.ModelMultipleChoiceField(
queryset=Conference.objects.filter(data_begin__gte=now),
queryset=Conference.objects.all(),
required=False
)
self.fields['seminars' ] = forms.ModelMultipleChoiceField(
queryset=Seminar.objects.filter(data_begin__gte=now),
queryset=Seminar.objects.all(),
required=False
)
self.fields['webinars' ] = forms.ModelMultipleChoiceField(
queryset=Webinar.objects.filter(data_begin__gte=now),
queryset=Webinar.objects.all(),
required=False
)
def save(self):

@ -170,11 +170,11 @@
<dl class="add-info">
<dt>{% trans 'Организатор' %}:</dt>
<dd>
{% for organiser in exposition.organiser.all %}
{{ organiser.name }}<br />
<a target="_blank" href="{{ organiser.web_page }}">{{ organiser.web_page }}</a><br />
{{ organiser.email }}
{% endfor %}
{% with organisers=exposition.organiser.all %}
{% for organiser in organisers %}
{{ organiser.name }}<br />
{% endfor %}
{% endwith %}
</dd>
{% if exposition.web_page %}
<dt>{% trans 'Веб-сайт' %}:</dt>

@ -88,13 +88,13 @@
{% if exposition.price_day %}
<li>
<div class="prl-value">{{ exposition.price_day }} {{ exposition.get_currency_html }}</div>
<div class="prl-value">{{ exposition.price_day }} {% if exposition.price_day|isdigit %}{{ exposition.get_currency_html }}{% endif %}</div>
<div class="prl-descr"><span>{% trans 'на 1 день' %}</span></div>
</li>
{% endif %}
{% if exposition.price_all %}
<li>
<div class="prl-value">{{ exposition.price_all }} {{ exposition.get_currency_html }}</div>
<div class="prl-value">{{ exposition.price_all }} {% if exposition.price_all|isdigit %}{{ exposition.get_currency_html }}{% endif %}</div>
<div class="prl-descr"><span>{% trans 'на все дни' %}</span></div>
</li>
{% endif %}
@ -113,7 +113,7 @@
<ul class="pr-list gray">
{% if exposition.price_day_bar %}
<li>
<div class="prl-value">{{ exposition.price_day_bar }} {{ exposition.get_currency_html }}</div>
<div class="prl-value">{{ exposition.price_day_bar }} {% if exposition.price_day_bar|isdigit %}{{ exposition.get_currency_html }}{% endif %}</div>
<div class="prl-descr"><span>на 1 день</span></div>
</li>
@ -122,7 +122,7 @@
<li>
{# {% if exposition.price_all_bar|isdigit %} #}
<div class="prl-value">{{ exposition.price_all_bar }} {{ exposition.get_currency_html }}</div>
<div class="prl-value">{{ exposition.price_all_bar }} {% if exposition.price_all_bar|isdigit %}{{ exposition.get_currency_html }}{% endif %}</div>
<div class="prl-descr"><span>{% trans 'на все дни' %}</span></div>
</li>
@ -186,7 +186,7 @@
<li>
<div class="prl-value">
{% if exposition.min_open_area %}
{{ exposition.min_open_area }}-{{ exposition.max_closed_area }} {{ exposition.get_currency_html }}
{{ exposition.min_open_area }}-{{ exposition.max_open_area }} {{ exposition.get_currency_html }}
{% else %}
{{ exposition.max_open_area }} {{ exposition.get_currency_html }}
{% endif %}
@ -200,8 +200,8 @@
<a class="button big orange b-more" href="#">{% trans 'Заявка на участие' %}</a>
<div class="epr-conditons">
{% if exposition.min_area %}
<p>{% trans 'Минимальный размер стенда' %} — {{ exposition.min_area }}м²</p>
{% if exposition.min_stand_size %}
<p>{% trans 'Минимальный размер стенда' %} — {{ exposition.min_stand_size }}м²</p>
{% endif %}
{% if exposition.registration_payment %}
<p>{% trans 'Регистрационный взнос' %} — {{ exposition.registration_payment }}{{ exposition.get_currency_html }}</p>

@ -25,21 +25,11 @@
</a>
<div class="cli-info">
<div class="cli-top clearfix">
{% if user.is_staff %}
{% if result.object.is_published %}
<div class="cli-status"><div class="status active">Активная</div></div>
{% else %}
<div class="cli-status"><div class="status canceled">Неактивная</div></div>
{% endif %}
{% else %}
{% if result.object.quality_label.ufi.is_set %}
<div class="cli-approved">
<img src="{% static 'client/img/approved-logo.png' %}" alt="" title="Approved Event" />
</div>
{% endif %}
{% endif %}
<header>
<div class="cli-title"><a href="{{ result.object.get_permanent_url }}">{{ result.object.name|safe }}</a></div>
</header>

@ -0,0 +1,38 @@
{% load i18n %}
{% load template_filters %}
{% get_current_language as LANGUAGE_CODE %}
{% load pytils_dt %}
{% if obj.data_begin|timesince_exp:obj.data_end %}
{{ obj.data_begin|date:"F" }}
{% else %}
{% if obj.data_begin|timesince:obj.data_end < "1 day" %}
{% ifequal LANGUAGE_CODE 'ru' %}
{{ obj.data_begin|ru_strftime:"%d %B %Y" }}
{% else %}
{{ obj.data_begin }}
{% endifequal %}
{% else %}
{% if obj.data_end %}
{% trans 'с' %}
{% ifnotequal obj.data_begin|date:"F" obj.data_end|date:"F" %}
{% ifequal LANGUAGE_CODE 'ru' %}
{{ obj.data_begin|ru_strftime:"%d %B" }}
{% else %}
{{ obj.data_begin|date:"F j" }}
{% endifequal %}
{% else %}
{{ obj.data_begin|date:"j" }}{% endifnotequal %} {% trans 'по' %} {{ obj.data_end|date:"j E Y" }} {% trans 'года' %}
{% else %}
{{ obj.data_begin }}
{% endif %}
{% endif %}
{% endif %}

@ -0,0 +1,64 @@
{% load thumbnail %}
{% load i18n %}
{% load template_filters %}
<div class="mcl">
<div id="mp-recent-expo" class="recent-expo swiper-container">
<ul class="swiper-wrapper">
{% for event in events %}
<li class="swiper-slide">
<div class="re-pict pict-over" >
{% if event.logo %}
<a href="{{ event.get_permanent_url }}">
<!--<img src="{{ event.logo.url }}">-->
{% thumbnail event.get_preview "220x220" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}
</a>
{% endif %}
</div>
<div class="re-body">
<div class="re-info">
<a href="{{ event.get_permanent_url }}">
<div class="re-title">{{ event.name|safe }}</div>
<div class="re-date">
{% include 'client/includes/index/main_date_block.html' with obj=event %}
</div>
<div class="re-descr" title="{{ event.main_title|safe }}">{{ event.main_title|safe }}</div>
</a>
</div>
<footer>
<div class="re-buttons">
<a class="button blue icon-calendar {% if event|in_calendar:request.user %}removecalendar {% else %}addcalendar {% endif %}" href="{{ event.get_calendar_url }}">{% if event|in_calendar:request.user %}{% trans 'Убрать из календаря' %}{% else %}{% trans 'добавить в календарь' %}{% endif %}</a>
<div class="main-page {% if request.user.is_authenticated%}note-wrap{% else %}note-wrap-disabled{% endif %}">
<a class="button green icon-note {% if note %}active{% endif %} note-button" href="/expo/add-note/{{ event.url }}/">{% trans 'заметка' %}</a>
<div class="note-overlay">
<form action="">
<textarea name="note_text" class="note-text"> {{ note }}</textarea>
</form>
</div>
</div>
</div>
<div class="re-tags">
{% with tags=event.tag.all %}
{% for tag in tags %}
<a href="{{ event.get_catalog_url }}tag/{{ tag.url }}">{{ tag }}</a>{% if forloop.counter < tags|length %},{% endif %}
{% endfor %}
{% endwith %}
</div>
</footer>
</div>
</li>
{% endfor %}
</ul>
<div class="re-controls">
<a class="prev" href="#">&lt;</a>
<a class="next" href="#">&gt;</a>
</div>
</div>
</div>

@ -4,6 +4,33 @@
{% load thumbnail %}
{% load template_filters %}
{% block styles %}
<style>
.pict-over{
width: 220px;
height: 220px;
line-height: 212px;
text-align: center;
background: #ffffff;
border-radius: 4px;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: block;
}
.pict-over img{
max-width: 100%;
max-height: 100%;
border-radius: 4px;
vertical-align: middle;
}
</style>
{% endblock %}
{% block body_class %} class="main-page" {% endblock %}
{% block top %}
@ -15,63 +42,8 @@
{% include 'menu.html' %}
</aside>
<div class="mcl">
<div id="mp-recent-expo" class="recent-expo swiper-container">
<ul class="swiper-wrapper">
{% for event in events %}
<li class="swiper-slide">
<div class="re-pict">
{% if event.logo %}
<a href="{{ event.get_permanent_url }}">
<!--<img src="{{ event.logo.url }}">-->
{% thumbnail event.get_preview "220x220" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}
{% include 'client/includes/index/main_events.html' with events=events %}
</a>
{% endif %}
</div>
<div class="re-body">
<div class="re-info">
<a href="{{ event.get_permanent_url }}">
<div class="re-title">{{ event.name|safe }}</div>
<div class="re-date">
{% with obj=event %}
{% include 'client/includes/show_date_block.html' %}
{% endwith %}
</div>
<div class="re-descr" title="{{ event.main_title|safe }}">{{ event.main_title|safe }}</div>
</a>
</div>
<footer>
<div class="re-buttons">
<a class="button blue icon-calendar {% if event|in_calendar:request.user %}removecalendar {% else %}addcalendar {% endif %}" href="{{ event.get_calendar_url }}">{% if event|in_calendar:request.user %}{% trans 'Убрать из календаря' %}{% else %}{% trans 'добавить в календарь' %}{% endif %}</a>
<div class="main-page {% if request.user.is_authenticated%}note-wrap{% else %}note-wrap-disabled{% endif %}">
<a class="button green icon-note {% if note %}active{% endif %} note-button" href="/expo/add-note/{{ event.url }}/">{% trans 'заметка' %}</a>
<div class="note-overlay">
<form action="">
<textarea name="note_text" class="note-text"> {{ note }}</textarea>
</form>
</div>
</div>
</div>
<div class="re-tags">
{% for tag in event.tag.all %}
<a href="{{ event.get_catalog_url }}tag-{{ tag.url }}">{{ tag }}</a>,
{% endfor %}
</div>
</footer>
</div>
</li>
{% endfor %}
</ul>
<div class="re-controls">
<a class="prev" href="#">&lt;</a>
<a class="next" href="#">&gt;</a>
</div>
</div>
</div>
</div>
</section>

Loading…
Cancel
Save