add jci acc
This commit is contained in:
parent
26b823b14d
commit
9e76020aee
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
@ -3,12 +3,16 @@ from django.contrib import admin
|
|||
from process.models import Approval, Review, GatherComments, Knowledge, Task
|
||||
|
||||
|
||||
class ProcessAdmin(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'percentage_of_completion')
|
||||
|
||||
|
||||
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(Approval, ProcessAdmin)
|
||||
admin.site.register(Review, ProcessAdmin)
|
||||
admin.site.register(GatherComments, ProcessAdmin)
|
||||
admin.site.register(Knowledge, ProcessAdmin)
|
||||
admin.site.register(Task, TaskAdmin)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-21 18:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('process', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='task',
|
||||
name='assigned_to',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-21 18:55
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('process', '0002_auto_20170921_1847'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='task',
|
||||
name='process',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tasks', to='process.Process'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='task',
|
||||
unique_together=set([('assigned_to', 'process', 'status')]),
|
||||
),
|
||||
]
|
|
@ -1,5 +1,7 @@
|
|||
from django.db import models
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from evolus.models import Version
|
||||
|
||||
|
||||
|
@ -7,6 +9,12 @@ class Process(models.Model):
|
|||
process_type = models.CharField(max_length=50)
|
||||
document_version = models.ForeignKey(Version)
|
||||
|
||||
def percentage_of_completion(self):
|
||||
total = self.tasks.count()
|
||||
if total:
|
||||
return self.tasks.filter(status=3).count() / self.tasks.count() * 100
|
||||
return 'NaN'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if not self.pk and not self.process_type:
|
||||
|
@ -24,9 +32,6 @@ class Process(models.Model):
|
|||
def allow_tasks_delegation(self):
|
||||
return True
|
||||
|
||||
def save(self):
|
||||
raise NotImplemented('is_valid has to be implemented on the subprocess')
|
||||
|
||||
|
||||
TASK_STATUS = (
|
||||
(1, 'Created'),
|
||||
|
@ -35,13 +40,16 @@ TASK_STATUS = (
|
|||
|
||||
|
||||
class Task(models.Model):
|
||||
assigned_to = models.EmailField()
|
||||
process = models.ForeignKey(Process)
|
||||
assigned_to = models.ForeignKey(User)
|
||||
process = models.ForeignKey(Process, related_name='tasks')
|
||||
status = models.IntegerField(choices=TASK_STATUS)
|
||||
|
||||
def __str__(self):
|
||||
return '{} - {}'.format(self.process, self.assigned_to)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('assigned_to', 'process', 'status')
|
||||
|
||||
|
||||
class PublishedProcessMixin(object):
|
||||
def save(self, *args, **kwargs):
|
||||
|
@ -67,10 +75,20 @@ class Review(Process, PublishedProcessMixin):
|
|||
class Approval(Process, DraftProcessMixin):
|
||||
PROCESS_TYPE = 'Approval'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super().save()
|
||||
for validator in self.document_version.validators.all():
|
||||
self.create_task(validator)
|
||||
|
||||
|
||||
class GatherComments(Process, DraftProcessMixin):
|
||||
PROCESS_TYPE = 'GatherComments'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super().save()
|
||||
for reviewer in self.document_version.reviewers.all():
|
||||
self.create_task(reviewer)
|
||||
|
||||
|
||||
class Knowledge(Process, PublishedProcessMixin):
|
||||
PROCESS_TYPE = 'Knowledge'
|
||||
|
|
Loading…
Reference in New Issue