parent
d738fccd86
commit
c09c058905
10 changed files with 330 additions and 17 deletions
@ -0,0 +1 @@ |
||||
__author__ = 'dev' |
||||
@ -0,0 +1 @@ |
||||
__author__ = 'dev' |
||||
@ -0,0 +1,25 @@ |
||||
from django.core.management.base import BaseCommand |
||||
from django.utils.translation import activate |
||||
from service.models import Service,LinkedService |
||||
from country.models import Country |
||||
from exposition.models import Exposition |
||||
from conference.models import Conference |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
activate('ru') |
||||
LinkedService.objects.all().delete() |
||||
services = Service.objects.all() |
||||
for service in services: |
||||
linked = LinkedService() |
||||
linked.service = service |
||||
linked.save() |
||||
if Country.objects.language().filter(services=getattr(Country.services, service.url)).count() == Country.objects.language().count(): |
||||
linked.all_countries = True |
||||
else: |
||||
linked.countries = Country.objects.language().filter(services=getattr(Country.services, service.url)) |
||||
linked.expositions = Exposition.objects.language().filter(services=getattr(Exposition.services, service.url)) |
||||
linked.conferences = Conference.objects.language().filter(services=getattr(Conference.services, service.url)) |
||||
linked.save() |
||||
|
||||
@ -0,0 +1,162 @@ |
||||
{% 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 () { |
||||
console.log(1); |
||||
$('#id_expositions').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 = []; |
||||
var values = element.val(); |
||||
element.val(""); |
||||
$(values.split(",")).each(function (i) { |
||||
var item = this.split(':'); |
||||
data.push({ |
||||
id: item[0], |
||||
text: item[1] |
||||
}); |
||||
}); |
||||
console.log("initselection data: " ); |
||||
console.log( data); |
||||
callback(data); |
||||
|
||||
} |
||||
|
||||
}); |
||||
$('#id_conferences').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 = []; |
||||
var values = element.val(); |
||||
element.val(""); |
||||
$(values.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="post" action="" >{% csrf_token %} |
||||
{{ form.errors }} |
||||
<div class="form-group"> |
||||
<label class="col-sm-2 control-label">Type:</label> |
||||
<div id = 'types' class="col-sm-10"> |
||||
{{ form.type }}{{ form.type.errors }} |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="col-sm-2 control-label">Countries:</label> |
||||
<div class="col-sm-10"> |
||||
{{ form.countries }}{{ form.countries.errors }} |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<label class="col-sm-4 control-label">All:</label> |
||||
<div class="col-sm-8"> |
||||
{{ form.all_countries }} |
||||
</div> |
||||
</div> |
||||
|
||||
<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 %} |
||||
@ -0,0 +1,11 @@ |
||||
{% extends 'base.html' %} |
||||
{% block sidebar %}{% endblock %} |
||||
{% block body %} |
||||
<form action="" method="post">{% csrf_token %} |
||||
<div class="controls"> |
||||
<p>Вы точно хотите удалить настройку для сервиса "{{ object.service.name }}" ?</p> |
||||
<input class="btn btn-large btn-danger delete" type="submit" value="Да" /> |
||||
<a class="btn btn-large btn-primary" href = {% url 'linked_service_all' %}>Нет</a> |
||||
</div> |
||||
</form> |
||||
{% endblock %} |
||||
@ -0,0 +1,48 @@ |
||||
{% extends 'base.html' %} |
||||
|
||||
{% block body %} |
||||
|
||||
<div class="box span8"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-arrow-down"></i>Настройки услуг</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
<table class="table table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th>id</th> |
||||
<th>Название услуги</th> |
||||
<th>Тип</th> |
||||
<th>Стран</th> |
||||
<th>Виставок</th> |
||||
<th>Конференций</th> |
||||
<th> </th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{{ object }} |
||||
{% for item in object_list %} |
||||
<tr> |
||||
<td>{{ item.id }}</td> |
||||
<td>{{ item.service.name }}</td> |
||||
<td>{% if item.service.type.mask == 1 %} expo {% elif item.service.type.mask == 2%} conf {% elif item.service.type.mask == 3 %} expo, conf{% endif %}</td> |
||||
<td>{{ item.countries.count }}</td> |
||||
<td>{{ item.expositions.count }}</td> |
||||
<td>{{ item.conferences.count }}</td> |
||||
<td class="center sorting_1"> |
||||
<a class="btn btn-info" href="{% url 'linked_service_update' item.service.url %}"> |
||||
<i class="icon-edit icon-white"></i> Изменить |
||||
</a> |
||||
<a class="btn btn-danger" href="{% url 'linked_service_delete' item.service.url %}"> |
||||
<i class="icon-trash icon-white"></i> Удалить |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
{% endblock %} |
||||
Loading…
Reference in new issue