From 4e1fc79435e61dd5c3406545ca2dfb4438a2743b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=9A=D0=BE=D1=82=D1=8E?= =?UTF-8?q?=D0=BA?= Date: Tue, 5 May 2015 04:02:00 +0300 Subject: [PATCH] Paid expo functional --- banners/models.py | 3 + city/models.py | 2 +- exposition/admin.py | 21 +- exposition/admin_urls.py | 5 +- exposition/forms.py | 7 + exposition/models.py | 11 + exposition/views.py | 16 +- place_exposition/models.py | 2 +- templates/admin/exposition/paid.html | 59 +++ templates/client/exposition/catalog.html | 3 + .../client/exposition/catalog_theme.html | 3 + .../client/exposition/exposition_detail.html | 6 +- .../client/includes/exposition/expo_paid.html | 414 ++++++++++++++++++ .../exposition/exposition_object.html | 2 +- .../client/includes/exposition/services.html | 20 +- 15 files changed, 557 insertions(+), 17 deletions(-) create mode 100644 templates/admin/exposition/paid.html create mode 100644 templates/client/includes/exposition/expo_paid.html diff --git a/banners/models.py b/banners/models.py index a690ec3f..aa17c039 100644 --- a/banners/models.py +++ b/banners/models.py @@ -8,3 +8,6 @@ class Redirect(models.Model): def __unicode__(self): return self.redirect + + def get_object_url(self): + return '/redirect/reditect/%d/'%self.id diff --git a/city/models.py b/city/models.py index 77920a05..0f2a2035 100644 --- a/city/models.py +++ b/city/models.py @@ -70,7 +70,7 @@ class City(TranslatableModel): return self.lazy_translation_getter('name', self.pk) def get_hotels(self): - return self.hotels.all()[:4] + return list(self.hotels.all()[:4]) def get_events(self): now = date.today() diff --git a/exposition/admin.py b/exposition/admin.py index a5b1164e..7bdf2d09 100644 --- a/exposition/admin.py +++ b/exposition/admin.py @@ -384,4 +384,23 @@ def search_expo(request): qs = SearchQuerySet().models(Exposition).autocomplete(content_auto=term).order_by('text')[:30] result = [{'id': item.pk, 'label': get_by_lang(item, 'name', lang)} for item in qs] - return HttpResponse(json.dumps(result), content_type='application/json') \ No newline at end of file + return HttpResponse(json.dumps(result), content_type='application/json') + + +from django.views.generic import FormView +from forms import PaidForm +class PaidView(FormView): + form_class = PaidForm + success_url = '/admin/exposition/all/' + template_name = 'admin/exposition/paid.html' + + def form_valid(self, form): + expo = Exposition.objects.get(url=self.kwargs.get('url')) + paid = form.save(commit=False) + paid.expo = expo + paid.save() + + return HttpResponseRedirect(self.success_url) + + + diff --git a/exposition/admin_urls.py b/exposition/admin_urls.py index 07715753..096b5444 100644 --- a/exposition/admin_urls.py +++ b/exposition/admin_urls.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- from django.conf.urls import patterns, include, url -from admin import ExpositionListView, ExpositionView +from admin import ExpositionListView, ExpositionView, PaidView urlpatterns = patterns('exposition.admin', - url(r'^upload-photo/(?P.*)/$', 'upload_exposition_photo'), + url(r'^upload-photo/(?P.*)/$', 'upload_exposition_photo'), + url(r'^(?P.*)/paid/$', PaidView.as_view()), #url(r'^add.*/$', 'exposition_add'), url(r'^delete/(?P.*)/$', 'exposition_delete'), diff --git a/exposition/forms.py b/exposition/forms.py index be955bc1..05633fd1 100644 --- a/exposition/forms.py +++ b/exposition/forms.py @@ -616,3 +616,10 @@ class ExpositionFilterForm(AdminFilterForm): return qs +from exposition.models import Paid + +class PaidForm(forms.ModelForm): + class Meta: + model = Paid + exclude = ('expo',) + diff --git a/exposition/models.py b/exposition/models.py index 5fb497ff..4c38ceed 100644 --- a/exposition/models.py +++ b/exposition/models.py @@ -358,6 +358,17 @@ class TmpTimeTable(TranslatableModel): ) +def logo_name(instance, filename): + url = instance.expo.url + return '/'.join(['exposition', url, url+'_org_logo.jpg']) + +class Paid(models.Model): + expo = models.OneToOneField(Exposition) + org_logo = models.ImageField(upload_to=logo_name, blank=True, max_length=255) + oficial_link = models.ForeignKey('banners.Redirect', null=True, blank=True) + participation_link = models.ForeignKey('banners.Redirect', null=True, blank=True) + tickets_link = models.ForeignKey('banners.Redirect', null=True, blank=True) + pre_save.connect(pre_save_handler, sender=Exposition) post_save.connect(post_save_handler, sender=Exposition) diff --git a/exposition/views.py b/exposition/views.py index 13ea4857..ffa4f6a7 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -280,6 +280,7 @@ class ExpoCatalog(MetadataMixin, ListView): month = None country = None city = None + paid = None def get_filtered_qs(self): # diferent for views @@ -331,6 +332,8 @@ class ExpoCatalog(MetadataMixin, ListView): def get_context_data(self, **kwargs): context = super(ExpoCatalog, self).get_context_data(**kwargs) + if self.paid: + context['paid'] = self.paid context['search_form'] = self.search_form context['filter_object'] = self.filter_object context['year'] = self.year @@ -362,7 +365,7 @@ class ExpoCityCatalog(ExpoCatalog): class ExpoThemeCatalog(ExpoCatalog): - template_name = 'exposition/catalog_theme.html' + template_name = 'client/exposition/catalog_theme.html' catalog_url = '/expo/theme/' country = None city = None @@ -375,7 +378,10 @@ class ExpoThemeCatalog(ExpoCatalog): theme = get_object_or_404(Theme, url=slug) self.kwargs['theme'] = theme - qs = self.model.enable.upcoming().filter(theme=theme) + qs = self.model.enable.upcoming().filter(theme=theme).exclude(paid__isnull=False) + paid= list(self.model.enable.filter(theme=theme).filter(paid__isnull=False)) + if paid: + self.paid = paid if country_slug: country = get_object_or_404(Country, url=country_slug) self.country = country @@ -408,7 +414,11 @@ class ExpoTagCatalog(ExpoCatalog): slug = self.kwargs.get('slug') tag = get_object_or_404(Tag, url=slug) self.kwargs['tag'] = tag - qs = self.model.enable.upcoming().filter(tag=tag) + qs = self.model.enable.upcoming().filter(tag=tag).exclude(paid__isnull=False) + paid= list(self.model.enable.filter(tag=tag).filter(paid__isnull=False)) + if paid: + self.paid = paid + self.filter_object = tag return qs diff --git a/place_exposition/models.py b/place_exposition/models.py index 0c572908..78b329d8 100644 --- a/place_exposition/models.py +++ b/place_exposition/models.py @@ -202,7 +202,7 @@ class PlaceExposition(TranslatableModel, ExpoMixin): qs = [Q(latitude=item[0]) & Q(longitude=item[1]) for item in hotels_coord] res = reduce(lambda a,b: a|b, qs) - return qs_hotels_all.filter(res) + return list(qs_hotels_all.filter(res)) def get_type(self): type = {'Convention centre': _(u'Конгрессно-выставочный центр'), 'Exposition centre': _(u'Выставочный центр'), diff --git a/templates/admin/exposition/paid.html b/templates/admin/exposition/paid.html new file mode 100644 index 00000000..2345c4df --- /dev/null +++ b/templates/admin/exposition/paid.html @@ -0,0 +1,59 @@ +{% extends 'base.html' %} +{% load static %} +{% load thumbnail %} + +{% block scripts %} + + + + +{% endblock %} + +{% block body %} +
{% csrf_token %} +
+ {% if object %} Изменить {% else %} Добавить {% endif %}выставку{% if object %}(на сайте){% endif %} + +
+
+

Основная информация

+
+
+
+ +
{{ form.org_logo }} + {{ form.org_logo.errors }} +
+
+ +
+ +
{{ form.oficial_link }} + {{ form.oficial_link.errors }} +
+
+ +
+ +
{{ form.participation_link }} + {{ form.participation_link.errors }} +
+
+ +
+ +
{{ form.tickets_link }} + {{ form.tickets_link.errors }} +
+
+
+
+ +
+ + +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/client/exposition/catalog.html b/templates/client/exposition/catalog.html index cb8941dc..e7b03d05 100644 --- a/templates/client/exposition/catalog.html +++ b/templates/client/exposition/catalog.html @@ -33,6 +33,9 @@ {% endblock %} {% block content_list %} + {% if paid %} + {% include 'includes/exposition/exposition_list.html' with object_list=paid %} + {% endif %} {% include 'includes/exposition/exposition_list.html' with object_list=object_list %} {% endblock %} diff --git a/templates/client/exposition/catalog_theme.html b/templates/client/exposition/catalog_theme.html index ab39aceb..ec72ee80 100644 --- a/templates/client/exposition/catalog_theme.html +++ b/templates/client/exposition/catalog_theme.html @@ -58,6 +58,9 @@ {% endblock %} {% block content_list %} + {% if paid %} + {% include 'includes/exposition/exposition_list.html' with object_list=paid %} + {% endif %} {% include 'includes/exposition/exposition_list.html' with object_list=object_list %} {% endblock %} diff --git a/templates/client/exposition/exposition_detail.html b/templates/client/exposition/exposition_detail.html index bac1ce97..69faaf1f 100644 --- a/templates/client/exposition/exposition_detail.html +++ b/templates/client/exposition/exposition_detail.html @@ -16,7 +16,11 @@ {% endblock %} {% block content_list %} - {% include 'client/includes/exposition/exposition_object.html' with exposition=object %} + {% ifnotequal object.url 'ipsa-osen-2015' %} + {% include 'client/includes/exposition/exposition_object.html' with exposition=object %} + {% else %} + {% include 'client/includes/exposition/expo_paid.html' with exposition=object %} + {% endifnotequal %} {% endblock %} {% block paginator %} diff --git a/templates/client/includes/exposition/expo_paid.html b/templates/client/includes/exposition/expo_paid.html new file mode 100644 index 00000000..e7ced932 --- /dev/null +++ b/templates/client/includes/exposition/expo_paid.html @@ -0,0 +1,414 @@ +{% load static %} +{% load i18n %} +{% load thumbnail %} +{% load template_filters %} +{% block page_body %} + +
+
+ +
+
+
+ {% if exposition.main_title %} + {{ exposition.main_title|safe }} {{ exposition.name|safe }} + {% else %} + {{ exposition.name|safe }} + {% endif %} +
+
+
+ {% with obj=exposition %} + {% include 'client/includes/show_date_block.html' %} + {% endwith %} +
+ {% if exposition.place %} +
+
+
+ {{ exposition.place.adress }} +
+ +
+ + +
+ {% endif %} +
+
+
+ {% with event=exposition user=user %} + {% include 'client/includes/visit_button.html' %} + {% endwith %} + {% include 'client/includes/calendar_button.html' with obj=object %} +
+ {% with note=object|note_by_user:request.user %} + {% trans 'заметка' %} +
+
+ +
+
+ {% endwith %} +
+ {% if request.user.is_admin %} + {% trans 'изменить' %} + {% endif %} +
+ +
+
+
+
+ +
+
+ {% with tags=exposition.tag.all %} + {% for tag in tags %} + {{ tag.name }}{% if forloop.counter != tags|length %},{% endif %} + {% endfor %} + {% endwith %} +
+
+
+
+ + + +
+
{% trans 'Посетить/участвовать в выставке' %}
+ +
+ {% if exposition.get_photos %} + {% with photos=exposition.get_photos|slice:"5" %} +
+
+ + +
+ {% endwith %} + {% endif %} + + {% if exposition.description %} +
+
{% trans 'О выставке' %} {{ exposition.name|safe }}
+
{{ exposition.description|safe|linebreaks }}
+
+
+ {% endif %} +
+
{% trans 'Дополнительная информация' %}
+ +
+ {% if exposition.organiser.all|length > 0 %} +
{% trans 'Организатор' %}:
+
+ {% with organisers=exposition.organiser.all %} + {% for organiser in organisers %} + {{ organiser.name }}
+ {% endfor %} + {% endwith %} +
+ {% endif %} + {% if exposition.web_page %} +
{% trans 'Веб-сайт' %}:
+
+ {{ exposition.web_page }} +
+ {% endif %} + {% if exposition.get_audience %} +
{% trans 'Аудитория' %}:
+
+ {{ exposition.get_audience }} +
+ {% endif %} + {% if exposition.get_periodic %} +
{% trans 'Периодичность' %}:
+
{{ exposition.get_periodic }}
+ {% endif %} + {% if exposition.products %} +
{% trans 'Экспонируемые продукты' %}:
+
{{ exposition.products|safe }}
+ {% endif %} + {% if exposition.time %} +
{% trans 'Время работы' %}:
+
{{ exposition.time|safe }}
+ {% endif %} +
+
+ +
+
+ {% with companies=exposition.company.all|slice:":6" %} + {% if companies %} + {# есть участники #} +
+
{% trans 'Участники' %}
+ + {% trans 'Все участники' %} +
+ + {% else %} + {# нет участников #} +
+
{% trans 'Участники' %}
+

{% trans 'Привлекайте целевых посетителей на стенд' %}

+

Рекламировать участника

+
+ {% endif %} + {% endwith %} +
+
+ {% with visitors=exposition.users.all|slice:":17" %} +
+
{% trans 'Посетители' %}
+
+ + {% trans 'Все посетители' %} + {% endwith %} +

{% trans 'Пока никто не отметился на событии.' %}

+ {% with event=exposition user=user %} + {% include 'client/includes/visit_button.html' %} + {% endwith %} +
+
+
+ + {% if exposition.area %} + {% else %} + {% if exposition.members or exposition.visitors or exposition.foundation_year %} +

 Статистика

+ {% endif %} + {% endif %} + {% if exposition.members or exposition.visitors or exposition.foundation_year or exposition.area %} +
+ {% if exposition.area %} +
+
{% trans 'Общая выставочная площадь' %}
+
+ {{ exposition.area }} {% trans 'м²' %} +
+
+ {% endif %} +
+ {% if exposition.members %} +
{{ exposition.members }} {% trans 'участников' %}
+ {% endif %} + {% if exposition.visitors %} +
{{ exposition.visitors }} {% trans 'посетителей' %}
+ {% endif %} + {% if exposition.foundation_year %} +
{% trans 'Основано в' %} {{ exposition.foundation_year }} {% trans 'году' %}
+ {% endif %} +
+
+ {% endif %} +
+ + {% include 'client/includes/booking_block.html' with city=exposition.city place=exposition.place %} +
+ {% if exposition.get_nearest_events|slice:":6" %} +
+
{% trans 'Ближайшие выставки по тематике' %} «{{ exposition.theme.all.0 }}»
+ +
+ {% endif %} + + +{% endblock %} +{% block content_text %} +{% endblock %} + +{% block popup %} + {% include 'client/popups/advertise_member.html' with form=advertising_form %} +{% endblock %} + +{% block scripts %} +{% if request.GET.debug == '1' %} + +{% else %} + +{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/templates/client/includes/exposition/exposition_object.html b/templates/client/includes/exposition/exposition_object.html index 15745390..1fe3e432 100644 --- a/templates/client/includes/exposition/exposition_object.html +++ b/templates/client/includes/exposition/exposition_object.html @@ -339,7 +339,7 @@ {% endwith %}
- {{ exp.country }}, {{ exp.city }} + {{ exp.country }}, {{ exp.city }} {% if exp.place %} , {{ exp.place }} {% endif %} diff --git a/templates/client/includes/exposition/services.html b/templates/client/includes/exposition/services.html index 217182c4..6b13022c 100644 --- a/templates/client/includes/exposition/services.html +++ b/templates/client/includes/exposition/services.html @@ -4,13 +4,19 @@ {% trans 'услуги' %}