瀏覽代碼

Corrige les erreurs de redirection avec l'accès aux stories

omassot 7 年之前
父節點
當前提交
42279147ef
共有 4 個文件被更改,包括 60 次插入53 次删除
  1. 11 5
      main/static/js/custom.js
  2. 1 1
      main/templates/story_details.html
  3. 42 44
      main/templates/story_li.html
  4. 6 3
      main/views.py

+ 11 - 5
main/static/js/custom.js

@@ -81,11 +81,17 @@ $(document).ready( function () {
 		window.location.href = target;
 	});
 	
-	$('#id_epic').val([getUrlParameter('epic')])
-	$('#id_name').val([getUrlParameter('name')])
-	$('#id_weight').val([getUrlParameter('weight')])
-	$('#id_assignees').val([getUrlParameter('assignee')])
-	$('#id_sprints').val([getUrlParameter('sprint')])
+	var epic = getUrlParameter('epic');
+	var name = getUrlParameter('name');
+	var weight = getUrlParameter('weight');
+	var assignee = getUrlParameter('assignee');
+	var sprint = getUrlParameter('sprint');
+	
+	if (epic) { $('#id_epic').val(epic); }
+	if (name) { $('#id_name').val(name); }
+	if (weight) { $('#id_weight').val(weight); }
+	if (assignee) { $('#id_assignees').val([assignee]); }
+	if (sprint) { $('#id_sprints').val([sprint]); }
 	
 	$(document).on('click', function(event) {
 	    if(!$(event.target).closest('#user-panel').length) {

+ 1 - 1
main/templates/story_details.html

@@ -7,7 +7,7 @@
 
 {% block breadcrumb %}
 	<li><a href="{% url 'index' %}">Accueil</a></li>
-	{% if story.epic %}
+	{% if from == 'epic_details' %}
 	<li><a href="{% url 'epic_details' epic_id=story.epic.id %}">Epic #{{ story.epic.id }}</a></li>
 	{% else %}
 	<li><a href="{% url 'story_index' %}">Toutes les Stories</a></li>

+ 42 - 44
main/templates/story_li.html

@@ -1,45 +1,43 @@
-<!-- story item in used in stories indexes -->
-<li class="story-item" id="story_{{ story_id }}" data-id="{{ story_id }}">
-
-	<div class="flex-col">
-		
-		<div class="flex-row ">  {# ligne 1 #}
-
-			<div class="flex-extend">  {# partie gauche #}
-				<div class="story-title">
-					{% if story.closed %}
-	    			<a href="{% url 'story_details' story_id=story.id %}" class="story-closed"> {{ story.name }} </a>
-		    		{% else %}
-	    			<a href="{% url 'story_details' story_id=story.id %}"> {{ story.name }} </a>
-		    		{% endif %}
-	    		</div>
-	    	</div>
-	    	
-	    	<div>  {# partie droite #}
-	       		<div class="flex-row controls">
-	       			{% if story.running %}<span class="running">En cours</span>{% endif %}
-					{% if story.weight %}<span>{% include 'weight_svg.html' with weight=story.weight h=20 %}</span>{% endif %}
-					{# <a href="#" class="disabled annotation"><i class="fa fa-comment"></i> 0</a> #}
-	       		</div>
-	    	</div>
-	    </div>
-	    
-	    <div class="flex-row">   {# ligne 2 #}
-	    	
-	    	<div class="flex-extend"> {# partie gauche #}
-    			<span class="annotation">Ajoutée le {{ story.created|date:"d M. Y" }} par {{ story.author.username }}</span>
-	    	</div>
-	    	
-	       	<div>  {# partie droite #}
-	       		<div class="annotation">		      
-	       			{% if from == "story_index" %}	
-	       				{% if story.epic_id %}
-	    				<a href="{% url 'epic_details' epic_id=story.epic_id %}">{{ story.epic.name }}</a>
-	    				{% endif %}
-	    			{% endif %}
-	   			</div>
-	       	</div>
-	    </div>
-    </div>
-    
+<!-- story item in used in stories indexes -->
+<li class="story-item" id="story_{{ story_id }}" data-id="{{ story_id }}">
+
+	<div class="flex-col">
+		
+		<div class="flex-row ">  {# ligne 1 #}
+
+			<div class="flex-extend">  {# partie gauche #}
+				<div class="story-title">
+					
+	    			<a href="{% url 'story_details' story_id=story.id %}?from={{ from }}"{% if story.closed %}class="story-closed"{% endif %}> {{ story.name }} </a>
+
+	    		</div>
+	    	</div>
+	    	
+	    	<div>  {# partie droite #}
+	       		<div class="flex-row controls">
+	       			{% if story.running %}<span class="running">En cours</span>{% endif %}
+					{% if story.weight %}<span>{% include 'weight_svg.html' with weight=story.weight h=20 %}</span>{% endif %}
+					{# <a href="#" class="disabled annotation"><i class="fa fa-comment"></i> 0</a> #}
+	       		</div>
+	    	</div>
+	    </div>
+	    
+	    <div class="flex-row">   {# ligne 2 #}
+	    	
+	    	<div class="flex-extend"> {# partie gauche #}
+    			<span class="annotation">Ajoutée le {{ story.created|date:"d M. Y" }} par {{ story.author.username }}</span>
+	    	</div>
+	    	
+	       	<div>  {# partie droite #}
+	       		<div class="annotation">		      
+	       			{% if from == "story_index" %}	
+	       				{% if story.epic_id %}
+	    				<a href="{% url 'epic_details' epic_id=story.epic_id %}">{{ story.epic.name }}</a>
+	    				{% endif %}
+	    			{% endif %}
+	   			</div>
+	       	</div>
+	    </div>
+    </div>
+    
 </li>

+ 6 - 3
main/views.py

@@ -125,7 +125,10 @@ def story_index(request):
 @login_required
 def story_details(request, story_id):
     story = get_object_or_404(Story, id=story_id)
-    return render(request, 'story_details.html', {'story': story})
+    
+    from_ = request.GET['from'] if ('from' in request.GET and request.GET['from']) else 'epic_details';
+    
+    return render(request, 'story_details.html', {'story': story, 'from': from_})
 
 @login_required
 def story_create(request, epic_id=None):
@@ -190,7 +193,7 @@ def story_close(request, story_id):
     if request.is_ajax():
         return HttpResponse(story.to_json())
     else:
-        return redirect('epic_details', story.epic.id)
+        return redirect(request.META['HTTP_REFERER'])
 
 @login_required
 def story_reaffect(request, story_id):
@@ -208,7 +211,7 @@ def story_reopen(request, story_id):
     story = get_object_or_404(Story, id=story_id)
     story.reopen()
     notify_story_reopened(story, request.user)
-    return redirect('story_details', story_id)
+    return redirect(request.META['HTTP_REFERER'])
 
 @login_required
 def epic_details(request, epic_id):