diff --git a/accounts/views.py b/accounts/views.py index 138d5343..f0cf357a 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -296,7 +296,7 @@ class AvatarView(BaseProfileView): form = self.form_class(self.request.POST, self.request.FILES, instance=profile) profile = form.save() if self.request.is_ajax(): - im = get_thumbnail(profile.avatar, '100x100', crop='center') + im = get_thumbnail(profile.avatar, '100x100') response = {'success': True, 'url': im.url, 'rating': profile.user.rating} return HttpResponse(json.dumps(response), content_type='application/json') else: diff --git a/company/edit_forms.py b/company/edit_forms.py index 74c25cef..bd3481b4 100644 --- a/company/edit_forms.py +++ b/company/edit_forms.py @@ -4,6 +4,7 @@ from django.utils.translation import ugettext as _, get_language from country.models import Country from city.models import City from company.models import Company +from theme.models import Theme class BaseForm(forms.ModelForm): @@ -36,7 +37,7 @@ class SpecializationForm(BaseForm): class HomeForm(BaseForm): city = forms.CharField(label='Город', required=False, widget=forms.HiddenInput(attrs={'class': 'select2'})) - country = forms.ChoiceField(label=_(u'Страна'), choices=[(c.id, c.name) for c in Country.objects.all()], required=False, + country = forms.ChoiceField(label=_(u'Страна'), choices=[('', '')]+[(c.id, c.name) for c in list(Country.objects.all())], required=False, widget=forms.Select(attrs={'class': 'select2'})) def __init__(self, *args, **kwargs): super(HomeForm, self).__init__(*args, **kwargs) @@ -107,6 +108,13 @@ class SocialForm(BaseForm): fields = ('facebook', 'twitter', 'vk', 'linkedin') +class ThemeForm(BaseForm): + theme = forms.ModelMultipleChoiceField(oqueryset=Theme.objects.all()) + class Meta: + model = Company + fields = ('theme',) + + class TagForm(BaseForm): tag = forms.CharField(required=False, widget=forms.HiddenInput(attrs={'class': 'select2'})) class Meta: diff --git a/company/edit_views.py b/company/edit_views.py index f2ed62ad..25ecbd10 100644 --- a/company/edit_views.py +++ b/company/edit_views.py @@ -53,7 +53,7 @@ class LogoView(BaseView): form = self.form_class(self.request.POST, self.request.FILES, instance=company) company = form.save() if self.request.is_ajax(): - im = get_thumbnail(company.logo, '100x100', crop='center') + im = get_thumbnail(company.logo, '100x100') response = {'success': True, 'url': im.url, 'rating': company.rating} return HttpResponse(json.dumps(response), content_type='application/json') else: @@ -87,9 +87,56 @@ class SocialView(BaseView): form_class = SocialForm +class ThemeView(BaseView): + form_class = ThemeForm + + def form_valid(self, form): + slug = self.kwargs.get('slug') + if not slug: + raise Http404 + + company = Company.objects.get(url=slug) + if company.creator_id != self.request.user.id: + return HttpResponseForbidden() + + + form = self.form_class(self.request.POST, instance=company) + + company = form.save() + try: + rating = company.rating + except AttributeError: + rating = company.master.rating + themes = [{'text': item.name,'id': str(item.id),'url': '/members/theme/%s/'%item.url} for item in company.theme.all()] + response = {'success': True, 'rating': rating, 'tags': themes} + return HttpResponse(json.dumps(response), content_type='application/json') + + class TagView(BaseView): form_class = TagForm + def form_valid(self, form): + slug = self.kwargs.get('slug') + if not slug: + raise Http404 + + company = Company.objects.get(url=slug) + if company.creator_id != self.request.user.id: + return HttpResponseForbidden() + + + form = self.form_class(self.request.POST, instance=company) + + company = form.save() + try: + rating = company.rating + except AttributeError: + rating = company.master.rating + tags = [{'text': item.name,'id': str(item.id),'url': '/members/tag/%s/'%item.url} for item in company.tag.all()] + response = {'success': True, 'rating': rating, 'tags': tags} + return HttpResponse(json.dumps(response), content_type='application/json') + + class FoundationView(BaseView): form_class = FoundationForm diff --git a/company/urls.py b/company/urls.py index 88c9e07f..8c42af1c 100644 --- a/company/urls.py +++ b/company/urls.py @@ -9,7 +9,6 @@ urlpatterns = patterns('', url(r'company/create-company/$', 'company.views.create_company'), url(r'company/get-company/$', 'company.views.get_company'), # - url(r'members/search/$', CompanySearchView.as_view()), #url(r'members/(?P.*)/(?P\d+)/$', CompanyView.as_view()), #url(r'members/(?P\d+)/$', CompanyView.as_view()), @@ -32,6 +31,7 @@ urlpatterns = patterns('', url(r'^company/update/web-page/(?P.*)/$', login_required(WebPageView.as_view())), url(r'^company/update/social/(?P.*)/$', login_required(SocialView.as_view())), url(r'^company/update/tag/(?P.*)/$', login_required(TagView.as_view())), + url(r'^company/update/theme/(?P.*)/$', login_required(ThemeView.as_view())), url(r'^company/update/foundation/(?P.*)/$', login_required(FoundationView.as_view())), url(r'^company/update/staff/(?P.*)/$', login_required(StaffView.as_view())), url(r'^company/update/description/(?P.*)/$', login_required(DescriptionView.as_view())), diff --git a/company/views.py b/company/views.py index 07691436..3b419b84 100644 --- a/company/views.py +++ b/company/views.py @@ -15,7 +15,7 @@ from .edit_forms import NameForm as CompNameForm, HomeForm as CompHomeForm, Phon EmailForm as CompEmailForm, WebPageForm as CompWebPageForm, SocialForm as CompSocialForm,\ TagForm as CompTagForm, DescriptionForm as CompDescr, StaffForm as CompStaff, \ FoundationForm as CompFound, SpecializationForm as CompSpec, AddressForm as CompAddress,\ - LogoForm as CompLogo + LogoForm as CompLogo, ThemeForm as CompThemeForm class CompanySearchView(ListView): @@ -112,11 +112,17 @@ class MemberDetail(DetailView): 'staff_form': CompStaff(instance=company), 'found_form': CompFound(instance=company), 'logo_form': CompLogo(instance=company) } - tags = [{'id': str(tag.id), 'text': tag.name } for tag in company.tag.all()] + tags = [{'id': str(tag.id), 'text': tag.name, 'url': '/members/tag/%s/'%tag.url} for tag in company.tag.all()] tag_form = CompTagForm() tag_form.fields['tag'].widget.attrs['data-predifined'] = json.dumps(tags) tag_form.fields['tag'].widget.attrs['value'] = '' - forms.update({'tag_form': tag_form}) + + #themes = [{'id': str(item.id), 'text': item.name } for item in company.theme.all()] + theme_form = CompThemeForm(instance=company) + + #theme_form.fields['theme'].widget.attrs['data-predifined'] = json.dumps(themes) + #theme_form.fields['tag'].widget.attrs['value'] = '' + forms.update({'tag_form': tag_form, 'theme_form': theme_form}) lang = get_language() comp_transl = company.translations.get(language_code=lang) diff --git a/exposition/management/commands/exposition_load.py b/exposition/management/commands/exposition_load.py index 2e3a9b2a..7a755020 100644 --- a/exposition/management/commands/exposition_load.py +++ b/exposition/management/commands/exposition_load.py @@ -26,7 +26,7 @@ class Command(BaseCommand): 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[344:400]): + for row_number, row in enumerate(row_list[1:]): #print(row_number) if row[0] != '': @@ -44,6 +44,7 @@ class Command(BaseCommand): # if id blank - its a new place object = Exposition() object.translate('ru') + methods = [] for col_number, cell in enumerate(row): label = labels[col_number] diff --git a/exposition/views.py b/exposition/views.py index 1e709f0a..da69a6e3 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -145,12 +145,17 @@ def exposition_visit(request, id): return HttpResponse(json.dumps(args), content_type='application/json') #------------------------------------------------------------------------------ - +from service.order_forms import AdvertiseForm class ExpoDetail(DetailView): model = Exposition slug_field = 'url' template_name = 'client/exposition/exposition_detail.html' + def get_context_data(self, **kwargs): + context = super(ExpoDetail, self).get_context_data(**kwargs) + context['advertising_form'] = AdvertiseForm() + return context + class ExpositionProgramme(DetailView): model = Exposition slug_field = 'url' diff --git a/file/forms.py b/file/forms.py index 8816ec37..094e6e7e 100644 --- a/file/forms.py +++ b/file/forms.py @@ -17,8 +17,8 @@ import pytils, re class FileForm(forms.Form): file_path = forms.FileField(label='Выберите файл') model = forms.CharField(required=False, widget=forms.HiddenInput()) - purposes = [('scheme teritory','Схема територии'),('preview','Превью')] - purpose = forms.ChoiceField(label='Назаначение', choices=purposes) + purposes = [('scheme teritory','Схема территории'),('preview','Превью')] + purpose = forms.ChoiceField(label='Назначение', choices=purposes) def __init__(self, *args, **kwargs): """ diff --git a/import_xls/excel_settings.py b/import_xls/excel_settings.py index 0473b787..fb9510b5 100644 --- a/import_xls/excel_settings.py +++ b/import_xls/excel_settings.py @@ -247,7 +247,6 @@ def to_phone(value): value = value.replace(elem, '') value = to_int(value) - print(value) return value @@ -279,9 +278,16 @@ def save_halls(obj, value): name = l[0].strip() res.append({'area': area, 'name':name, 'number': number}) + Hall.objects.filter(place_exposition=obj).delete() for hall in res: h = Hall(place_exposition = obj, name=hall.get('name'), number=hall.get('number'), capacity=hall.get('area')) - h.save() + try: + h.save() + except Exception, e: + print('---------------hall error---------') + print e + print('---------------------------------') + place_exp_sett = { u'ID':{u'field': u'id', u'func': to_int}, @@ -295,7 +301,7 @@ place_exp_sett = { u'Тел.':{u'field': u'phone', u'func': to_phone}, u'Факс':{u'field': u'fax', u'func': to_phone}, u'Фото':{u'field': u'photo', u'func': save_photo, u'method': True}, - u'Лого':{u'field': u'logo', u'func': save_file, u'method': True, u'purpose': 'logo'}, + u'Лого':{u'field': u'logo', u'func': save_logo, u'method': True}, u'Веб-сайт':{u'field': u'web_page', u'func': unicode}, u'Email':{u'field': u'email', u'func': unicode}, u'Карта проезда':{u'field': u'map', u'func': save_file, u'method': True, u'purpose': 'map'}, diff --git a/import_xls/utils.py b/import_xls/utils.py index 807202c8..b2c29481 100644 --- a/import_xls/utils.py +++ b/import_xls/utils.py @@ -41,7 +41,9 @@ def to_country(value): country = query.filter(name=value)[0] return country except IndexError: + print('---------------------') print(value.encode('utf8')) + print('AAAAAAAA') return None def to_city(value, lang, country): @@ -51,9 +53,9 @@ def to_city(value, lang, country): # except IndexError if no found city = City.objects.filter(translations__name=value, country=country)[0] # print(city) - return city.id + return city except IndexError: - print('---------------------') + print('---------city error------------') print(value.encode('utf8')) print('---------------------') return None diff --git a/place_exposition/admin_urls.py b/place_exposition/admin_urls.py index 47ab735d..6de2ec5c 100644 --- a/place_exposition/admin_urls.py +++ b/place_exposition/admin_urls.py @@ -10,7 +10,7 @@ urlpatterns = patterns('place_exposition.admin', url(r'^all/$', PlaceExpositionListView.as_view()), #url(r'^add.*/$', 'exposition_add'), - #url(r'^delete/(?P.*)/$', 'exposition_delete'), + url(r'^delete/(?P.*)/$', 'exposition_delete'), #url(r'^change/(?P.*)/$', 'exposition_change'), #url(r'^copy/(?P.*)/$', 'place_exposition_copy'), url(r'^(?P.*)/$', PlaceExpositionView.as_view()), diff --git a/place_exposition/forms.py b/place_exposition/forms.py index d8a4a818..0aac6a59 100644 --- a/place_exposition/forms.py +++ b/place_exposition/forms.py @@ -27,13 +27,13 @@ class ExpositionForm(forms.Form): """ types = [(item1, item2) for item1, item2 in EXPOSITION_TYPE] type = forms.ChoiceField(required=False, choices=types) - logo = forms.ImageField(label='Logo', required=False) + logo = forms.ImageField(label='Logo', required=False, max_length=500) country = forms.ChoiceField(label='Страна', choices=[(c.id, c.name) for c in Country.objects.all()]) # creates select input with empty choices cause it will be filled with ajax city = forms.CharField(label='Город', widget=forms.HiddenInput()) - address = forms.CharField(label='Адресс', widget=LocationWidget, required=False) + address = forms.CharField(label='Адрес', widget=LocationWidget, required=False) phone = forms.CharField(label='Телефон', required=False, widget=forms.TextInput(attrs={'placeholder': 'Введите телефон'})) @@ -48,7 +48,7 @@ class ExpositionForm(forms.Form): widget=forms.TextInput(attrs={'placeholder': 'Год основания'})) total_area = forms.CharField(label='Общая выставочная площадь', required=False, widget=forms.TextInput(attrs={'placeholder': 'Общая выст. площадь'})) - closed_area = forms.CharField(label='Закрытая выствочная площадь', required=False, + closed_area = forms.CharField(label='Закрытая выставочная площадь', required=False, widget=forms.TextInput(attrs={'placeholder': 'Закр. выст. площадь'})) open_area = forms.CharField(label='Открытая выставочная площадь', required=False, widget=forms.TextInput(attrs={'placeholder': 'Откр. выст. площадь'})) @@ -62,10 +62,10 @@ class ExpositionForm(forms.Form): children_room = forms.BooleanField(label='Детская комната', required=False) disabled_service = forms.BooleanField(label='Сервис для инвалидов', required=False) conference_centre = forms.BooleanField(label='Конгресс-центр', required=False) - business_centre = forms.BooleanField(label='Бизнес центр', required=False) + business_centre = forms.BooleanField(label='Бизнес-центр', required=False) online_registration = forms.BooleanField(label='Онлайн регистрация', required=False) cafe = forms.BooleanField(label='Кафе', required=False) - terminals = forms.BooleanField(label='Информационые терминалы', required=False) + terminals = forms.BooleanField(label='Информационные терминалы', required=False) parking = forms.BooleanField(label='Парковка', required=False) press_centre = forms.BooleanField(label='Пресс-центр', required=False) mobile_application = forms.BooleanField(label='Мобильное приложение', required=False) @@ -148,9 +148,10 @@ class ExpositionForm(forms.Form): place_exposition.country = Country.objects.get(id=data['country']) if data.get('city'): place_exposition.city = City.objects.get(id=data['city']) - - fill_with_signal(PlaceExposition, place_exposition, data) + a = place_exposition.logo place_exposition.save() + fill_with_signal(PlaceExposition, place_exposition, data) + return place_exposition diff --git a/place_exposition/management/commands/place_exposition_load.py b/place_exposition/management/commands/place_exposition_load.py index c2f889e8..c1b5435a 100644 --- a/place_exposition/management/commands/place_exposition_load.py +++ b/place_exposition/management/commands/place_exposition_load.py @@ -5,7 +5,7 @@ from place_exposition.models import PlaceExposition from import_xls.excel_settings import import_settings, place_exp_sett from django.conf import settings -PLACE_FILE = settings.MEDIA_ROOT+'/import/places.xlsx' +PLACE_FILE = settings.MEDIA_ROOT+'import/places_ru.xls' class Command(BaseCommand): def handle(self, *args, **options): @@ -17,90 +17,98 @@ class Command(BaseCommand): labels = [label for label in row_list[0]] existing = 0 - for row_number, row in enumerate(row_list): + for row_number, row in enumerate(row_list[1:]): + new = 0 # go through all rows in file - if row_number > 0: - # first field is label - if row[0] != '': - # in first column ids + if row[0] != '': + # in first column ids - try: - object = PlaceExposition.objects.language('ru').get(id=int(row[0])) - existing += 1 - except ValueError: - object = PlaceExposition() - object.translate('ru') - - except PlaceExposition.DoesNotExist: - object = PlaceExposition(id= int(row[0])) - object.translate('ru') - existing += 1 - else: - # if id blank - its a new place - object = PlaceExposition + try: + object = PlaceExposition.objects.language('ru').get(id=int(row[0])) + existing += 1 + except ValueError: + object = PlaceExposition() object.translate('ru') - methods = [] - for col_number, cell in enumerate(row): - # go through row cells - # field name current cell - label = labels[col_number] - setting = place_exp_sett.get(label) - - if setting is None: - continue + new = 1 - if setting.get('method'): - if cell != "": - methods.append({'func': setting['func'], 'value': cell, 'purpose': setting.get('purpose')}) - continue + except PlaceExposition.DoesNotExist: + object = PlaceExposition(id= int(row[0])) + object.translate('ru') + existing += 1 + new = 1 + else: + # if id blank - its a new place + object = PlaceExposition + object.translate('ru') + + + methods = [] + for col_number, cell in enumerate(row): + # go through row cells + # field name current cell + label = labels[col_number] + setting = place_exp_sett.get(label) + + if setting is None: + continue - field_name = setting['field'] + if setting.get('method'): + if cell != "": + methods.append({'func': setting['func'], 'value': cell, 'purpose': setting.get('purpose')}) + continue + field_name = setting['field'] + func = setting.get('func') - func = setting.get('func') - if func is not None: - extra_value = setting.get('extra_values') - if extra_value is not None: - # if setting has extra value then - # it is some field like city, theme, tag - # that has relation and can be created + if func is not None: + extra_value = setting.get('extra_values') + if extra_value is not None: + # if setting has extra value then + # it is some field like city, theme, tag + # that has relation and can be created - # in function we add language(need for relation fields) - # and extra value from object (like for city need country) - value = func(cell, 'ru', getattr(object, extra_value)) - else: - value = func(cell) - #if field_name =='adress': - # setattr(object, 'address', google_address(value)) - setattr(object, field_name, value) + # in function we add language(need for relation fields) + # and extra value from object (like for city need country) + value = func(cell, 'ru', getattr(object, extra_value)) - #object.save() - print('post save %s'% str(object)) - """ - try: - print(object) - #object.save() - except IntegrityError: - continue - #url = object.url + translit_with_separator(object.city.name) - #object.url = url - #object.save() - """ - """ - for method in methods: - func = method['func'] - if method.get('purpose'): - try: - func(object, method['value'], method['purpose']) - except: - continue + else: + value = func(cell) + #if field_name =='adress': + # setattr(object, 'address', google_address(value)) + if field_name == 'city' and new == 0: + pass else: try: - func(object, method['value']) - except: - continue + setattr(object, field_name, value) + except ValueError, e: + print(value, field_name) + - """ - print(existing) + object.save() + print('post save %s'% str(object)) + """ + try: + print(object) + #object.save() + + except IntegrityError: + continue + #url = object.url + translit_with_separator(object.city.name) + #object.url = url + #object.save() + """ + + for method in methods: + func = method['func'] + if method.get('purpose'): + try: + func(object, method['value'], method['purpose']) + except: + continue + else: + try: + func(object, method['value']) + except: + continue \ No newline at end of file diff --git a/place_exposition/models.py b/place_exposition/models.py index 5d90d64b..96dda2c7 100644 --- a/place_exposition/models.py +++ b/place_exposition/models.py @@ -78,7 +78,7 @@ class PlaceExposition(TranslatableModel, ExpoMixin): press_centre = models.NullBooleanField() mobile_application = models.NullBooleanField() # - logo = models.ImageField(verbose_name='Logo', upload_to=logo_name, blank=True) + logo = models.ImageField(verbose_name='Logo', upload_to=logo_name, blank=True, max_length=255) rating = models.IntegerField(default=0) # delete after profiling @@ -263,7 +263,42 @@ class Hall(TranslatableModel): +def calculate_rating(place): + rating_simple = {'address': 20, 'phone': 5, 'fax': 5, 'email': 5, + 'web_page': 5, 'logo': 20, 'event_in_year': 5, 'total_area': 5, 'closed_area': 5, + 'total_pavilions': 5, 'description':15, 'foundation_year': 5, 'total_halls': 5, 'virtual_tour': 5 } + rating_methods = {'theme': 10, 'tag': 5, 'photo':5} + # base rating + rating = 100 + for key, value in rating_simple.iteritems(): + if getattr(place, key): + rating += value + + place.rating = rating + # call to prevent recursion + post_save.disconnect(create_place, sender=PlaceExposition) + place.save() + post_save.connect(create_place, sender=PlaceExposition) + + +def create_place(sender, instance, created, **kwargs): + post_save_handler(sender, instance=instance, **kwargs) + calculate_rating(instance) #test pre_save.connect(pre_save_handler, sender=PlaceExposition) -post_save.connect(post_save_handler, sender=PlaceExposition) -post_save.connect(post_save_handler, sender=Hall) \ No newline at end of file +post_save.connect(create_place, sender=PlaceExposition) +post_save.connect(post_save_handler, sender=Hall) + + + + +""" +def calculate_rating_for_translations(sender, instance, created, **kwargs): + company = instance.master + post_save.disconnect(calculate_rating_for_translations, sender=Company._meta.translations_model) + calculate_rating(company) + post_save.connect(calculate_rating_for_translations, sender=Company._meta.translations_model) + +post_save.connect(create_company, sender=Company) +post_save.connect(calculate_rating_for_translations, sender=Company._meta.translations_model) +""" \ No newline at end of file diff --git a/place_exposition/views.py b/place_exposition/views.py index aac4d1dc..13ceea97 100644 --- a/place_exposition/views.py +++ b/place_exposition/views.py @@ -128,7 +128,7 @@ class PlaceList(ListView): def get_queryset(self): lang = translation.get_language() - qs = super(PlaceList, self).get_queryset().filter(language_code=lang) + qs = super(PlaceList, self).get_queryset().filter(language_code=lang).order_by('-rating') conf_qs = PlaceConference.objects.language().all() return list(qs)+list(conf_qs) diff --git a/service/models.py b/service/models.py index 377f4578..28ca45b4 100644 --- a/service/models.py +++ b/service/models.py @@ -4,7 +4,7 @@ from hvad.models import TranslatableModel, TranslatedFields, TranslationManager from functions.custom_fields import EnumField -CURENCIES = ('USD', 'RUB', 'EUR') +CURENCIES = ('', 'USD', 'RUB', 'EUR') @@ -122,3 +122,6 @@ class Visit(AbstractOrder): excursion = models.BooleanField() notes = models.TextField(blank=True) + +class Advertising(AbstractOrder): + pass \ No newline at end of file diff --git a/service/order_forms.py b/service/order_forms.py index 8b459adb..12d6dbfc 100644 --- a/service/order_forms.py +++ b/service/order_forms.py @@ -2,7 +2,7 @@ from django import forms from django.utils.translation import ugettext as _ from accounts.models import User -from models import Catalog, Tickets, Remote, Participation, Translation, Visit, CURENCIES +from models import Catalog, Tickets, Remote, Participation, Translation, Visit, CURENCIES, Advertising from exposition.models import Exposition from conference.models import Conference from seminar.models import Seminar @@ -15,7 +15,7 @@ class AbstractOrderForm(forms.ModelForm): phone = forms.CharField(widget=forms.TextInput(attrs={'placeholder': _(u'Контактный номер телефона')})) person = forms.EmailField(widget=forms.TextInput(attrs={'placeholder': _(u'Электронная почта')})) - currency = forms.CharField(widget=forms.HiddenInput()) + currency = forms.CharField(widget=forms.HiddenInput(), required=False) exposition = forms.CharField(widget=forms.HiddenInput(), required=False) conference = forms.CharField(widget=forms.HiddenInput(), required=False) @@ -195,4 +195,10 @@ class VisitForm(AbstractOrderForm): if not avia_type: return '' else: - return ', '.join(avia_type) \ No newline at end of file + return ', '.join(avia_type) + +class AdvertiseForm(AbstractOrderForm): + action = '/service/advertise/' + class Meta: + model = Advertising + diff --git a/service/urls.py b/service/urls.py index bb0f88f7..44ef4f0f 100644 --- a/service/urls.py +++ b/service/urls.py @@ -3,6 +3,7 @@ from django.conf.urls import patterns, include, url from views import ServiceView urlpatterns = patterns('', + url(r'service/advertise/$', 'service.views.advertise'), url(r'service/(?P.*)/$', ServiceView.as_view()), ) diff --git a/service/views.py b/service/views.py index 605a14a2..b6ea0fd8 100644 --- a/service/views.py +++ b/service/views.py @@ -9,7 +9,7 @@ from django.http import Http404 import json from functions.search_forms import CompanySearchForm -from order_forms import TranslationForm, CatalogForm, VisitForm, RemoteForm, ParticipationForm, TicketsForm +from order_forms import TranslationForm, CatalogForm, VisitForm, RemoteForm, ParticipationForm, TicketsForm, AdvertiseForm order_forms = {'translator': TranslationForm, 'catalog': CatalogForm, 'participation': ParticipationForm, @@ -34,3 +34,19 @@ class ServiceView(FormView): return service.template + +def advertise(request): + if request.POST: + response = {'success': False} + form = AdvertiseForm(request.POST) + if form.is_valid(): + form.save() + response['success'] = True + else: + response['erros'] = form.errors + + return HttpResponse(json.dumps(response), content_type='application/json') + + + + diff --git a/templates/admin/place_exposition/place_exposition.html b/templates/admin/place_exposition/place_exposition.html index 761c9642..add84f46 100644 --- a/templates/admin/place_exposition/place_exposition.html +++ b/templates/admin/place_exposition/place_exposition.html @@ -192,7 +192,7 @@
-

Павилионы

+

Павильоны

{% if object %} @@ -200,7 +200,7 @@ - + @@ -358,7 +358,7 @@
-

Мета даные

+

Мета данные

diff --git a/templates/client/accounts/user.html b/templates/client/accounts/user.html index 5d76c2cf..0e9cbe80 100644 --- a/templates/client/accounts/user.html +++ b/templates/client/accounts/user.html @@ -12,10 +12,11 @@ {% block content_list %} - {% if request.user == member %} - {% include 'client/includes/accounts/current_user.html' %} - {% else %} + {% if request.user != member or request.GET.logout %} {% include 'client/includes/accounts/simple_user.html' %} + {% else %} + {% include 'client/includes/accounts/current_user.html' %} + {% endif %} {% endblock %} diff --git a/templates/client/company/company_detail.html b/templates/client/company/company_detail.html index 5e7892bc..934b7b7d 100644 --- a/templates/client/company/company_detail.html +++ b/templates/client/company/company_detail.html @@ -13,11 +13,10 @@ {% endblock %} {% block content_list %} - {% if request.user == object.creator %} - - {% include 'client/includes/company/company_edit.html' with company=object %} - {% else %} + {% if request.user != object.creator or request.GET.logout %} {% include 'client/includes/company/company_object.html' with company=object %} + {% else %} + {% include 'client/includes/company/company_edit.html' with company=object %} {% endif %} diff --git a/templates/client/includes/accounts/current_user.html b/templates/client/includes/accounts/current_user.html index b19fffed..3b89d3be 100644 --- a/templates/client/includes/accounts/current_user.html +++ b/templates/client/includes/accounts/current_user.html @@ -22,7 +22,7 @@
{% if request.user.profile.avatar %} - {% thumbnail request.user.profile.avatar "100x100" crop="center" as im %} + {% thumbnail request.user.profile.avatar "100x100" as im %} {% endthumbnail %} {% else %} diff --git a/templates/client/includes/accounts/simple_user.html b/templates/client/includes/accounts/simple_user.html index d14e9558..96e5de74 100644 --- a/templates/client/includes/accounts/simple_user.html +++ b/templates/client/includes/accounts/simple_user.html @@ -8,7 +8,7 @@
diff --git a/templates/client/includes/company/company_edit.html b/templates/client/includes/company/company_edit.html index 5e51b7f1..a6e1b883 100644 --- a/templates/client/includes/company/company_edit.html +++ b/templates/client/includes/company/company_edit.html @@ -20,7 +20,7 @@
{% if company.logo %} - {% thumbnail company.logo "100x100" crop="center" as im %} + {% thumbnail company.logo "100x100" as im %} {% endthumbnail %} {% else %} @@ -186,9 +186,10 @@
{% with themes=company.theme.all %}
- {% for th in themes %} - {{ th.name }}{% ifnotequal forloop.counter themes|length %},{% endifnotequal %} - {% endfor %} +
+ {% csrf_token %} +
{{ theme_form.theme }}
+
{% endwith %} diff --git a/templates/client/includes/company/company_object.html b/templates/client/includes/company/company_object.html index 3fb825e8..7ed4b367 100644 --- a/templates/client/includes/company/company_object.html +++ b/templates/client/includes/company/company_object.html @@ -9,7 +9,7 @@
diff --git a/templates/client/includes/exposition/exposition_object.html b/templates/client/includes/exposition/exposition_object.html index daf154e3..26486f16 100644 --- a/templates/client/includes/exposition/exposition_object.html +++ b/templates/client/includes/exposition/exposition_object.html @@ -362,6 +362,7 @@ {% endfor %}
+ {% include 'client/popups/advertise_member.html' with form=advertising_form %} {% endif %} diff --git a/templates/client/includes/show_logo.html b/templates/client/includes/show_logo.html index df1a0698..ffc3a6e2 100644 --- a/templates/client/includes/show_logo.html +++ b/templates/client/includes/show_logo.html @@ -1,4 +1,5 @@ {% load static %} +{% load thumbnail %} {% if obj.get_logo %} {# delete after changing all logos #} @@ -9,5 +10,12 @@ {% endif %} {% else %} - + {% if obj.logo %} + {% thumbnail obj.logo "100x100" as im %} + + {% endthumbnail %} + {% else %} + + + {% endif %} {% endif %} \ No newline at end of file diff --git a/templates/client/popups/advertise_member.html b/templates/client/popups/advertise_member.html new file mode 100644 index 00000000..566e88a3 --- /dev/null +++ b/templates/client/popups/advertise_member.html @@ -0,0 +1,47 @@ +{% load static %} +{% load i18n %} + + \ No newline at end of file
Название павилионаНазвание павильона Номер Вместимость