Merge branch 'develop' of git.general-servers.com:expomap/expomap into develop

remotes/origin/1203
pavel 11 years ago
commit d877b2dc1d
  1. 2
      accounts/views.py
  2. 10
      company/edit_forms.py
  3. 49
      company/edit_views.py
  4. 2
      company/urls.py
  5. 12
      company/views.py
  6. 3
      exposition/management/commands/exposition_load.py
  7. 7
      exposition/views.py
  8. 4
      file/forms.py
  9. 12
      import_xls/excel_settings.py
  10. 6
      import_xls/utils.py
  11. 2
      place_exposition/admin_urls.py
  12. 15
      place_exposition/forms.py
  13. 156
      place_exposition/management/commands/place_exposition_load.py
  14. 41
      place_exposition/models.py
  15. 2
      place_exposition/views.py
  16. 5
      service/models.py
  17. 12
      service/order_forms.py
  18. 1
      service/urls.py
  19. 18
      service/views.py
  20. 6
      templates/admin/place_exposition/place_exposition.html
  21. 7
      templates/client/accounts/user.html
  22. 7
      templates/client/company/company_detail.html
  23. 2
      templates/client/includes/accounts/current_user.html
  24. 20
      templates/client/includes/accounts/simple_user.html
  25. 9
      templates/client/includes/company/company_edit.html
  26. 20
      templates/client/includes/company/company_object.html
  27. 5
      templates/client/includes/exposition/exposition_object.html
  28. 10
      templates/client/includes/show_logo.html
  29. 47
      templates/client/popups/advertise_member.html

@ -296,7 +296,7 @@ class AvatarView(BaseProfileView):
form = self.form_class(self.request.POST, self.request.FILES, instance=profile) form = self.form_class(self.request.POST, self.request.FILES, instance=profile)
profile = form.save() profile = form.save()
if self.request.is_ajax(): 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} response = {'success': True, 'url': im.url, 'rating': profile.user.rating}
return HttpResponse(json.dumps(response), content_type='application/json') return HttpResponse(json.dumps(response), content_type='application/json')
else: else:

@ -4,6 +4,7 @@ from django.utils.translation import ugettext as _, get_language
from country.models import Country from country.models import Country
from city.models import City from city.models import City
from company.models import Company from company.models import Company
from theme.models import Theme
class BaseForm(forms.ModelForm): class BaseForm(forms.ModelForm):
@ -36,7 +37,7 @@ class SpecializationForm(BaseForm):
class HomeForm(BaseForm): class HomeForm(BaseForm):
city = forms.CharField(label='Город', required=False, city = forms.CharField(label='Город', required=False,
widget=forms.HiddenInput(attrs={'class': 'select2'})) 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'})) widget=forms.Select(attrs={'class': 'select2'}))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(HomeForm, self).__init__(*args, **kwargs) super(HomeForm, self).__init__(*args, **kwargs)
@ -107,6 +108,13 @@ class SocialForm(BaseForm):
fields = ('facebook', 'twitter', 'vk', 'linkedin') fields = ('facebook', 'twitter', 'vk', 'linkedin')
class ThemeForm(BaseForm):
theme = forms.ModelMultipleChoiceField(oqueryset=Theme.objects.all())
class Meta:
model = Company
fields = ('theme',)
class TagForm(BaseForm): class TagForm(BaseForm):
tag = forms.CharField(required=False, widget=forms.HiddenInput(attrs={'class': 'select2'})) tag = forms.CharField(required=False, widget=forms.HiddenInput(attrs={'class': 'select2'}))
class Meta: class Meta:

@ -53,7 +53,7 @@ class LogoView(BaseView):
form = self.form_class(self.request.POST, self.request.FILES, instance=company) form = self.form_class(self.request.POST, self.request.FILES, instance=company)
company = form.save() company = form.save()
if self.request.is_ajax(): 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} response = {'success': True, 'url': im.url, 'rating': company.rating}
return HttpResponse(json.dumps(response), content_type='application/json') return HttpResponse(json.dumps(response), content_type='application/json')
else: else:
@ -87,9 +87,56 @@ class SocialView(BaseView):
form_class = SocialForm 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): class TagView(BaseView):
form_class = TagForm 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): class FoundationView(BaseView):
form_class = FoundationForm form_class = FoundationForm

@ -9,7 +9,6 @@ urlpatterns = patterns('',
url(r'company/create-company/$', 'company.views.create_company'), url(r'company/create-company/$', 'company.views.create_company'),
url(r'company/get-company/$', 'company.views.get_company'), url(r'company/get-company/$', 'company.views.get_company'),
# #
url(r'members/search/$', CompanySearchView.as_view()), url(r'members/search/$', CompanySearchView.as_view()),
#url(r'members/(?P<params>.*)/(?P<page>\d+)/$', CompanyView.as_view()), #url(r'members/(?P<params>.*)/(?P<page>\d+)/$', CompanyView.as_view()),
#url(r'members/(?P<page>\d+)/$', CompanyView.as_view()), #url(r'members/(?P<page>\d+)/$', CompanyView.as_view()),
@ -32,6 +31,7 @@ urlpatterns = patterns('',
url(r'^company/update/web-page/(?P<slug>.*)/$', login_required(WebPageView.as_view())), url(r'^company/update/web-page/(?P<slug>.*)/$', login_required(WebPageView.as_view())),
url(r'^company/update/social/(?P<slug>.*)/$', login_required(SocialView.as_view())), url(r'^company/update/social/(?P<slug>.*)/$', login_required(SocialView.as_view())),
url(r'^company/update/tag/(?P<slug>.*)/$', login_required(TagView.as_view())), url(r'^company/update/tag/(?P<slug>.*)/$', login_required(TagView.as_view())),
url(r'^company/update/theme/(?P<slug>.*)/$', login_required(ThemeView.as_view())),
url(r'^company/update/foundation/(?P<slug>.*)/$', login_required(FoundationView.as_view())), url(r'^company/update/foundation/(?P<slug>.*)/$', login_required(FoundationView.as_view())),
url(r'^company/update/staff/(?P<slug>.*)/$', login_required(StaffView.as_view())), url(r'^company/update/staff/(?P<slug>.*)/$', login_required(StaffView.as_view())),
url(r'^company/update/description/(?P<slug>.*)/$', login_required(DescriptionView.as_view())), url(r'^company/update/description/(?P<slug>.*)/$', login_required(DescriptionView.as_view())),

@ -15,7 +15,7 @@ from .edit_forms import NameForm as CompNameForm, HomeForm as CompHomeForm, Phon
EmailForm as CompEmailForm, WebPageForm as CompWebPageForm, SocialForm as CompSocialForm,\ EmailForm as CompEmailForm, WebPageForm as CompWebPageForm, SocialForm as CompSocialForm,\
TagForm as CompTagForm, DescriptionForm as CompDescr, StaffForm as CompStaff, \ TagForm as CompTagForm, DescriptionForm as CompDescr, StaffForm as CompStaff, \
FoundationForm as CompFound, SpecializationForm as CompSpec, AddressForm as CompAddress,\ FoundationForm as CompFound, SpecializationForm as CompSpec, AddressForm as CompAddress,\
LogoForm as CompLogo LogoForm as CompLogo, ThemeForm as CompThemeForm
class CompanySearchView(ListView): class CompanySearchView(ListView):
@ -112,11 +112,17 @@ class MemberDetail(DetailView):
'staff_form': CompStaff(instance=company), 'found_form': CompFound(instance=company), 'staff_form': CompStaff(instance=company), 'found_form': CompFound(instance=company),
'logo_form': CompLogo(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 = CompTagForm()
tag_form.fields['tag'].widget.attrs['data-predifined'] = json.dumps(tags) tag_form.fields['tag'].widget.attrs['data-predifined'] = json.dumps(tags)
tag_form.fields['tag'].widget.attrs['value'] = '' 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() lang = get_language()
comp_transl = company.translations.get(language_code=lang) comp_transl = company.translations.get(language_code=lang)

@ -26,7 +26,7 @@ class Command(BaseCommand):
row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)] row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)]
labels = [label for label in row_list[0]] 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) #print(row_number)
if row[0] != '': if row[0] != '':
@ -44,6 +44,7 @@ class Command(BaseCommand):
# if id blank - its a new place # if id blank - its a new place
object = Exposition() object = Exposition()
object.translate('ru') object.translate('ru')
methods = [] methods = []
for col_number, cell in enumerate(row): for col_number, cell in enumerate(row):
label = labels[col_number] label = labels[col_number]

@ -145,12 +145,17 @@ def exposition_visit(request, id):
return HttpResponse(json.dumps(args), content_type='application/json') return HttpResponse(json.dumps(args), content_type='application/json')
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
from service.order_forms import AdvertiseForm
class ExpoDetail(DetailView): class ExpoDetail(DetailView):
model = Exposition model = Exposition
slug_field = 'url' slug_field = 'url'
template_name = 'client/exposition/exposition_detail.html' 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): class ExpositionProgramme(DetailView):
model = Exposition model = Exposition
slug_field = 'url' slug_field = 'url'

@ -17,8 +17,8 @@ import pytils, re
class FileForm(forms.Form): class FileForm(forms.Form):
file_path = forms.FileField(label='Выберите файл') file_path = forms.FileField(label='Выберите файл')
model = forms.CharField(required=False, widget=forms.HiddenInput()) model = forms.CharField(required=False, widget=forms.HiddenInput())
purposes = [('scheme teritory','Схема територии'),('preview','Превью')] purposes = [('scheme teritory','Схема территории'),('preview','Превью')]
purpose = forms.ChoiceField(label='Назаначение', choices=purposes) purpose = forms.ChoiceField(label='Назначение', choices=purposes)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """

@ -247,7 +247,6 @@ def to_phone(value):
value = value.replace(elem, '') value = value.replace(elem, '')
value = to_int(value) value = to_int(value)
print(value)
return value return value
@ -279,9 +278,16 @@ def save_halls(obj, value):
name = l[0].strip() name = l[0].strip()
res.append({'area': area, 'name':name, 'number': number}) res.append({'area': area, 'name':name, 'number': number})
Hall.objects.filter(place_exposition=obj).delete()
for hall in res: for hall in res:
h = Hall(place_exposition = obj, name=hall.get('name'), number=hall.get('number'), capacity=hall.get('area')) 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 = { place_exp_sett = {
u'ID':{u'field': u'id', u'func': to_int}, 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'phone', u'func': to_phone},
u'Факс':{u'field': u'fax', 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'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'Веб-сайт':{u'field': u'web_page', u'func': unicode},
u'Email':{u'field': u'email', 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'}, u'Карта проезда':{u'field': u'map', u'func': save_file, u'method': True, u'purpose': 'map'},

@ -41,7 +41,9 @@ def to_country(value):
country = query.filter(name=value)[0] country = query.filter(name=value)[0]
return country return country
except IndexError: except IndexError:
print('---------------------')
print(value.encode('utf8')) print(value.encode('utf8'))
print('AAAAAAAA')
return None return None
def to_city(value, lang, country): def to_city(value, lang, country):
@ -51,9 +53,9 @@ def to_city(value, lang, country):
# except IndexError if no found # except IndexError if no found
city = City.objects.filter(translations__name=value, country=country)[0] city = City.objects.filter(translations__name=value, country=country)[0]
# print(city) # print(city)
return city.id return city
except IndexError: except IndexError:
print('---------------------') print('---------city error------------')
print(value.encode('utf8')) print(value.encode('utf8'))
print('---------------------') print('---------------------')
return None return None

@ -10,7 +10,7 @@ urlpatterns = patterns('place_exposition.admin',
url(r'^all/$', PlaceExpositionListView.as_view()), url(r'^all/$', PlaceExpositionListView.as_view()),
#url(r'^add.*/$', 'exposition_add'), #url(r'^add.*/$', 'exposition_add'),
#url(r'^delete/(?P<url>.*)/$', 'exposition_delete'), url(r'^delete/(?P<url>.*)/$', 'exposition_delete'),
#url(r'^change/(?P<url>.*)/$', 'exposition_change'), #url(r'^change/(?P<url>.*)/$', 'exposition_change'),
#url(r'^copy/(?P<url>.*)/$', 'place_exposition_copy'), #url(r'^copy/(?P<url>.*)/$', 'place_exposition_copy'),
url(r'^(?P<url>.*)/$', PlaceExpositionView.as_view()), url(r'^(?P<url>.*)/$', PlaceExpositionView.as_view()),

@ -27,13 +27,13 @@ class ExpositionForm(forms.Form):
""" """
types = [(item1, item2) for item1, item2 in EXPOSITION_TYPE] types = [(item1, item2) for item1, item2 in EXPOSITION_TYPE]
type = forms.ChoiceField(required=False, choices=types) 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()]) 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 # creates select input with empty choices cause it will be filled with ajax
city = forms.CharField(label='Город', widget=forms.HiddenInput()) 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, phone = forms.CharField(label='Телефон', required=False,
widget=forms.TextInput(attrs={'placeholder': 'Введите телефон'})) widget=forms.TextInput(attrs={'placeholder': 'Введите телефон'}))
@ -48,7 +48,7 @@ class ExpositionForm(forms.Form):
widget=forms.TextInput(attrs={'placeholder': 'Год основания'})) widget=forms.TextInput(attrs={'placeholder': 'Год основания'}))
total_area = forms.CharField(label='Общая выставочная площадь', required=False, total_area = forms.CharField(label='Общая выставочная площадь', required=False,
widget=forms.TextInput(attrs={'placeholder': 'Общая выст. площадь'})) widget=forms.TextInput(attrs={'placeholder': 'Общая выст. площадь'}))
closed_area = forms.CharField(label='Закрытая выствочная площадь', required=False, closed_area = forms.CharField(label='Закрытая выставочная площадь', required=False,
widget=forms.TextInput(attrs={'placeholder': 'Закр. выст. площадь'})) widget=forms.TextInput(attrs={'placeholder': 'Закр. выст. площадь'}))
open_area = forms.CharField(label='Открытая выставочная площадь', required=False, open_area = forms.CharField(label='Открытая выставочная площадь', required=False,
widget=forms.TextInput(attrs={'placeholder': 'Откр. выст. площадь'})) widget=forms.TextInput(attrs={'placeholder': 'Откр. выст. площадь'}))
@ -62,10 +62,10 @@ class ExpositionForm(forms.Form):
children_room = forms.BooleanField(label='Детская комната', required=False) children_room = forms.BooleanField(label='Детская комната', required=False)
disabled_service = forms.BooleanField(label='Сервис для инвалидов', required=False) disabled_service = forms.BooleanField(label='Сервис для инвалидов', required=False)
conference_centre = 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) online_registration = forms.BooleanField(label='Онлайн регистрация', required=False)
cafe = 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) parking = forms.BooleanField(label='Парковка', required=False)
press_centre = forms.BooleanField(label='Пресс-центр', required=False) press_centre = forms.BooleanField(label='Пресс-центр', required=False)
mobile_application = 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']) place_exposition.country = Country.objects.get(id=data['country'])
if data.get('city'): if data.get('city'):
place_exposition.city = City.objects.get(id=data['city']) place_exposition.city = City.objects.get(id=data['city'])
a = place_exposition.logo
fill_with_signal(PlaceExposition, place_exposition, data)
place_exposition.save() place_exposition.save()
fill_with_signal(PlaceExposition, place_exposition, data)
return place_exposition return place_exposition

@ -5,7 +5,7 @@ from place_exposition.models import PlaceExposition
from import_xls.excel_settings import import_settings, place_exp_sett from import_xls.excel_settings import import_settings, place_exp_sett
from django.conf import settings 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): class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
@ -17,90 +17,98 @@ class Command(BaseCommand):
labels = [label for label in row_list[0]] labels = [label for label in row_list[0]]
existing = 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 # go through all rows in file
if row_number > 0: if row[0] != '':
# first field is label # in first column ids
if row[0] != '':
# in first column ids
try: try:
object = PlaceExposition.objects.language('ru').get(id=int(row[0])) object = PlaceExposition.objects.language('ru').get(id=int(row[0]))
existing += 1 existing += 1
except ValueError: except ValueError:
object = PlaceExposition() 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
object.translate('ru') object.translate('ru')
methods = [] new = 1
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
if setting.get('method'): except PlaceExposition.DoesNotExist:
if cell != "": object = PlaceExposition(id= int(row[0]))
methods.append({'func': setting['func'], 'value': cell, 'purpose': setting.get('purpose')}) object.translate('ru')
continue 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:
if func is not None: extra_value = setting.get('extra_values')
extra_value = setting.get('extra_values') if extra_value is not None:
if extra_value is not None: # if setting has extra value then
# if setting has extra value then # it is some field like city, theme, tag
# it is some field like city, theme, tag # that has relation and can be created
# that has relation and can be created
# in function we add language(need for relation fields) # in function we add language(need for relation fields)
# and extra value from object (like for city need country) # and extra value from object (like for city need country)
value = func(cell, 'ru', getattr(object, extra_value)) 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)
#object.save()
print('post save %s'% str(object))
"""
try:
print(object)
#object.save()
except IntegrityError: else:
continue value = func(cell)
#url = object.url + translit_with_separator(object.city.name) #if field_name =='adress':
#object.url = url # setattr(object, 'address', google_address(value))
#object.save() if field_name == 'city' and new == 0:
""" pass
"""
for method in methods:
func = method['func']
if method.get('purpose'):
try:
func(object, method['value'], method['purpose'])
except:
continue
else: else:
try: try:
func(object, method['value']) setattr(object, field_name, value)
except: except ValueError, e:
continue 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

@ -78,7 +78,7 @@ class PlaceExposition(TranslatableModel, ExpoMixin):
press_centre = models.NullBooleanField() press_centre = models.NullBooleanField()
mobile_application = 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) rating = models.IntegerField(default=0)
# delete after profiling # 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 #test
pre_save.connect(pre_save_handler, sender=PlaceExposition) pre_save.connect(pre_save_handler, sender=PlaceExposition)
post_save.connect(post_save_handler, sender=PlaceExposition) post_save.connect(create_place, sender=PlaceExposition)
post_save.connect(post_save_handler, sender=Hall) 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)
"""

@ -128,7 +128,7 @@ class PlaceList(ListView):
def get_queryset(self): def get_queryset(self):
lang = translation.get_language() 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() conf_qs = PlaceConference.objects.language().all()
return list(qs)+list(conf_qs) return list(qs)+list(conf_qs)

@ -4,7 +4,7 @@ from hvad.models import TranslatableModel, TranslatedFields, TranslationManager
from functions.custom_fields import EnumField from functions.custom_fields import EnumField
CURENCIES = ('USD', 'RUB', 'EUR') CURENCIES = ('', 'USD', 'RUB', 'EUR')
@ -122,3 +122,6 @@ class Visit(AbstractOrder):
excursion = models.BooleanField() excursion = models.BooleanField()
notes = models.TextField(blank=True) notes = models.TextField(blank=True)
class Advertising(AbstractOrder):
pass

@ -2,7 +2,7 @@
from django import forms from django import forms
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from accounts.models import User 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 exposition.models import Exposition
from conference.models import Conference from conference.models import Conference
from seminar.models import Seminar from seminar.models import Seminar
@ -15,7 +15,7 @@ class AbstractOrderForm(forms.ModelForm):
phone = forms.CharField(widget=forms.TextInput(attrs={'placeholder': _(u'Контактный номер телефона')})) phone = forms.CharField(widget=forms.TextInput(attrs={'placeholder': _(u'Контактный номер телефона')}))
person = forms.EmailField(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) exposition = forms.CharField(widget=forms.HiddenInput(), required=False)
conference = 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: if not avia_type:
return '' return ''
else: else:
return ', '.join(avia_type) return ', '.join(avia_type)
class AdvertiseForm(AbstractOrderForm):
action = '/service/advertise/'
class Meta:
model = Advertising

@ -3,6 +3,7 @@ from django.conf.urls import patterns, include, url
from views import ServiceView from views import ServiceView
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'service/advertise/$', 'service.views.advertise'),
url(r'service/(?P<url>.*)/$', ServiceView.as_view()), url(r'service/(?P<url>.*)/$', ServiceView.as_view()),
) )

@ -9,7 +9,7 @@ from django.http import Http404
import json import json
from functions.search_forms import CompanySearchForm 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, order_forms = {'translator': TranslationForm, 'catalog': CatalogForm, 'participation': ParticipationForm,
@ -34,3 +34,19 @@ class ServiceView(FormView):
return service.template 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')

@ -192,7 +192,7 @@
<div class="box span8"> <div class="box span8">
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-pencil"></i> Павилионы</h2> <h2><i class="icon-pencil"></i> Павильоны</h2>
</div> </div>
<div class="box-content"> <div class="box-content">
{% if object %} {% if object %}
@ -200,7 +200,7 @@
<table class="table table-hover" style=" width: 100%;"> <table class="table table-hover" style=" width: 100%;">
<thead> <thead>
<tr> <tr>
<td>Название павилиона</td> <td>Название павильона</td>
<td>Номер</td> <td>Номер</td>
<td>Вместимость</td> <td>Вместимость</td>
<td></td> <td></td>
@ -358,7 +358,7 @@
<div class="box span8"> <div class="box span8">
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-pencil"></i> Мета даные</h2> <h2><i class="icon-pencil"></i> Мета данные</h2>
</div> </div>
<div class="box-content"> <div class="box-content">

@ -12,10 +12,11 @@
{% block content_list %} {% block content_list %}
{% if request.user == member %} {% if request.user != member or request.GET.logout %}
{% include 'client/includes/accounts/current_user.html' %}
{% else %}
{% include 'client/includes/accounts/simple_user.html' %} {% include 'client/includes/accounts/simple_user.html' %}
{% else %}
{% include 'client/includes/accounts/current_user.html' %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

@ -13,11 +13,10 @@
{% endblock %} {% endblock %}
{% block content_list %} {% block content_list %}
{% if request.user == object.creator %} {% if request.user != object.creator or request.GET.logout %}
{% include 'client/includes/company/company_edit.html' with company=object %}
{% else %}
{% include 'client/includes/company/company_object.html' with company=object %} {% include 'client/includes/company/company_object.html' with company=object %}
{% else %}
{% include 'client/includes/company/company_edit.html' with company=object %}
{% endif %} {% endif %}

@ -22,7 +22,7 @@
<div id="pick-block" class="pic_block"> <div id="pick-block" class="pic_block">
{% if request.user.profile.avatar %} {% if request.user.profile.avatar %}
{% thumbnail request.user.profile.avatar "100x100" crop="center" as im %} {% thumbnail request.user.profile.avatar "100x100" as im %}
<img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/> <img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
{% endthumbnail %} {% endthumbnail %}
{% else %} {% else %}

@ -8,7 +8,7 @@
<aside> <aside>
<div class="i-pict"> <div class="i-pict">
{% if member.profile.avatar %} {% if member.profile.avatar %}
{% thumbnail member.profile.avatar "100x100" crop="center" as im %} {% thumbnail member.profile.avatar "100x100" as im %}
<img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/> <img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
{% endthumbnail %} {% endthumbnail %}
{% else %} {% else %}
@ -48,16 +48,24 @@
<ul class="soc-media-buttons"> <ul class="soc-media-buttons">
{% if member.profile.facebook %} {% if member.profile.facebook %}
<li><a href="{{ member.profile.facebook }}"><img src="{% static 'client/img/soc-medias/sm-icon-fb.png' %}" title="Facebook" alt="Facebook" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="fb" data-url="{{ member.profile.facebook|base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-fb.png' %}" title="Facebook" alt="Facebook" /></a>
</li>
{% endif %} {% endif %}
{% if member.profile.linkedin %} {% if member.profile.linkedin %}
<li><a href="{{ member.profile.linkedin }}"><img src="{% static 'client/img/soc-medias/sm-icon-lin.png' %}" title="LinkedIn" alt="LinkedIn" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="ld" data-url="{{ member.profile.linkedin|base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-lin.png' %}" title="LinkedIn" alt="LinkedIn" /></a>
</li>
{% endif %} {% endif %}
{% if member.profile.vk %} {% if member.profile.vk %}
<li><a href="{{ member.profile.vk }}"><img src="{% static 'client/img/soc-medias/sm-icon-vk.png' %}" title="В контакте" alt="В контакте" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="vk" data-url="{{ member.profile.vk|base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-vk.png' %}" title="В контакте" alt="В контакте" /></a>
</li>
{% endif %} {% endif %}
{% if member.profile.twitter %} {% if member.profile.twitter %}
<li><a href="{{ member.profile.twitter }}"><img src="{% static 'client/img/soc-medias/sm-icon-twit.png' %}" title="Twitter" alt="Twitter" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="tw" data-url="{{ member.profile.twitter|base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-twit.png' %}" title="Twitter" alt="Twitter" /></a>
</li>
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
@ -75,7 +83,7 @@
{% endif %} {% endif %}
{% if member.profile.web_page %} {% if member.profile.web_page %}
<div class="ic-site"> <div class="ic-site">
<a class="icon-ext-link" href="{{ member.profile.web_page }}" target="_blank">{{ member.profile.web_page }}</a> <a target="_blank" href="#" data-type="href" data-hash="web" data-url="{{ member.profile.web_page|base64_encode }}" class="icon-ext-link link-encode">{{ member.profile.web_page }}</a>
</div> </div>
{% endif %} {% endif %}
</div> </div>

@ -20,7 +20,7 @@
<div id="pick-block" class="pic_block"> <div id="pick-block" class="pic_block">
{% if company.logo %} {% if company.logo %}
{% thumbnail company.logo "100x100" crop="center" as im %} {% thumbnail company.logo "100x100" as im %}
<img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/> <img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
{% endthumbnail %} {% endthumbnail %}
{% else %} {% else %}
@ -186,9 +186,10 @@
</div> </div>
{% with themes=company.theme.all %} {% with themes=company.theme.all %}
<div class="i-area" id="theme-inf" data-theme="{% for th in themes %}{{ th.id }},{% endfor %}"> <div class="i-area" id="theme-inf" data-theme="{% for th in themes %}{{ th.id }},{% endfor %}">
{% for th in themes %} <form class="inline-block" id="theme_form" action="/company/update/theme/{{ company.url }}/" method="post">
<a href="/members/theme/{{ th.url }}">{{ th.name }}</a>{% ifnotequal forloop.counter themes|length %},{% endifnotequal %} {% csrf_token %}
{% endfor %} <div class="tag-select">{{ theme_form.theme }}</div>
</form>
</div> </div>
{% endwith %} {% endwith %}

@ -9,7 +9,7 @@
<aside> <aside>
<div class="i-pict"> <div class="i-pict">
{% if company.logo %} {% if company.logo %}
{% thumbnail company.logo "100x100" crop="center" as im %} {% thumbnail company.logo "100x100" as im %}
<img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/> <img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
{% endthumbnail %} {% endthumbnail %}
{% else %} {% else %}
@ -53,16 +53,24 @@
--> -->
<ul class="soc-media-buttons"> <ul class="soc-media-buttons">
{% if company.facebook %} {% if company.facebook %}
<li><a href="{{ company.facebook }}"><img src="{% static 'client/img/soc-medias/sm-icon-fb.png' %}" title="Facebook" alt="Facebook" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="fb" data-url="{{ company.facebook |base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-fb.png' %}" title="Facebook" alt="Facebook" /></a>
</li>
{% endif %} {% endif %}
{% if company.linkedin %} {% if company.linkedin %}
<li><a href="{{ company.linkedin }}"><img src="{% static 'client/img/soc-medias/sm-icon-lin.png' %}" title="LinkedIn" alt="LinkedIn" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="ld" data-url="{{ company.linkedin|base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-lin.png' %}" title="LinkedIn" alt="LinkedIn" /></a>
</li>
{% endif %} {% endif %}
{% if company.vk %} {% if company.vk %}
<li><a href="{{ company.vk }}"><img src="{% static 'client/img/soc-medias/sm-icon-vk.png' %}" title="В контакте" alt="В контакте" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="vk" data-url="{{ company.vk|base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-vk.png' %}" title="В контакте" alt="В контакте" /></a>
</li>
{% endif %} {% endif %}
{% if company.twitter %} {% if company.twitter %}
<li><a href="{{ company.twitter }}"><img src="{% static 'client/img/soc-medias/sm-icon-twit.png' %}" title="Twitter" alt="Twitter" /></a></li> <li>
<a target="_blank" href="#" data-type="href" data-hash="tw" data-url="{{ company.twitter|base64_encode }}" class="link-encode"><img src="{% static 'client/img/soc-medias/sm-icon-twit.png' %}" title="Twitter" alt="Twitter" /></a>
</li>
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
@ -80,7 +88,7 @@
{% endif %} {% endif %}
{% if company.web_page %} {% if company.web_page %}
<div class="ic-site"> <div class="ic-site">
<a class="icon-ext-link" href="{{ company.web_page }}" target="_blank">{{ company.web_page }}</a> <a target="_blank" href="#" data-type="href" data-hash="web" data-url="{{ company.web_page|base64_encode }}" class="icon-ext-link link-encode">{{ company.web_page }}</a>
</div> </div>
{% endif %} {% endif %}
</div> </div>

@ -362,6 +362,7 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
{% include 'client/popups/advertise_member.html' with form=advertising_form %}
{% endif %} {% endif %}
<!-- <!--
<div class="abn"><a href="#"><img src="{% static 'client/img/_del-temp/banner-2.gif' %}" alt="" /></a></div> <div class="abn"><a href="#"><img src="{% static 'client/img/_del-temp/banner-2.gif' %}" alt="" /></a></div>
@ -377,6 +378,10 @@
{% endblock %} {% endblock %}
{% block content_text %} {% block content_text %}
{% endblock %} {% endblock %}
{% block popup %}
{% include 'client/popups/advertise_member.html' with form=advertising_form %}
{% endblock %}
{% block scripts %} {% block scripts %}
<!-- todo: вернуть .min--> <!-- todo: вернуть .min-->
<!--<script src="{% static 'client/js' %}{% if debug %}/{% else %}_min/{% endif %}_modules/page.exposition.object{% if debug %}{% else %}.min{% endif %}.js"></script>--> <!--<script src="{% static 'client/js' %}{% if debug %}/{% else %}_min/{% endif %}_modules/page.exposition.object{% if debug %}{% else %}.min{% endif %}.js"></script>-->

@ -1,4 +1,5 @@
{% load static %} {% load static %}
{% load thumbnail %}
{% if obj.get_logo %} {% if obj.get_logo %}
{# delete after changing all logos #} {# delete after changing all logos #}
@ -9,5 +10,12 @@
{% endif %} {% endif %}
{% else %} {% else %}
<img src="{% static 'client/img/no-logo.png' %}" class="no-logo" alt="" /> {% if obj.logo %}
{% thumbnail obj.logo "100x100" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
{% endthumbnail %}
{% else %}
<img src="{% static 'client/img/no-logo.png' %}" class="no-logo" alt="" />
{% endif %}
{% endif %} {% endif %}

@ -0,0 +1,47 @@
{% load static %}
{% load i18n %}
<div id="pw-advertise" class="popup-window">
<header class="clearfix">
<div class="pw-title">{% trans 'Рекламировать участника' %}</div>
</header>
<div class="pw-body clearfix">
<form id="advertise_form" method="post" class="pw-form" action="{{ form.action }}">{% csrf_token %}
<div class="pwf-line">
<div class="pwf-field required">
{{ form.person_inf }}
</div>
</div>
<div class="pwf-line">
<div class="pwf-field required">
{{ form.person }}
</div>
</div>
<div class="pwf-line">
<div class="pwf-field required">
{{ form.phone }}
</div>
</div>
<div class="pwf-line">
<div class="pwf-field select-input required">
{{ form.country }}
</div>
</div>
<div class="pwf-line">
<div class="pwf-field select-input required">
{{ form.city }}
</div>
</div>
<div class="pwf-buttons-line">
<button type="submit" class="icon-check">{% trans 'Рекламировать' %}</button>
</div>
</form>
</div>
</div>
Loading…
Cancel
Save