Explorar o código

corrections sprint_end

omassot %!s(int64=7) %!d(string=hai) anos
pai
achega
57df291c26
Modificáronse 2 ficheiros con 131 adicións e 122 borrados
  1. 127 118
      main/templates/sprint_end.html
  2. 4 4
      main/views.py

+ 127 - 118
main/templates/sprint_end.html

@@ -19,130 +19,139 @@
 		</div>
 	</header>
 	
-	<h4>Clore les stories</h4>
-	<table>
-	{% for story in sprint.stories.all|dictsort:"id" %}
-		<tr data-id="{{ story.id }}">
-			<td class="btn-cell">
-				{% if story.closed %}
-				<a href="" class="story_close button special icon fa-check tool-btn already-checked"></a>
-				{% else %}
-				<a href="" class="story_close button special icon fa-check tool-btn" title="Clôre"></a>
-				{% endif %}
-			</td>
-			<td class="btn-cell-2">
-				{% if story.closed %}
-				<a class="button special icon fa-mail-forward tool-btn disabled"></a>
-				{% else %}
-				<a href="" class="story_reaffect button special icon fa-mail-forward tool-btn" title="Ré-affecter à {{ next_sprint }}"></a>
-				{% endif %}
-			</td>
-			
-			<td><a href="{% url 'story_details' story_id=story.id %}">{{ story.name }}</a></td>
-			
-			<td width="1%">{% if story.weight %}<span>{% include 'weight_svg.html' with weight=story.weight h=20 %}</span>{% endif %}</td>
-		</tr>
-	{% endfor %}
-	</table>
+	{% if not next_sprint %}
+		<p class="error">Le sprint suivant n'existe pas!</p>
+	{% else %}
 	
-	<h4>Rétrospective</h4>
-	<form id="retro-section" action="." method="post" enctype="multipart/form-data">
-		{% csrf_token %}
-		
-		{{ form.retro }}
+		<h4>Clore les stories</h4>
+		<table>
+		{% for story in sprint.stories.all|dictsort:"id" %}
+			<tr data-id="{{ story.id }}">
+				<td class="btn-cell">
+					{% if story.closed %}
+					<a href="" class="story_close button special icon fa-check tool-btn already-checked"></a>
+					{% elif next_sprint in story.sprints.all %}
+					<a href="" class="story_close button special icon fa-check tool-btn disabled"></a>
+					{% else %}
+					<a href="" class="story_close button special icon fa-check tool-btn" title="Clôre"></a>
+					{% endif %}
+				</td>
+				<td class="btn-cell-2">
+					{% if story.closed %}
+					<a class="button special icon fa-mail-forward tool-btn disabled"></a>
+					{% elif next_sprint in story.sprints.all %}
+					<a href="" class="story_reaffect button special icon fa-mail-forward tool-btn already-checked"></a>
+					{% else %}
+					<a href="" class="story_reaffect button special icon fa-mail-forward tool-btn" title="Ré-affecter à {{ next_sprint }}"></a>
+					{% endif %}
+				</td>
+				
+				<td><a href="{% url 'story_details' story_id=story.id %}">{{ story.name }}</a></td>
+				
+				<td width="1%">{% if story.weight %}<span>{% include 'weight_svg.html' with weight=story.weight h=20 %}</span>{% endif %}</td>
+			</tr>
+		{% endfor %}
+		</table>
 		
-    	<div class="flex-row flex-end" style="margin-top: 10px;">
-    		<input type="submit" value="Enregistrer et clôre le sprint">
-    	</div>
-	</form>
-	
-	<script>
-		function csrfSafeMethod(method) {
-		    // these HTTP methods do not require CSRF protection
-		    return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
-		}
-		function getCookie(name) {
-		    var cookieValue = null;
-		    if (document.cookie && document.cookie !== '') {
-		        var cookies = document.cookie.split(';');
-		        for (var i = 0; i < cookies.length; i++) {
-		            var cookie = jQuery.trim(cookies[i]);
-		            // Does this cookie string begin with the name we want?
-		            if (cookie.substring(0, name.length + 1) === (name + '=')) {
-		                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
-		                break;
-		            }
-		        }
-		    }
-		    return cookieValue;
-		}
-		var csrftoken = getCookie('csrftoken');
-	
-		$(".story_close").click(function(event) {
-			event.preventDefault();
-			var story_tr = $(this).closest('tr');
-			var story_id = story_tr.data('id');
+		<h4>Rétrospective</h4>
+		<form id="retro-section" action="." method="post" enctype="multipart/form-data">
+			{% csrf_token %}
 			
-            $.ajax({
-                type: "POST",
-                url: "/stories/axclose/" + story_id + "/",
-                data: '{story_id:' + story_id + '}',
-                contentType: "application/json; charset=utf-8",
-                dataType: "json",
-                beforeSend: function(xhr, settings) {
-                    if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
-                        xhr.setRequestHeader("X-CSRFToken", csrftoken);
-                    }
-                },
-                success: function (response) {
-                	story_tr.find('.btn-cell').html('<a class="button special icon fa-check tool-btn already-checked"></a>');
-                	story_tr.find('.btn-cell-2').html('<a class="button special icon fa-mail-forward tool-btn disabled"></a>');
-                },
-                failure: function (response) {
-                    alert(response.responseText);
-                },
-                error: function (response) {
-                    alert(response.responseText);
-                }
-            });
-		});
-	
-		$(".story_reaffect").click(function(event) {
-			event.preventDefault();
-			var story_tr = $(this).closest('tr');
-			var story_id = story_tr.data('id');
+			{{ form.retro }}
 			
-            $.ajax({
-                type: "POST",
-                url: "/stories/axreaffect/" + story_id + "/",
-                data: '{story_id:' + story_id + '}',
-                contentType: "application/json; charset=utf-8",
-                dataType: "json",
-                beforeSend: function(xhr, settings) {
-                    if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
-                        xhr.setRequestHeader("X-CSRFToken", csrftoken);
-                    }
-                },
-                success: function (response) {
-                	story_tr.find('.btn-cell').html('<a class="button special icon fa-check tool-btn disabled"></a>');
-                	story_tr.find('.btn-cell-2').html('<a class="button special icon fa-mail-forward tool-btn already-checked"></a>');
-                },
-                failure: function (response) {
-                    alert(response.responseText);
-                },
-                error: function (response) {
-                    alert(response.responseText);
-                }
-            });
-		});
-
-		$(".retro-section input").click(function (event) {
-			if (confirm('Le sprint courant va être marqué comme terminé, continuer?')) {
-				return true;
+	    	<div class="flex-row flex-end" style="margin-top: 10px;">
+	    		<input type="submit" value="Enregistrer et clôre le sprint">
+	    	</div>
+		</form>
+		
+		<script>
+			function csrfSafeMethod(method) {
+			    // these HTTP methods do not require CSRF protection
+			    return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
+			}
+			function getCookie(name) {
+			    var cookieValue = null;
+			    if (document.cookie && document.cookie !== '') {
+			        var cookies = document.cookie.split(';');
+			        for (var i = 0; i < cookies.length; i++) {
+			            var cookie = jQuery.trim(cookies[i]);
+			            // Does this cookie string begin with the name we want?
+			            if (cookie.substring(0, name.length + 1) === (name + '=')) {
+			                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+			                break;
+			            }
+			        }
+			    }
+			    return cookieValue;
 			}
-		});
+			var csrftoken = getCookie('csrftoken');
 		
-	</script>
+			$(".story_close").click(function(event) {
+				event.preventDefault();
+				var story_tr = $(this).closest('tr');
+				var story_id = story_tr.data('id');
+				
+	            $.ajax({
+	                type: "POST",
+	                url: "/stories/axclose/" + story_id + "/",
+	                data: '{story_id:' + story_id + '}',
+	                contentType: "application/json; charset=utf-8",
+	                dataType: "json",
+	                beforeSend: function(xhr, settings) {
+	                    if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
+	                        xhr.setRequestHeader("X-CSRFToken", csrftoken);
+	                    }
+	                },
+	                success: function (response) {
+	                	story_tr.find('.btn-cell').html('<a class="button special icon fa-check tool-btn already-checked"></a>');
+	                	story_tr.find('.btn-cell-2').html('<a class="button special icon fa-mail-forward tool-btn disabled"></a>');
+	                },
+	                failure: function (response) {
+	                    alert(response.responseText);
+	                },
+	                error: function (response) {
+	                    alert(response.responseText);
+	                }
+	            });
+			});
+		
+			$(".story_reaffect").click(function(event) {
+				event.preventDefault();
+				var story_tr = $(this).closest('tr');
+				var story_id = story_tr.data('id');
+				
+	            $.ajax({
+	                type: "POST",
+	                url: "/stories/axreaffect/" + story_id + "/",
+	                data: '{story_id:' + story_id + '}',
+	                contentType: "application/json; charset=utf-8",
+	                dataType: "json",
+	                beforeSend: function(xhr, settings) {
+	                    if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
+	                        xhr.setRequestHeader("X-CSRFToken", csrftoken);
+	                    }
+	                },
+	                success: function (response) {
+	                	story_tr.find('.btn-cell').html('<a class="button special icon fa-check tool-btn disabled"></a>');
+	                	story_tr.find('.btn-cell-2').html('<a class="button special icon fa-mail-forward tool-btn already-checked"></a>');
+	                },
+	                failure: function (response) {
+	                    alert(response.responseText);
+	                },
+	                error: function (response) {
+	                    alert(response.responseText);
+	                }
+	            });
+			});
+	
+			$(".retro-section input").click(function (event) {
+				if (confirm('Le sprint courant va être marqué comme terminé, continuer?')) {
+					return true;
+				}
+			});
+			
+		</script>
 
+	{% endif %}
 
 {% endblock %}

+ 4 - 4
main/views.py

@@ -79,10 +79,10 @@ def sprint_end(request):
         current_sprint.retro = request.POST["retro"]
         current_sprint.closed = True
         current_sprint.save()
-        return HttpResponseRedirect(request.META['HTTP_REFERER'].split("#")[0] + "#retro-section")
+        return redirect("index")
     
     form = SprintForm(instance=current_sprint)
-    return render(request, 'sprint_end.html', {'sprint': current_sprint, 'next': next_sprint, 'form': form})
+    return render(request, 'sprint_end.html', {'sprint': current_sprint, 'next_sprint': next_sprint, 'form': form})
 
 @login_required
 def story_index(request):
@@ -185,14 +185,14 @@ def story_reaffect_ajax(_, story_id):
     next_sprint = Sprint.next()
     story.sprints.add(next_sprint)
     story.save()
-    return redirect("sprint_end")
+    return HttpResponse(story.to_json())
 
 @login_required
 def story_reopen(request, story_id):
     story = get_object_or_404(Story, id=story_id)
     story.closed = False
     story.save()
-    return render(request, 'story_details.html', {'story': story})
+    return redirect('story_details.html', {'story_id': story_id})
 
 @login_required
 def epic_details(request, epic_id):