фикс отображения стран в админке

remotes/origin/HEAD
Slava Kyrachevsky 9 years ago
parent 6c3b3091fb
commit 560e8ae437
  1. 2
      apps/conference/forms.py
  2. 2
      apps/exposition/forms.py
  3. 2
      apps/place_exposition/forms.py
  4. 2
      proj/admin.py
  5. 27
      static/custom_js/main.js
  6. 8
      templates/c_admin/place_exposition/place_exposition.html

@ -56,7 +56,7 @@ class ConferenceCreateForm(forms.Form):
#organiser = forms.MultipleChoiceField(label=u'Организаторы', required=False, #organiser = forms.MultipleChoiceField(label=u'Организаторы', required=False,
# choices=[(item.id, item.name) for item in Organiser.objects.language().all()]) # choices=[(item.id, item.name) for item in Organiser.objects.language().all()])
org = forms.CharField(required=False, label=_(u'Организатор')) org = forms.CharField(required=False, label=_(u'Организатор'))
country = forms.ChoiceField(label=_(u'Страна'), choices=[(c.id, c.name) for c in Country.objects.language().all()]) country = forms.ChoiceField(label=_(u'Страна'), choices=list(set([(c.id, c.name) for c in Country.objects.language().all()])))
theme = forms.MultipleChoiceField(label=_(u'Тематики'), theme = forms.MultipleChoiceField(label=_(u'Тематики'),
choices=[(item.id, item.name) for item in Theme.objects.language().all()]) choices=[(item.id, item.name) for item in Theme.objects.language().all()])

@ -49,7 +49,7 @@ class ExpositionCreateForm(forms.Form):
#company = forms.MultipleChoiceField(label=u'Компании', required=False, #company = forms.MultipleChoiceField(label=u'Компании', required=False,
# choices=[(item.id, item.name) for item in Company.objects.language().all()] ) # choices=[(item.id, item.name) for item in Company.objects.language().all()] )
country = forms.ChoiceField(label=_(u'Страна'), choices=[(c.id, c.name) for c in Country.objects.language().all()]) country = forms.ChoiceField(label=_(u'Страна'), choices=list(set([(c.id, c.name) for c in Country.objects.language().all()])))
theme = forms.MultipleChoiceField( theme = forms.MultipleChoiceField(
label=_(u'Тематики'), label=_(u'Тематики'),
choices=[(item.id, item.name) for item in Theme.objects.language().filter(types=Theme.types.exposition)]) choices=[(item.id, item.name) for item in Theme.objects.language().filter(types=Theme.types.exposition)])

@ -30,7 +30,7 @@ class ExpositionForm(forms.Form):
type = forms.ChoiceField(required=False, choices=types) type = forms.ChoiceField(required=False, choices=types)
logo = forms.ImageField(label=_(u'Logo'), required=False, max_length=500) logo = forms.ImageField(label=_(u'Logo'), required=False, max_length=500)
country = forms.ChoiceField(label=_(u'Страна'), choices=[(c.id, c.name) for c in Country.objects.language().all()]) country = forms.ChoiceField(label=_(u'Страна'), choices=list(set([(c.id, c.name) for c in Country.objects.language().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=_(u'Город'), widget=forms.HiddenInput()) city = forms.CharField(label=_(u'Город'), widget=forms.HiddenInput())

@ -26,7 +26,7 @@ def ajax_city(request):
returns html <option> tags filled with cities filtered by country value from request returns html <option> tags filled with cities filtered by country value from request
""" """
objects = City.objects.language().filter(country=request.GET['id']).order_by('name') objects = City.objects.language().filter(country=request.GET['id']).order_by('name')
return render_to_response('select.html', {'objects': objects}) return render_to_response('c_admin/select.html', {'objects': objects})
def ajax_tag(request): def ajax_tag(request):

@ -224,18 +224,17 @@ $(document).ready(function(){
$('.off').click(function(){ $('.off').click(function(){
var url = $(this).attr('href') var url = $(this).attr('href')
var $this = $(this) var $this = $(this)
$.get( $.get(url,function(data){
url, function(data){ if (data == 'off'){
if (data == 'off'){ $this.hide();
$this.hide(); $this.siblings('.on').show();
$this.siblings('.on').show(); }
} });
}
)
return false; return false;
}); });
// end on-of events // end on-of events
if( $("#id_city" ).length ) { if( $("#id_city").length ) {
$('#id_city').select2({ $('#id_city').select2({
placeholder: "Город", placeholder: "Город",
width: 'element', width: 'element',
@ -245,7 +244,7 @@ $(document).ready(function(){
dataType: "json", dataType: "json",
quietMillis: 200, quietMillis: 200,
data: function(term, page, country){ data: function(term, page){
var country = $('#id_country').val(); var country = $('#id_country').val();
return {term: term, return {term: term,
page: page, page: page,
@ -253,21 +252,23 @@ $(document).ready(function(){
}, },
results: function (data) { results: function (data) {
console.log('results');
if (typeof(data) == 'string'){ if (typeof(data) == 'string'){
data = JSON.parse(data); data = JSON.parse(data);
} }
console.log(data);
var results = []; var results = [];
$.each(data, function(index, item){ $.each(data, function(index, item){
results.push({ results.push({
id: item.id, id: item.id,
text: item.label text: item.label
}); });
}); });
return {results: results}; return {results: results};
} }
}, },
initSelection : function(element, callback) { initSelection : function(element, callback) {
var id= $(element).val(); var id = $(element).val();
var text = $(element).attr('data-init-text'); var text = $(element).attr('data-init-text');
callback({id: id, text:text}); callback({id: id, text:text});
} }

@ -16,13 +16,13 @@
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script> <script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script>
{# google map не забыть скачать скрипты на локал #} {# google map не забыть скачать скрипты на локал #}
<link href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/redmond/jquery-ui.css' rel="stylesheet"/> <link href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/redmond/jquery-ui.css' rel="stylesheet"/>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> {# <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>#}
<script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js'></script>
<script src='https://maps.google.com/maps/api/js?sensor=false'></script> <script src='https://maps.google.com/maps/api/js?sensor=false'></script>
{# selects #} {# selects #}
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> {# <link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/>#}
<script src="{% static 'js/select/select2.js' %}"></script> {# <script src="{% static 'js/select/select2.js' %}"></script>#}
<script src="{% static 'custom_js/formset_add.js' %}"></script> {# <script src="{% static 'custom_js/formset_add.js' %}"></script>#}
{# ajax #} {# ajax #}
<!-- <script src="{% static 'custom_js/file_post_ajax.js' %}"></script>--> <!-- <script src="{% static 'custom_js/file_post_ajax.js' %}"></script>-->

Loading…
Cancel
Save