From 1097ffaeaab7c74669a1d297f4ba05acc588abe0 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Tue, 18 Oct 2016 11:50:56 -0200 Subject: [PATCH] =?UTF-8?q?Ajusta=20regra=C3=A7=C3=A3o=20em=20JS=20de=20ba?= =?UTF-8?q?se/autor=5Fform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 5 ++++- sapl/templates/base/autor_form.html | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 8033c37f6..3fa1f456d 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -225,7 +225,10 @@ class AutorForm(ModelForm): self.fields['autor_related'].choices = [ (self.instance.autor_related.pk, self.instance.autor_related)] - self.fields['q'].initial = self.instance.nome + self.fields['q'].initial = '' + + self.fields[ + 'autor_related'].initial = self.instance.autor_related if self.instance.user: self.fields['username'].initial = self.instance.user.username diff --git a/sapl/templates/base/autor_form.html b/sapl/templates/base/autor_form.html index 7df595493..a15b019b8 100644 --- a/sapl/templates/base/autor_form.html +++ b/sapl/templates/base/autor_form.html @@ -1,3 +1,4 @@ + {% extends "crud/form.html" %} {% load i18n %} {% block extra_js %} @@ -40,6 +41,7 @@ $(document).ready(function(){ if (atualizar) { var radios = $("#div_id_autor_related .controls").html(''); data.models.forEach(function (val, index) { + var html_radio = '
'; radios.append(html_radio); }); @@ -63,6 +65,11 @@ $(document).ready(function(){ } else{ $('#id_nome, #id_q').val(''); + if ($('input[name=autor_related]').length == 1 ) { + $('input[name=autor_related]').prop('checked', 'checked'); + $('input[name=autor_related]').closest('.radio').addClass('checked'); + } + } }).fail(function(data) { active('nome', atualizar); @@ -132,7 +139,8 @@ $(document).ready(function(){ }); $('input[name=action_user]:checked').trigger('change'); - $('input[name=autor_related]').closest('.radio').remove(); + if (flag_create) + $('input[name=autor_related]').closest('.radio').remove(); var pk = $('#id_tipo').val(); if (pk)