From: Maciej Tronowski Date: Tue, 5 May 2015 12:51:07 +0000 (+0200) Subject: fix saving template from job submission form X-Git-Tag: v1.0~17 X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=commitdiff_plain;h=1459b7887e4f4c9bae86a37c80ab9c0b030c08f2;p=qcg-portal.git fix saving template from job submission form --- diff --git a/qcg/templates/qcg/job_submit.html b/qcg/templates/qcg/job_submit.html index 560bd99..87b8a2c 100644 --- a/qcg/templates/qcg/job_submit.html +++ b/qcg/templates/qcg/job_submit.html @@ -131,34 +131,14 @@ }); $('#template').on('show.bs.modal', function() { - $(this).find('.alert').remove(); this.reset(); }).on('shown.bs.modal', function() { $(this).find('input[type="text"]')[0].focus(); }).on('submit', function(e) { e.preventDefault(); - var $this = $(this), - $btn = $this.find('[type="submit"]'); - - $this.find('.alert-danger').remove(); - $btn.button('loading'); - - $.post(this.action, $('#description,#template').serializeArray(), function(response) { - // FIXME url after redirection - document.open(); - document.write(response); - document.close(); - }).fail(function(xhr) { - var error = (xhr.responseJSON || {}).error || 'Błąd serwera'; - - $('
', { - 'class': 'alert alert-danger', - html: ' ' + error - }).prependTo($this.find('.modal-body')); - - $btn.button('reset'); - }); + // copy this form's fields to description form and send it + $('#description').append($(this).find('input').clone().attr('type', 'hidden')).submit(); }); }); diff --git a/qcg/views.py b/qcg/views.py index 6462613..8a14c2f 100644 --- a/qcg/views.py +++ b/qcg/views.py @@ -188,7 +188,7 @@ def job_submit(request, template_id=None): env_formset = EnvFormSet(request.POST, initial=env_formset_data) template_form = JobTemplateForm(request.POST, prefix='template', instance=template) - if form.is_valid() and env_formset.is_valid() and (not save_template or template_form.is_valid): + if form.is_valid() and env_formset.is_valid() and (not save_template or template_form.is_valid()): params = form.cleaned_data params['env_variables'] = [(env['name'], env['value']) for env in env_formset.cleaned_data if env and not env['DELETE']]