diff --git a/country/models.py b/country/models.py index bd376ba7..42ad7358 100644 --- a/country/models.py +++ b/country/models.py @@ -69,7 +69,7 @@ class Area(TranslatableModel): return Exposition.objects.filter(country__in=countries) def get_sub_categories(self): - objects = [{'name':item.name, 'id':item.id} for item in self.countries()] + objects = [{'text':item.name, 'id':item.id, 'name':'co', 'sub':True} for item in self.countries()] return objects @@ -162,7 +162,7 @@ class Country(TranslatableModel): .filter(exposition_city__city__isnull=False, translations__language_code=lang, country=self).distinct() def get_sub_categories(self): - objects = [{'name':item.name, 'id':item.id} for item in self.active_cities()] + objects = [{'text':item.name, 'id':item.id, 'name':'ci', 'sub': False} for item in self.active_cities()] return objects diff --git a/exposition/admin.py b/exposition/admin.py index 18a4cbc7..98fe8b5d 100644 --- a/exposition/admin.py +++ b/exposition/admin.py @@ -14,12 +14,13 @@ from theme.models import Tag from city.models import City from file.models import FileModel, TmpFile from file.forms import FileModelForm +from photologue.forms import PhotoForm # python import random # custom views from functions.custom_views import objects_list, delete_object from functions.views_help import get_referer -from functions.admin_views import AdminListView +from functions.admin_views import AdminListView, AdminView, upload_photo def exposition_all(request): @@ -232,7 +233,84 @@ def exposition_change(request, url): return render_to_response('exposition_add.html', args) + +class ExpositionView(AdminView): + form_class = ExpositionCreateForm + model = Exposition + success_url = 'admin/exposition/all/' + template_name = 'admin/exposition/exposition.html' + + def get_form(self, form_class): + if self.request.POST: + return super(ExpositionView, self).get_form(form_class) + obj = self.set_obj() + if obj: + data = {'web_page':obj.web_page, 'foundation_year': obj.foundation_year, + 'data_begin':obj.data_begin, 'data_end':obj.data_end, 'periodic':obj.periodic, + 'min_area':obj.min_area, 'currency':obj.currency, 'tax':obj.tax, + 'price_day':obj.price_day, 'price_all':obj.price_all, 'price_catalog':obj.price_catalog, + 'price_day_bar':obj.price_day_bar, 'price_all_bar':obj.price_all_bar, + 'min_closed_area':obj.min_closed_area, 'max_closed_area':obj.max_closed_area, + 'min_closed_equipped_area':obj.min_closed_equipped_area, + 'max_closed_equipped_area':obj.max_closed_equipped_area, + 'min_stand_size':obj.min_stand_size, 'application_deadline':obj.application_deadline, + 'min_open_area':obj.min_open_area, 'max_open_area':obj.max_open_area, + 'registration_payment':obj.registration_payment, 'exposition_id':obj.id, + 'expohit': obj.expohit, 'discount': obj.discount, + 'canceled': obj.canceled, 'moved': obj.moved, 'logo': obj.logo, + 'visitors': obj.visitors, 'members': obj.members, + 'audience':[item for item, bool in obj.audience if bool==True], + 'quality_label': [item for item, bool in obj.quality_label if bool==True]} + + if obj.place: + data['place'] = obj.place.id + + data['theme'] = [item.id for item in obj.theme.all()] + data['tag'] = ','.join(['%s:%s'%(item.id, item.name) for item in obj.tag.all()]) + data['organiser'] = [item.id for item in obj.organiser.all()] + data['company'] = [item.id for item in obj.company.all()] + + data['country'] = obj.country_id + data['city'] = obj.city_id + + for code, name in settings.LANGUAGES: + trans_obj = self.model._meta.translations_model.objects.get(language_code = code,master__id=obj.id) #access to translated fields + data['name_%s' % code] = trans_obj.name + data['description_%s' % code] = trans_obj.description + data['main_title_%s' % code] = trans_obj.main_title + data['time_%s' % code] = trans_obj.time + data['products_%s' % code] = trans_obj.products + data['discount_description_%s' % code] = trans_obj.discount_description + data['stat_countries_%s' % code] = trans_obj.stat_countries + data['pre_condition_%s' % code] = trans_obj.pre_condition + data['stand_condition_%s' % code] = trans_obj.stand_condition + data['visit_note_%s' % code] = trans_obj.visit_note + data['participation_note_%s' % code] = trans_obj.participation_note + data['title_%s' % code] = trans_obj.title + data['keywords_%s' % code] = trans_obj.keywords + data['descriptions_%s' % code] = trans_obj.descriptions + + form =form_class(initial=data) + form.fields['city'].widget.attrs['data-init-text'] = obj.city.name + form.fields['tag'].choices = [(item.id, item.name) for item in Tag.objects.filter(theme__in=data['theme'])] + return form + else: + return form_class() + + + def get_context_data(self, **kwargs): + context = super(ExpositionView, self).get_context_data(**kwargs) + obj = self.set_obj() + context['photo_form'] = PhotoForm() + context['timetable_form'] = TimeTableForm() + context['timetables'] = TimeTable.objects.filter(exposition=obj) + return context + class ExpositionListView(AdminListView): template_name = 'admin/exposition/exposition_list.html' form_class = ExpositionFilterForm - model = Exposition \ No newline at end of file + model = Exposition + + +def upload_exposition_photo(request, expo_id): + return upload_photo(request, expo_id, Exposition) \ No newline at end of file diff --git a/exposition/admin_urls.py b/exposition/admin_urls.py index e34e9b1b..5e1c266b 100644 --- a/exposition/admin_urls.py +++ b/exposition/admin_urls.py @@ -1,12 +1,18 @@ # -*- coding: utf-8 -*- from django.conf.urls import patterns, include, url -from admin import ExpositionListView +from admin import ExpositionListView, ExpositionView urlpatterns = patterns('exposition.admin', + url(r'^upload-photo/(?P.*)/$', 'upload_exposition_photo'), + url(r'^add.*/$', 'exposition_add'), url(r'^delete/(?P.*)/$', 'exposition_delete'), url(r'^change/(?P.*)/$', 'exposition_change'), url(r'^all/$', ExpositionListView.as_view()), url(r'^switch/(?P.*)/(?P.*)$', 'exposition_switch'), url(r'^copy/(?P.*)$', 'exposition_copy'), + + url(r'^$', ExpositionView.as_view()), + url(r'^(?P.*)/$', ExpositionView.as_view()), + ) diff --git a/exposition/forms.py b/exposition/forms.py index 4b678cc9..4a4c48dd 100644 --- a/exposition/forms.py +++ b/exposition/forms.py @@ -8,6 +8,7 @@ from django.forms.util import ErrorList from django.core.validators import validate_email, URLValidator #models from models import Exposition, TimeTable, TmpTimeTable, AUDIENCE1, CURRENCY, Statistic, BIT_AUDIENCE +from theme.models import Tag from country.models import Country from theme.models import Theme from organiser.models import Organiser @@ -42,6 +43,7 @@ class ExpositionCreateForm(forms.Form): data_begin = forms.DateField(label=u'Дата начала') data_end = forms.DateField(label=u'Дата окночания') + logo = forms.ImageField(label='Logo', required=False) organiser = forms.ModelMultipleChoiceField(label=u'Организаторы', queryset=Organiser.objects.all(), required=False) company = forms.ModelMultipleChoiceField(label=u'Компании', queryset=Company.objects.all(), required=False) @@ -51,7 +53,8 @@ class ExpositionCreateForm(forms.Form): empty_label='', required=False) #creates select input with empty choices cause it will be filled with ajax city = forms.CharField(label=u'Город', widget=forms.HiddenInput()) - tag = forms.MultipleChoiceField(label=u'Теги', required=False) + tag = forms.CharField(label=u'Теги', widget=forms.HiddenInput(), required=False) + #tag = forms.MultipleChoiceField(label=u'Теги', required=False) periodic = forms.ChoiceField(label=u'Периодичность', choices=PERIODIC, required=False) audience = forms.MultipleChoiceField(label=u'Аудитория', choices=public, initial='', required=False) @@ -103,7 +106,8 @@ class ExpositionCreateForm(forms.Form): # uses enumerate for detect iteration number # first iteration is a default lang so it required fields required = True if lid == 0 else False - self.fields['name_%s' % code] = forms.CharField(label=u'Название', required=required) + self.fields['name_%s' % code] = forms.CharField(label=u'Название', required=required, + widget=forms.TextInput(attrs={'style':'width: 550px'})) self.fields['main_title_%s' % code] = forms.CharField(label=u'Краткое описание', required=False, widget=CKEditorWidget) self.fields['description_%s' % code] = forms.CharField(label=u'Описание', @@ -114,6 +118,17 @@ class ExpositionCreateForm(forms.Form): required=False, widget=CKEditorWidget) self.fields['discount_description_%s' % code] = forms.CharField(label=u'Описание скидки', required=False, widget=CKEditorWidget) + self.fields['stat_countries_%s' % code] = forms.CharField(label=u'Участвующие страны', + required=False, widget=CKEditorWidget) + self.fields['pre_condition_%s' % code] = forms.CharField(label=u'Условия предварительной регистрации',required=False, + widget=forms.TextInput(attrs={'style':'width: 550px'})) + self.fields['stand_condition_%s' % code] = forms.CharField(label=u'Условия регистрации на стойке',required=False, + widget=forms.TextInput(attrs={'style':'width: 550px'})) + self.fields['visit_note_%s' % code] = forms.CharField(label=u'Примечание по посещению',required=False, + widget=forms.TextInput(attrs={'style':'width: 550px'})) + self.fields['participation_note_%s' % code] = forms.CharField(label=u'Примечание по участии',required=False, + widget=forms.TextInput(attrs={'style':'width: 550px'})) + #meta data self.fields['title_%s' % code] = forms.CharField(label=u'Meta title', required=False, max_length=255, widget=forms.TextInput(attrs={'style':'width: 550px'})) @@ -127,7 +142,7 @@ class ExpositionCreateForm(forms.Form): #self.fields['service'] = forms.MultipleChoiceField(label='Услуги', choices=services, required=False) - def save(self, id=None): + def save(self, obj=None): """ change Exposition model object with id = id N/A add new Exposition model object @@ -135,17 +150,19 @@ class ExpositionCreateForm(forms.Form): form.save() - if add exposition """ data = self.cleaned_data - if not id: + if not obj: exposition = Exposition() else: - exposition = Exposition.objects.get(id=id) + exposition = obj exposition.theme.clear() exposition.tag.clear() exposition.organiser.clear() exposition.company.clear() #simple fields + exposition.url = translit_with_separator(data['name_ru'].strip()).lower() + exposition.logo = data['logo'] exposition.data_begin = data['data_begin'] exposition.data_end = data['data_end'] exposition.periodic = data['periodic'] @@ -205,9 +222,9 @@ class ExpositionCreateForm(forms.Form): #fill manytomany fields for item in data['theme']: exposition.theme.add(item.id)#.id cause select uses queryset - - for item in data['tag']: - exposition.tag.add(item) + exposition.tag.add(*Tag.objects.filter(id__in=data['tag'])) + #for item in data['tag']: + # exposition.tag.add(item) # uses because in the next loop data will be overwritten for item in data['organiser']: exposition.organiser.add(item) @@ -234,6 +251,19 @@ class ExpositionCreateForm(forms.Form): return self.cleaned_data + def clean_tag(self): + tags = self.cleaned_data.get('tag') + if tags: + res = [] + for id in tags.split(','): + try: + res.append(int(id)) + except: + continue + return res + else: + return [] + def clean_web_page(self): """ checking web_page diff --git a/exposition/management/commands/convert_expo_logo.py b/exposition/management/commands/convert_expo_logo.py new file mode 100644 index 00000000..ea78109b --- /dev/null +++ b/exposition/management/commands/convert_expo_logo.py @@ -0,0 +1,48 @@ +from django.core.management.base import BaseCommand, CommandError +from exposition.models import Exposition +from django.contrib.sites.models import Site +from photologue.models import Gallery, Photo +from file.models import FileModel +from django.core.files import File +from django.core.files.temp import NamedTemporaryFile +import urllib2 +from django.conf import settings +from django.utils import translation + +def handle_expo(item): + logo = item.get_logo() + translation.activate('en') + + domain = 'http://hit.expomap.ru' + url = domain+logo.file_path.url + file_name = url.split('/')[-1] + download_to = settings.MEDIA_ROOT+'exposition/logo/'+file_name + try: + response = urllib2.urlopen(url, timeout=5) + except: + print('download error') + return None + + with open(download_to,'wb') as f: + f.write(response.read()) + f.close() + file_name = 'exposition/logo/'+file_name + item.logo = file_name + item.save() + + + + +class Command(BaseCommand): + def handle(self, *args, **options): + for exposition in Exposition.objects.all('en'): + + + if exposition.files.filter(purpose='logo').exists(): + handle_expo(exposition) + + print(exposition) + + + + diff --git a/exposition/models.py b/exposition/models.py index 527f3f26..24826302 100644 --- a/exposition/models.py +++ b/exposition/models.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- +import copy, datetime from django.db import models from django.db.models.signals import post_save, pre_save from django.utils.translation import ugettext as _ +from django.conf import settings from hvad.models import TranslatableModel, TranslatedFields, TranslationManager -import copy, datetime + from django.contrib.contenttypes import generic from bitfield import BitField from service.models import Service @@ -15,6 +17,8 @@ from functions.custom_fields import EnumField from functions.signal_handlers import post_save_handler, pre_save_handler from functions.models_methods import ExpoManager from functions.model_mixin import EventMixin, ExpoMixin +from functions.translate import fill_with_signal +from photologue.models import Gallery AUDIENCE1 = ((None,_(u'Не выбрано')), ('experts', _(u'Специалисты')), @@ -65,7 +69,9 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): blank=True, null=True, related_name='exposition_companies') users = models.ManyToManyField('accounts.User', verbose_name='Посетители выставки', blank=True, null=True, related_name='exposition_users') - #photogallery = models.ForeignKey('photologue.Gallery', blank=True, null=True) + photogallery = models.ForeignKey('photologue.Gallery', blank=True, null=True) + logo = models.ImageField(verbose_name='Logo', upload_to='exposition/logo/', blank=True) + rating = models.IntegerField(default=0) quality_label = BitField(flags=['ufi', 'rsva', 'exporating']) visitors = models.PositiveIntegerField(verbose_name='Посетители', blank=True, null=True) @@ -93,6 +99,14 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): products = models.TextField(verbose_name='Экспонируемые продукты', blank=True), discount_description = models.TextField(verbose_name='Описание скидки', blank=True), time = models.TextField(verbose_name='Время работы', blank=True), + # visit and particaption data + stat_countries = models.TextField(verbose_name='Участвующие страны', blank=True), + pre_condition = models.CharField(verbose_name='Условия предварительной регистрации', max_length=255, blank=True), + stand_condition = models.CharField(verbose_name='Условия регистрации на стойке', max_length=255, blank=True), + visit_note = models.CharField(verbose_name='Примечание по посещению', max_length=255, blank=True), + participation_note = models.CharField(verbose_name='Примечание по участии', max_length=255, blank=True), + + #-----meta data title = models.CharField(max_length=250), descriptions = models.CharField(max_length=250), @@ -114,8 +128,11 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): min_stand_size = models.PositiveIntegerField(verbose_name='Минимальный размер стэнда', blank=True, null=True) price_day = models.PositiveIntegerField(verbose_name='Стоимость билета 1 день', blank=True, null=True) price_all = models.PositiveIntegerField(verbose_name='Стоимость билета все дни', blank=True, null=True) + # Условие price_day_bar = models.PositiveIntegerField(verbose_name='Стоимость на стойке 1 день', blank=True, null=True) price_all_bar = models.PositiveIntegerField(verbose_name='Стоимость на стойке все дни', blank=True, null=True) + # условие + # примечание price_catalog = models.PositiveIntegerField(verbose_name='Стоимость каталога', blank=True, null=True) tax = models.BooleanField(verbose_name='Налог', default=1) min_closed_area = models.PositiveIntegerField(verbose_name='Минимальная цена закрытой НЕ оборудованной площади', @@ -131,6 +148,7 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): max_open_area = models.PositiveIntegerField(verbose_name='Максимальная цена открытой площади', blank=True, null=True) registration_payment = models.PositiveIntegerField(verbose_name='Регистрационный взнос', blank=True, null=True) + # примечание # statistic @@ -143,6 +161,40 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): def __unicode__(self): return self.lazy_translation_getter('name', unicode(self.pk)) + def upload_photo_url(self): + return '/admin/exposition/upload-photo/%s/'%self.id + + def get_gallery(self): + if self.photogallery: + return self.photogallery + + data = {} + model = type(self) + for code, name in settings.LANGUAGES: + obj = model._meta.translations_model.objects.get(language_code = code,master__id=self.id) #access to translated fields + data['title_%s'%code] = obj.name + data['description_%s'%code] = obj.description + + gallery = Gallery() + + fill_with_signal(Gallery, gallery, data) + self.photogallery = gallery + self.save() + + + return gallery + + + def upload_photo(self, photo ,gallery=None): + """ + uploading photo to gallery + """ + if gallery is None: + gallery = self.get_gallery() + + gallery.photos.add(photo) + + def get_index_text(self): names = [tr.name for tr in self.translations.all()] return names @@ -157,6 +209,7 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): return ', '.join(audience) + def get_periodic(self): periodic = {0: '', 1.0: _(u'Ежегодно'), 2.0: _(u'2 раза в год'), 3.0: _(u'3 раза в год'), 4.0: _(u'4 раза в год'), 5.0: _(u'5 раз в год'), 0.5: _(u'Раз в 2 года'), diff --git a/functions/admin_views.py b/functions/admin_views.py index 14478e1c..3cadc997 100644 --- a/functions/admin_views.py +++ b/functions/admin_views.py @@ -1,13 +1,17 @@ -from django.views.generic import FormView, ListView -from django.shortcuts import render_to_response, get_object_or_404 +import json +from django.views.generic import FormView +from django.shortcuts import render_to_response, get_object_or_404, HttpResponse, Http404 from django.http import HttpResponseRedirect from django.conf import settings +from photologue.forms import PhotoForm class AdminView(FormView): obj = None def set_obj(self): url = self.kwargs.get('url') + + #rewrwe if url: obj = get_object_or_404(self.model, url=url) self.obj = obj @@ -118,27 +122,23 @@ class AdminListView(FormView): context['object_list'] = result return context +def upload_photo(request, id, Model): + """ + uploading photo to some instance of Model + instance must have upload_photo method, which download photo -""" -class AdminListView(ListView): - model = None - paginate_by = settings.ADMIN_PAGINATION - template_name = None - filter_form = None - - def get_queryset(self): - - if self.filter_form is None: - return super(AdminListView, self).get_queryset() + """ + obj = get_object_or_404(Model, pk=id) + if request.POST: + response = {'success': False} + form = PhotoForm(request.POST, request.FILES) + if form.is_valid(): + photo = form.save() + obj.upload_photo(photo) + response['success'] = True else: - form = self.filter_form(self.request.GET) - if form.is_valid(): - result = form.filter() - return result - else: - return super(AdminListView, self).get_queryset() + response.update({'errors':form.errors}) - def get_context_data(self, **kwargs): - context = super(AdminListView, self).get_context_data(self, **kwargs) - context = -""" \ No newline at end of file + return HttpResponse(json.dumps(response), content_type='application/json') + else: + return HttpResponse('not post') diff --git a/functions/model_mixin.py b/functions/model_mixin.py index ff4a7f0b..59ced194 100644 --- a/functions/model_mixin.py +++ b/functions/model_mixin.py @@ -33,11 +33,13 @@ class EventMixin(object): return url def get_logo(self): - + return self.logo + """ logo = self.files.filter(purpose='logo') if logo: return logo[0] return logo + """ def get_preview(self): @@ -47,8 +49,15 @@ class EventMixin(object): return preview def get_photos(self): + if self.photogallery: + return self.photogallery.photos.language().all() + else: + return None + + """ photos = self.files.filter(purpose='photo') return photos + """ def on(self): self.is_published = True diff --git a/place_exposition/admin.py b/place_exposition/admin.py index 5e738dd0..9a09397b 100644 --- a/place_exposition/admin.py +++ b/place_exposition/admin.py @@ -22,6 +22,7 @@ import random #custom fields from functions.custom_views import objects_list, delete_object from functions.views_help import get_referer +from functions.admin_views import AdminView, AdminListView, upload_photo def exposition_all(request): @@ -194,7 +195,7 @@ def exposition_change(request, url): #test---------------------- -from functions.admin_views import AdminView, AdminListView + class PlaceExpositionView(AdminView): @@ -276,18 +277,5 @@ class PlaceExpositionListView(AdminListView): -def upload_photo(request, place_id): - place = get_object_or_404(PlaceExposition, pk=place_id) - if request.POST: - response = {'success': False} - form = PhotoForm(request.POST, request.FILES) - if form.is_valid(): - photo = form.save() - place.upload_photo(photo) - response['success'] = True - else: - response.update({'errors':form.errors}) - - return HttpResponse(json.dumps(response), content_type='application/json') - else: - return HttpResponse('not post') +def upload_place_photo(request, place_id): + return upload_photo(request, place_id, PlaceExposition) diff --git a/place_exposition/admin_urls.py b/place_exposition/admin_urls.py index dba9a06a..53d1782b 100644 --- a/place_exposition/admin_urls.py +++ b/place_exposition/admin_urls.py @@ -6,7 +6,7 @@ urlpatterns = patterns('place_exposition.admin', #url(r'^all/$', 'exposition_all'), url(r'^add-hall/(?P.*)/$', 'add_hall'), url(r'^delete-hall/(?P.*)/$', 'delete_hall'), - url(r'^upload-photo/(?P.*)/$', 'upload_photo'), + url(r'^upload-photo/(?P.*)/$', 'upload_place_photo'), url(r'^all/$', PlaceExpositionListView.as_view()), url(r'^add.*/$', 'exposition_add'), diff --git a/place_exposition/management/commands/convert_logo.py b/place_exposition/management/commands/convert_logo.py index e2a1b408..14f5e3e7 100644 --- a/place_exposition/management/commands/convert_logo.py +++ b/place_exposition/management/commands/convert_logo.py @@ -1,14 +1,10 @@ -from django.core.management.base import BaseCommand, CommandError -from place_exposition.models import PlaceExposition -from django.contrib.sites.models import Site -from photologue.models import Gallery, Photo -from file.models import FileModel -from django.core.files import File -from django.core.files.temp import NamedTemporaryFile import urllib2 from django.conf import settings - from django.utils import translation +from django.core.management.base import BaseCommand, CommandError +from place_exposition.models import PlaceExposition + + def handle_place(place): logo = place.get_logo() translation.activate('en') diff --git a/settings/views.py b/settings/views.py index b998b9e3..c46e1a0a 100644 --- a/settings/views.py +++ b/settings/views.py @@ -21,8 +21,8 @@ def sub_category(request): model = categorie['model'] obj = get_object_or_404(model, pk=categorie_id) objects = obj.get_sub_categories() - response = {'sub_categories': objects, 'sub':categorie['sub'], 'sub_name': categorie['sub_categorie_name']} - return HttpResponse(json.dumps(response), content_type='application/json') + #response = {'sub_categories': objects, 'sub':categorie['sub'], 'sub_name': categorie['sub_categorie_name']} + return HttpResponse(json.dumps(objects), content_type='application/json') else: raise Http404 diff --git a/static/admin/js/pages/place_exposition.js b/static/admin/js/pages/place_exposition.js deleted file mode 100644 index e69de29b..00000000 diff --git a/static/custom_js/event_switcher.js b/static/custom_js/event_switcher.js index 93396abc..da429969 100644 --- a/static/custom_js/event_switcher.js +++ b/static/custom_js/event_switcher.js @@ -1,3 +1,4 @@ +// replace $(document).ready(function(){ $('.on').click(function(){ diff --git a/static/custom_js/file_post_ajax.js b/static/custom_js/file_post_ajax.js index e4d398d0..40dc4fdf 100644 --- a/static/custom_js/file_post_ajax.js +++ b/static/custom_js/file_post_ajax.js @@ -1,3 +1,4 @@ +//replace $(document).ready(function(){ $('.delete_file').click(function(){ var url = '/admin/ajax_delete_file/'; diff --git a/static/custom_js/main.js b/static/custom_js/main.js index fd1623ef..256dade8 100644 --- a/static/custom_js/main.js +++ b/static/custom_js/main.js @@ -34,6 +34,57 @@ function deletePhoto(data){ console.log(data); } } +function postSuccess(data, textStatus, jqXHR){ + + //console.log(data); + //$('#close').click(); + + if (data.indexOf(" + + {# selects #} + + + {# datepicker #} + + + + + + + {# datetimepicker #} + + + + + {% endblock %} + +{% block body %} + +{# Uses multilang.html template for translated fields #} + +
{% csrf_token %} +
+ {% if object %} Изменить {% else %} Добавить {% endif %}выставку + +
+
+

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

+
+
+ {# Hidden inputs uses for comparing with TmpFile objects #} + {{ form.key }} + {# Hidden input uses in clean method for checking url #} + {{ form.exposition_id }} + + {# name #} + {% with field='name' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + {# main_title #} + {% with field='main_title' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + {# data_begin #} +
+ +
+ + {{ form.data_begin }} + + + + + {{ form.data_begin.errors }} +
+
+ {# data_end #} +
+ +
{{ form.data_end }} + {{ form.data_end.errors }} +
+
+ + {# country #} +
+ +
{{ form.country }} + {{ form.country.errors }} +
+
+ {# city #} +
+ +
{{ form.city }} + {{ form.city.errors }} +
+
+ {# place #} +
+ +
{{ form.place }} + {{ form.place.errors }} +
+
+ {# theme #} +
+ +
{{ form.theme }} + {{ form.theme.errors }} +
+
+ {# tag #} +
+ +
{{ form.tag }} + {{ form.tag.errors }} +
+
+ {# logo #} +
+ +
{{ form.logo }} + {{ form.logo.errors }} +
+
+ + {# quality_label #} +
+ +
{{ form.quality_label }} + {{ form.quality_label.errors }} +
+
+ {# canceled #} +
+ +
{{ form.canceled }} + {{ form.canceled.errors }} +
+
+ {# moved #} +
+ +
{{ form.moved }} + {{ form.moved.errors }} +
+
+ {# expohit #} +
+ +
{{ form.expohit }} + {{ form.expohit.errors }} +
+
+
+ +
+ +
+
+

Дополнительная информация

+
+
+ {# description #} + {% with field='description' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + {# periodic #} +
+ +
{{ form.periodic }} + {{ form.periodic.errors }} +
+
+ {# audience #} +
+ +
{{ form.audience }} + {{ form.audience.errors }} +
+
+ {# web_page #} +
+ +
{{ form.web_page }} + {{ form.web_page.errors }} +
+
+ {# products #} + {% with field='products' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + {# time #} + {% with field='time' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + +
+
+ +
+
+

Условия участия

+
+
+ {# currency #} +
+ +
{{ form.currency }} + {{ form.currency.errors }} +
+
+ {# application_deadline #} +
+ +
{{ form.application_deadline }} + {{ form.application_deadline.errors }} +
+
+ + {# min_stand_size #} +
+ +
{{ form.min_stand_size }} + {{ form.min_stand_size.errors }} +
+
+ {# price_day #} +
+ +
{{ form.price_day }} + {{ form.price_day.errors }} +
+
+ {# price_all #} +
+ +
{{ form.price_all }} + {{ form.price_all.errors }} +
+
+ {% include 'admin/forms/multilang.html' with field='pre_condition' form=form languages=languages %} + {# price_day_bar #} +
+ +
{{ form.price_day_bar }} + {{ form.price_day_bar.errors }} +
+
+ {# price_all_bar #} +
+ +
{{ form.price_all_bar }} + {{ form.price_all_bar.errors }} +
+
+ + {% include 'admin/forms/multilang.html' with field='stand_condition' form=form languages=languages %} + {# price_catalog #} +
+ +
{{ form.price_catalog }} + {{ form.price_catalog.errors }} +
+
+ {# tax #} +
+ +
{{ form.tax }} + {{ form.tax.errors }} +
+
+ {% include 'admin/forms/multilang.html' with field='visit_note' form=form languages=languages %} + {# min_closed_area #} +
+ +
{{ form.min_closed_area }} + {{ form.min_closed_area.errors }} +
+
+ {# max_closed_area #} +
+ +
{{ form.max_closed_area }} + {{ form.max_closed_area.errors }} +
+
+ {# min_closed_equipped_area #} +
+ +
{{ form.min_closed_equipped_area }} + {{ form.min_closed_equipped_area.errors }} +
+
+ {# max_closed_equipped_area #} +
+ +
{{ form.max_closed_equipped_area }} + {{ form.max_closed_equipped_area.errors }} +
+
+ {# min_open_area #} +
+ +
{{ form.min_open_area }} + {{ form.min_open_area.errors }} +
+
+ {# max_open_area #} +
+ +
{{ form.max_open_area }} + {{ form.max_open_area.errors }} +
+
+ {# min_area #} +
+ +
{{ form.min_area }} + {{ form.min_area.errors }} +
+
+ {# registration_payment #} +
+ +
{{ form.registration_payment }} + {{ form.registration_payment.errors }} +
+
+ {% include 'admin/forms/multilang.html' with field='participation_note' form=form languages=languages %} + {# discount #} +
+ +
{{ form.discount }} + {{ form.discount.errors }} +
+
+ {# discount_description #} + {% with field='discount_description' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + {% include 'admin/forms/multilang.html' with field='stat_countries' form=form languages=languages %} +
+
+ + +
+
+

Участники

+
+
+ {# organiser #} +
+ +
{{ form.organiser }} + {{ form.organiser.errors }} +
+
+ {# company #} +
+ +
{{ form.company }} + {{ form.company.errors }} +
+
+ +
+
+ + +
+
+

Деловая программа

+
+
+ {% if object %} +
+ + + + + + + + + + + + + + + + + + + + + + {% for timetable in timetables %} + + + + + + + + + {% endfor %} + +
ПрограммаНачалоКонецСпикерыОрганизатор 
{{ timetable.programe|safe }}{{ timetable.begin|date:"o-m-d H:i" }}{{ timetable.end|date:"o-m-d H:i" }}{{ timetable.speaker }} + {{ timetable.timetable_organiser }} + + +
+
+ + Добавить program + {% else %} +

Фото можна добавлять только после введения основных даных

+ {% endif %} + + +
+
+ +
+
+

Статистика

+
+ +
+ {# foundation_year #} +
+ +
{{ form.foundation_year }} + {{ form.foundation_year.errors }} +
+
+ {# members #} +
+ +
{{ form.members }} + {{ form.members.errors }} +
+
+ {# visitors #} +
+ +
{{ form.visitors }} + {{ form.visitors.errors }} +
+
+ + {% if formset_statistic.errors %} +
+ {% for form in formset_statistic.forms %} + + {% for key, value in form.errors.items %} +

{{ value }}

+ {% endfor %} + + {% endfor %} +
+ {% endif %} + + {# formset of stat #} + {{ formset_statistic.management_form }} + +
+ + + + + + + + + + + + {% for form in formset_statistic.forms %} + + + + + + + {% endfor %} + +
ГодПосетителиУчастники
{{ form.year }}{{ form.visitors }}{{ form.members }} Удалить
+
+

Добавить год

+
+
+ {% include 'admin/includes/photogallery.html' with object=object %} + + +
+
+

Мета данные

+
+
+ {# keywords #} + {% with field='keywords' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + {# title #} + {% with field='title' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} + {# descriptions #} + {% with field='descriptions' form=form languages=languages %} + {% include 'admin/forms/multilang.html' %} + {% endwith %} +
+
+ +
+ + +
+ +
+
+ +{# modal window #} + +{% include 'admin/includes/photo_form.html' with form=photo_form object=object %} +{% endblock %} diff --git a/templates/admin/includes/photogallery.html b/templates/admin/includes/photogallery.html new file mode 100644 index 00000000..bf8627ff --- /dev/null +++ b/templates/admin/includes/photogallery.html @@ -0,0 +1,34 @@ +
+
+

Фотогалерея

+
+
+ {% if object %} + Фото + Просмотреть галерею

+ {% else %} +

Фото можна добавлять только после введения основных даных

+ {% endif %} + + {% with photos=object.photogallery.photos.all %} + {% for photo in photos %} + +
+ +
+ + {{ photo.title }} + +
+ + + + +
+ {% endfor %} + {% endwith %} + +
+
\ No newline at end of file diff --git a/templates/admin/place_exposition/place_exposition.html b/templates/admin/place_exposition/place_exposition.html index 3536ae5c..d98e0a65 100644 --- a/templates/admin/place_exposition/place_exposition.html +++ b/templates/admin/place_exposition/place_exposition.html @@ -25,6 +25,7 @@ {# ajax #} + @@ -371,40 +372,7 @@ -
-
-

Фотогалерея

-
-
- {% if object %} - Фото - Просмотреть галерею

- {% else %} -

Фото можна добавлять только после введения основных даных

- {% endif %} - - {% with photos=object.photogallery.photos.all %} - {% for photo in photos %} - -
- -
- - {{ photo.title }} - -
- - - - -
- {% endfor %} - {% endwith %} - -
-
+ {% include 'admin/includes/photogallery.html' with object=object %}
diff --git a/templates/client/includes/event_object.html b/templates/client/includes/event_object.html index 6272b4b4..fc06f421 100644 --- a/templates/client/includes/event_object.html +++ b/templates/client/includes/event_object.html @@ -113,14 +113,17 @@ {% include 'includes/event_steps.html' with event=exposition filter=filter %} {% if exposition.get_photos %} + {% with photos=exposition.get_photos|slice:"5" %}
+ {% endwith %} {% endif %} {% if exposition.description %}
diff --git a/theme/models.py b/theme/models.py index cb00d370..d5de47db 100644 --- a/theme/models.py +++ b/theme/models.py @@ -64,7 +64,7 @@ class Theme(TranslatableModel): return self.expositions_number() + self.conferences_number() + self.seminars_number() + self.webinars_number() def get_sub_categories(self): - objects = [{'name':item.name, 'id':item.id} for item in self.tags.language().all()] + objects = [{'text':item.name, 'id':item.id, 'name':'tg', 'sub':False} for item in self.tags.language().all()] return objects def clone(self):