Browse Source

Fixes #1265

pull/1322/head
Edward Ribeiro 8 years ago
parent
commit
d5072d6be4
  1. 2
      sapl/materia/views.py
  2. 2
      sapl/templates/crud/detail.html
  3. 31
      sapl/templates/materia/autoria_form.html

2
sapl/materia/views.py

@ -1098,8 +1098,6 @@ class AutoriaCrud(MasterDetailCrud):
autores_ativos = self.autores_ativos()
autores = []
for a in autores_ativos:
autores.append([a.id, a.__str__()])
context['form'].fields['autor'].choices = autores
return context

2
sapl/templates/crud/detail.html

@ -114,4 +114,6 @@
</div>
{% include "paginacao.html" %}
{% endblock table_content %}
{% block extra_js %}{% endblock %}
{% endblock base_content %}

31
sapl/templates/materia/autoria_form.html

@ -0,0 +1,31 @@
{% extends "crud/form.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% load common_tags %}
{% block extra_js %}
<script language="Javascript">
$(document).ready(function() {
$("#id_tipo_autor").change(function() {
$("#id_autor option").remove()
var selected = $("#id_tipo_autor").val();
if (selected !== undefined && selected !== null) {
$.getJSON("/api/autor?tipo=" + selected, function(data){
if (data) {
var results = data.results;
if (results.length > 1) {
$("#id_autor").append("<option>-----</option>");
}
$.each(results, function(idx, obj) {
$("#id_autor")
.append($("<option></option>")
.attr("value", obj.value)
.text(obj.text));
});
}
});
}
});
});
</script>
{% endblock %}
Loading…
Cancel
Save