From 9d6c21e27aa6f61cb9cd1c137d7baa8c188f167e Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Wed, 20 Sep 2017 15:51:01 +0200 Subject: [PATCH] searching how tasks and process should work together --- db.sqlite3 | Bin 389120 -> 389120 bytes process/admin.py | 7 ++++++- process/migrations/0003_task_status.py | 21 +++++++++++++++++++++ process/models.py | 21 ++++++++++++++++++++- 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 process/migrations/0003_task_status.py diff --git a/db.sqlite3 b/db.sqlite3 index 7d20d18e7a47e2655b56116e13289acd53682188..f8dab28aa2202f21aa5666eff38700a8b4570c1d 100644 GIT binary patch delta 695 zcmYjNO-vI(6rP#gv21^w5{eCC;<^Tr&~|sJP~_A`PtsCt8O1fJNx30x# zOi0isj(Q|`;AF@~dNA=|;>81nc<^K(@d$}C|p?@Ss+{p&sJUjVT5NL-5gaVbm~9MNy)frJD~l z)6%Vy*`uhjuyQfnqljvB;DS2P8;eAH`=foT^SL$QhD=NBZt~6hX2~L1bP`J1*A`5) z##=6N-S9wDJGhZEA6|wqRJ|kjBC=JTlTS8Z<~okj8fCfa2U+D=*MZ8m{A62(42XfN zZOeRMwF!}3Kz@_m_g=h7=;}wv(_cT4P~-hrRNUZ^`;}+S?eVPDB5^z|5Kj_h?VMe3 z1!WmlApMlYofIZ4c5xWo zfWlbO7%LQ~BUZ7L&l}_Vgc&!Ax;bt{O8HDgAB|)TbPi#V7U*&vOUF7P2G<1oy^ha% o8?uP31F}ihndnz?#*KI&v|Tr*a>m0J$ar_wxUZM;mU!UyFYxrr4FCWD delta 529 zcmX|6F>KRN5dGi&SI23h?*PRr2oXh!pfccA$O}`VPE8XfOr;=jLSw3mP)D%~0+u)o ztSKITCx%djV6zPMz}%q|jIG2F#F$EitwRQWP{Zk-?sWI`^j^EKw)<-LV(I`PWO6*< zz`XBmU%QD9g6b|6HQ4thWhKnduS2*$laJ$`FQv5@{g~|0V|vUV<>aiI7Y(`Dvezuf zF(=cs8}+bveGg;JU)2o(A-}6%Nae&Vo>1JH^H}h|>I>w|qNu$Z>aT}7<`6iQ2^i4r3b0X`#3G_VdOkjVG+jiU_zvnsH*)Y?o=rsPk2K{uQ#=Vm-Yu^s zsg{Agb@r|RIWWhb*slUq7XPi8^wmt=UfX(NZMx=DtL1Fio90G6Gsks~B-Jo*r{vZi zHmr%^$sFr6*-imI6HoSlQ$c-}P)s&1P}u8T+vem+*ZSc~Y80S8%+x+~SQW1+t9!m)}z{1!%d&Y F`U{rio;d&j diff --git a/process/admin.py b/process/admin.py index b18c799..73cf816 100644 --- a/process/admin.py +++ b/process/admin.py @@ -2,8 +2,13 @@ from django.contrib import admin from process.models import Approval, Review, GatherComments, Knowledge, Task + +class TaskAdmin(admin.ModelAdmin): + list_display = ('assigned_to', 'process',) + + admin.site.register(Approval) admin.site.register(Review) admin.site.register(GatherComments) admin.site.register(Knowledge) -admin.site.register(Task) +admin.site.register(Task, TaskAdmin) diff --git a/process/migrations/0003_task_status.py b/process/migrations/0003_task_status.py new file mode 100644 index 0000000..c254f03 --- /dev/null +++ b/process/migrations/0003_task_status.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-09-20 13:41 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('process', '0002_process_process_type'), + ] + + operations = [ + migrations.AddField( + model_name='task', + name='status', + field=models.IntegerField(choices=[(1, 'Created'), (3, 'Completed')], default=1), + preserve_default=False, + ), + ] diff --git a/process/models.py b/process/models.py index f737f31..13f219f 100644 --- a/process/models.py +++ b/process/models.py @@ -13,12 +13,28 @@ class Process(models.Model): self.process_type = self.PROCESS_TYPE def __str__(self): - return self.process_type + return '{}: {}'.format(self.process_type, self.document_version) + + def create_task(self, assigned_to): + task, created = Task.objects.get_or_create(status=1, assigned_to=assigned_to, process=self) + + if created: + task.save() + + def allow_tasks_delegation(self): + return True + + +TASK_STATUS = ( + (1, 'Created'), + (3, 'Completed') +) class Task(models.Model): assigned_to = models.EmailField() process = models.ForeignKey(Process) + status = models.IntegerField(choices=TASK_STATUS) def __str__(self): return '{} - {}'.format(self.process, self.assigned_to) @@ -41,3 +57,6 @@ class GatherComments(Process): class Knowledge(Process): PROCESS_TYPE = 'Knowledge' + + def allow_tasks_delegation(self): + return False