sprint_end.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 de 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. <h5>Clore les stories</h5>
  18. <table>
  19. {% for story in sprint.stories.all|dictsort:"id" %}
  20. <tr data-id="{{ story.id }}">
  21. <td class="btn-cell">
  22. {% if story.closed %}
  23. <a class="button special icon fa-check tool-btn" style="color: green !important; background: none !important;"></a>
  24. {% else %}
  25. <a href="" class="story_close button special icon fa-check tool-btn"></a>
  26. {% endif %}
  27. </td>
  28. <td>{{ story.name }}</td>
  29. <td width="1%">{% if story.weight %}<span>{% include 'weight_svg.html' with weight=story.weight h=20 %}</span>{% endif %}</td>
  30. </tr>
  31. {% endfor %}
  32. </table>
  33. <h5>Rétrospective</h5>
  34. <form action="." method="post" enctype="multipart/form-data">
  35. {% csrf_token %}
  36. {{ form.retro }}
  37. <div class="flex-row flex-end" style="margin-top: 10px;">
  38. <input type="submit" value="Enregistrer">
  39. </div>
  40. </form>
  41. <script>
  42. function csrfSafeMethod(method) {
  43. // these HTTP methods do not require CSRF protection
  44. return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
  45. }
  46. function getCookie(name) {
  47. var cookieValue = null;
  48. if (document.cookie && document.cookie !== '') {
  49. var cookies = document.cookie.split(';');
  50. for (var i = 0; i < cookies.length; i++) {
  51. var cookie = jQuery.trim(cookies[i]);
  52. // Does this cookie string begin with the name we want?
  53. if (cookie.substring(0, name.length + 1) === (name + '=')) {
  54. cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  55. break;
  56. }
  57. }
  58. }
  59. return cookieValue;
  60. }
  61. var csrftoken = getCookie('csrftoken');
  62. $(".story_close").click(function(event) {
  63. event.preventDefault();
  64. var story_tr = $(this).closest('tr');
  65. var story_id = story_tr.data('id');
  66. $.ajax({
  67. type: "POST",
  68. url: "/stories/axclose/" + story_id + "/",
  69. data: '{story_id:' + story_id + '}',
  70. contentType: "application/json; charset=utf-8",
  71. dataType: "json",
  72. beforeSend: function(xhr, settings) {
  73. if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
  74. xhr.setRequestHeader("X-CSRFToken", csrftoken);
  75. }
  76. },
  77. success: function (response) {
  78. story_tr.find('.btn-cell').html('<a class="button special icon fa-check tool-btn" style="color: green !important; background: none !important;"></a>');
  79. },
  80. failure: function (response) {
  81. alert(response.responseText);
  82. },
  83. error: function (response) {
  84. alert(response.responseText);
  85. }
  86. });
  87. });
  88. </script>
  89. {% endblock %}