diff --git a/accounts/forms.py b/accounts/forms.py
index 3934bcf8..93161e6a 100644
--- a/accounts/forms.py
+++ b/accounts/forms.py
@@ -90,6 +90,9 @@ class UserForm(forms.ModelForm):
def clean_web_page(self):
cleaned_data = super(UserForm, self).clean()
web_page = cleaned_data.get('web_page')
+ if not web_page:
+ return web_page
+
import socket
try:
socket.getaddrinfo(web_page, 80)
diff --git a/accounts/templates/user_change.html b/accounts/templates/user_change.html
index 48ded337..a4f6705e 100644
--- a/accounts/templates/user_change.html
+++ b/accounts/templates/user_change.html
@@ -35,6 +35,7 @@
+ {{ form.user_id }}
{# email #}
diff --git a/accounts/urls.py b/accounts/urls.py
index 976f16ed..49c5e718 100644
--- a/accounts/urls.py
+++ b/accounts/urls.py
@@ -7,7 +7,8 @@ urlpatterns = patterns('',
url(r'^logout', logout, {'next_page': '/accounts/login/'}),
url(r'^create_admin/$', 'accounts.views.create_admin'),
url(r'^create_md5user/$', 'accounts.views.create_md5'),
- url(r'^change/(?P\d+).*/$', 'accounts.views.user_change'),
+ url(r'^change/(.*)/$', 'accounts.views.user_change'),
+# url(r'^change/(?P\d+).*/$', 'accounts.views.user_change'),
url(r'^all/$', 'accounts.views.user_all'),
url(r'^translators/$', 'accounts.views.translators'),
url(r'^translators/(?P\d+)/$', 'accounts.views.translator_change'),
diff --git a/accounts/views.py b/accounts/views.py
index 90e45e90..da46e646 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -56,13 +56,18 @@ def translator_change(request, user_id):
-def user_change(request, user_id):
+def user_change(request, url):
"""
Return form of user and post it on the server.
If form is posted redirect on the page of all users.
"""
try:
- user = User.objects.get(id=user_id)
+ try:
+ user = User.objects.get(id=url)
+ user_id = getattr(user, 'id')
+ except:
+ user = User.objects.get(url=url)
+ user_id = getattr(user, 'id')
except:
return HttpResponseRedirect('/accounts/all')
diff --git a/city/models.py b/city/models.py
index 101dc642..e11df6bc 100644
--- a/city/models.py
+++ b/city/models.py
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
from django.db import models
from hvad.models import TranslatableModel, TranslatedFields
+from bitfield import BitField
# my models
from directories.models import Iata
+from service.models import Service
class City(TranslatableModel):
@@ -12,6 +14,18 @@ class City(TranslatableModel):
Uses hvad.TranslatableModel which is child of django.db.models class
"""
+ flags = []
+ """
+ ids = [item.id for item in Service.objects.all() ]
+ if len(ids):
+ max = sorted(ids)[-1]
+ for i in range(max):
+ flags.append(str(i))
+ """
+
+
+ services = BitField(flags=flags)
+
url = models.SlugField(unique=True)
country = models.ForeignKey('country.Country', null=True)
population = models.PositiveIntegerField(blank=True, null=True)
diff --git a/country/admin.py b/country/admin.py
index b1e54c7c..495a1fa8 100644
--- a/country/admin.py
+++ b/country/admin.py
@@ -2,8 +2,15 @@
from django.contrib import admin
from hvad.admin import TranslatableAdmin
from models import Country
+from bitfield import BitField
+from bitfield.forms import BitFieldCheckboxSelectMultiple
+from bitfield.admin import BitFieldListFilter
+
class CountryAdmin(TranslatableAdmin):
- pass
+ formfield_overrides = {
+ BitField: {'widget': BitFieldCheckboxSelectMultiple},
+ }
+
admin.site.register(Country, CountryAdmin)
diff --git a/country/models.py b/country/models.py
index 2f47e415..69433bc9 100644
--- a/country/models.py
+++ b/country/models.py
@@ -5,8 +5,10 @@ from django.contrib.contenttypes import generic
#models
from directories.models import Language, Currency
from city.models import City
+from service.models import Service
#func
from functions.custom_fields import EnumField
+from bitfield import BitField
class Country(TranslatableModel):
"""
@@ -15,6 +17,18 @@ class Country(TranslatableModel):
Uses hvad.TranslatableModel which is child of django.db.models class
"""
+ flags = []
+
+ try:
+ ids = [item.id for item in Service.objects.all() ]
+ max = sorted(ids)[-1]
+ for i in range(max):
+ flags.append(str(i))
+ except: pass
+
+ services = BitField(flags=flags)
+
+
REGIONS =('europa', 'asia', 'america', 'africa')
url = models.SlugField(unique=True)
diff --git a/country/views.py b/country/views.py
index caed66bf..5b15c09b 100644
--- a/country/views.py
+++ b/country/views.py
@@ -97,4 +97,3 @@ def country_change(request, url):
args['obj_id'] = country_id
return render_to_response('country_add.html', args)
-
diff --git a/organiser/forms.py b/organiser/forms.py
index 65d60703..b55c525a 100644
--- a/organiser/forms.py
+++ b/organiser/forms.py
@@ -9,6 +9,7 @@ from country.models import Country
from city.models import City
from theme.models import Theme
from place_exposition.models import PlaceExposition
+from place_conference.models import PlaceConference
#functions
from functions.translate import populate_all, fill_trans_fields_all
from functions.form_check import is_positive_integer
@@ -24,9 +25,12 @@ class OrganiserForm(forms.Form):
save function saves data in Organiser object. If it doesnt exist create new object
"""
+ url = forms.CharField(label='url', required=False)
+
country = forms.ModelChoiceField(label='Страна', queryset=Country.objects.all(), empty_label=None)
theme = forms.ModelMultipleChoiceField(label='Тематики', queryset=Theme.objects.all())
- place = forms.ModelMultipleChoiceField(label='Место проведения', queryset=PlaceExposition.objects.all(), required=False)
+ place_exposition = forms.ModelMultipleChoiceField(label='Места проведения выставок', queryset=PlaceExposition.objects.all(), required=False)
+ place_conference = forms.ModelMultipleChoiceField(label='Места проведения конференций', queryset=PlaceConference.objects.all(), required=False)
#creates select input with empty choices cause it will be filled with ajax
city = forms.ChoiceField(label='Город', choices=[('','')])
tag = forms.MultipleChoiceField(label='Теги', required=False)
@@ -49,7 +53,6 @@ class OrganiserForm(forms.Form):
widget=forms.TextInput(attrs={'placeholder': 'Количество'}))
foundation = forms.CharField(label='Год основания', required=False,
widget=forms.TextInput(attrs={'placeholder': 'Год основания'}))
- own_place = forms.BooleanField(label='Собственные площадки', required=False)
#field for comparing tmp files
key = forms.CharField(required=False, widget=forms.HiddenInput())
@@ -98,9 +101,11 @@ class OrganiserForm(forms.Form):
organiser = Organiser.objects.get(id=id)
organiser.theme.clear()
organiser.tag.clear()
- organiser.place.clear()
+ organiser.place_conference.clear()
+ organiser.place_exposition.clear()
#simple fields
+ organiser.url = data['url']
organiser.address = data['address']
organiser.phone = data['phone']
organiser.fax = data['fax']
@@ -108,7 +113,6 @@ class OrganiserForm(forms.Form):
organiser.email = data['email']
organiser.foundation = data['foundation']
organiser.social = data['social']
- organiser.own_place = data['own_place']
organiser.staff_number = data['staff_number']
organiser.events_number = data['events_number']
@@ -129,9 +133,11 @@ class OrganiserForm(forms.Form):
for item in data['tag']:
organiser.tag.add(item)
+ for item in data['place_exposition']:
+ organiser.place_exposition.add(item.id)#.id cause select uses queryset
- for item in data['place']:
- organiser.place.add(item.id)#.id cause select uses queryset
+ for item in data['place_conference']:
+ organiser.place_conference.add(item.id)#.id cause select uses queryset
# uses because in the next loop data will be overwritten
organiser.save()
@@ -148,6 +154,11 @@ class OrganiserForm(forms.Form):
#save files
check_tmp_files(organiser, data['key'])
+ def clean_url(self):
+ cleaned_data = super(OrganiserForm, self).clean()
+ url = cleaned_data.get('url').strip()
+ return url
+
def clean_foundation(self):
"""
checking foundation
diff --git a/organiser/models.py b/organiser/models.py
index ef555cdd..c3300531 100644
--- a/organiser/models.py
+++ b/organiser/models.py
@@ -4,6 +4,7 @@ from hvad.models import TranslatableModel, TranslatedFields
from accounts.models import User
from django.db.models.signals import post_save
#custom functions
+from functions.translate import fill_trans_fields_all, populate_all
from functions.custom_fields import LocationField
from functions.form_check import translit_with_separator
@@ -24,7 +25,7 @@ class Organiser(TranslatableModel):
theme = models.ManyToManyField('theme.Theme', verbose_name='Отрасль', blank=True, null=True)
tag = models.ManyToManyField('theme.Tag', verbose_name='Теги', blank=True, null=True)
#address. uses LocationField. saves data in json format
- address = LocationField(verbose_name='Адресс', blank=True)
+ address = LocationField(verbose_name='Адресс', blank=True, null=True)
phone = models.FloatField(verbose_name='Телефон', blank=True, null=True)
fax = models.FloatField(verbose_name='Факс', blank=True, null=True)
diff --git a/organiser/templates/organiser_add.html b/organiser/templates/organiser_add.html
index 2a9089a4..6452f30d 100644
--- a/organiser/templates/organiser_add.html
+++ b/organiser/templates/organiser_add.html
@@ -144,18 +144,18 @@
{{ form.staff_number.errors }}
- {# own_place #}
-