Clean-up / modernize templates and views

This commit is contained in:
Scot Hacker 2016-04-09 02:23:11 -07:00
parent 8ee28118fe
commit 37aef01c0f
9 changed files with 354 additions and 429 deletions

View file

@ -4,70 +4,59 @@
{% block content %}
<h2>{{ task }}</h2>
<form action="" method="POST">
{% csrf_token %}
{% csrf_token %}
{% if task.note %}
<div class="task_note"><strong>Note:</strong> {{ task.note|safe|urlize|linebreaks }}</div>
{% endif %}
{% if task.note %}
<div class="task_note"><strong>Note:</strong> {{ task.note|safe|urlize|linebreaks }}</div>
{% endif %}
<div id="TaskEdit">
<h3>File Trouble Ticket</h3>
<p>Trouble with a computer or other technical system at the J-School? <br />
Use this form to report the difficulty - we'll get right back to you. </p>
<div id="TaskEdit">
<h3>File Trouble Ticket</h3>
<p>Trouble with a computer or other technical system at the J-School? <br />
Use this form to report the difficulty - we'll get right back to you. </p>
{% if form.errors %}
{% if form.errors %}
{% for error in form.errors %}
<ul class="errorlist">
<li><strong>The {{ error|escape }} field is required.</strong></li>
</ul>
{% endfor %}
<br />
{% for error in form.errors %}
<ul class="errorlist">
<li><strong>The {{ error|escape }} field is required.</strong></li>
</ul>
{% endfor %}
<br />
{% endif %}
{% endif %}
<table>
{{ form.management_form }}
{{ form.id }}
<tr>
<td>Summary:</td>
<td>{{ form.title }} <br />
Include the workstation number in your summary, e.g. <br />
"Radio Lab # 4: Purple smoke pouring out the back."
</td>
</tr>
<table>
{{ form.management_form }}
{{ form.id }}
<tr>
<td>Summary:</td>
<td>{{ form.title }} <br />
Include the workstation number in your summary, e.g. <br />
"Radio Lab # 4: Purple smoke pouring out the back."
</td>
</tr>
<tr>
<td valign="top">Note:</td>
<td valign="top">{{ form.note }}<br />
Please describe the problem. </td>
</tr>
<tr>
<td>Priority:</td>
<td>{{ form.priority }} <br />
Enter a number between 1 and 5, <br />
where 5 is highest ("Computer is on fire = True").
</td>
</tr>
</table>
<p><input type="submit" class="todo-button" name="add_task" value="Submit"></p>
</div>
<tr>
<td valign="top">Note:</td>
<td valign="top">{{ form.note }}<br />
Please describe the problem.
</td>
</tr>
<tr>
<td>Priority:</td>
<td>{{ form.priority }} <br />
Enter a number between 1 and 5, <br />
where 5 is highest ("Computer is on fire = True").
</td>
</tr>
</table>
<p><input type="submit" class="todo-button" name="add_task" value="Submit"></p>
</div>
</form>
{% endblock %}

View file

@ -1,4 +1,5 @@
{% extends "todo/base.html" %}
{% block page_heading %}{% endblock %}
{% block title %}Add Todo List{% endblock %}

View file

@ -4,15 +4,12 @@
{% block extrahead %}
<!-- CSS and JavaScript for django-todo -->
<link rel="stylesheet" type="text/css" href="{% static 'todo/css/styles.css' %}" />
<script src="{% static 'todo/js/jquery.tablednd_0_5.js' %}" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
// thedate.x comes from the edit_task view. If this is a new entry,
// thedate won't be present and datepicker will fall back on the default (today).
$(document).ready(function(){
$('#id_due_date').datepicker({defaultDate: new Date({{thedate.year}}, {{thedate.month}} - 1, {{thedate.day}}),});
});
</script>
{% endblock extrahead %}

View file

@ -1,51 +1,32 @@
{% extends "base.html" %}
{% extends "todo/base.html" %}
{% block title %}{{ list_title }} to-do items{% endblock %}
{% block content %}
{# Only admins can delete lists. #}
{% ifequal can_del 1 %}
{% if user.is_staff %}
<h1>Delete entire list: {{ list.name }} ?</h1>
<p>Category tally:</p>
{% if list_killed %}
<ul>
<li>Incomplete: {{ item_count_undone }} </li>
<li>Complete: {{ item_count_done }} </li>
<li><strong>Total: {{ item_count_total }}</strong> </li>
</ul>
<p> {{ list.name }} is gone.</p>
<p> ... all of which will be irretrievably <strong>blown away</strong>. Are you sure you want to do that?</p>
<a href="{% url 'todo-lists' %}">Return to lists</a>
{% else %}
<h1>Delete entire list: {{ list.name }} ?</h1>
<p>Category tally:</p>
<ul>
<li>Incomplete: {{ item_count_undone }} </li>
<li>Complete: {{ item_count_done }} </li>
<li><strong>Total: {{ item_count_total }}</strong> </li>
</ul>
<p> ... all of which will be irretrievably <strong>blown away</strong>. Are you sure you want to do that?</p>
<form action="" method="post" accept-charset="utf-8">
{% csrf_token %}
<input type="hidden" name="list" value="{{ list.id }}" id="some_name">
<p><input type="submit" name="delete-confirm" value="Do it! &rarr;" class="todo-button"> </p>
</form>
<a href="{% url 'todo-incomplete_tasks' list.id list_slug %}">Return to list: {{ list.name }}</a>
{% endif %}
<form action="" method="post" accept-charset="utf-8">
{% csrf_token %}
<input type="hidden" name="list" value="{{ list.id }}" id="some_name">
<p><input type="submit" name="delete-confirm" value="Do it! &rarr;" class="todo-button"> </p>
</form>
<a href="{% url 'todo-incomplete_tasks' list.id list_slug %}">Return to list: {{ list.name }}</a>
{% else %}
<p>Sorry, you don't have permission to delete lists. Please contact your group administrator.</p>
{% endif %}
{% endifequal %}
{% endblock %}
{% endblock %}

View file

@ -3,32 +3,25 @@
{% block title %}Search results{% endblock %}
{% block body_id %}post_search{% endblock %}
{% block content_title %}
<h2 class="page_title">Search</h2>
<h2 class="page_title">Search</h2>
{% endblock %}
{% block content %}
{% if found_items %}
<h2>{{found_items.count}} search results for term: "{{ query_string }}"</h2>
<div class="post_list">
{% for f in found_items %}
<p><strong><a href="{% url 'todo-task_detail' f.id %}">{{ f.title }}</a></strong><br />
<span class="minor">
On list: <a href="{% url 'todo-incomplete_tasks' f.list.id f.list.slug %}">{{ f.list.name }}</a><br />
Assigned to: {{ f.assigned_to }} (created by: {{ f.created_by }})<br />
Complete: {{ f.completed|yesno:"Yes,No" }}
</span>
</p>
{% endfor %}
</div>
{% else %}
<h2> No results to show, sorry.</h2>
{% endif %}
{% endblock %}
{% if found_items %}
<h2>{{found_items.count}} search results for term: "{{ query_string }}"</h2>
<div class="post_list">
{% for f in found_items %}
<p><strong><a href="{% url 'todo-task_detail' f.id %}">{{ f.title }}</a></strong><br />
<span class="minor">
On list: <a href="{% url 'todo-incomplete_tasks' f.list.id f.list.slug %}">{{ f.list.name }}</a><br />
Assigned to: {{ f.assigned_to }} (created by: {{ f.created_by }})<br />
Complete: {{ f.completed|yesno:"Yes,No" }}
</span>
</p>
{% endfor %}
</div>
{% else %}
<h2> No results to show, sorry.</h2>
{% endif %}
{% endblock %}

View file

@ -3,181 +3,169 @@
{% block title %}Todo List: {{ list.name }}{% endblock %}
{% block content %}
<script type="text/javascript">
function order_tasks(data) {
// The JQuery plugin tableDnD provides a serialize() function which provides the re-ordered
// data in a list. We pass that list as an object called "data" to a Django view
// to save the re-ordered data into the database.
function order_tasks(data) {
// The JQuery plugin tableDnD provides a serialize() function which provides the re-ordered
// data in a list. We pass that list as an object called "data" to a Django view
// to save the re-ordered data into the database.
$.post("{% url 'todo-reorder_tasks' %}", data, "json");
return false;
};
$.post("{% url 'todo-reorder_tasks' %}", data, "json");
return false;
};
$(document).ready(function() {
// Initialise the task table for drag/drop re-ordering
$("#tasktable").tableDnD();
$(document).ready(function() {
// Initialise the task table for drag/drop re-ordering
$("#tasktable").tableDnD();
$('#tasktable').tableDnD({
onDrop: function(table, row) {
order_tasks($.tableDnD.serialize());
}
});
$('#tasktable').tableDnD({
onDrop: function(table, row) {
order_tasks($.tableDnD.serialize());
}
// Initially hide the Add Task form
$('#AddTask').hide();
// toggle slide to show the Add Task form when link clicked
$('#slideToggle').click(function(){
$(this).siblings('#AddTask').slideToggle();
});
});
// Initially hide the Add Task form
$('#AddTask').hide();
// toggle slide to show the Add Task form when link clicked
$('#slideToggle').click(function(){
$(this).siblings('#AddTask').slideToggle();
});
});
</script>
{% ifequal list_slug "mine" %}
{% if list_slug == "mine" %}
<h1>Tasks assigned to {{ request.user }}</h1>
{% else %}
{% ifequal auth_ok 1 %}
<h1>Tasks filed under "{{ list.name }}"</h1>
<p>This list belongs to group {{ list.group }}</p>
{% endifequal %}
{% endifequal %}
{% elif auth_ok %}
<h1>Tasks filed under "{{ list.name }}"</h1>
<p>This list belongs to group {{ list.group }}</p>
{% endif %}
{% ifequal auth_ok 1 %}
{% if auth_ok %}
<form action="" method="POST">
{% csrf_token %}
{% csrf_token %}
{# Only show task adder if viewing a proper list #}
{% ifnotequal list_slug "mine" %}
<h2 style="margin-bottom:0px;" id="slideToggle" >&rarr; Click to add task &larr;</h2>
{# Only show task adder if viewing a proper list #}
{% if list_slug != "mine" %}
<h2 style="margin-bottom:0px;" id="slideToggle" >&rarr; Click to add task &larr;</h2>
<div id="AddTask">
<table class="nocolor" border="0" cellspacing="5" cellpadding="5">
<tr>
<td>{{ form.title.errors }}</td>
<td>{{ form.due_date.errors }}</td>
</tr>
<tr>
<td><label for="id_title">Task:</label> {{ form.title }}</td>
<td><label for="id_due_date">Due date:</label> {{ form.due_date }}</td>
<td><label for="id_assigned">Assign to:</label> {{ form.assigned_to }}</td>
<td><label for="id_notify">Notify*:</label> <input type="checkbox" checked="checked" name="notify" value="1" id="notify"></td>
</tr>
<tr>
<td><label for="id_note">Note:</label>
{{ form.note }}
<p class="minor">*Email notifications will only be sent if task is assigned to someone besides yourself.</p>
</td>
</tr>
</table>
<div id="AddTask">
<table class="nocolor" border="0" cellspacing="5" cellpadding="5">
<tr>
<td>{{ form.title.errors }}</td>
<td>{{ form.due_date.errors }}</td>
</tr>
<tr>
<td><label for="id_title">Task:</label> {{ form.title }}</td>
<td><label for="id_due_date">Due date:</label> {{ form.due_date }}</td>
<td><label for="id_assigned">Assign to:</label> {{ form.assigned_to }}</td>
<td><label for="id_notify">Notify*:</label> <input type="checkbox" checked="checked" name="notify" value="1" id="notify"></td>
</tr>
<tr>
<td><label for="id_note">Note:</label>
{{ form.note }}
<p class="minor">*Email notifications will only be sent if task is assigned to someone besides yourself.</p>
</td>
</tr>
</table>
<input type="hidden" name="priority" value="999" id="id_priority">
<input type="hidden" name="created_by" value="{{ request.user.id }}" id="id_created_by">
<input type="hidden" name="list" value="{{ listid }}" id="id_list">
<input type="hidden" name="created_date" value="{{ created_date }}" id="id_created_date">
<input type="hidden" name="priority" value="999" id="id_priority">
<input type="hidden" name="created_by" value="{{ request.user.id }}" id="id_created_by">
<input type="hidden" name="list" value="{{ listid }}" id="id_list">
<input type="hidden" name="created_date" value="{{ created_date }}" id="id_created_date">
<p><input type="submit" name="add_task" value="Add task" class="todo-button"></p>
</div>
{% endif %}
<p><input type="submit" name="add_task" value="Add task" class="todo-button"></p>
</div>
{% if not view_completed %}
{% endifnotequal %}
<h3>Incomplete tasks :: Drag rows to set priorities</h3>
<table border="0" id="tasktable">
<tr>
<th>Done</th>
<th>Task</th>
<th>Created</th>
<th>Due on</th>
<th>Owner</th>
<th>Assigned</th>
<th>Note</th>
<th>Comm</th>
{% ifequal view_completed 0 %}
{% ifequal list_slug "mine" %}
<th>List</th>
{% endifequal %}
<h3>Incomplete tasks :: Drag rows to set priorities</h3>
<th>Del</th>
</tr>
{% for task in task_list %}
<tr id="{{ task.id }}">
<td><input type="checkbox" name="mark_done" value="{{ task.id }}" id="mark_done_{{ task.id }}"> </td>
<td><a href="{% url 'todo-task_detail' task.id %}">{{ task.title|truncatewords:20 }}</a></td>
<td>{{ task.created_date|date:"m/d/Y" }}</td>
<td>
{% if task.overdue_status %}<span class="overdue">{% endif %}
{{ task.due_date|date:"m/d/Y" }}
{% if task.overdue_status %}</span>{% endif %}
</td>
<td>{{ task.created_by }}</td>
<td>{{ task.assigned_to }}</td>
<td style="text-align:center;">{% if task.note %}&asymp;{% endif %} </td>
<td style="text-align:center;">{% ifnotequal task.comment_set.all.count 0 %}{{ task.comment_set.all.count }}{% endifnotequal %}
<table border="0" id="tasktable">
<tr>
<th>Done</th>
<th>Task</th>
<th>Created</th>
<th>Due on</th>
<th>Owner</th>
<th>Assigned</th>
<th>Note</th>
<th>Comm</th>
</td>
{% ifequal list_slug "mine" %}
<td><a href="{% url 'todo-incomplete_tasks' task.list.id task.list.slug %}">{{ task.list }}</a></td>
{% endifequal %}
{% ifequal list_slug "mine" %}
<th>List</th>
{% endifequal %}
<td><input type="checkbox" name="del_task" value="{{ task.id }}" id="del_task_{{ task.id }}"> </td>
</tr>
{% endfor %}
</table>
<th>Del</th>
</tr>
{% for task in task_list %}
<tr id="{{ task.id }}">
<td><input type="checkbox" name="mark_done" value="{{ task.id }}" id="mark_done_{{ task.id }}"> </td>
<td><a href="{% url 'todo-task_detail' task.id %}">{{ task.title|truncatewords:20 }}</a></td>
<td>{{ task.created_date|date:"m/d/Y" }}</td>
<td>
{% if task.overdue_status %}<span class="overdue">{% endif %}
{{ task.due_date|date:"m/d/Y" }}
{% if task.overdue_status %}</span>{% endif %}
</td>
<td>{{ task.created_by }}</td>
<td>{{ task.assigned_to }}</td>
<td style="text-align:center;">{% if task.note %}&asymp;{% endif %} </td>
<td style="text-align:center;">{% ifnotequal task.comment_set.all.count 0 %}{{ task.comment_set.all.count }}{% endifnotequal %}
<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>
</td>
{% ifequal list_slug "mine" %}
<td><a href="{% url 'todo-incomplete_tasks' task.list.id task.list.slug %}">{{ task.list }}</a></td>
{% endifequal %}
{% else %}
<td><input type="checkbox" name="del_task" value="{{ task.id }}" id="del_task_{{ task.id }}"> </td>
</tr>
{% endfor %}
</table>
<p><input type="submit" name="mark_tasks_done" value="Continue..." class="todo-button"></p>
<h3>Completed tasks</h3>
<p><a class="todo" href="{% url 'todo-completed_tasks' list_id list_slug %}">View completed tasks</a></p>
{% endifequal %}
<table border="0" id="tasktable">
<tr>
<th>Undo</th>
<th>Task</th>
<th>Created</th>
<th>Completed on</th>
<th>Note</th>
<th>Comm</th>
{% ifequal list_slug "mine" %}
<th>List</th>
{% endifequal %}
<th>Del</th>
</tr>
{% ifequal view_completed 1 %}
<h3>Completed tasks</h3>
{% for task in completed_list %}
<tr>
<td><input type="checkbox" name="undo_completed_task" value="{{ task.id }}" id="id_undo_completed_task{{ task.id }}"> </td>
<td><a href="{% url 'todo-task_detail' task.id %}">{{ task.title|truncatewords:20 }}</a></td>
<td>{{ task.created_date|date:"m/d/Y" }}</td>
<td>{{ task.completed_date|date:"m/d/Y" }}</td>
<td style="text-align:center;">{% if task.note %}&asymp;{% endif %} </td>
<td style="text-align:center;">{% ifnotequal task.comment_set.all.count 0 %}{{ task.comment_set.all.count }}{% endifnotequal %}
<td><input type="checkbox" name="del_completed_task" value="{{ task.id }}" id="del_completed_task_{{ task.id }}"> </td>
</tr>
{% endfor %}
<table border="0" id="tasktable">
<tr>
<th>Undo</th>
<th>Task</th>
<th>Created</th>
<th>Completed on</th>
<th>Note</th>
<th>Comm</th>
{% ifequal list_slug "mine" %}
<th>List</th>
{% endifequal %}
<th>Del</th>
</tr>
</table>
<p><input type="submit" name="deldonetasks" value="Continue..." class="todo-button"></p>
</form>
<p><a class="todo" href="{% url 'todo-incomplete_tasks' list_id list_slug %}">View incomplete tasks</a></p>
{% endif %}
{% if user.is_staff %}
{% if list_slug != "mine" %}
<p><a class="todo" href="{% url 'todo-del_list' list_id list_slug %}">Delete this list</a></p>
{% endif %}
{% endif %}
{% for task in completed_list %}
<tr>
<td><input type="checkbox" name="undo_completed_task" value="{{ task.id }}" id="id_undo_completed_task{{ task.id }}"> </td>
<td><a href="{% url 'todo-task_detail' task.id %}">{{ task.title|truncatewords:20 }}</a></td>
<td>{{ task.created_date|date:"m/d/Y" }}</td>
<td>{{ task.completed_date|date:"m/d/Y" }}</td>
<td style="text-align:center;">{% if task.note %}&asymp;{% endif %} </td>
<td style="text-align:center;">{% ifnotequal task.comment_set.all.count 0 %}{{ task.comment_set.all.count }}{% endifnotequal %}
<td><input type="checkbox" name="del_completed_task" value="{{ task.id }}" id="del_completed_task_{{ task.id }}"> </td>
</tr>
{% endfor %}
</table>
<p><input type="submit" name="deldonetasks" value="Continue..." class="todo-button"></p>
</form>
<p><a class="todo" href="{% url 'todo-incomplete_tasks' list_id list_slug %}">View incomplete tasks</a></p>
{% endifequal %}
{% ifequal can_del 1 %}
{% ifnotequal list_slug "mine" %}
<p><a class="todo" href="{% url 'todo-del_list' list_id list_slug %}">Delete this list</a></p>
{% endifnotequal %}
{% endifequal %}
{% endifequal %}
{% endblock %}
{% endif %}
{% endblock %}

View file

@ -17,73 +17,70 @@
});
</script>
{% ifequal auth_ok 1 %}
<h2>{{ task }}</h2>
<form action="" method="POST">
{% csrf_token %}
<p id="slideToggle" ><strong>&rarr; Click to edit details &larr;</strong></p>
{% csrf_token %}
<p><strong>In list:</strong> <a href="{% url 'todo-incomplete_tasks' task.list.id task.list.slug %}" class="showlink">{{ task.list }}</a><br />
<strong>Assigned to:</strong> {{ task.assigned_to.first_name }} {{ task.assigned_to.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>Completed:</strong> {{ form.completed }}<br />
</p>
<p id="slideToggle" ><strong>&rarr; Click to edit details &larr;</strong></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>Assigned to:</strong> {{ task.assigned_to.first_name }} {{ task.assigned_to.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>Completed:</strong> {{ form.completed }}<br />
</p>
{% if task.note %}
<div class="task_note"><strong>Note:</strong> {{ task.note|safe|urlize|linebreaks }}</div>
{% endif %}
{% if task.note %}
<div class="task_note"><strong>Note:</strong> {{ task.note|safe|urlize|linebreaks }}</div>
{% endif %}
<div id="TaskEdit">
<h3>Edit Task</h3>
<div id="TaskEdit">
<h3>Edit Task</h3>
<table>
{{ form.management_form }}
{{ form.id }}
<tr>
<td>Title:</td>
<td>{{ form.title }} </td>
</tr>
<table>
{{ form.management_form }}
{{ form.id }}
<tr>
<td>Title:</td>
<td>{{ form.title }} </td>
</tr>
<tr>
<td>List:</td>
<td>{{ form.list }} </td>
</tr>
<tr>
<td>List:</td>
<td>{{ form.list }} </td>
</tr>
<tr>
<td>Due:</td>
<td>{{ form.due_date }} </td>
</tr>
<tr>
<td>Due:</td>
<td>{{ form.due_date }} </td>
</tr>
<tr>
<td>Assigned to:</td>
<td>{{ form.assigned_to }} </td>
</tr>
<tr>
<td>Assigned to:</td>
<td>{{ form.assigned_to }} </td>
</tr>
<tr>
<td valign="top">Note:</td>
<td>{{ form.note }} </td>
</tr>
<tr>
<td valign="top">Note:</td>
<td>{{ form.note }} </td>
</tr>
<tr>
<td>Priority:</td>
<td>{{ form.priority }} </td>
</tr>
<tr>
<td>Priority:</td>
<td>{{ form.priority }} </td>
</tr>
</table>
<p><input type="submit" class="todo-button" name="edit_task" value="Edit task"></p>
</div>
</table>
<p><input type="submit" class="todo-button" name="edit_task" value="Edit task"></p>
</div>
<hr />
<hr />
<h3>Add comment</h3>
<h3>Add comment</h3>
<textarea name="comment-body"></textarea>
<p><input class="todo-button"type="submit" value="Submit"></p>
@ -92,12 +89,16 @@
<h3>Comments on this task</h3>
<div class="task_comments">
{% for comment in comment_list %}
<p><strong>{{ comment.author.first_name }} {{ comment.author.last_name }}, {{ comment.date|date:"F d Y P" }}</strong> </p>
{{ comment.body|safe|urlize|linebreaks }}
{% empty %}
<p>No Comments</p>
{% endfor %}
{% for comment in comment_list %}
<p>
<strong>{{ comment.author.first_name }} {{ comment.author.last_name }},
{{ comment.date|date:"F d Y P" }}
</strong>
</p>
{{ comment.body|safe|urlize|linebreaks }}
{% empty %}
<p>No Comments</p>
{% endfor %}
</div>
{% endifequal %}