add when and completed to teamtask model, move task list to an included file
This commit is contained in:
parent
eb8e548c3f
commit
73ec701b06
24
src/teams/migrations/0043_auto_20180804_1641.py
Normal file
24
src/teams/migrations/0043_auto_20180804_1641.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 2.0.4 on 2018-08-04 14:41
|
||||
|
||||
import django.contrib.postgres.fields.ranges
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('teams', '0042_auto_20180413_1933'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='teamtask',
|
||||
name='completed',
|
||||
field=models.BooleanField(default=False, help_text='Check to mark this task as completed.'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='teamtask',
|
||||
name='when',
|
||||
field=django.contrib.postgres.fields.ranges.DateTimeRangeField(blank=True, help_text='When does this task need to be started and/or finished?', null=True),
|
||||
),
|
||||
]
|
|
@ -4,6 +4,7 @@ from django.dispatch import receiver
|
|||
from django.utils.text import slugify
|
||||
from utils.models import CampRelatedModel
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.contrib.postgres.fields import DateTimeRangeField
|
||||
from django.contrib.auth.models import User
|
||||
from django.urls import reverse_lazy
|
||||
from django.conf import settings
|
||||
|
@ -280,6 +281,15 @@ class TeamTask(CampRelatedModel):
|
|||
description = models.TextField(
|
||||
help_text='Description of the task. Markdown is supported.'
|
||||
)
|
||||
when = DateTimeRangeField(
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='When does this task need to be started and/or finished?'
|
||||
)
|
||||
completed = models.BooleanField(
|
||||
help_text='Check to mark this task as completed.',
|
||||
default=False
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
|
|
44
src/teams/templates/includes/team_tasks.html
Normal file
44
src/teams/templates/includes/team_tasks.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Tasks</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>The {{ team.name }} Team is responsible for the following tasks</p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>When</th>
|
||||
<th>Completed</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for task in team.tasks.all %}
|
||||
<tr>
|
||||
<td><a href="{% url 'teams:task_detail' slug=task.slug camp_slug=camp.slug team_slug=team.slug %}">{{ task.name }}</a></td>
|
||||
<td>{{ task.description }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Start: {{ task.when.lower|default:"N/A" }}<br>
|
||||
<li>Finish: {{ task.when.upper|default:"N/A" }}<br>
|
||||
</ul>
|
||||
</td>
|
||||
<td>{{ task.completed }}</td>
|
||||
<td>
|
||||
<a href="{% url 'teams:task_detail' camp_slug=camp.slug team_slug=team.slug slug=task.slug %}" class="btn btn-primary btn-sm"><i class="fas fa-search"></i> Details</a>
|
||||
{% if request.user in team.responsible_members.all %}
|
||||
<a href="{% url 'teams:task_update' camp_slug=camp.slug team_slug=team.slug slug=task.slug %}" class="btn btn-primary btn-sm"><i class="fas fa-edit"></i> Edit Task</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if request.user in team.responsible_members.all %}
|
||||
<a href="{% url 'teams:task_create' camp_slug=camp.slug team_slug=team.slug %}" class="btn btn-primary"><i class="fas fa-plus"></i> Create Task</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -7,8 +7,15 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><h4>Task: {{ task.name }}</h4></div>
|
||||
<div class="panel-body">{{ task.description|untrustedcommonmark }}</div>
|
||||
<div class="panel-heading"><h4>Task: {{ task.name }} ({% if not task.completed %}Not {% endif %}Completed)</h4></div>
|
||||
<div class="panel-body">
|
||||
{{ task.description|untrustedcommonmark }}
|
||||
<hr>
|
||||
<ul>
|
||||
<li>Start: {{ task.when.lower|default:"N/A" }}<br>
|
||||
<li>Finish: {{ task.when.upper|default:"N/A" }}<br>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="panel-footer"><i>This task belongs to the <a href="{% url 'teams:detail' team_slug=task.team.slug camp_slug=task.team.camp.slug %}">{{ task.team.name }} Team</a></i></div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -53,41 +53,7 @@ Team: {{ team.name }} | {{ block.super }}
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{# Team tasks #}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Tasks</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>The {{ team.name }} Team is responsible for the following tasks</p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for task in team.tasks.all %}
|
||||
<tr>
|
||||
<td><a href="{% url 'teams:task_detail' slug=task.slug camp_slug=camp.slug team_slug=team.slug %}">{{ task.name }}</a></td>
|
||||
<td>{{ task.description }}</td>
|
||||
<td>
|
||||
<a href="{% url 'teams:task_detail' camp_slug=camp.slug team_slug=team.slug slug=task.slug %}" class="btn btn-primary btn-sm"><i class="fas fa-search"></i> Details</a>
|
||||
{% if request.user in team.responsible_members.all %}
|
||||
<a href="{% url 'teams:task_update' camp_slug=camp.slug team_slug=team.slug slug=task.slug %}" class="btn btn-primary btn-sm"><i class="fas fa-edit"></i> Edit Task</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if request.user in team.responsible_members.all %}
|
||||
<a href="{% url 'teams:task_create' camp_slug=camp.slug team_slug=team.slug %}" class="btn btn-primary"><i class="fas fa-plus"></i> Create Task</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% include 'includes/team_tasks.html' %}
|
||||
|
||||
{# Team members #}
|
||||
<div class="panel panel-default">
|
||||
|
|
|
@ -94,5 +94,9 @@ Manage Team: {{ team.name }} | {{ block.super }}
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include 'includes/team_tasks.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class TaskDetailView(CampViewMixin, DetailView):
|
|||
class TaskCreateView(LoginRequiredMixin, CampViewMixin, EnsureTeamResponsibleMixin, CreateView):
|
||||
model = TeamTask
|
||||
template_name = "task_form.html"
|
||||
fields = ['name', 'description']
|
||||
fields = ['name', 'description', 'when', 'completed']
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
@ -38,7 +38,7 @@ class TaskCreateView(LoginRequiredMixin, CampViewMixin, EnsureTeamResponsibleMix
|
|||
class TaskUpdateView(LoginRequiredMixin, CampViewMixin, EnsureTeamResponsibleMixin, UpdateView):
|
||||
model = TeamTask
|
||||
template_name = "task_form.html"
|
||||
fields = ['name', 'description']
|
||||
fields = ['name', 'description', 'when', 'completed']
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
|
Loading…
Reference in a new issue