parent
c09c058905
commit
e5fd4682f3
6 changed files with 167 additions and 365 deletions
@ -1,162 +1,143 @@ |
|||||||
{% extends 'base.html' %} |
{% extends 'base.html' %} |
||||||
{% load static %} |
{% load static %} |
||||||
|
|
||||||
{% block scripts %} |
{% block scripts %} |
||||||
|
|
||||||
{# selects #} |
{# selects #} |
||||||
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> |
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> |
||||||
<style > |
<style> |
||||||
ul{ |
ul { |
||||||
list-style: none; |
list-style: none; |
||||||
} |
} |
||||||
</style> |
</style> |
||||||
<script src="{% static 'js/select/select2.js' %}"></script> |
<script src="{% static 'js/select/select2.js' %}"></script> |
||||||
|
|
||||||
<script> |
<script> |
||||||
$(document).ready(function () { |
$(document).ready(function () { |
||||||
console.log(1); |
console.log(1); |
||||||
$('#id_expositions').select2({ |
$('#id_expositions').select2({ |
||||||
placeholder: "Expositions", |
placeholder: "Expositions", |
||||||
width: 'element', |
width: 'element', |
||||||
multiple: true, |
multiple: true, |
||||||
ajax: { |
ajax: { |
||||||
|
|
||||||
url: "/admin/exposition/search/", |
url: "/admin/exposition/search/", |
||||||
dataType: "json", |
dataType: "json", |
||||||
quietMillis: 200, |
quietMillis: 200, |
||||||
multiple: true, |
multiple: true, |
||||||
|
|
||||||
data: function (term, page) { |
data: function (term, page) { |
||||||
return { |
return { |
||||||
term: term, |
term: term, |
||||||
page: page |
page: page |
||||||
}; |
}; |
||||||
}, |
}, |
||||||
|
|
||||||
results: function (data) { |
results: function (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 data = []; |
var data = []; |
||||||
var values = element.val(); |
var values = element.val(); |
||||||
element.val(""); |
element.val(""); |
||||||
$(values.split(",")).each(function (i) { |
$(values.split(",")).each(function (i) { |
||||||
var item = this.split(':'); |
var item = this.split(':'); |
||||||
data.push({ |
data.push({ |
||||||
id: item[0], |
id: item[0], |
||||||
text: item[1] |
text: item[1] |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
console.log("initselection data: " ); |
console.log("initselection data: "); |
||||||
console.log( data); |
console.log(data); |
||||||
callback(data); |
callback(data); |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
}); |
}); |
||||||
$('#id_conferences').select2({ |
$('#id_conferences').select2({ |
||||||
placeholder: "Conferences", |
placeholder: "Conferences", |
||||||
width: 'element', |
width: 'element', |
||||||
multiple: true, |
multiple: true, |
||||||
ajax: { |
ajax: { |
||||||
|
|
||||||
url: "/admin/conference/search/", |
url: "/admin/conference/search/", |
||||||
dataType: "json", |
dataType: "json", |
||||||
quietMillis: 200, |
quietMillis: 200, |
||||||
multiple: true, |
multiple: true, |
||||||
|
|
||||||
data: function (term, page) { |
data: function (term, page) { |
||||||
return { |
return { |
||||||
term: term, |
term: term, |
||||||
page: page |
page: page |
||||||
}; |
}; |
||||||
}, |
}, |
||||||
|
|
||||||
results: function (data) { |
results: function (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 data = []; |
var data = []; |
||||||
var values = element.val(); |
var values = element.val(); |
||||||
element.val(""); |
element.val(""); |
||||||
$(values.split(",")).each(function (i) { |
$(values.split(",")).each(function (i) { |
||||||
var item = this.split(':'); |
var item = this.split(':'); |
||||||
data.push({ |
data.push({ |
||||||
id: item[0], |
id: item[0], |
||||||
text: item[1] |
text: item[1] |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
callback(data); |
callback(data); |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
}); |
}); |
||||||
|
|
||||||
}); |
}); |
||||||
|
|
||||||
</script> |
</script> |
||||||
|
|
||||||
{% endblock %} |
{% endblock %} |
||||||
|
|
||||||
{% block body %} |
{% block body %} |
||||||
|
|
||||||
{# Uses multilang.html template for translated fields #} |
{# Uses multilang.html template for translated fields #} |
||||||
<form class="form-horizontal" method="post" action="" >{% csrf_token %} |
<form class="form-horizontal" method="post" action="">{% csrf_token %} |
||||||
{{ form.errors }} |
<div class="box span8"> |
||||||
<div class="form-group"> |
<div class="box-header well"> |
||||||
<label class="col-sm-2 control-label">Type:</label> |
<h2><i class="icon-pencil"></i> Основная информация</h2> |
||||||
<div id = 'types' class="col-sm-10"> |
</div> |
||||||
{{ form.type }}{{ form.type.errors }} |
|
||||||
</div> |
{% for f in form %} |
||||||
</div> |
<div class="control-group {% if f.errors %}error{% endif %}"> |
||||||
<div class="form-group"> |
<label class="control-label"><b>{{ f.label }}:</b></label> |
||||||
<label class="col-sm-2 control-label">Countries:</label> |
<div class="controls">{{ f }} |
||||||
<div class="col-sm-10"> |
<span class="help-inline">{{ f.errors }}</span> |
||||||
{{ form.countries }}{{ form.countries.errors }} |
</div> |
||||||
</div> |
</div> |
||||||
</div> |
{% endfor %} |
||||||
<div class="row"> |
<div class="controls"> |
||||||
<label class="col-sm-4 control-label">All:</label> |
<button type="submit" class="btn btn-large btn-primary">Submit</button> |
||||||
<div class="col-sm-8"> |
<button type="reset" class="btn btn-large">Reset</button> |
||||||
{{ form.all_countries }} |
</div> |
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
|
</form> |
||||||
<div class="form-group"> |
|
||||||
<label class="col-sm-2 control-label">Expos:</label> |
|
||||||
<div class="col-sm-10"> |
|
||||||
{{ form.expositions }}{{ form.expositions.errors }} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label class="col-sm-2 control-label">Conferences:</label> |
|
||||||
<div class="col-sm-10"> |
|
||||||
{{ form.conferences }}{{ form.conferences.errors }} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<div class="col-sm-offset-6 col-sm-4"> |
|
||||||
<button type="submit" class="btn btn-default">Submit</button> |
|
||||||
<button type="reset" class="btn">Reset</button> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</form> |
|
||||||
|
|
||||||
|
|
||||||
{% endblock %} |
{% endblock %} |
||||||
@ -1,155 +0,0 @@ |
|||||||
{% extends 'base.html' %} |
|
||||||
{% load static %} |
|
||||||
|
|
||||||
{% block scripts %} |
|
||||||
|
|
||||||
{# selects #} |
|
||||||
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> |
|
||||||
<style > |
|
||||||
ul{ |
|
||||||
list-style: none; |
|
||||||
} |
|
||||||
</style> |
|
||||||
<script src="{% static 'js/select/select2.js' %}"></script> |
|
||||||
|
|
||||||
<script> |
|
||||||
$(document).ready(function () { |
|
||||||
$('#id_expos').select2({ |
|
||||||
placeholder: "Expositions", |
|
||||||
width: 'element', |
|
||||||
multiple: true, |
|
||||||
ajax: { |
|
||||||
|
|
||||||
url: "/admin/exposition/search/", |
|
||||||
dataType: "json", |
|
||||||
quietMillis: 200, |
|
||||||
multiple: true, |
|
||||||
|
|
||||||
data: function (term, page) { |
|
||||||
return { |
|
||||||
term: term, |
|
||||||
page: page |
|
||||||
}; |
|
||||||
}, |
|
||||||
|
|
||||||
results: function (data) { |
|
||||||
var results = []; |
|
||||||
$.each(data, function (index, item) { |
|
||||||
results.push({ |
|
||||||
id: item.id, |
|
||||||
text: item.label |
|
||||||
}); |
|
||||||
}); |
|
||||||
return {results: results}; |
|
||||||
} |
|
||||||
}, |
|
||||||
initSelection: function (element, callback) { |
|
||||||
var data = []; |
|
||||||
$(element.val().split(",")).each(function (i) { |
|
||||||
var item = this.split(':'); |
|
||||||
data.push({ |
|
||||||
id: item[0], |
|
||||||
text: item[1] |
|
||||||
}); |
|
||||||
}); |
|
||||||
callback(data); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
}); |
|
||||||
$('#id_confs').select2({ |
|
||||||
placeholder: "Conferences", |
|
||||||
width: 'element', |
|
||||||
multiple: true, |
|
||||||
ajax: { |
|
||||||
|
|
||||||
url: "/admin/conference/search/", |
|
||||||
dataType: "json", |
|
||||||
quietMillis: 200, |
|
||||||
multiple: true, |
|
||||||
|
|
||||||
data: function (term, page) { |
|
||||||
return { |
|
||||||
term: term, |
|
||||||
page: page |
|
||||||
}; |
|
||||||
}, |
|
||||||
|
|
||||||
results: function (data) { |
|
||||||
var results = []; |
|
||||||
$.each(data, function (index, item) { |
|
||||||
results.push({ |
|
||||||
id: item.id, |
|
||||||
text: item.label |
|
||||||
}); |
|
||||||
}); |
|
||||||
return {results: results}; |
|
||||||
} |
|
||||||
}, |
|
||||||
initSelection: function (element, callback) { |
|
||||||
var data = []; |
|
||||||
$(element.val().split(",")).each(function (i) { |
|
||||||
var item = this.split(':'); |
|
||||||
data.push({ |
|
||||||
id: item[0], |
|
||||||
text: item[1] |
|
||||||
}); |
|
||||||
}); |
|
||||||
callback(data); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
}); |
|
||||||
|
|
||||||
}); |
|
||||||
|
|
||||||
</script> |
|
||||||
|
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{% block body %} |
|
||||||
|
|
||||||
{# Uses multilang.html template for translated fields #} |
|
||||||
<form class="form-horizontal" method="get" action="" > |
|
||||||
{{ form.errors }} |
|
||||||
<div class="form-group"> |
|
||||||
<label class="col-sm-2 control-label">Type:</label> |
|
||||||
<div id = 'types' class="col-sm-10"> |
|
||||||
{{ form.type }} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label class="col-sm-2 control-label">Countries:</label> |
|
||||||
<div class="col-sm-10"> |
|
||||||
{{ form.countries }} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="row"> |
|
||||||
<label class="col-sm-4 control-label">All:</label> |
|
||||||
<div class="col-sm-8"> |
|
||||||
{{ form.all_counties }} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="form-group"> |
|
||||||
<label class="col-sm-2 control-label">Expos:</label> |
|
||||||
<div class="col-sm-10"> |
|
||||||
{{ form.expos }} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label class="col-sm-2 control-label">Conferences:</label> |
|
||||||
<div class="col-sm-10"> |
|
||||||
{{ form.confs }} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<div class="col-sm-offset-2 col-sm-10"> |
|
||||||
<button type="submit" class="btn btn-default">Submit</button> |
|
||||||
<button type="reset" class="btn">Reset</button> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</form> |
|
||||||
|
|
||||||
|
|
||||||
{% endblock %} |
|
||||||
Loading…
Reference in new issue