ipsg, aop & pfr checked!
This commit is contained in:
parent
05c217a7df
commit
7247ed1083
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
14
jci/admin.py
14
jci/admin.py
|
@ -1,17 +1,23 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Headline, Section, Standard
|
||||
from .models import Chapter, Section, Standard
|
||||
|
||||
|
||||
class HeadlineAdmin(admin.ModelAdmin):
|
||||
class InlineStandard(admin.StackedInline):
|
||||
model = Standard
|
||||
|
||||
|
||||
class ChapterAdmin(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'acronym')
|
||||
list_filter = ('section',)
|
||||
inlines = [InlineStandard]
|
||||
|
||||
|
||||
class StandardAdmin(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'name')
|
||||
list_display = ('__str__', 'name', 'parent')
|
||||
list_filter = ('headline__acronym',)
|
||||
|
||||
|
||||
admin.site.register(Headline, HeadlineAdmin)
|
||||
admin.site.register(Chapter, ChapterAdmin)
|
||||
admin.site.register(Standard, StandardAdmin)
|
||||
admin.site.register(Section)
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-10-18 07:02
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0014_auto_20170920_1436'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='Headline',
|
||||
new_name='Chapter',
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='standardclosure',
|
||||
unique_together=set([]),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='standardclosure',
|
||||
name='child',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='standardclosure',
|
||||
name='parent',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='standard',
|
||||
name='order',
|
||||
field=models.CharField(max_length=50),
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='StandardClosure',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-10-18 07:05
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0015_auto_20171018_0902'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='standard',
|
||||
name='parent',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-10-18 07:39
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0016_remove_standard_parent'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='standard',
|
||||
options={'ordering': ('headline__acronym', 'order')},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='standard',
|
||||
name='parent',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='jci.Standard'),
|
||||
),
|
||||
]
|
|
@ -1,5 +1,4 @@
|
|||
from django.db import models
|
||||
from closuretree.models import ClosureModel
|
||||
|
||||
|
||||
class Section(models.Model):
|
||||
|
@ -12,7 +11,7 @@ class Section(models.Model):
|
|||
ordering = ('name',)
|
||||
|
||||
|
||||
class Headline(models.Model):
|
||||
class Chapter(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
section = models.ForeignKey(Section, related_name='headlines')
|
||||
acronym = models.CharField(max_length=10)
|
||||
|
@ -25,19 +24,19 @@ class Headline(models.Model):
|
|||
ordering = ('name',)
|
||||
|
||||
|
||||
class Standard(ClosureModel):
|
||||
class Standard(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
parent = models.ForeignKey('self', related_name='children', null=True, blank=True)
|
||||
headline = models.ForeignKey(Headline, related_name='standards')
|
||||
order = models.IntegerField()
|
||||
headline = models.ForeignKey(Chapter, related_name='standards')
|
||||
order = models.CharField(max_length=50)
|
||||
parent = models.ForeignKey('self', null=True, blank=True)
|
||||
|
||||
@property
|
||||
def structure(self):
|
||||
return '.'.join([str(x.order) for x in self.get_ancestors()] + [str(self.order)])
|
||||
return self.order
|
||||
|
||||
def __str__(self):
|
||||
return '{}.{}'.format(self.headline.acronym, self.structure)
|
||||
|
||||
class Meta:
|
||||
ordering = ('headline__acronym',)
|
||||
ordering = ('headline__acronym', 'order')
|
||||
|
||||
|
|
Loading…
Reference in New Issue