Commit c797f02d2ebb5807d3dd2b034aa0af4c6f40972d

Authored by Alexis Koralewski
1 parent 860eb6af
Exists in dev

Adding unsubmit button for sequence, fixing bug on plan view ('show more informa…

…tion' button), re-enabling 'cancel' button for sequence (cancel = delete), adjusting UI on sequence detail view
CHANGELOG
  1 +27-04-2022 (AKo): v0.4.5.0
  2 + - Adding unsubmit button for sequences
  3 + - Re-enabling cancel button for sequence and plan views (cancel = delete)
  4 + - Fixing bug where "show more informations" button on plan view page was submitting form
  5 +
1 6 26-04-2022 (AKo): v0.4.4.1
2 7 - Adding 3 full sequences to debris scientific program in initial fixture
3 8 - Fixing view / edit page of sequences (new messages to explain errors/warnings)
... ...
VERSION
1   -0.4.4.1
2 1 \ No newline at end of file
  2 +0.4.5.0
3 3 \ No newline at end of file
... ...
src/core/pyros_django/pyros/settings.py
... ... @@ -439,10 +439,9 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
439 439  
440 440 python_version = subprocess.run( "python --version | cut -d ' ' -f 2 | cut -d '.' -f 1,2",shell=True,stdout=subprocess.PIPE,universal_newlines=True)
441 441 python_version = python_version.stdout
442   -day = "2022-04-26"
  442 +day = "2022-04-27"
443 443 django_version_major,django_version_minor = django.VERSION[:2][0],django.VERSION[:2][1]
444 444 pyros_version = read_version_number_from_file(f"{BASE_DIR}/../../../VERSION")
445   -#TODO: create function to read VERSION file
446 445  
447 446 #pyros_version = "0.2.12.0"
448 447 VERSION_NUMBER = f"{pyros_version}_{django_version_major}.{django_version_minor}_{python_version}_{day}"
... ...
src/core/pyros_django/routine_manager/templates/routine_manager/edit_base.html
... ... @@ -7,7 +7,21 @@
7 7 {% endblock %}
8 8  
9 9 {% block content %}
10   - <a class="btn btn-primary" href="{% url 'sequences_list' %}"> Return to list of sequences</a>
  10 + <div class="row h-10 text-center">
  11 + <div class="col-lg-auto">
  12 + <a class="btn btn-primary" href="{% url 'sequences_list' %}"> Return to list of sequences</a>
  13 + </div>
  14 + <div class="col-lg-auto">
  15 + Export
  16 + {% if seq.complete %}
  17 + <a href="{% url 'export_sequence' seq_id=seq_id type="copy" %}" class="btn btn-info">As is</a>
  18 + <a href="{% url 'export_sequence' seq_id=seq_id type="template" %}" class="btn btn-info">As template</a>
  19 + {% else %}
  20 + <a href="{% url 'export_sequence' seq_id=seq_id type="copy" %}" disabled class="btn btn-info">As is</a>
  21 + <a href="{% url 'export_sequence' seq_id=seq_id type="template" %}" disabled class="btn btn-info">As template</a>
  22 + {% endif %}
  23 + </div>
  24 + </div>
11 25 <div class="row text-center" style="margin-top: 20px;">
12 26  
13 27 <ul class="nav nav-tabs col-lg-4" style="margin-bottom: 15px;">
... ... @@ -29,11 +43,11 @@
29 43 {% if depth_level > 2 %}
30 44 <li {% if depth_level == 3 %}class="active"{% endif %}><a href="{% url "action_plan" plan_id action%}" >Plan Info</a></li>
31 45 {% endif %}
32   - </ul>
  46 + </ul>
33 47  
34 48  
35   - <div class="nav-tabs col-lg-6 text-left" style="margin-top:1px">
36 49 {% comment %}
  50 + <div class="nav-tabs col-lg-6 text-left" style="margin-top:1px">
37 51 <div class="row col-lg-4">
38 52 {% if req.submitted == False %}
39 53 {% if req.complete == True %}
... ... @@ -51,25 +65,14 @@
51 65 </div>
52 66 {% endcomment %}
53 67  
54   - <div class="row col-lg-4">
55   - {# TODO : ajouter url export sequence as yaml file #}
56   - <p>Export</p>
57   - {% if seq.complete %}
58   - <a href="{% url 'export_sequence' seq_id=seq_id type="copy" %}" class="btn btn-info">As is</a>
59   - <a href="{% url 'export_sequence' seq_id=seq_id type="template" %}" class="btn btn-info">As template</a>
60   - {% else %}
61   - <a href="{% url 'export_sequence' seq_id=seq_id type="copy" %}" disabled class="btn btn-info">As is</a>
62   - <a href="{% url 'export_sequence' seq_id=seq_id type="template" %}" disabled class="btn btn-info">As template</a>
63   - {% endif %}
64   - </div>
65   -
66   - <div class="row col-lg-4">
  68 +
67 69 {% comment %}
  70 + <div class="row col-lg-4">
68 71  
69 72 TODO : ajouter checkbox pour choisir en dynamique JD / GD
70   - {% endcomment %}
71 73 </div>
72 74 </div>
  75 + {% endcomment %}
73 76  
74 77 </div>
75 78 <div class="row">
... ...
src/core/pyros_django/routine_manager/templates/routine_manager/sequences_list.html
... ... @@ -103,12 +103,10 @@
103 103 <td>{{ row.nb_plan }}</td>
104 104 <td>
105 105 <center>
106   - {% if row.seq.submitted == False %}
  106 + {# {% if row.seq.status == "DRAFT" %} #}
107 107 <a href="{% url "action_sequence" row.seq.id 'edit' %}" class="btn btn-primary"><i title="Edit" class="fa-solid fa-pen-to-square"></i></a>
108   - {% endif %}
109   - {% if row.seq.submitted == False %}
110   - <a href="{% url "copy_sequence" row.seq.id %}" class="btn btn-primary"><i title="Copy" class="fa-solid fa-copy"></i></a>
111   - {% endif %}
  108 + {# {% endif %} #}
  109 + <a href="{% url "copy_sequence" row.seq.id %}" class="btn btn-primary"><i title="Copy" class="fa-solid fa-copy"></i></a>
112 110 {% comment %}
113 111  
114 112 <a href="{% url "action_sequence" row.id 'view' %}" class="btn btn-primary">View</a>
... ...
src/core/pyros_django/routine_manager/templates/routine_manager/view_plan.html
... ... @@ -48,12 +48,15 @@
48 48 <td><button type="submit" class="btn btn-success" name="action" value="save">Save</button></td>
49 49 <td>&nbsp</td>
50 50 <td><button type="submit" class="btn btn-danger" name="action" value="delete"><i title="Delete" class="fa-regular fa-trash-can"></i></button></td>
  51 + {% comment %}
  52 + NB : Had to add type="button" to prevent button to submit form
  53 + {% endcomment %}
  54 + <td><button type="button" id="showUneditableForm" class="btn btn-info"> Show more informations </button></td>
51 55 </tr>
52 56 </table>
53 57 </div>
54 58 {% endif %}
55 59 </form>
56   - <button id="showUneditableForm" class="btn btn-info"> Show more informations </button>
57 60 <div id="uneditableForm">
58 61 <table class="table table-hover table-striped tablesorter">
59 62 {% for field in uneditableForm %}
... ...
src/core/pyros_django/routine_manager/templates/routine_manager/view_sequence.html
... ... @@ -14,6 +14,9 @@
14 14 <tr>
15 15 <td><b>Submitted by:</b></td><td> {{ seq.pyros_user }} </td>
16 16 </tr>
  17 + <tr>
  18 + <td><b>Status :</b></td><td> {{ seq.status}} </td>
  19 + </tr>
17 20 {% for field in form %}
18 21 <tr>
19 22 <td title="{{ field.help_text }}">{{ field.label_tag }} {% if field.field.required %}&nbsp*{% endif %} </td>
... ... @@ -41,13 +44,18 @@
41 44 <td>&nbsp</td>
42 45 <td><button type="submit" class="btn btn-success" name="action" value="check_validity">Check validity</button></td>
43 46 <td>&nbsp</td>
44   - {% if seq.complete %}
  47 + {% if seq.complete and request.user == seq.pyros_user and seq.status == "DRAFT" %}
45 48 <td><button type="submit" class="btn btn-success" name="action" value="save_and_submit">Save and Submit</button></td>
46 49 <td>&nbsp</td>
47 50 {% else %}
48 51 <td><button type="submit" class="btn btn-success" name="action" value="save_and_submit" disabled>Save and Submit</button></td>
49 52 <td>&nbsp</td>
50 53 {% endif %}
  54 + {% if seq.status == "TBP" and request.user == seq.pyros_user %}
  55 +
  56 + <td><a href="{% url "unsubmit_sequence" seq.id %}" class="btn btn-warning" onclick="return confirm('The sequence will be unsubmitted')"
  57 + title="The sequence will be unsubmitted">Unsubmit sequence</a></td>
  58 + {% endif %}
51 59 {% comment %}
52 60 <td><button type="submit" class="btn btn-success" name="action" value="save_and_add"> Album(s)</button></td>
53 61 <td>&nbsp</td>
... ...
src/core/pyros_django/routine_manager/urls.py
... ... @@ -59,5 +59,7 @@ urlpatterns = [
59 59 path("export_sequence/<int:seq_id>/<str:type>",
60 60 views.export_sequence, name="export_sequence"),
61 61 path("import_sequence/", views.import_sequence, name="import_sequence"),
62   - path("copy_sequence/<int:seq_id>", views.copy_sequence, name="copy_sequence")
  62 + path("copy_sequence/<int:seq_id>", views.copy_sequence, name="copy_sequence"),
  63 + path("unsubmit_sequence/<int:seq_id>", views.unsubmit_sequence, name="unsubmit_sequence")
  64 +
63 65 ]
... ...
src/core/pyros_django/routine_manager/views.py
... ... @@ -187,11 +187,12 @@ def action_sequence(request, seq_id, action, status=0, message=&quot;&quot;):
187 187 elif status == "1":
188 188 success = True
189 189 if seq.status != Sequence.DRAFT and action == "edit":
190   - error = True
191   - message = "You can't edit a submitted request"
192   - messages.add_message(
193   - request, messages.WARNING, "You can't edit a submitted request")
194   - action = "view"
  190 + pass
  191 + # error = True
  192 + # message = "You can't edit a submitted request"
  193 + # messages.add_message(
  194 + # request, messages.WARNING, "You can't edit a submitted request")
  195 + # action = "view"
195 196  
196 197 horizon_line = config.getHorizonLine(config.unit_name)
197 198 horizon_line_svg = f'<svg id="horizonline" width="30vw" height="5vh">\
... ... @@ -233,6 +234,22 @@ def action_sequence(request, seq_id, action, status=0, message=&quot;&quot;):
233 234  
234 235  
235 236 @login_required
  237 +@level_required("Admin", "Unit-PI", "Unit-board", "Observer")
  238 +def unsubmit_sequence(request, seq_id):
  239 + seq = Sequence.objects.get(id=int(seq_id))
  240 + status = seq.status
  241 + message = ""
  242 + if status == Sequence.TOBEPLANNED:
  243 + seq.status = Sequence.DRAFT
  244 + seq.save()
  245 + message = "Sequence unsubmitted"
  246 + else:
  247 + message = "The sequence isn't submitted."
  248 + messages.add_message(request,messages.INFO,message)
  249 + return redirect(action_sequence, seq_id, "view")
  250 +
  251 +
  252 +@login_required
236 253 @level_required("Admin", "Unit-PI", "Observer")
237 254 def sequence_validate(request, seq_id):
238 255 """
... ... @@ -252,8 +269,7 @@ def sequence_validate(request, seq_id):
252 269 config.unit_name), layouts=config.get_layouts(config.unit_name))
253 270  
254 271 if action == "cancel":
255   - if seq.name == "New sequence":
256   - seq.delete()
  272 + seq.delete()
257 273 return redirect(sequences_list)
258 274 elif action == "delete":
259 275 return redirect(action_sequence, seq_id, "delete")
... ... @@ -267,7 +283,8 @@ def sequence_validate(request, seq_id):
267 283 if is_seq_valid == True:
268 284 message = f"The sequence is valid and can be submitted."
269 285 else:
270   - message = f"The sequence isn't valid. Check if your sequence have at least one album with one plan."
  286 + message = f"The sequence isn't valid. Check if your sequence have, at least, an album and that album has one plan at minimum.\
  287 + Each album needs at least one plan."
271 288 messages.add_message(request, messages.INFO, message)
272 289 return redirect(action_sequence, seq_id, "edit")
273 290 elif form.is_valid():
... ... @@ -381,9 +398,7 @@ def album_validate(request, alb_id):
381 398 pass
382 399  
383 400 if action == "cancel":
384   - pass
385   - if alb.name == "New album":
386   - alb.delete()
  401 + alb.delete()
387 402 return redirect(action_sequence, seq_id=alb.sequence.id, action="edit", status='1', message="Cancelled album modification")
388 403 elif action == "delete":
389 404 return redirect(action_album, alb_id, "delete")
... ...