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

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,
# choices=[(item.id, item.name) for item in Organiser.objects.language().all()])
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'Тематики'),
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,
# 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(
label=_(u'Тематики'),
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)
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
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
"""
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):

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

@ -16,13 +16,13 @@
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script>
{# google map не забыть скачать скрипты на локал #}
<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://maps.google.com/maps/api/js?sensor=false'></script>
{# selects #}
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/>
<script src="{% static 'js/select/select2.js' %}"></script>
<script src="{% static 'custom_js/formset_add.js' %}"></script>
{# <link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/>#}
{# <script src="{% static 'js/select/select2.js' %}"></script>#}
{# <script src="{% static 'custom_js/formset_add.js' %}"></script>#}
{# ajax #}
<!-- <script src="{% static 'custom_js/file_post_ajax.js' %}"></script>-->

Loading…
Cancel
Save