Browse Source

Добавил задачи

devel
Dmitry 9 years ago
parent
commit
5de617c27d
  1. 3
      taskapp/forms.py
  2. 32
      taskapp/models.py
  3. 8
      templates/taskapp/add_edit_task.html
  4. 8
      templates/taskapp/tasklist.html
  5. 8
      templates/taskapp/tasklist_active.html
  6. 8
      templates/taskapp/tasklist_finish.html
  7. 8
      templates/taskapp/tasklist_own.html

3
taskapp/forms.py

@ -20,7 +20,8 @@ class TaskFrm(forms.ModelForm):
'priority': forms.Select(attrs={'class': 'form-control'}),
'state': forms.Select(attrs={'class': 'form-control'}),
'out_date': forms.DateInput(attrs={'class': 'form-control'}),
'attachment': forms.FileInput(attrs={'class': 'form-control'})
'attachment': forms.FileInput(attrs={'class': 'form-control'}),
'mode': forms.Select(attrs={'class': 'form-control'})
}
initials = {
'out_date': datetime.now()+timedelta(days=7)

32
taskapp/models.py

@ -2,11 +2,13 @@
from __future__ import unicode_literals
from datetime import datetime, timedelta
import os
from subprocess import call
from django.db import models
from django.conf import settings
from devapp.models import Device
from djing.settings import BASE_DIR
TASK_PRIORITIES = (
@ -23,6 +25,18 @@ TASK_STATES = (
(b'F', u'Выполнена')
)
TASK_TYPES = (
(b'na', u'не выбрано'),
(b'yt', u'жёлтый треугольник'),
(b'rc', u'красный крестик'),
(b'ls', u'слабая скорость'),
(b'cf', u'обрыв кабеля'),
(b'cn', u'подключение'),
(b'pf', u'переодическое пропадание'),
(b'cr', u'настройка роутера'),
(b'ot', u'другое')
)
class Task(models.Model):
descr = models.CharField(max_length=128)
@ -34,6 +48,7 @@ class Task(models.Model):
time_of_create = models.DateTimeField(auto_now_add=True)
state = models.CharField(max_length=1, choices=TASK_STATES, default=TASK_STATES[0][0])
attachment = models.ImageField(upload_to='task_attachments/%Y.%m.%d', blank=True, null=True)
mode = models.CharField(max_length=2, choices=TASK_TYPES, default=TASK_TYPES[0][0])
def __unicode__(self):
return self.descr
@ -48,3 +63,18 @@ class Task(models.Model):
def begin(self, current_user):
self.state = 'C' # Начата
def task_handler(sender, instance, **kwargs):
cur_dir = os.path.join(BASE_DIR, "taskapp")
if kwargs['created']:
call(['%s/handle.sh' % cur_dir, 'start', instance.mode, instance.device.ip_address,
instance.state, instance.descr])
print 'Create task from', instance.author, ' to ', instance.recipient
else:
call(['%s/handle.sh' % cur_dir, 'change', instance.mode, instance.device.ip_address,
instance.state, instance.descr])
print 'Change task'
models.signals.post_save.connect(task_handler, sender=Task)

8
templates/taskapp/add_edit_task.html

@ -48,6 +48,14 @@
{{ form.device }}{{ form.device.errors }}
</div>
</div>
<div class="form-group">
<label for="id_mode">Характер поломки</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-pawn"></span></span>
{{ form.mode }}{{ form.mode.errors }}
</div>
</div>
<div class="form-group">
<label for="id_priority">Приоритет</label>

8
templates/taskapp/tasklist.html

@ -6,9 +6,10 @@
<thead>
<tr>
<th>#</th>
<th class="col-sm-3">Пару слов..</th>
<th class="col-sm-2">Пару слов..</th>
<th class="col-sm-1">Кому назначена</th>
<th class="col-sm-1">Кто назначил</th>
<th class="col-sm-1">Характер поломки</th>
<th class="col-sm-1">Состояние</th>
<th class="col-sm-1">Приоритет</th>
<th class="col-sm-1">Устройство</th>
@ -37,6 +38,7 @@
<td>{{ task.descr }}</td>
<td><a href="{% url 'other_profile' task.recipient.id %}" title="{{ task.recipient.get_full_name }}">{{ task.recipient.username }}</a></td>
<td><a href="{% url 'other_profile' task.author.id %}" title="{{ task.author.get_full_name }}">{{ task.author.username }}</a></td>
<td>{{ task.get_mode_display }}</td>
<td>{{ task.get_state_display }}</td>
<td>{{ task.get_priority_display }}</td>
<td><a href="{% url 'devs_view_link' task.device.id %}" target="_blank">{{ task.device.ip_address }}</a></td>
@ -56,13 +58,13 @@
</tr>
{% empty %}
<tr>
<td colspan="12">Список пуст</td>
<td colspan="13">Список пуст</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="12">
<td colspan="13">
<a href="{% url 'task_add' %}" class="btn btn-sm btn-success" title="Создать новую задачу">
<span class="glyphicon glyphicon-plus"></span>
</a>

8
templates/taskapp/tasklist_active.html

@ -6,9 +6,10 @@
<thead>
<tr>
<th>#</th>
<th class="col-sm-3">Пару слов..</th>
<th class="col-sm-2">Пару слов..</th>
<th class="col-sm-1">Кому назначена</th>
<th class="col-sm-1">Кто назначил</th>
<th class="col-sm-1">Характер поломки</th>
<th class="col-sm-1">Состояние</th>
<th class="col-sm-1">Приоритет</th>
<th class="col-sm-1">Устройство</th>
@ -39,6 +40,7 @@
title="{{ task.recipient.get_full_name }}">{{ task.recipient.username }}</a></td>
<td><a href="{% url 'other_profile' task.author.id %}"
title="{{ task.author.get_full_name }}">{{ task.author.username }}</a></td>
<td>{{ task.get_mode_display }}</td>
<td>{{ task.get_state_display }}</td>
<td>{{ task.get_priority_display }}</td>
<td><a href="{% url 'devs_view_link' task.device.id %}" target="_blank">{{ task.device.ip_address }}</a></td>
@ -58,13 +60,13 @@
</tr>
{% empty %}
<tr>
<td colspan="12">Список пуст</td>
<td colspan="13">Список пуст</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="12">
<td colspan="13">
<a href="{% url 'task_add' %}" class="btn btn-sm btn-success" title="Создать новую задачу">
<span class="glyphicon glyphicon-plus"></span>
</a>

8
templates/taskapp/tasklist_finish.html

@ -6,9 +6,10 @@
<thead>
<tr>
<th>#</th>
<th class="col-sm-3">Пару слов..</th>
<th class="col-sm-2">Пару слов..</th>
<th class="col-sm-1">Кому назначена</th>
<th class="col-sm-1">Кто назначил</th>
<th class="col-sm-1">Характер поломки</th>
<th class="col-sm-1">Состояние</th>
<th class="col-sm-1">Приоритет</th>
<th class="col-sm-1">Устройство</th>
@ -39,6 +40,7 @@
title="{{ task.recipient.get_full_name }}">{{ task.recipient.username }}</a></td>
<td><a href="{% url 'other_profile' task.author.id %}"
title="{{ task.author.get_full_name }}">{{ task.author.username }}</a></td>
<td>{{ task.get_mode_display }}</td>
<td>{{ task.get_state_display }}</td>
<td>{{ task.get_priority_display }}</td>
<td><a href="{% url 'devs_view_link' task.device.id %}" target="_blank">{{ task.device.ip_address }}</a></td>
@ -55,13 +57,13 @@
</tr>
{% empty %}
<tr>
<td colspan="12">Список пуст</td>
<td colspan="13">Список пуст</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="12">
<td colspan="13">
<a href="{% url 'task_add' %}" class="btn btn-sm btn-success" title="Создать новую задачу">
<span class="glyphicon glyphicon-plus"></span>
</a>

8
templates/taskapp/tasklist_own.html

@ -6,8 +6,9 @@
<thead>
<tr>
<th>#</th>
<th class="col-sm-5">Пару слов..</th>
<th class="col-sm-4">Пару слов..</th>
<th class="col-sm-1">Кому назначена</th>
<th class="col-sm-1">Характер поломки</th>
<th class="col-sm-1">Состояние</th>
<th class="col-sm-1">Приоритет</th>
<th class="col-sm-1">Устройство</th>
@ -36,6 +37,7 @@
<td>{{ task.descr }}</td>
<td><a href="{% url 'other_profile' task.recipient.id %}"
title="{{ task.recipient.get_full_name }}">{{ task.recipient.username }}</a></td>
<td>{{ task.get_mode_display }}</td>
<td>{{ task.get_state_display }}</td>
<td>{{ task.get_priority_display }}</td>
<td><a href="{% url 'devs_view_link' task.device.id %}" target="_blank">{{ task.device.ip_address }}</a></td>
@ -52,13 +54,13 @@
</tr>
{% empty %}
<tr>
<td colspan="9">Все ваши задачи выполнены</td>
<td colspan="10">Все ваши задачи выполнены</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="9">
<td colspan="10">
<a href="{% url 'task_add' %}" class="btn btn-sm btn-success" title="Создать новую задачу">
<span class="glyphicon glyphicon-plus"></span>
</a>

Loading…
Cancel
Save