рефакторинг

remotes/origin/tests
Slava Kyrachevsky 9 years ago
parent 9b7037c34d
commit bf88765564
  1. 1
      apps/company/admin.py
  2. 2
      apps/emencia/django/newsletter/admin_forms.py
  3. 1
      apps/functions/custom_views.py
  4. 1
      apps/functions/utils.py
  5. 9
      apps/place_exposition/models.py
  6. 1
      apps/settings/forms.py
  7. 8
      apps/theme/models.py
  8. 8
      templates/client/includes/exposition/tags.html
  9. 72
      templates/client/includes/index/main_events.html
  10. 293
      templates/client/index.html

@ -43,7 +43,6 @@ def company_delete(request, url):
@login_required @login_required
def company_change(request, url): def company_change(request, url):
print('URL\n' + url)
""" """
Return form and fill it with existing Company object data. Return form and fill it with existing Company object data.

@ -276,14 +276,12 @@ class NewsletterRecommendForm(forms.ModelForm):
def clean_event(self): def clean_event(self):
event = self.cleaned_data.get('event') event = self.cleaned_data.get('event')
print(event)
match = self.rx.match(event) match = self.rx.match(event)
if not match: if not match:
raise forms.ValidationError(_(u'Введены неверные данные')) raise forms.ValidationError(_(u'Введены неверные данные'))
model = self.event_models.get(match.group('type')) model = self.event_models.get(match.group('type'))
self.event_model = model self.event_model = model
event_id = match.group('pk') event_id = match.group('pk')
print(model, event_id, event)
try: try:
event = model.objects.get(pk=event_id) event = model.objects.get(pk=event_id)
except model.DoesNotExist: except model.DoesNotExist:

@ -486,7 +486,6 @@ class SimpleObjectChangeView(RedirectView, SingleObjectMixin):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
self.change_object() self.change_object()
print(self.request.META.get('QUERY_STRING', ''))
return super(SimpleObjectChangeView, self).get(request, *args, **kwargs) return super(SimpleObjectChangeView, self).get(request, *args, **kwargs)

@ -21,7 +21,6 @@ def strfdelta(tdelta, fmt):
class CachedSting(object): class CachedSting(object):
def __init__(self, path, timeout=None): def __init__(self, path, timeout=None):
super(CachedSting, self).__init__() super(CachedSting, self).__init__()
print('initiated', path)
self.path = path self.path = path
self.timeout = timeout or timedelta(days=1) self.timeout = timeout or timedelta(days=1)
self.get_object() self.get_object()

@ -196,8 +196,13 @@ class PlaceExposition(TranslatableModel, ExpoMixin):
if not self.address: if not self.address:
return [] return []
# get coordinates of all hotels in current city # get coordinates of all hotels in current city
qs_hotels_all = self.city.hotels.filter(city=self.city) qs_hotels_all = self.city.hotels.language().filter(
hotels_coord = [(hotel.latitude, hotel.longitude) for hotel in qs_hotels_all] city=self.city
).values(
'latitude', 'longitude', 'url', 'photo', 'name',
'min_price', 'currency'
)
hotels_coord = [(hotel['latitude'], hotel['longitude']) for hotel in qs_hotels_all]
# coordinate current place # coordinate current place
place_coord = (float(self.address['lat']), float(self.address['lng'])) place_coord = (float(self.address['lat']), float(self.address['lng']))
# 4 coordinates of 4 nearest hotels # 4 coordinates of 4 nearest hotels

@ -197,7 +197,6 @@ class EventDefaultDescriptionEditForm(forms.Form):
for field_name, path in templates.iteritems(): for field_name, path in templates.iteritems():
try: try:
with open(os.path.join(settings.SITE_ROOT, path), 'w+') as f: with open(os.path.join(settings.SITE_ROOT, path), 'w+') as f:
print(self.cleaned_data.get(field_name))
f.write(self.cleaned_data.get(field_name).encode('utf-8')) f.write(self.cleaned_data.get(field_name).encode('utf-8'))
except Exception as e: except Exception as e:
print(e) print(e)

@ -63,19 +63,19 @@ class Theme(TranslatableModel):
def expositions_number(self): def expositions_number(self):
return Exposition.enable.upcoming().filter(theme__id=self.id).count() return Exposition.enable.upcoming().filter(theme=self).count()
def conferences_number(self): def conferences_number(self):
return Conference.enable.upcoming().filter(theme__id=self.id).count() return Conference.enable.upcoming().filter(theme=self).count()
def seminars_number(self): def seminars_number(self):
return Seminar.objects.filter(theme__id=self.id).count() return Seminar.objects.filter(theme=self).count()
def webinars_number(self): def webinars_number(self):
return Webinar.objects.filter(theme__id=self.id).count() return Webinar.objects.filter(theme=self).count()
def events_number(self): def events_number(self):
return self.expositions_number() + self.conferences_number() + self.seminars_number() + self.webinars_number() return self.expositions_number() + self.conferences_number() + self.seminars_number() + self.webinars_number()

@ -1,5 +1,3 @@
{% with tags=obj.tags %} {% for tag in obj.tags.all %}
{% for tag in tags %} <a href="{{ obj.catalog }}tag/{{ tag.url }}">{{ tag.name }}</a>{% if not forloop.last %},{% endif %}
<a href="{{ obj.catalog }}tag/{{ tag.url }}">{{ tag.name }}</a>{% if forloop.counter != tags|length %},{% endif %} {% endfor %}
{% endfor %}
{% endwith %}

@ -1,72 +0,0 @@
{% load thumbnail %}
{% load i18n %}
{% load template_filters %}
<div class="mcl">
<div id="mp-recent-expo" class="recent-expo">
<ul class="cycle-slideshow"
data-cycle-fx="scrollHorz"
data-cycle-timeout="4000"
data-cycle-prev=".swiper-button-prev"
data-cycle-next=".swiper-button-next"
data-cycle-pause-on-hover="true"
data-cycle-slides="> li"
data-cycle-log="false">
{% for event in events %}
<li>
<div class="re-pict pict-over" >
{% if event.logo %}
<a href="{{ event.get_main_link }}">
{# <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_main_link }}">
<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="{{ event.get_note_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.tags %}
{% 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 swiper-button-prev" href="javascript:void(0)">&lt;</a>
<a class="next swiper-button-next" href="javascript:void(0)">&gt;</a>
</div>
</div>
</div>

@ -1,152 +1,223 @@
{% extends "blank.html" %} {% extends "client/blank.html" %}
{% load static %} {% load static i18n %}
{% load i18n %}
{% load thumbnail %} {% load thumbnail %}
{% load template_filters %} {% load template_filters %}
{% block styles %} {% block styles %}
<style> <style>
.pict-over{width:220px;height:220px;line-height:212px;text-align:center;background:#fff;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} .pict-over{width:220px;height:220px;line-height:212px;text-align:center;background:#fff;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> </style>
{% endblock %} {% endblock %}
{% block body_class %} class="main-page" {% endblock %} {% block body_class %} class="main-page" {% endblock %}
{% block top %} {% block top %}
<section class="layout mp-top"> <section class="layout mp-top">
<div class="layout-wrap"> <div class="layout-wrap">
<aside> <aside>
{% include 'client/includes/menu.html' %} {% include 'client/includes/menu.html' %}
</aside> </aside>
{% include 'client/includes/index/main_events.html' with events=events %} <div class="mcl">
</div> <div id="mp-recent-expo" class="recent-expo">
</section> <ul class="cycle-slideshow"
data-cycle-fx="scrollHorz"
data-cycle-timeout="4000"
data-cycle-prev=".swiper-button-prev"
data-cycle-next=".swiper-button-next"
data-cycle-pause-on-hover="true"
data-cycle-slides="> li"
data-cycle-log="false">
{% for event in events %}
<li>
<div class="re-pict pict-over" >
{% if event.logo %}
<a href="{{ event.get_main_link }}">
{# <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_main_link }}">
<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="{{ event.get_note_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.tags %}
{% 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 swiper-button-prev" href="javascript:void(0)">&lt;</a>
<a class="next swiper-button-next" href="javascript:void(0)">&gt;</a>
</div>
</div>
</div>
</div>
</section>
{% endblock %} {% endblock %}
{% block search %} {% block search %}
{% include 'client/includes/catalog_search_main.html' with search_form=search_form %} {% include 'client/includes/catalog_search_main.html' with search_form=search_form %}
{% endblock %} {% endblock %}
{% block catalog %} {% block catalog %}
<section class="layout mp-catalog"> <section class="layout mp-catalog">
<div class="layout-wrap"> <div class="layout-wrap">
<aside> <aside>
{% include 'client/includes/feedback.html' %} {% include 'client/includes/feedback.html' %}
{% include 'client/includes/online_consult.html' %} {% include 'client/includes/online_consult.html' %}
{% comment %} {% comment %}
<!-- task EXPO-145--> <!-- task EXPO-145-->
{% include 'client/includes/announces.html' %} {% include 'client/includes/announces.html' %}
{% endcomment %} {% endcomment %}
{% include 'client/includes/services.html' %} {% include 'client/includes/services.html' %}
</aside> </aside>
<div class="mcl"> <div class="mcl">
<div class="mp-catalog-lists"> <div class="mp-catalog-lists">
<div class="mpc-list"> <div class="mpc-list">
{% include 'client/includes/index/expos.html' with themes=exposition_themes %} {% include 'client/includes/index/expos.html' with themes=exposition_themes %}
</div> </div>
<div class="mpc-list"> <div class="mpc-list">
{% include 'client/includes/index/confs.html' with themes=conference_themes %} {% include 'client/includes/index/confs.html' with themes=conference_themes %}
</div> </div>
</div> </div>
{% include 'client/includes/banners/main_page_inner.html' %} {% include 'client/includes/banners/main_page_inner.html' %}
</div> </div>
</div> </div>
</section> </section>
{% endblock %} {% endblock %}
{% block announces %} {% block announces %}
<section class="layout mp-announces"> <section class="layout mp-announces">
<div class="layout-wrap"> <div class="layout-wrap">
<aside> <aside>
<div class="mp-news-list"> <div class="mp-news-list">
{% include 'client/includes/index/news.html' with news=news_list %} {% include 'client/includes/index/news.html' with news=news_list %}
</div> </div>
</aside> </aside>
<div class="mcl"> <div class="mcl">
<div class="mp-photo-gallery"> <div class="mp-photo-gallery">
{% if main_page_block %} {% if main_page_block %}
{{ main_page_block.text|safe }} {{ main_page_block.text|safe }}
{% endif %} {% endif %}
{% comment %} {% comment %}
<div id="mp-photo-gallery" class="photo-gallery swiper-container"> <div id="mp-photo-gallery" class="photo-gallery swiper-container">
<ul class="swiper-wrapper"> <ul class="swiper-wrapper">
<li class="swiper-slide"> <li class="swiper-slide">
<div class="pg-item"> <div class="pg-item">
<div class="pgi-pict"><img src="{% static 'client/img/_del-temp/mp-phg-1.jpg' %}" alt="" /></div> <div class="pgi-pict"><img src="{% static 'client/img/_del-temp/mp-phg-1.jpg' %}" alt="" /></div>
<div class="pgi-descr clearfix"> <div class="pgi-descr clearfix">
<div class="pgi-date"><b>с 1 по 8 августа</b> 2013 года</div> <div class="pgi-date"><b>с 1 по 8 августа</b> 2013 года</div>
<div class="pgi-text">Международный фестиваль оперы, музыки, драматических и танцевальных постановок Edinburgh International Festival 2013</div> <div class="pgi-text">Международный фестиваль оперы, музыки, драматических и танцевальных постановок Edinburgh International Festival 2013</div>
</div> </div>
</div> </div>
</li> </li>
<li class="swiper-slide"> <li class="swiper-slide">
<div class="pg-item"> <div class="pg-item">
<div class="pgi-pict"><img src="{% static 'client/img/_del-temp/mp-phg-1.jpg' %}" alt="" /></div> <div class="pgi-pict"><img src="{% static 'client/img/_del-temp/mp-phg-1.jpg' %}" alt="" /></div>
<div class="pgi-descr clearfix"> <div class="pgi-descr clearfix">
<div class="pgi-date"><b>с 1 по 8 августа</b> 2013 года</div> <div class="pgi-date"><b>с 1 по 8 августа</b> 2013 года</div>
<div class="pgi-text">Международный фестиваль оперы, музыки, драматических и танцевальных постановок Edinburgh International Festival 2013</div> <div class="pgi-text">Международный фестиваль оперы, музыки, драматических и танцевальных постановок Edinburgh International Festival 2013</div>
</div> </div>
</div> </div>
</li> </li>
</ul> </ul>
<div class="re-controls"> <div class="re-controls">
<a class="prev" href="#">&lt;</a> <a class="prev" href="#">&lt;</a>
<a class="next" href="#">&gt;</a> <a class="next" href="#">&gt;</a>
</div> </div>
</div> </div>
{% endcomment %} {% endcomment %}
</div> </div>
</div> </div>
</div> </div>
</section> </section>
{% endblock %} {% endblock %}
{% block partners %} {% block partners %}
<section class="layout mp-partners"> <section class="layout mp-partners">
<div class="mpp-wrap"> <div class="mpp-wrap">
<header>{% trans 'Наши партнеры:' %}</header> <header>{% trans 'Наши партнеры:' %}</header>
<ul class="mp-partners-list"> <ul class="mp-partners-list">
<li><img src="{% static 'client/img/partners/deutsche-messe-2.png' %}" /></li> <li><img src="{% static 'client/img/partners/deutsche-messe-2.png' %}" /></li>
<li><img src="{% static 'client/img/partners/ite.png' %}" /></li> <li><img src="{% static 'client/img/partners/ite.png' %}" /></li>
<li><img src="{% static 'client/img/partners/congress_office.png' %}" /></li> <li><img src="{% static 'client/img/partners/congress_office.png' %}" /></li>
{% comment %} {% comment %}
<li><img src="{% static 'client/img/partners/nurnberg-messe.png' %}" /></li> <li><img src="{% static 'client/img/partners/nurnberg-messe.png' %}" /></li>
{% endcomment %} {% endcomment %}
<li><img src="{% static 'client/img/partners/reed-exhibitions.png' %}" /></li> <li><img src="{% static 'client/img/partners/reed-exhibitions.png' %}" /></li>
<li><img src="{% static 'client/img/partners/messe-dusseldorf.png' %}" /></li> <li><img src="{% static 'client/img/partners/messe-dusseldorf.png' %}" /></li>
</ul> </ul>
</div> </div>
</section> </section>
{% endblock %} {% endblock %}
{% block services %} {% block services %}
<section class="layout mp-services"> <section class="layout mp-services">
<div class="layout-wrap"> <div class="layout-wrap">
<aside> <aside>
{% include 'client/includes/side_confs.html' %} {% include 'client/includes/side_confs.html' %}
</aside> </aside>
<div class="mcl"> <div class="mcl">
<div class="mp-reviews-wrap clearfix"> <div class="mp-reviews-wrap clearfix">
{% include 'client/includes/index/blogs.html' with blogs=blogs %} {% include 'client/includes/index/blogs.html' with blogs=blogs %}
</div> </div>
</div> </div>
</div> </div>
</section> </section>
{% if request.GET.debug == '1' %} {% if request.GET.debug == '1' %}
<script src="{% static 'client/js/_modules/page.index.js' %}"></script> <script src="{% static 'client/js/_modules/page.index.js' %}"></script>

Loading…
Cancel
Save