sprint_end.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. {% extends '_layout.html' %}
  2. {% block title %}
  3. Clotûre de {{ sprint }}
  4. {% endblock %}
  5. {% block breadcrumb %}
  6. <li><a href="{% url 'index' %}">Accueil</a></li>
  7. <li><a>Clotûre du {{ sprint }}</a></li>
  8. {% endblock %}
  9. {% block main %}
  10. <header>
  11. <div class="flex-row">
  12. <h2 class="flex-extend">Clotûre du {{ sprint }}</h2>
  13. <span>
  14. </span>
  15. </div>
  16. </header>
  17. {% if not next_sprint %}
  18. <p class="error">Le sprint suivant n'existe pas!</p>
  19. {% else %}
  20. <h4>Clore les stories</h4>
  21. <table>
  22. {% for story in sprint.stories.all|dictsort:"id" %}
  23. <tr data-id="{{ story.id }}">
  24. <td class="btn-cell">
  25. {% if story.closed %}
  26. <a href="" class="story_close button special icon fa-check tool-btn already-checked"></a>
  27. {% elif next_sprint in story.sprints.all %}
  28. <a href="" class="story_close button special icon fa-check tool-btn disabled"></a>
  29. {% else %}
  30. <a href="" class="story_close button special icon fa-check tool-btn" title="Clôre"></a>
  31. {% endif %}
  32. </td>
  33. <td class="btn-cell-2">
  34. {% if story.closed %}
  35. <a class="button special icon fa-mail-forward tool-btn disabled"></a>
  36. {% elif next_sprint in story.sprints.all %}
  37. <a href="" class="story_reaffect button special icon fa-mail-forward tool-btn already-checked"></a>
  38. {% else %}
  39. <a href="" class="story_reaffect button special icon fa-mail-forward tool-btn" title="Ré-affecter à {{ next_sprint }}"></a>
  40. {% endif %}
  41. </td>
  42. <td><a href="{% url 'story_details' story_id=story.id %}">{{ story.name }}</a></td>
  43. <td width="1%">{% if story.weight %}<span>{% include 'weight_svg.html' with weight=story.weight h=20 %}</span>{% endif %}</td>
  44. </tr>
  45. {% endfor %}
  46. </table>
  47. <h4>Rétrospective</h4>
  48. <form id="retro-section" action="." method="post" enctype="multipart/form-data">
  49. {% csrf_token %}
  50. {{ form.retro }}
  51. <div class="flex-row flex-end" style="margin-top: 10px;">
  52. <input type="submit" value="Enregistrer et clôre le sprint">
  53. </div>
  54. </form>
  55. <script>
  56. function csrfSafeMethod(method) {
  57. // these HTTP methods do not require CSRF protection
  58. return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
  59. }
  60. function getCookie(name) {
  61. var cookieValue = null;
  62. if (document.cookie && document.cookie !== '') {
  63. var cookies = document.cookie.split(';');
  64. for (var i = 0; i < cookies.length; i++) {
  65. var cookie = jQuery.trim(cookies[i]);
  66. // Does this cookie string begin with the name we want?
  67. if (cookie.substring(0, name.length + 1) === (name + '=')) {
  68. cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  69. break;
  70. }
  71. }
  72. }
  73. return cookieValue;
  74. }
  75. var csrftoken = getCookie('csrftoken');
  76. $(".story_close").click(function(event) {
  77. event.preventDefault();
  78. var story_tr = $(this).closest('tr');
  79. var story_id = story_tr.data('id');
  80. $.ajax({
  81. type: "POST",
  82. url: "/stories/axclose/" + story_id + "/",
  83. data: '{story_id:' + story_id + '}',
  84. contentType: "application/json; charset=utf-8",
  85. dataType: "json",
  86. beforeSend: function(xhr, settings) {
  87. if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
  88. xhr.setRequestHeader("X-CSRFToken", csrftoken);
  89. }
  90. },
  91. success: function (response) {
  92. story_tr.find('.btn-cell').html('<a class="button special icon fa-check tool-btn already-checked"></a>');
  93. story_tr.find('.btn-cell-2').html('<a class="button special icon fa-mail-forward tool-btn disabled"></a>');
  94. },
  95. failure: function (response) {
  96. alert(response.responseText);
  97. },
  98. error: function (response) {
  99. alert(response.responseText);
  100. }
  101. });
  102. });
  103. $(".story_reaffect").click(function(event) {
  104. event.preventDefault();
  105. var story_tr = $(this).closest('tr');
  106. var story_id = story_tr.data('id');
  107. $.ajax({
  108. type: "POST",
  109. url: "/stories/axreaffect/" + story_id + "/",
  110. data: '{story_id:' + story_id + '}',
  111. contentType: "application/json; charset=utf-8",
  112. dataType: "json",
  113. beforeSend: function(xhr, settings) {
  114. if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
  115. xhr.setRequestHeader("X-CSRFToken", csrftoken);
  116. }
  117. },
  118. success: function (response) {
  119. story_tr.find('.btn-cell').html('<a class="button special icon fa-check tool-btn disabled"></a>');
  120. story_tr.find('.btn-cell-2').html('<a class="button special icon fa-mail-forward tool-btn already-checked"></a>');
  121. },
  122. failure: function (response) {
  123. alert(response.responseText);
  124. },
  125. error: function (response) {
  126. alert(response.responseText);
  127. }
  128. });
  129. });
  130. $(".retro-section input").click(function (event) {
  131. if (confirm('Le sprint courant va être marqué comme terminé, continuer?')) {
  132. return true;
  133. }
  134. });
  135. </script>
  136. {% endif %}
  137. {% endblock %}