Rename some views and URLs more logically
This commit is contained in:
parent
c348ea1179
commit
0c42de2ffb
10 changed files with 29 additions and 26 deletions
|
@ -17,7 +17,7 @@ class List(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def incomplete_tasks(self):
|
def list_detail(self):
|
||||||
# Count all incomplete tasks on the current list instance
|
# Count all incomplete tasks on the current list instance
|
||||||
return Item.objects.filter(list=self, completed=0)
|
return Item.objects.filter(list=self, completed=0)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class Item(models.Model):
|
||||||
def overdue_status(self):
|
def overdue_status(self):
|
||||||
"Returns whether the item's due date has passed or not."
|
"Returns whether the item's due date has passed or not."
|
||||||
if self.due_date and datetime.date.today() > self.due_date:
|
if self.due_date and datetime.date.today() > self.due_date:
|
||||||
return 1
|
return True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<p><input type="submit" name="delete-confirm" value="Do it! →" class="todo-button"> </p>
|
<p><input type="submit" name="delete-confirm" value="Do it! →" class="todo-button"> </p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<a href="{% url 'todo:incomplete_tasks' list.id list_slug %}">Return to list: {{ list.name }}</a>
|
<a href="{% url 'todo:list_detail' list.id list_slug %}">Return to list: {{ list.name }}</a>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Sorry, you don't have permission to delete lists. Please contact your group administrator.</p>
|
<p>Sorry, you don't have permission to delete lists. Please contact your group administrator.</p>
|
||||||
|
|
|
@ -17,4 +17,4 @@ Task details/comments:
|
||||||
http://{{ site }}{% url 'todo:task_detail' task.id %}
|
http://{{ site }}{% url 'todo:task_detail' task.id %}
|
||||||
|
|
||||||
List {{ task.list.name }}:
|
List {{ task.list.name }}:
|
||||||
http://{{ site }}{% url 'todo:incomplete_tasks' task.list.id task.list.slug %}
|
http://{{ site }}{% url 'todo:list_detail' task.list.id task.list.slug %}
|
||||||
|
|
|
@ -12,5 +12,5 @@ Task details/comments:
|
||||||
https://{{ site }}{% url 'todo:task_detail' task.id %}
|
https://{{ site }}{% url 'todo:task_detail' task.id %}
|
||||||
|
|
||||||
List {{ task.list.name }}:
|
List {{ task.list.name }}:
|
||||||
https://{{ site }}{% url 'todo:incomplete_tasks' task.list.id task.list.slug %}
|
https://{{ site }}{% url 'todo:list_detail' task.list.id task.list.slug %}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
{% if auth_ok %}
|
{% if auth_ok %}
|
||||||
<form action="" method="POST">
|
<form action="" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
{# Only show task adder if viewing a list is not "mine" #}
|
||||||
{# Only show task adder if viewing a proper list #}
|
|
||||||
{% if list_slug != "mine" %}
|
{% if list_slug != "mine" %}
|
||||||
<h2 style="margin-bottom:0px;" id="slideToggle" >→ Click to add task ←</h2>
|
<h2 style="margin-bottom:0px;" id="slideToggle" >→ Click to add task ←</h2>
|
||||||
|
|
||||||
|
@ -110,15 +109,15 @@
|
||||||
<td style="text-align:center;">{% if task.note %}≈{% endif %} </td>
|
<td style="text-align:center;">{% if task.note %}≈{% endif %} </td>
|
||||||
<td style="text-align:center;">{% if task.comment_set.all.count != 0 %}{{ task.comment_set.all.count }}{% endif %}</td>
|
<td style="text-align:center;">{% if task.comment_set.all.count != 0 %}{{ task.comment_set.all.count }}{% endif %}</td>
|
||||||
{% if list_slug == "mine" %}
|
{% if list_slug == "mine" %}
|
||||||
<td><a href="{% url 'todo:incomplete_tasks' task.list.id task.list.slug %}">{{ task.list }}</a></td>
|
<td><a href="{% url 'todo:list_detail' task.list.id task.list.slug %}">{{ task.list }}</a></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><input type="checkbox" name="del_tasks" value="{{ task.id }}" id="del_task_{{ task.id }}"> </td>
|
<td><input type="checkbox" name="del_tasks" value="{{ task.id }}" id="del_task_{{ task.id }}"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p><input type="submit" name="mark_tasks_done" value="Continue..." class="todo-button"></p>
|
<p><input type="submit" name="mark_tasks_done" value="Continue..." class="todo-button"></p>
|
||||||
<p><a class="todo" href="{% url 'todo:completed_tasks' list_id list_slug %}">View completed tasks</a></p>
|
<p><a class="todo" href="{% url 'todo:completed_tasks' list_id list_slug %}">View completed tasks</a></p>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
|
@ -153,7 +152,7 @@
|
||||||
</table>
|
</table>
|
||||||
<p><input type="submit" name="deldonetasks" value="Continue..." class="todo-button"></p>
|
<p><input type="submit" name="deldonetasks" value="Continue..." class="todo-button"></p>
|
||||||
</form>
|
</form>
|
||||||
<p><a class="todo" href="{% url 'todo:incomplete_tasks' list_id list_slug %}">View incomplete tasks</a></p>
|
<p><a class="todo" href="{% url 'todo:list_detail' list_id list_slug %}">View incomplete tasks</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if user.is_staff %}
|
{% if user.is_staff %}
|
|
@ -15,8 +15,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% for item in group.list %}
|
{% for item in group.list %}
|
||||||
<li>
|
<li>
|
||||||
<a class="todo" href="{% url 'todo:incomplete_tasks' item.id item.slug %}">{{ item.name }}</a>
|
<a class="todo" href="{% url 'todo:list_detail' item.id item.slug %}">{{ item.name }}</a>
|
||||||
({{ item.incomplete_tasks.count }}/{{ item.item_set.count }})
|
({{ item.list_detail.count }}/{{ item.item_set.count }})
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{% for f in found_items %}
|
{% for f in found_items %}
|
||||||
<p><strong><a href="{% url 'todo:task_detail' f.id %}">{{ f.title }}</a></strong><br />
|
<p><strong><a href="{% url 'todo:task_detail' f.id %}">{{ f.title }}</a></strong><br />
|
||||||
<span class="minor">
|
<span class="minor">
|
||||||
On list: <a href="{% url 'todo:incomplete_tasks' f.list.id f.list.slug %}">{{ f.list.name }}</a><br />
|
On list: <a href="{% url 'todo:list_detail' f.list.id f.list.slug %}">{{ f.list.name }}</a><br />
|
||||||
Assigned to: {% if f.assigned_to %}{{ f.assigned_to }}{% else %}Anyone{% endif %} (created by: {{ f.created_by }})<br />
|
Assigned to: {% if f.assigned_to %}{{ f.assigned_to }}{% else %}Anyone{% endif %} (created by: {{ f.created_by }})<br />
|
||||||
Complete: {{ f.completed|yesno:"Yes,No" }}
|
Complete: {{ f.completed|yesno:"Yes,No" }}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<p id="slideToggle" ><strong>→ Click to edit details ←</strong></p>
|
<p id="slideToggle" ><strong>→ Click to edit details ←</strong></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>In list:</strong> <a href="{% url 'todo:incomplete_tasks' task.list.id task.list.slug %}" class="showlink">{{ task.list }}</a><br />
|
<strong>In list:</strong> <a href="{% url 'todo:list_detail' task.list.id task.list.slug %}" class="showlink">{{ task.list }}</a><br />
|
||||||
<strong>Assigned to:</strong> {% if task.assigned_to %}{{ task.assigned_to.get_full_name }}{% else %}Anyone{% endif %}<br />
|
<strong>Assigned to:</strong> {% if task.assigned_to %}{{ task.assigned_to.get_full_name }}{% else %}Anyone{% endif %}<br />
|
||||||
<strong>Created by:</strong> {{ task.created_by.first_name }} {{ task.created_by.last_name }}<br />
|
<strong>Created by:</strong> {{ task.created_by.first_name }} {{ task.created_by.last_name }}<br />
|
||||||
<strong>Due date:</strong> {{ task.due_date }}<br />
|
<strong>Due date:</strong> {{ task.due_date }}<br />
|
||||||
|
|
16
todo/urls.py
16
todo/urls.py
|
@ -6,13 +6,17 @@ app_name = 'todo'
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.list_lists, name="lists"),
|
path('', views.list_lists, name="lists"),
|
||||||
path('mine/', views.view_list, {'list_slug': 'mine'}, name="mine"),
|
|
||||||
|
# Three paths into `list_detail` view
|
||||||
|
path('<int:list_id>/<str:list_slug>/', views.list_detail, name='list_detail'),
|
||||||
|
path('mine/', views.list_detail, {'list_slug': 'mine'}, name="mine"),
|
||||||
|
path('<int:list_id>/<str:list_slug>/completed/', views.list_detail, {'view_completed': True}, name='completed_tasks'),
|
||||||
|
|
||||||
path('<int:list_id>/<str:list_slug>/delete/', views.del_list, name="del_list"),
|
path('<int:list_id>/<str:list_slug>/delete/', views.del_list, name="del_list"),
|
||||||
path('task/<int:task_id>', views.view_task, name='task_detail'),
|
|
||||||
path('<int:list_id>/<str:list_slug>', views.view_list, name='incomplete_tasks'),
|
|
||||||
path('<int:list_id>/<str:list_slug>/completed/', views.view_list, {'view_completed': True}, name='completed_tasks'),
|
|
||||||
path('add_list/', views.add_list, name="add_list"),
|
path('add_list/', views.add_list, name="add_list"),
|
||||||
|
|
||||||
|
path('task/<int:task_id>/', views.task_detail, name='task_detail'),
|
||||||
|
|
||||||
# FIXME need both of these?
|
# FIXME need both of these?
|
||||||
path('search-post/', views.search_post, name="search-post"),
|
path('search-post/', views.search_post, name="search-post"),
|
||||||
path('search/', views.search, name="search"),
|
path('search/', views.search, name="search"),
|
||||||
|
@ -21,6 +25,6 @@ urlpatterns = [
|
||||||
path('reorder_tasks/', views.reorder_tasks, name="reorder_tasks"),
|
path('reorder_tasks/', views.reorder_tasks, name="reorder_tasks"),
|
||||||
|
|
||||||
path('ticket/add/', views.external_add, name="external-add"),
|
path('ticket/add/', views.external_add, name="external-add"),
|
||||||
path('recent/added/', views.view_list, {'list_slug': 'recent-add'}, name="recently_added"),
|
path('recent/added/', views.list_detail, {'list_slug': 'recent-add'}, name="recently_added"),
|
||||||
path('recent/completed/', views.view_list, {'list_slug': 'recent-complete'}, name="recently_completed"),
|
path('recent/completed/', views.list_detail, {'list_slug': 'recent-complete'}, name="recently_completed"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -77,7 +77,7 @@ def del_list(request, list_id, list_slug):
|
||||||
|
|
||||||
|
|
||||||
@user_passes_test(check_user_allowed)
|
@user_passes_test(check_user_allowed)
|
||||||
def view_list(request, list_id=0, list_slug=None, view_completed=False):
|
def list_detail(request, list_id=None, list_slug=None, view_completed=False):
|
||||||
"""Display and manage items in a list.
|
"""Display and manage items in a list.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -145,11 +145,11 @@ def view_list(request, list_id=0, list_slug=None, view_completed=False):
|
||||||
'priority': 999,
|
'priority': 999,
|
||||||
})
|
})
|
||||||
|
|
||||||
return render(request, 'todo/view_list.html', locals())
|
return render(request, 'todo/list_detail.html', locals())
|
||||||
|
|
||||||
|
|
||||||
@user_passes_test(check_user_allowed)
|
@user_passes_test(check_user_allowed)
|
||||||
def view_task(request, task_id):
|
def task_detail(request, task_id):
|
||||||
"""View task details. Allow task details to be edited.
|
"""View task details. Allow task details to be edited.
|
||||||
"""
|
"""
|
||||||
task = get_object_or_404(Item, pk=task_id)
|
task = get_object_or_404(Item, pk=task_id)
|
||||||
|
@ -201,7 +201,7 @@ def view_task(request, task_id):
|
||||||
|
|
||||||
messages.success(request, "The task has been edited.")
|
messages.success(request, "The task has been edited.")
|
||||||
|
|
||||||
return redirect('todo:lists', args=[task.list.id, task.list.slug])
|
return redirect('todo:list_detail', list_id=task.list.id, list_slug=task.list.slug)
|
||||||
else:
|
else:
|
||||||
form = EditItemForm(instance=task)
|
form = EditItemForm(instance=task)
|
||||||
if task.due_date:
|
if task.due_date:
|
||||||
|
@ -217,7 +217,7 @@ def view_task(request, task_id):
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@user_passes_test(check_user_allowed)
|
@user_passes_test(check_user_allowed)
|
||||||
def reorder_tasks(request):
|
def reorder_tasks(request):
|
||||||
"""Handle task re-ordering (priorities) from JQuery drag/drop in view_list.html
|
"""Handle task re-ordering (priorities) from JQuery drag/drop in list_detail.html
|
||||||
"""
|
"""
|
||||||
newtasklist = request.POST.getlist('tasktable[]')
|
newtasklist = request.POST.getlist('tasktable[]')
|
||||||
# First item in received list is always empty - remove it
|
# First item in received list is always empty - remove it
|
||||||
|
|
Loading…
Reference in a new issue