From 8689a4fdec618356023301c67046c6841a671b31 Mon Sep 17 00:00:00 2001 From: Kotiuk Nazarii Date: Fri, 15 May 2015 03:20:51 +0300 Subject: [PATCH] Services bugs --- proj/settings.py | 4 +-- service/models.py | 12 ++++++-- service/order_forms.py | 3 ++ service/urls.py | 1 + service/views.py | 29 +++++++++++++++++-- templates/client/popups/advertise_member.html | 2 +- templates/client/service/participation.html | 11 +++++++ templates/client/service/remotely.html | 12 +++++++- templates/client/service/tickets.html | 11 +++++++ templates/client/service/tour.html | 11 +++++++ templates/client/service/translator.html | 11 +++++++ 11 files changed, 98 insertions(+), 9 deletions(-) diff --git a/proj/settings.py b/proj/settings.py index a828c6bc..e0e21c5d 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -408,8 +408,8 @@ try: from local import * except ImportError, e: pass - - +# save sessions in redis +SESSION_ENGINE = 'django.contrib.sessions.backends.cache' if not DEBUG: # cache template loading TEMPLATE_LOADERS = ( diff --git a/service/models.py b/service/models.py index 09a8a657..16177e67 100644 --- a/service/models.py +++ b/service/models.py @@ -59,11 +59,12 @@ post_save.connect(post_save_handler, sender=Service) class AbstractOrder(models.Model): person = models.ForeignKey('accounts.User') phone = models.BigIntegerField() - city = models.CharField(max_length=255) - country = models.CharField(max_length=255) + city = models.CharField(max_length=255, blank=True, default='') + country = models.CharField(max_length=255, blank=True, default='') person_inf = models.CharField(max_length=255) price = models.IntegerField(blank=True, null=True) currency = EnumField(values=CURENCIES, blank=True) + event = models.CharField(max_length=255, blank=True, null=True) exposition = models.ForeignKey('exposition.Exposition', null=True) conference = models.ForeignKey('conference.Conference', null=True) seminar = models.ForeignKey('seminar.Seminar', null=True) @@ -130,8 +131,13 @@ class Visit(AbstractOrder): excursion = models.BooleanField() notes = models.TextField(blank=True) +ADVERTYSE_TYPES = ((u'Рекламировать участника', u'Рекламировать участника'), + (u'Баннерная реклама', u'Баннерная реклама'), + (u'Приоритетное размещение событий в каталоге',u'Приоритетное размещение событий в каталоге'), + (u'Персональная визитка Вашей компании',u'Персональная визитка Вашей компании')) class Advertising(AbstractOrder): - pass + type = models.CharField(choices=ADVERTYSE_TYPES, max_length=255, blank=True, null=True) + class CallBack(models.Model): phone = models.CharField(max_length=30) diff --git a/service/order_forms.py b/service/order_forms.py index e3facc7f..bded10f3 100644 --- a/service/order_forms.py +++ b/service/order_forms.py @@ -10,6 +10,7 @@ from django.conf import settings class AbstractOrderForm(forms.ModelForm): + event = forms.CharField(widget=forms.TextInput(attrs={'placeholder': _(u'Интересующее событие')}) ,required=False) person_inf = forms.CharField(widget=forms.TextInput(attrs={'placeholder': _(u'Контактное лицо')})) country = forms.CharField(widget=forms.TextInput(attrs={'placeholder': _(u'Страна')})) city = forms.CharField(widget=forms.TextInput(attrs={'placeholder': _(u'Город')})) @@ -189,6 +190,8 @@ class VisitForm(AbstractOrderForm): class AdvertiseForm(AbstractOrderForm): action = '/service/com_rek/' + country = forms.CharField(required=False, widget=forms.TextInput(attrs={'placeholder': _(u'Страна')})) + city = forms.CharField(required=False, widget=forms.TextInput(attrs={'placeholder': _(u'Город')})) class Meta: model = Advertising diff --git a/service/urls.py b/service/urls.py index ef77cb97..10efb29a 100644 --- a/service/urls.py +++ b/service/urls.py @@ -5,6 +5,7 @@ from views import ServiceView, CallBackListView, VisitListView, TranslationListV urlpatterns = patterns('', url(r'service/thanks/$', Thanks.as_view()), + url(r'service/com_rek/(?P.*)/(?P.*)/$', 'service.views.advertise'), url(r'service/com_rek/$', 'service.views.advertise'), url(r'service/(?P.*)/$', ServiceView.as_view()), diff --git a/service/views.py b/service/views.py index 67f2c0ac..9fbc0586 100644 --- a/service/views.py +++ b/service/views.py @@ -55,15 +55,40 @@ class ServiceView(MetadataMixin, FormView): kwargs.update({'meta_id': meta_id}) return super(ServiceView, self).get_context_data(**kwargs) +from exposition.models import Exposition +from conference.models import Conference +def advertise(request, catalog=None, event_url=None): -def advertise(request): if request.POST: response = {'success': False} form = AdvertiseForm(request.POST) if form.is_valid(): - form.save() + if not catalog or not event_url: + form.save() + else: + order = form.save(commit=False) + if catalog == 'expo': + + try: + expo = Exposition.objects.get(url=event_url) + except Exposition.DoesNotExist: + expo = None + order.exposition = expo + elif catalog == 'conference': + try: + conf = Conference.objects.get(url=event_url) + except Conference.DoesNotExist: + conf = None + order.conference= conf + + order.save() + + response['success'] = True + + + else: response['errors'] = form.errors diff --git a/templates/client/popups/advertise_member.html b/templates/client/popups/advertise_member.html index dfde763d..76cafb62 100644 --- a/templates/client/popups/advertise_member.html +++ b/templates/client/popups/advertise_member.html @@ -10,7 +10,7 @@

Оставьте свои контакты, и мы вышлем Вам информацию о вариантах и ценах!

-