diff --git a/functions/form_check.py b/functions/form_check.py index 93f03cdd..2b14aec5 100644 --- a/functions/form_check.py +++ b/functions/form_check.py @@ -31,3 +31,6 @@ def translit_with_separator(string, separator='-'): st = re.sub('%s+'%separator, separator, st) return st + +#def check_url(url, id, Model, field='url', msg='Такой урл уже занят'): +# try: diff --git a/proj/settings.py b/proj/settings.py index 947c77fb..73a67302 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -141,20 +141,24 @@ TEMPLATE_DIRS = ( # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. '/home/kotzilla/Documents/qwer/proj/templates', - '/home/kotzilla/Documents/qwer/proj/country/tamplates', - '/home/kotzilla/Documents/qwer/proj/city/templates', - '/home/kotzilla/Documents/qwer/proj/directories/templates', - '/home/kotzilla/Documents/qwer/proj/proj/templates', - '/home/kotzilla/Documents/qwer/proj/theme/templates', - '/home/kotzilla/Documents/qwer/proj/service/templates', - '/home/kotzilla/Documents/qwer/proj/article/templates', - '/home/kotzilla/Documents/qwer/proj/place_conference/templates', - '/home/kotzilla/Documents/qwer/proj/place_exposition/templates', - '/home/kotzilla/Documents/qwer/proj/conference/templates', - '/home/kotzilla/Documents/qwer/proj/exposition/templates', - '/home/kotzilla/Documents/qwer/proj/webinar/templates', - '/home/kotzilla/Documents/qwer/proj/seminar/templates', - '/home/kotzilla/Documents/qwer/proj/news/templates', + '/home/kotzilla/Documents/qwer/proj/templates/admin/accounts', + '/home/kotzilla/Documents/qwer/proj/templates/admin/article', + '/home/kotzilla/Documents/qwer/proj/templates/admin/country', + '/home/kotzilla/Documents/qwer/proj/templates/admin/city', + '/home/kotzilla/Documents/qwer/proj/templates/admin/company', + '/home/kotzilla/Documents/qwer/proj/templates/admin/conference', + '/home/kotzilla/Documents/qwer/proj/templates/admin/directories', + '/home/kotzilla/Documents/qwer/proj/templates/admin/exposition', + '/home/kotzilla/Documents/qwer/proj/templates/admin/news', + '/home/kotzilla/Documents/qwer/proj/templates/admin/organiser', + '/home/kotzilla/Documents/qwer/proj/templates/admin/place_conference', + '/home/kotzilla/Documents/qwer/proj/templates/admin/place_exposition', + '/home/kotzilla/Documents/qwer/proj/templates/admin/proj', + '/home/kotzilla/Documents/qwer/proj/templates/admin/seminar', + '/home/kotzilla/Documents/qwer/proj/templates/admin/service', + '/home/kotzilla/Documents/qwer/proj/templates/admin/theme', + '/home/kotzilla/Documents/qwer/proj/templates/admin/webinar', + ) AUTH_USER_MODEL = 'accounts.User' diff --git a/service/forms.py b/service/forms.py index 90874334..0f79ca5e 100644 --- a/service/forms.py +++ b/service/forms.py @@ -10,6 +10,10 @@ from models import Review, Service from country.models import Country, City from functions.form_check import translit_with_separator + +from django.forms.util import ErrorList + + class ServiceForm(forms.Form): europa = forms.ModelMultipleChoiceField(queryset=Country.objects.filter(region='europa'), required=False, @@ -31,6 +35,8 @@ class ServiceForm(forms.Form): currency_list = [('USD','USD'), ('EUR','EUR'), ('RUB','RUB')] currency = forms.ChoiceField(choices=currency_list) + service_id = forms.CharField(required=False, widget=forms.HiddenInput()) + def __init__(self, *args, **kwargs): @@ -92,12 +98,32 @@ class ServiceForm(forms.Form): update(services = F('services').bitand(~getattr(Country.services, str(service.id)))) + + + + def clean(self): + id = self.cleaned_data.get('service_id') + url = self.cleaned_data.get('url') + + try: + service = Service.objects.get(url=translit_with_separator(url)) + if (str(service.id) != str(id)): + msg = 'Такой урл уже занят' + self._errors['url'] = ErrorList([msg]) + del self.cleaned_data['url'] + except: + pass + + return self.cleaned_data + + def clean_url(self): """ check name which must be unique because it generate slug field """ cleaned_data = super(ServiceForm, self).clean() url = cleaned_data.get('url') + id = cleaned_data.get('service_id') try: service = Service.objects.get(url=translit_with_separator(url)) if (translit_with_separator(url) == service.url): diff --git a/service/urls.py b/service/urls.py index ba1208a2..e72a1681 100644 --- a/service/urls.py +++ b/service/urls.py @@ -7,6 +7,7 @@ urlpatterns = patterns('', url(r'^all/$', 'service.views.service_all'), url(r'^get_city/$', 'service.views.get_city'), + url(r'^get_country/$', 'service.views.get_country'), url(r'^review/add.*/$', 'service.views.review_add'), url(r'^review/change/(?P\d+).*/$', 'service.views.review_change'), diff --git a/service/views.py b/service/views.py index 06b28e7a..3c143e9e 100644 --- a/service/views.py +++ b/service/views.py @@ -54,6 +54,8 @@ def service_change(request, url): data['asia'] = services_in_countries data['africa'] = services_in_countries data['america'] = services_in_countries + #hidden field + data['service_id'] = service_id data['url'] = service.url @@ -141,8 +143,14 @@ def review_change(request, review_id): return render_to_response('review_add.html', args) +def get_country(request): + if request.GET: + country_region = request.GET['region'] + countries = Country.objects.filter(region=country_region) + return render_to_response('checkbox_option.html', {'options': countries}) + def get_city(request): if request.GET: country_id = request.GET['id'] - City.objects.filter(country=country_id) - return HttpResponse(id) \ No newline at end of file + cities = City.objects.filter(country=country_id) + return render_to_response('checkbox_option.html', {'options': cities}) \ No newline at end of file diff --git a/static/custom_js/service.js b/static/custom_js/service.js index 4ead68c0..6533f3a1 100644 --- a/static/custom_js/service.js +++ b/static/custom_js/service.js @@ -1,15 +1,33 @@ $(document).ready(function(){ - $("input:checkbox[name='europa'] ").click(function(){ - if ($(this).is(':checked')){ + $('.toggle').click(function(){ + $(this).parent().next().toggle(); + return false; + }); + $('.check').click(function(){ + var $input = $(this).prev(); + if ($input.is(':checked')){ + $input.prop('checked', false); + $input.parent().next().find('input').prop('checked', false); + } + else{ + $input.prop('checked', true); + $input.parent().next().find('input').prop('checked', true); + } + return false; + }); + $("input:checkbox[name='europa'] ").change(function(){ + var $this = $(this); + if ($this.is(':checked')){ $.get( "/service/get_city/", {'id': $(this).val()}, function(j){ - console.log(j); + $this.parent().after(j); + console.log($this); }); } else{ - console.log('false'); + $this.parent().next().remove(); } }) }); diff --git a/templates/admin/accounts/create_admin.html b/templates/admin/accounts/create_admin.html new file mode 100644 index 00000000..14db2814 --- /dev/null +++ b/templates/admin/accounts/create_admin.html @@ -0,0 +1,68 @@ +{% extends 'base.html' %} +{% load static %} + +{% block scripts %} +{% endblock %} + +{% block body%} +
{% csrf_token %} +
+ Создать администратора + +
+
+

+
+
+ {# email #} +
+ +
+ {{ form.email }} + {{ form.email.errors }} +
+
+ {# password1 #} +
+ +
+ {{ form.password1 }} + {{ form.password1.errors }} +
+
+ {# password2 #} +
+ +
+ {{ form.password2 }} + {{ form.password2.errors }} +
+
+ {# first_name #} +
+ +
+ {{ form.first_name }} + {{ form.first_name.errors }} +
+
+ {# last_name #} +
+ +
+ {{ form.last_name }} + {{ form.last_name.errors }} +
+
+
+
+ +
+ + +
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/admin/accounts/translator_change.html b/templates/admin/accounts/translator_change.html new file mode 100644 index 00000000..e738d55b --- /dev/null +++ b/templates/admin/accounts/translator_change.html @@ -0,0 +1,75 @@ +{% extends 'base.html' %} + + +{% block body %} +
{% csrf_token %} +
+ Изменить переводчика + +
+
+

Информация

+
+
+ {# education #} +
+ +
{{ form.education }} + {{ form.education.errors }} +
+
+ {# specialization #} +
+ +
{{ form.specialization }} + {{ form.specialization.errors }} +
+
+ {# languages #} +
+ +
{{ form.languages }} + {{ form.languages.errors }} +
+
+ {# native_language #} +
+ +
{{ form.native_language }} + {{ form.native_language.errors }} +
+
+ {# car #} +
+ +
{{ form.car }} + {{ form.car.errors }} +
+
+ {# prices #} +
+ +
{{ form.prices }} + {{ form.prices.errors }} +
+
+ {# discounts #} +
+ +
{{ form.discounts }} + {{ form.discounts.errors }} +
+
+
+
+ +
+ + +
+ + +
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/admin/accounts/translators.html b/templates/admin/accounts/translators.html new file mode 100644 index 00000000..bb32209c --- /dev/null +++ b/templates/admin/accounts/translators.html @@ -0,0 +1,60 @@ +{% extends 'base.html' %} + +{% block body %} +
+
+

Список переводчиков

+
+
+ + + + + + + + + + + + {% for item in objects %} + + + + + + + {% if item.is_translator %} + + {% else %} + + {% endif %} + + + + {% endfor %} + +
idEmailПолное имяПереводчик 
{{ item.id }}{{ item.email }}{{ item.get_full_name }}Да  + + Изменить + +
+ +
+ {# pagination #} + + +
+ + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/accounts/user_all.html b/templates/admin/accounts/user_all.html new file mode 100644 index 00000000..68a7dcdd --- /dev/null +++ b/templates/admin/accounts/user_all.html @@ -0,0 +1,68 @@ +{% extends 'base.html' %} +{% load static %} + +{% block body %} + +
+
+

Список пользователей

+
+
+ + + + + + + + + + + + + {% for item in objects %} + + + + + + {% if item.is_admin %} + + {% else %} + + {% endif %} + + {% if item.is_translator %} + + {% else %} + + {% endif %} + + + + {% endfor %} + +
idEmailПолное имяАдминПереводчик 
{{ item.id }}{{ item.email }}{{ item.get_full_name }}Да Да  + + Изменить + +
+ +
+ {# pagination #} + + +
+ + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/accounts/user_change.html b/templates/admin/accounts/user_change.html new file mode 100644 index 00000000..a4f6705e --- /dev/null +++ b/templates/admin/accounts/user_change.html @@ -0,0 +1,220 @@ +{% extends 'base.html' %} +{% load static %} + +{% block scripts %} + + + {# selects #} + + + + + + + +{% endblock %} + +{% block body %} +
{% csrf_token %} +
+ Изменить пользователя + +
+
+

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

+
+
+ {{ form.user_id }} + {# email #} +
+ +
+ {{ form.email }} + {{ form.email.errors }} +
+
+ {# first_name #} +
+ +
+ {{ form.first_name }} + {{ form.first_name.errors }} +
+
+ {# last_name #} +
+ +
+ {{ form.last_name }} + {{ form.last_name.errors }} +
+
+ {# url #} +
+ +
+ {{ form.url }} + {{ form.url.errors }} +
+
+ {# country #} +
+ +
+ {{ form.country }} + {{ form.country.errors }} +
+
+ {# city #} +
+ +
+ {{ form.city }} + {{ form.city.errors }} +
+
+ {# position #} +
+ +
+ {{ form.position }} + {{ form.position.errors }} +
+
+
+
+ +
+
+

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

+
+
+ {# avatar #} +
+ +
+ {{ form.avatar }} + {{ form.avatar.errors }} +
+
+ {# about #} +
+ +
+ {{ form.about }} + {{ form.about.errors }} +
+
+ {# phone #} +
+ +
+ {{ form.phone }} + {{ form.phone.errors }} +
+
+ {# web_page #} +
+ +
+ {{ form.web_page }} + {{ form.web_page.errors }} +
+
+ {# social #} +
+ +
+ {{ form.social }} + {{ form.social.errors }} +
+
+ {# company #} +
+ +
+ {{ form.company }} + {{ form.company.errors }} +
+
+ {# organiser #} +
+ +
+ {{ form.organiser }} + {{ form.organiser.errors }} +
+
+ {# is_translator #} +
+ +
+ {{ form.is_translator }} + {{ form.is_translator.errors }} +
+
+
+
+
+
+

Мета данные

+
+
+ {# descriptions #} +
+ +
+ {{ form.descriptions }} + {{ form.descriptions.errors }} +
+
+ {# title #} +
+ +
+ {{ form.title }} + {{ form.title.errors }} +
+
+ {# keywords #} + + +
+ {{ form.keywords }} + {{ form.keywords.errors }} +
+
+ +
+ +
+ + +
+ + +
+
+ + + +{% comment %} +{% for field in form %} + + {{ field }} + +{% endfor %} +{% endcomment %} + +{% endblock %} \ No newline at end of file diff --git a/article/templates/article_add.html b/templates/admin/article/article_add.html similarity index 100% rename from article/templates/article_add.html rename to templates/admin/article/article_add.html diff --git a/article/templates/article_all.html b/templates/admin/article/article_all.html similarity index 100% rename from article/templates/article_all.html rename to templates/admin/article/article_all.html diff --git a/city/templates/city_add.html b/templates/admin/city/city_add.html similarity index 100% rename from city/templates/city_add.html rename to templates/admin/city/city_add.html diff --git a/city/templates/city_all.html b/templates/admin/city/city_all.html similarity index 100% rename from city/templates/city_all.html rename to templates/admin/city/city_all.html diff --git a/company/templates/company_add.html b/templates/admin/company/company_add.html similarity index 100% rename from company/templates/company_add.html rename to templates/admin/company/company_add.html diff --git a/company/templates/company_all.html b/templates/admin/company/company_all.html similarity index 100% rename from company/templates/company_all.html rename to templates/admin/company/company_all.html diff --git a/conference/templates/conference_add.html b/templates/admin/conference/conference_add.html similarity index 100% rename from conference/templates/conference_add.html rename to templates/admin/conference/conference_add.html diff --git a/conference/templates/conference_all.html b/templates/admin/conference/conference_all.html similarity index 100% rename from conference/templates/conference_all.html rename to templates/admin/conference/conference_all.html diff --git a/country/tamplates/country_add.html b/templates/admin/country/country_add.html similarity index 100% rename from country/tamplates/country_add.html rename to templates/admin/country/country_add.html diff --git a/country/tamplates/country_all.html b/templates/admin/country/country_all.html similarity index 100% rename from country/tamplates/country_all.html rename to templates/admin/country/country_all.html diff --git a/directories/templates/directories_add.html b/templates/admin/directories/directories_add.html similarity index 100% rename from directories/templates/directories_add.html rename to templates/admin/directories/directories_add.html diff --git a/directories/templates/directories_ajax.html b/templates/admin/directories/directories_ajax.html similarity index 100% rename from directories/templates/directories_ajax.html rename to templates/admin/directories/directories_ajax.html diff --git a/exposition/templates/exposition_add.html b/templates/admin/exposition/exposition_add.html similarity index 100% rename from exposition/templates/exposition_add.html rename to templates/admin/exposition/exposition_add.html diff --git a/exposition/templates/exposition_all.html b/templates/admin/exposition/exposition_all.html similarity index 100% rename from exposition/templates/exposition_all.html rename to templates/admin/exposition/exposition_all.html diff --git a/news/templates/news_add.html b/templates/admin/news/news_add.html similarity index 100% rename from news/templates/news_add.html rename to templates/admin/news/news_add.html diff --git a/news/templates/news_all.html b/templates/admin/news/news_all.html similarity index 100% rename from news/templates/news_all.html rename to templates/admin/news/news_all.html diff --git a/organiser/templates/organiser_add.html b/templates/admin/organiser/organiser_add.html similarity index 100% rename from organiser/templates/organiser_add.html rename to templates/admin/organiser/organiser_add.html diff --git a/organiser/templates/organiser_all.html b/templates/admin/organiser/organiser_all.html similarity index 100% rename from organiser/templates/organiser_all.html rename to templates/admin/organiser/organiser_all.html diff --git a/place_conference/templates/place_conference_add.html b/templates/admin/place_conference/place_conference_add.html similarity index 100% rename from place_conference/templates/place_conference_add.html rename to templates/admin/place_conference/place_conference_add.html diff --git a/place_conference/templates/place_conference_all.html b/templates/admin/place_conference/place_conference_all.html similarity index 100% rename from place_conference/templates/place_conference_all.html rename to templates/admin/place_conference/place_conference_all.html diff --git a/place_exposition/templates/place_exposition_add.html b/templates/admin/place_exposition/place_exposition_add.html similarity index 100% rename from place_exposition/templates/place_exposition_add.html rename to templates/admin/place_exposition/place_exposition_add.html diff --git a/place_exposition/templates/place_exposition_all.html b/templates/admin/place_exposition/place_exposition_all.html similarity index 100% rename from place_exposition/templates/place_exposition_all.html rename to templates/admin/place_exposition/place_exposition_all.html diff --git a/proj/templates/settings.html b/templates/admin/proj/settings.html similarity index 100% rename from proj/templates/settings.html rename to templates/admin/proj/settings.html diff --git a/seminar/templates/seminar_add.html b/templates/admin/seminar/seminar_add.html similarity index 100% rename from seminar/templates/seminar_add.html rename to templates/admin/seminar/seminar_add.html diff --git a/seminar/templates/seminar_all.html b/templates/admin/seminar/seminar_all.html similarity index 100% rename from seminar/templates/seminar_all.html rename to templates/admin/seminar/seminar_all.html diff --git a/templates/admin/service/checkbox_option.html b/templates/admin/service/checkbox_option.html new file mode 100644 index 00000000..d0f1ced0 --- /dev/null +++ b/templates/admin/service/checkbox_option.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/service/templates/review_add.html b/templates/admin/service/review_add.html similarity index 100% rename from service/templates/review_add.html rename to templates/admin/service/review_add.html diff --git a/service/templates/review_all.html b/templates/admin/service/review_all.html similarity index 100% rename from service/templates/review_all.html rename to templates/admin/service/review_all.html diff --git a/service/templates/service_add.html b/templates/admin/service/service_add.html similarity index 75% rename from service/templates/service_add.html rename to templates/admin/service/service_add.html index e6edb3c9..8b5fa8fa 100644 --- a/service/templates/service_add.html +++ b/templates/admin/service/service_add.html @@ -16,6 +16,14 @@ .region{ display: none; } + .country_child{ + margin-left: 20px; + } + + .toggle{ + border: none; + box-shadow: none; + } @@ -34,6 +42,7 @@

Информация о услуге

+ {{ form.service_id }} {# name #} {% with field='name' form=form languages=languages %} {% include 'admin/forms/multilang.html' %} @@ -70,13 +79,29 @@
-

{{ form.europa.label }}:

+

+ + {{ form.europa.label }} + +

{{ form.europa }} -

{{ form.asia.label }}:

+

+ + {{ form.asia.label }} + +

{{ form.asia }} -

{{ form.america.label }}:

+

+ + {{ form.america.label }} + +

{{ form.america }} -

{{ form.africa.label }}:

+

+ + {{ form.africa.label }} + +

{{ form.africa }}
diff --git a/service/templates/service_all.html b/templates/admin/service/service_all.html similarity index 100% rename from service/templates/service_all.html rename to templates/admin/service/service_all.html diff --git a/theme/templates/tag_add.html b/templates/admin/theme/tag_add.html similarity index 100% rename from theme/templates/tag_add.html rename to templates/admin/theme/tag_add.html diff --git a/theme/templates/tag_all.html b/templates/admin/theme/tag_all.html similarity index 100% rename from theme/templates/tag_all.html rename to templates/admin/theme/tag_all.html diff --git a/theme/templates/theme_add.html b/templates/admin/theme/theme_add.html similarity index 100% rename from theme/templates/theme_add.html rename to templates/admin/theme/theme_add.html diff --git a/theme/templates/theme_all.html b/templates/admin/theme/theme_all.html similarity index 100% rename from theme/templates/theme_all.html rename to templates/admin/theme/theme_all.html diff --git a/webinar/templates/webinar_add.html b/templates/admin/webinar/webinar_add.html similarity index 100% rename from webinar/templates/webinar_add.html rename to templates/admin/webinar/webinar_add.html diff --git a/webinar/templates/webinar_all.html b/templates/admin/webinar/webinar_all.html similarity index 100% rename from webinar/templates/webinar_all.html rename to templates/admin/webinar/webinar_all.html