presenting job description as form
authorMaciej Tronowski <mtro@man.poznan.pl>
Wed, 6 May 2015 14:27:35 +0000 (16:27 +0200)
committerMaciej Tronowski <mtro@man.poznan.pl>
Wed, 6 May 2015 14:27:35 +0000 (16:27 +0200)
12 files changed:
qcg/service.py
qcg/static/qcg/selectize/selectize.bootstrap3.css
qcg/templates/qcg/details_base.html [new file with mode: 0644]
qcg/templates/qcg/job.html
qcg/templates/qcg/job_description.html [new file with mode: 0644]
qcg/templates/qcg/job_submit.html
qcg/templates/qcg/job_submit_form.html [new file with mode: 0644]
qcg/templates/qcg/tags/bootstrap_button_group.html [new file with mode: 0644]
qcg/templates/qcg/tags/bootstrap_checkbox.html
qcg/templates/qcg/task.html
qcg/templatetags/qcg_utils.py
qcg/views.py

index c69eee0..787ea38 100644 (file)
@@ -84,9 +84,6 @@ def update_user_data(user, proxy):
 
 @transaction.atomic
 def update_job(job, proxy):
-    if job.terminated and job.purged:
-        return
-
     ts = time.time()
     QCG.start()
 
index b898ef6..3b91599 100644 (file)
   margin: 0 4px 0 -2px !important;
 }
 .selectize-control .selectize-input.disabled {
-  opacity: 0.5;
-  background-color: #ffffff;
+  /*opacity: 0.5;*/
+  /*background-color: #ffffff;*/
+    background-color: #eee;
 }
 .selectize-dropdown,
 .selectize-dropdown.form-control {
diff --git a/qcg/templates/qcg/details_base.html b/qcg/templates/qcg/details_base.html
new file mode 100644 (file)
index 0000000..265cb17
--- /dev/null
@@ -0,0 +1,39 @@
+{% extends 'qcg/base.html' %}
+{% load staticfiles %}
+
+{% block extra_css %}
+    <link href="{% static 'qcg/selectize/selectize.bootstrap3.css' %}" rel="stylesheet">
+
+    <style>
+        #env-controls > div > div:last-child {
+            display: none;
+        }
+
+        .btn-group .btn-default.active[disabled] {
+            background-color: #E6E6E6;
+            border-color: #ADADAD;
+            box-shadow: 0 3px 5px rgba(0, 0, 0, 0.125) inset;
+        }
+    </style>
+{% endblock %}
+
+{% block extra_js %}
+    <script>
+        $(function () {
+            'use strict';
+
+            $('#toggle-advanced').click(function(e) {
+                e.preventDefault();
+                $('.form-horizontal .collapse').collapse('toggle');
+                $(this).find('span').text(this.text == "Pokaż zaawansowane" ? "Ukryj zaawansowane" : "Pokaż zaawansowane");
+            });
+
+            $('#desc').find('select:not(#id_wall_time_1)').selectize();
+
+            $('input[name="notify_type"],input[name="watch_output_type"],input[name="preprocess_type"],input[name="postprocess_type"]').each(function() {
+                if (this.checked)
+                    $(this).tab('show');
+            });
+        });
+    </script>
+{% endblock extra_js %}
index d3c3922..4f44a3a 100644 (file)
@@ -1,5 +1,5 @@
-{% extends 'qcg/base.html' %}
-{% load qcg_utils bootstrap3 %}
+{% extends 'qcg/details_base.html' %}
+{% load qcg_utils %}
 
 {% block container %}
     <ol class="breadcrumb">
 
             </div>
             <div role="tabpanel" class="tab-pane" id="desc">
-                <button class="btn btn-default btn-sm pull-right" data-toggle="modal" data-target="#template">Zapisz jako szablon</button>
-
-                {% if job.get_description_type_display != 'QCG' %}
-                    <h3>Opis użytkownika</h3>
-                    <pre>{{ job.description }}</pre>
-                {% endif %}
-
-                <h3>Opis QCG</h3>
-                <pre>{{ job.qcg_description|format_xml }}</pre>
+                {% include 'qcg/job_description.html' %}
             </div>
         </div>
     </div>
 
-    <form id="template" action="{% url 'job_save_template' job.job_id %}" method="post" class="modal fade form-horizontal" tabindex="-1"
-          role="dialog" aria-labelledby="template-modal-label" aria-hidden="true">
-        <div class="modal-dialog">
-            <div class="modal-content">
-                <div class="modal-header">
-                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-                    <h4 class="modal-title" id="template-modal-label">Podaj nazwę szablonu</h4>
-                </div>
-                <div class="modal-body">
-                    {% csrf_token %}
-                    {% bootstrap_field template_form.name layout="horizontal" %}
-                </div>
-                <div class="modal-footer">
-                    <button type="button" class="btn btn-default" data-dismiss="modal">Anuluj</button>
-                    <button type="submit" class="btn btn-primary" data-loading-text="Zapisywanie...">Zapisz</button>
-                </div>
-            </div>
-        </div>
-    </form>
-
 {% endblock container %}
diff --git a/qcg/templates/qcg/job_description.html b/qcg/templates/qcg/job_description.html
new file mode 100644 (file)
index 0000000..4fc3afa
--- /dev/null
@@ -0,0 +1,40 @@
+{% load qcg_utils bootstrap3 %}
+
+<div class="form-horizontal">
+    {% include 'qcg/job_submit_form.html' %}
+</div>
+<hr>
+<div class="row">
+    <div class="col-sm-offset-3 col-md-offset-4 col-sm-9 col-md-6">
+        <button class="btn btn-default" data-toggle="modal" data-target="#template">Zapisz jako szablon</button>
+        <a id="toggle-advanced" href="#"><span class="text-muted">Pokaż zaawansowane</span></a>
+    </div>
+</div>
+
+{% if job.get_description_type_display != 'QCG' %}
+    <h3>Opis użytkownika</h3>
+    <pre>{{ job.description }}</pre>
+{% endif %}
+
+<h3>Opis QCG</h3>
+<pre>{{ job.qcg_description|format_xml }}</pre>
+
+<form id="template" action="{% url 'job_save_template' job.job_id %}" method="post" class="modal fade form-horizontal" tabindex="-1"
+      role="dialog" aria-labelledby="template-modal-label" aria-hidden="true">
+    <div class="modal-dialog">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                <h4 class="modal-title" id="template-modal-label">Podaj nazwę szablonu</h4>
+            </div>
+            <div class="modal-body">
+                {% csrf_token %}
+                {% bootstrap_field template_form.name layout="horizontal" %}
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-default" data-dismiss="modal">Anuluj</button>
+                <button type="submit" class="btn btn-primary">Zapisz</button>
+            </div>
+        </div>
+    </div>
+</form>
index 87b8a2c..83e9025 100644 (file)
@@ -1,5 +1,5 @@
 {% extends 'qcg/base.html' %}
-{% load staticfiles bootstrap3 qcg_utils %}
+{% load staticfiles bootstrap3 %}
 
 {% block extra_css %}
     <link href="{% static 'qcg/selectize/selectize.bootstrap3.css' %}" rel="stylesheet">
             $('input[name="notify_type"],input[name="watch_output_type"],input[name="preprocess_type"],input[name="postprocess_type"]').on('change', function () {
                 $(this).tab('show');
             }).each(function() {
-                $(this).parent().toggleClass('active', this.checked);
-
                 if (this.checked)
                     $(this).tab('show');
             });
     <form id="description" action="." method="post" class="form-horizontal">
         {% csrf_token %}
 
-        <!-- Nav tabs -->
-        <ul class="nav nav-tabs" style="margin-bottom: 20px">
-            <li role="presentation" class="active"><a href="#basic" data-toggle="tab">Podstawowe</a></li>
-            <li role="presentation"><a href="#resources" data-toggle="tab">Zasoby</a></li>
-            <li role="presentation"><a href="#files" data-toggle="tab">Pliki</a></li>
-            <li role="presentation"><a href="#environment" data-toggle="tab">Środowisko</a></li>
-            <li role="presentation"><a href="#monitoring" data-toggle="tab">Powiadomienia</a></li>
-            <li role="presentation"><a href="#other" data-toggle="tab">Inne</a></li>
-        </ul>
-
-        <div class="tab-content">
-            <fieldset id="basic" class="tab-pane active" role="tabpanel">
-                {% bootstrap_field form.application layout="horizontal" %}
-                {% bootstrap_field form.master_file layout="horizontal" %}
-                {% bootstrap_field form.executable layout="horizontal" form_group_class="form-group collapse" %}
-                {% bootstrap_field form.script layout="horizontal" form_group_class="form-group collapse" %}
-                {% bootstrap_field form.arguments layout="horizontal" %}
-                {% bootstrap_field form.note layout="horizontal" %}
-                {% bootstrap_field form.grant layout="horizontal" form_group_class="form-group collapse" %}
-            </fieldset>
-
-            <fieldset id="resources" class="tab-pane" role="tabpanel">
-                {% bootstrap_field form.hosts layout="horizontal" %}
-                {% bootstrap_field form.queue layout="horizontal" %}
-                {% bootstrap_field form.properties layout="horizontal" form_group_class="form-group collapse" %}
-                {% bootstrap_field form.modules layout="horizontal" form_group_class="form-group collapse" %}
-                {% bootstrap_field form.procs layout="horizontal" %}
-                {% bootstrap_field form.nodes layout="horizontal" form_group_class="form-group collapse" %}
-                {% bootstrap_field form.wall_time layout="horizontal" form_group_class="form-group timerange" %}
-                {% bootstrap_field form.memory layout="horizontal" form_group_class="form-group collapse" %}
-                {% bootstrap_field form.memory_per_slot layout="horizontal" form_group_class="form-group collapse" %}
-                {% bootstrap_field form.reservation layout="horizontal" form_group_class="form-group collapse" %}
-            </fieldset>
-
-            <fieldset id="files" class="tab-pane" role="tabpanel">
-                {% bootstrap_field form.input layout="horizontal" %}
-                {% bootstrap_field form.stage_in layout="horizontal" %}
-            </fieldset>
-
-            <fieldset id="environment" class="tab-pane" role="tabpanel">
-                {{ env_formset.management_form }}
-
-                <div class="form-group">
-                    <label class="col-sm-3 col-md-4 control-label">Zmienne środowiskowe</label>
-                    <div class="col-sm-9 col-md-6">
-                        <div id="env-controls">
-                            {% for env_form in env_formset %}
-                                <div>{% bootstrap_form env_form layout='inline' %}</div>
-                            {% endfor %}
-                        </div>
-                        <div id="add-env-form"></div>
-                        <div id="env-form-empty" style="display: none">
-                            {% bootstrap_form env_formset.empty_form layout='inline' %}
-                        </div>
-                    </div>
-                </div>
-            </fieldset>
-
-            <fieldset id="monitoring" class="tab-pane" role="tabpanel">
-                {% bootstrap_checkbox form.monitoring %}
-
-                <div class="form-group">
-                    <label class="col-sm-3 col-md-4 control-label">Monitorowanie stanu</label>
-                    <div class="col-sm-9 col-md-6">
-                        <div class="btn-group" data-toggle="buttons">
-                            {% for option in form.notify_type %}
-                                <label class="btn btn-default">
-                                    <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
-                                            {% if option.is_checked %}checked{% endif %}
-                                            data-target=".notify-type-{{ forloop.counter0 }}"> {{ option.choice_label }}
-                                </label>
-                            {% endfor %}
-                        </div>
-                    </div>
-                </div>
-
-                <div class="tab-content">
-                    <div class="tab-pane notify-type-0"></div>
-
-                    <div class="tab-pane notify-type-1 notify-type-2" style="margin-top: 15px">
-                        {% bootstrap_field form.notify_address layout="horizontal" %}
-                    </div>
-                </div>
-
-                <div class="collapse">
-                    <div class="form-group">
-                        <label class="col-sm-3 col-md-4 control-label">Monitorowanie wyjścia</label>
-                        <div class="col-sm-9 col-md-6">
-                            <div class="btn-group" data-toggle="buttons">
-                                {% for option in form.watch_output_type %}
-                                    <label class="btn btn-default">
-                                        <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
-                                                {% if option.is_checked %}checked{% endif %}
-                                                data-target=".watch-output-type-{{ forloop.counter0 }}"> {{ option.choice_label }}
-                                    </label>
-                                {% endfor %}
-                            </div>
-                        </div>
-                    </div>
-
-                    <div class="tab-content">
-                        <div class="tab-pane watch-output-type-0"></div>
-
-                        <div class="tab-pane watch-output-type-1 watch-output-type-2" style="margin-top: 15px">
-                            {% bootstrap_field form.watch_output_address layout="horizontal" %}
-                            {% bootstrap_field form.watch_output_pattern layout="horizontal" %}
-                        </div>
-                    </div>
-                </div>
-            </fieldset>
-
-            <fieldset id="other" class="tab-pane" role="tabpanel">
-                <div class="form-group">
-                    <label class="col-sm-3 col-md-4 control-label">Preprocessing</label>
-                    <div class="col-sm-9 col-md-6">
-                        <div class="btn-group" data-toggle="buttons">
-                            {% for option in form.preprocess_type %}
-                                <label class="btn btn-default">
-                                    <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
-                                            {% if option.is_checked %}checked{% endif %}
-                                            data-target=".preprocess-type-{{ forloop.counter0 }}"> {{ option.choice_label }}
-                                </label>
-                            {% endfor %}
-                        </div>
-                    </div>
-                </div>
-
-                <div class="tab-content">
-                    <div class="tab-pane preprocess-type-0"></div>
-
-                    <div class="tab-pane preprocess-type-1" style="margin-top: 15px">
-                        {% bootstrap_field form.preprocess_cmd layout="horizontal" %}
-                    </div>
-
-                    <div class="tab-pane preprocess-type-2" style="margin-top: 15px">
-                        {% bootstrap_field form.preprocess_script layout="horizontal" %}
-                    </div>
-                </div>
-
-                <div class="form-group">
-                    <label class="col-sm-3 col-md-4 control-label">Postprocessing</label>
-                    <div class="col-sm-9 col-md-6">
-                        <div class="btn-group" data-toggle="buttons">
-                            {% for option in form.postprocess_type %}
-                                <label class="btn btn-default">
-                                    <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
-                                            {% if option.is_checked %}checked{% endif %}
-                                            data-target=".postprocess-type-{{ forloop.counter0 }}"> {{ option.choice_label }}
-                                </label>
-                            {% endfor %}
-                        </div>
-                    </div>
-                </div>
-
-                <div class="tab-content">
-                    <div class="tab-pane postprocess-type-0"></div>
-
-                    <div class="tab-pane postprocess-type-1" style="margin-top: 15px">
-                        {% bootstrap_field form.postprocess_cmd layout="horizontal" %}
-                    </div>
-
-                    <div class="tab-pane postprocess-type-2" style="margin-top: 15px">
-                        {% bootstrap_field form.postprocess_script layout="horizontal" %}
-                    </div>
-                </div>
-
-                {% bootstrap_field form.native layout="horizontal" %}
-                {% bootstrap_checkbox form.persistent %}
-            </fieldset>
-        </div>
+        {% include 'qcg/job_submit_form.html' %}
 
         <hr>
 
diff --git a/qcg/templates/qcg/job_submit_form.html b/qcg/templates/qcg/job_submit_form.html
new file mode 100644 (file)
index 0000000..e9b5289
--- /dev/null
@@ -0,0 +1,116 @@
+{% load bootstrap3 qcg_utils %}
+
+<!-- Nav tabs -->
+<ul class="nav nav-tabs" style="margin-bottom: 20px">
+    <li role="presentation" class="active"><a href="#basic" data-toggle="tab">Podstawowe</a></li>
+    <li role="presentation"><a href="#resources" data-toggle="tab">Zasoby</a></li>
+    <li role="presentation"><a href="#files" data-toggle="tab">Pliki</a></li>
+    <li role="presentation"><a href="#environment" data-toggle="tab">Środowisko</a></li>
+    <li role="presentation"><a href="#monitoring" data-toggle="tab">Powiadomienia</a></li>
+    <li role="presentation"><a href="#other" data-toggle="tab">Inne</a></li>
+</ul>
+
+<div class="tab-content">
+    <fieldset id="basic" class="tab-pane active" role="tabpanel">
+        {% bootstrap_field form.application layout="horizontal" %}
+        {% bootstrap_field form.master_file layout="horizontal" %}
+        {% bootstrap_field form.executable layout="horizontal" form_group_class="form-group collapse" %}
+        {% bootstrap_field form.script layout="horizontal" form_group_class="form-group collapse" %}
+        {% bootstrap_field form.arguments layout="horizontal" %}
+        {% bootstrap_field form.note layout="horizontal" %}
+        {% bootstrap_field form.grant layout="horizontal" form_group_class="form-group collapse" %}
+    </fieldset>
+
+    <fieldset id="resources" class="tab-pane" role="tabpanel">
+        {% bootstrap_field form.hosts layout="horizontal" %}
+        {% bootstrap_field form.queue layout="horizontal" %}
+        {% bootstrap_field form.properties layout="horizontal" form_group_class="form-group collapse" %}
+        {% bootstrap_field form.modules layout="horizontal" form_group_class="form-group collapse" %}
+        {% bootstrap_field form.procs layout="horizontal" %}
+        {% bootstrap_field form.nodes layout="horizontal" form_group_class="form-group collapse" %}
+        {% bootstrap_field form.wall_time layout="horizontal" form_group_class="form-group timerange" %}
+        {% bootstrap_field form.memory layout="horizontal" form_group_class="form-group collapse" %}
+        {% bootstrap_field form.memory_per_slot layout="horizontal" form_group_class="form-group collapse" %}
+        {% bootstrap_field form.reservation layout="horizontal" form_group_class="form-group collapse" %}
+    </fieldset>
+
+    <fieldset id="files" class="tab-pane" role="tabpanel">
+        {% bootstrap_field form.input layout="horizontal" %}
+        {% bootstrap_field form.stage_in layout="horizontal" %}
+    </fieldset>
+
+    <fieldset id="environment" class="tab-pane" role="tabpanel">
+        {{ env_formset.management_form }}
+
+        <div class="form-group">
+            <label class="col-sm-3 col-md-4 control-label">Zmienne środowiskowe</label>
+            <div class="col-sm-9 col-md-6">
+                <div id="env-controls">
+                    {% for env_form in env_formset %}
+                        <div>{% bootstrap_form env_form layout='inline' %}</div>
+                    {% endfor %}
+                </div>
+                <div id="add-env-form"></div>
+                <div id="env-form-empty" style="display: none">
+                    {% bootstrap_form env_formset.empty_form layout='inline' %}
+                </div>
+            </div>
+        </div>
+    </fieldset>
+
+    <fieldset id="monitoring" class="tab-pane" role="tabpanel">
+        {% bootstrap_checkbox form.monitoring %}
+
+        {% bootstrap_button_group form.notify_type %}
+        <div class="tab-content">
+            <div class="tab-pane notify_type_0"></div>
+
+            <div class="tab-pane notify_type_1 notify_type_2" style="margin-top: 15px">
+                {% bootstrap_field form.notify_address layout="horizontal" %}
+            </div>
+        </div>
+
+        <div class="collapse">
+            {% bootstrap_button_group form.watch_output_type %}
+            <div class="tab-content">
+                <div class="tab-pane watch_output_type_0"></div>
+
+                <div class="tab-pane watch_output_type_1 watch_output_type_2" style="margin-top: 15px">
+                    {% bootstrap_field form.watch_output_address layout="horizontal" %}
+                    {% bootstrap_field form.watch_output_pattern layout="horizontal" %}
+                </div>
+            </div>
+        </div>
+    </fieldset>
+
+    <fieldset id="other" class="tab-pane" role="tabpanel">
+        {% bootstrap_button_group form.preprocess_type %}
+        <div class="tab-content">
+            <div class="tab-pane preprocess_type_0"></div>
+
+            <div class="tab-pane preprocess_type_1" style="margin-top: 15px">
+                {% bootstrap_field form.preprocess_cmd layout="horizontal" %}
+            </div>
+
+            <div class="tab-pane preprocess_type_2" style="margin-top: 15px">
+                {% bootstrap_field form.preprocess_script layout="horizontal" %}
+            </div>
+        </div>
+
+        {% bootstrap_button_group form.postprocess_type %}
+        <div class="tab-content">
+            <div class="tab-pane postprocess_type_0"></div>
+
+            <div class="tab-pane postprocess_type_1" style="margin-top: 15px">
+                {% bootstrap_field form.postprocess_cmd layout="horizontal" %}
+            </div>
+
+            <div class="tab-pane postprocess_type_2" style="margin-top: 15px">
+                {% bootstrap_field form.postprocess_script layout="horizontal" %}
+            </div>
+        </div>
+
+        {% bootstrap_field form.native layout="horizontal" %}
+        {% bootstrap_checkbox form.persistent %}
+    </fieldset>
+</div>
diff --git a/qcg/templates/qcg/tags/bootstrap_button_group.html b/qcg/templates/qcg/tags/bootstrap_button_group.html
new file mode 100644 (file)
index 0000000..8bc03ae
--- /dev/null
@@ -0,0 +1,16 @@
+{% load qcg_utils %}
+
+<div class="form-group">
+    <label class="control-label {{ label_class }}">{{ field.label }}</label>
+    <div class="{{ field_class }}">
+        <div class="btn-group" data-toggle="buttons">
+            {% for option in field %}
+                <label class="btn btn-default{% if option.is_checked %} active{% endif %}" {{ option.attrs|flatatt }}>
+                    <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
+                           {% if option.is_checked %}checked{% endif %} data-target=".{{ field.html_name }}_{{ forloop.counter0 }}">
+                    {{ option.choice_label }}
+                </label>
+            {% endfor %}
+        </div>
+    </div>
+</div>
index a0b9926..e5a9178 100644 (file)
@@ -1,6 +1,7 @@
 <div class="form-group{% if field.field.widget.is_required %} required{% endif %}">
     <label class="{{ label_class }} control-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
     <div class="{{ field_class }}">
-        <input type="checkbox" id="{{ field.id_for_label }}" name="{{ field.html_name }}"{% if field.value %} checked{% endif %}>
+        <input type="checkbox" id="{{ field.id_for_label }}" name="{{ field.html_name }}"
+                {% if field.value %} checked{% endif %} {{ attrs }}>
     </div>
 </div>
index e4fcf11..584fa63 100644 (file)
@@ -1,8 +1,9 @@
-{% extends 'qcg/base.html' %}
+{% extends 'qcg/details_base.html' %}
 {% load qcg_utils staticfiles %}
 
 {% block extra_js %}
     {% include 'filex/source.js.html' %}
+    {{ block.super }}
 
     <script>
         var filex = filex || {};
 {% block container %}
     <ol class="breadcrumb">
         <li><a href="{% url 'jobs' %}">Zadania</a></li>
-        <li><a href="{{ task.job.get_absolute_url }}">{{ task.job.job_id }}</a></li>
+        <li><a href="{{ job.get_absolute_url }}">{{ job.job_id }}</a></li>
         <li class="active">{{ task.task_id }}</li>
     </ol>
 
     <div class="pull-right">
         {% if not task.terminated %}
-            <form action="{% url 'task_cancel' task.job.job_id task.task_id %}" method="post">
+            <form action="{% url 'task_cancel' job.job_id task.task_id %}" method="post">
                 {% csrf_token %}
                 <button type="submit" class="btn btn-default">Anuluj zadanie</button>
             </form>
         {% elif not task.purged %}
-            <form action="{% url 'task_clean' task.job.job_id task.task_id %}" method="post">
+            <form action="{% url 'task_clean' job.job_id task.task_id %}" method="post">
                 {% csrf_token %}
                 <button type="submit" class="btn btn-default">Usuń katalog roboczy</button>
             </form>
             </div>
 
             <div role="tabpanel" class="tab-pane" id="desc">
-                <pre>{{ task.description|format_xml }}</pre>
+                {% include 'qcg/job_description.html' %}
             </div>
         </div>
     </div>
index 1fb673a..cb4e694 100644 (file)
@@ -4,6 +4,7 @@ from xml.dom import minidom
 
 from django import template
 from django.conf import settings
+from django.forms.utils import flatatt
 from django.utils.html import format_html, format_html_join, conditional_escape
 from django.utils.timesince import timesince
 from django.utils.timezone import now
@@ -12,6 +13,7 @@ from qcg.utils import localtime_str
 
 
 register = template.Library()
+register.filter('flatatt', flatatt)
 
 
 @register.simple_tag
@@ -41,6 +43,13 @@ def get_params_as_hidden(context, *params):
 @register.inclusion_tag('qcg/tags/bootstrap_checkbox.html')
 def bootstrap_checkbox(field, label_class=settings.BOOTSTRAP3['horizontal_label_class'],
                        field_class=settings.BOOTSTRAP3['horizontal_field_class']):
+    return {'field': field, 'attrs': flatatt(field.field.widget.attrs),
+            'label_class': label_class, 'field_class': field_class}
+
+
+@register.inclusion_tag('qcg/tags/bootstrap_button_group.html')
+def bootstrap_button_group(field, label_class=settings.BOOTSTRAP3['horizontal_label_class'],
+                           field_class=settings.BOOTSTRAP3['horizontal_field_class']):
     return {'field': field, 'label_class': label_class, 'field_class': field_class}
 
 
index f498f95..e5ff70f 100644 (file)
@@ -155,11 +155,7 @@ def jobs_list(request):
 def job_details(request, job_id):
     job = get_object_or_404(request.user.jobs.prefetch_related('tasks'), job_id=job_id)
 
-    update_job(job, request.session['proxy'])
-
-    template_form = JobTemplateForm(initial={'name': job.note or u'Szablon z {}'.format(job.job_id)})
-
-    return render(request, 'qcg/job.html', {'job': job, 'template_form': template_form})
+    return render(request, 'qcg/job.html', process_details(request, job))
 
 
 @login_required
@@ -167,9 +163,27 @@ def task_details(request, job_id, task_id):
     task = get_object_or_404(request.user.tasks.select_related('job').prefetch_related('allocations'),
                              job__job_id=job_id, task_id=task_id)
 
-    update_job(task.job, request.session['proxy'])
+    return render(request, 'qcg/task.html', process_details(request, task.job, task))
+
+
+def process_details(request, job, task=None):
+    if not job.terminated or not job.purged:
+        update_job(job, request.session['proxy'])
+
+    form_data = to_form_data(job.qcg_description)
+    env_formset_data = [{'name': name, 'value': value} for name, value in form_data.pop('env_variables', ())]
+
+    form = JobDescriptionForm(initial=form_data)
+    env_formset = EnvFormSet(initial=env_formset_data)
+    template_form = JobTemplateForm(initial={'name': (task and task.note) or u'Szablon z {}'.format(job.job_id)})
+
+    for field in form:
+        field.field.widget.attrs['disabled'] = 'True'
+    for env_form in env_formset:
+        for field in env_form:
+            field.field.widget.attrs['disabled'] = 'True'
 
-    return render(request, 'qcg/task.html', {'task': task})
+    return {'job': job, 'task': task, 'form': form, 'env_formset': env_formset, 'template_form': template_form}
 
 
 @login_required