create Tasks and process models
This commit is contained in:
parent
99a8d33660
commit
7e0bd7f999
|
@ -40,6 +40,8 @@ INSTALLED_APPS = [
|
|||
'evolus',
|
||||
'jci',
|
||||
'crispy_forms',
|
||||
'simple_history',
|
||||
'process'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
@ -1,6 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from simple_history.admin import SimpleHistoryAdmin
|
||||
|
||||
from .models import Audience, Document, DocumentType, Site, Structure
|
||||
from .models import Audience, Document, DocumentType, Version, Site, Structure
|
||||
|
||||
|
||||
class DocumentAdmin(admin.ModelAdmin):
|
||||
|
@ -16,3 +17,4 @@ admin.site.register(Site)
|
|||
admin.site.register(Structure)
|
||||
admin.site.register(Document, DocumentAdmin)
|
||||
admin.site.register(DocumentType, DocumentTypeAdmin)
|
||||
admin.site.register(Version)
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-20 12:36
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('evolus', '0012_auto_20170919_1619'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='HistoricalDocument',
|
||||
fields=[
|
||||
('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=255)),
|
||||
('overview', models.TextField(blank=True, null=True)),
|
||||
('created_at', models.DateTimeField(blank=True, editable=False)),
|
||||
('revised_at', models.DateTimeField(blank=True, null=True)),
|
||||
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('history_date', models.DateTimeField()),
|
||||
('history_change_reason', models.CharField(max_length=100, null=True)),
|
||||
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
||||
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
||||
('type', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='evolus.DocumentType')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'historical document',
|
||||
'ordering': ('-history_date', '-history_id'),
|
||||
'get_latest_by': 'history_date',
|
||||
},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='audience',
|
||||
options={'ordering': ('name',)},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='document',
|
||||
name='created_at',
|
||||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='document',
|
||||
name='revised_at',
|
||||
field=models.DateTimeField(blank=True, null=True),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-20 13:02
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('evolus', '0013_auto_20170920_1436'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Version',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('major', models.IntegerField()),
|
||||
('minor', models.IntegerField()),
|
||||
('patch', models.IntegerField()),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='evolus.Document')),
|
||||
],
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='version',
|
||||
unique_together=set([('document', 'major', 'minor', 'patch')]),
|
||||
),
|
||||
]
|
|
@ -4,6 +4,7 @@ This module defines the structure and properties of documents.
|
|||
|
||||
from django.db import models
|
||||
from closuretree.models import ClosureModel
|
||||
from simple_history.models import HistoricalRecords
|
||||
|
||||
from jci.models import Standard
|
||||
|
||||
|
@ -58,6 +59,29 @@ class Document(models.Model):
|
|||
title = models.CharField(max_length=255)
|
||||
overview = models.TextField(blank=True, null=True)
|
||||
type = models.ForeignKey(DocumentType, null=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
revised_at = models.DateTimeField(null=True, blank=True)
|
||||
history = HistoricalRecords()
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def update_version(self, document):
|
||||
pass
|
||||
|
||||
def publish(self):
|
||||
pass
|
||||
|
||||
|
||||
class Version(models.Model):
|
||||
document = models.ForeignKey(Document)
|
||||
major = models.IntegerField()
|
||||
minor = models.IntegerField()
|
||||
patch = models.IntegerField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('document', 'major', 'minor', 'patch')
|
||||
|
||||
def __str__(self):
|
||||
return '{} v{}.{}.{}'.format(self.document, self.major, self.minor, self.patch)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-20 12:36
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0013_auto_20170919_1930'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='standard',
|
||||
options={'ordering': ('headline__acronym',)},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='headline',
|
||||
name='section',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='headlines', to='jci.Section'),
|
||||
),
|
||||
]
|
|
@ -4,13 +4,10 @@ from django import template
|
|||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
@register.inclusion_tag('jci/documents_counting.html')
|
||||
def count_documents(standard):
|
||||
nbr_of_documents = standard.documents.count()
|
||||
if nbr_of_documents == 0:
|
||||
return "<span style='color: red;'>({} documents)</span>".format(nbr_of_documents)
|
||||
else:
|
||||
return "({} documents)".format(nbr_of_documents)
|
||||
return {'count': nbr_of_documents}
|
||||
|
||||
|
||||
@register.inclusion_tag('jci/_goals.html')
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from process.models import Approval, Review, GatherComments, Knowledge, Task
|
||||
|
||||
admin.site.register(Approval)
|
||||
admin.site.register(Review)
|
||||
admin.site.register(GatherComments)
|
||||
admin.site.register(Knowledge)
|
||||
admin.site.register(Task)
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProcessConfig(AppConfig):
|
||||
name = 'process'
|
|
@ -0,0 +1,69 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-20 13:06
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('evolus', '0014_auto_20170920_1502'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Process',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Task',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('assigned_to', models.EmailField(max_length=254)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Approval',
|
||||
fields=[
|
||||
('process_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='process.Process')),
|
||||
],
|
||||
bases=('process.process',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GatherComments',
|
||||
fields=[
|
||||
('process_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='process.Process')),
|
||||
],
|
||||
bases=('process.process',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Knowledge',
|
||||
fields=[
|
||||
('process_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='process.Process')),
|
||||
],
|
||||
bases=('process.process',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Review',
|
||||
fields=[
|
||||
('process_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='process.Process')),
|
||||
],
|
||||
bases=('process.process',),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='task',
|
||||
name='process',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='process.Process'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='process',
|
||||
name='document_version',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='evolus.Version'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-20 13:32
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('process', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='process',
|
||||
name='process_type',
|
||||
field=models.CharField(default='default process', max_length=50),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -0,0 +1,43 @@
|
|||
from django.db import models
|
||||
|
||||
from evolus.models import Version
|
||||
|
||||
|
||||
class Process(models.Model):
|
||||
process_type = models.CharField(max_length=50)
|
||||
document_version = models.ForeignKey(Version)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if not self.pk and not self.process_type:
|
||||
self.process_type = self.PROCESS_TYPE
|
||||
|
||||
def __str__(self):
|
||||
return self.process_type
|
||||
|
||||
|
||||
class Task(models.Model):
|
||||
assigned_to = models.EmailField()
|
||||
process = models.ForeignKey(Process)
|
||||
|
||||
def __str__(self):
|
||||
return '{} - {}'.format(self.process, self.assigned_to)
|
||||
|
||||
|
||||
class Review(Process):
|
||||
PROCESS_TYPE = 'Review'
|
||||
|
||||
def __str__(self):
|
||||
return 'Review: {}'.format(self.document_version)
|
||||
|
||||
|
||||
class Approval(Process):
|
||||
PROCESS_TYPE = 'Approval'
|
||||
|
||||
|
||||
class GatherComments(Process):
|
||||
PROCESS_TYPE = 'GatherComments'
|
||||
|
||||
|
||||
class Knowledge(Process):
|
||||
PROCESS_TYPE = 'Knowledge'
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
|
@ -1,3 +1,4 @@
|
|||
django<1.12
|
||||
django-closuretree<1.2
|
||||
django-filter==1.0.4
|
||||
django-simple-history==1.9.0
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{% if count %}
|
||||
<span style="color: green;">({{ count }} documents)</span>
|
||||
{% else %}
|
||||
<span style="color: red;">(0 documents)</span>
|
||||
{% endif %}
|
|
@ -11,7 +11,7 @@
|
|||
{% if headline.standards.all %}
|
||||
<ul>
|
||||
{% for std in headline.standards.all %}
|
||||
<li>{{std}} - {{std.name}} {{ std | count_documents }} </li>
|
||||
<li>{{std}} - {{std.name}} {% count_documents std %} </li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue