include basic django_filter on documents
This commit is contained in:
parent
173101ce30
commit
1f8c67632f
|
@ -0,0 +1,3 @@
|
|||
.vscode
|
||||
.idea
|
||||
*.pyc
|
|
@ -0,0 +1,122 @@
|
|||
"""
|
||||
Django settings for evolus project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 1.11.5.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.11/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.11/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'bob6lyq#dwr49fs26e!2#e!+e@1kr(2%7$-8767(vu+ja&c)uy'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'evolus',
|
||||
'jci',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'config.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': ['templates'],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'config.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.11/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
|
@ -0,0 +1,24 @@
|
|||
"""evolus URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/1.11/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.conf.urls import url, include
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf.urls import url
|
||||
from django.contrib import admin
|
||||
|
||||
from evolus.views import documents_list
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^list$', documents_list),
|
||||
]
|
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
WSGI config for evolus project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "evolus.settings")
|
||||
|
||||
application = get_wsgi_application()
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Audience, Document, Structure
|
||||
|
||||
|
||||
admin.site.register(Audience)
|
||||
admin.site.register(Structure)
|
||||
admin.site.register(Document)
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class EvolusConfig(AppConfig):
|
||||
name = 'evolus'
|
|
@ -0,0 +1,9 @@
|
|||
import django_filters
|
||||
|
||||
from evolus.models import Document
|
||||
|
||||
|
||||
class DocumentFilter(django_filters.FilterSet):
|
||||
class Meta:
|
||||
model = Document
|
||||
fields = ('audience', 'structure', 'standards')
|
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 07:12
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='JCI',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=50)),
|
||||
('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='evolus.JCI')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='JCIClosure',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('depth', models.IntegerField()),
|
||||
('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='jciclosure_parents', to='evolus.JCI')),
|
||||
('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='jciclosure_children', to='evolus.JCI')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'evolus_jciclosure',
|
||||
},
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='jciclosure',
|
||||
unique_together=set([('parent', 'child')]),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,83 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 07:25
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('evolus', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Audience',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=50)),
|
||||
('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='evolus.Audience')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AudienceClosure',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('depth', models.IntegerField()),
|
||||
('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='audienceclosure_parents', to='evolus.Audience')),
|
||||
('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='audienceclosure_children', to='evolus.Audience')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'evolus_audienceclosure',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Document',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('audience', models.ManyToManyField(to='evolus.Audience')),
|
||||
('jci', models.ManyToManyField(to='evolus.JCI')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Structure',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=50)),
|
||||
('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='evolus.Structure')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StructureClosure',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('depth', models.IntegerField()),
|
||||
('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='structureclosure_parents', to='evolus.Structure')),
|
||||
('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='structureclosure_children', to='evolus.Structure')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'evolus_structureclosure',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='document',
|
||||
name='structure',
|
||||
field=models.ManyToManyField(to='evolus.Structure'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='structureclosure',
|
||||
unique_together=set([('parent', 'child')]),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='audienceclosure',
|
||||
unique_together=set([('parent', 'child')]),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,37 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 07:49
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('evolus', '0002_auto_20170915_0925'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='jci',
|
||||
name='acronym',
|
||||
field=models.CharField(default='', max_length=50),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='audience',
|
||||
name='parent',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='evolus.Audience'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='jci',
|
||||
name='parent',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='evolus.JCI'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='structure',
|
||||
name='parent',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='evolus.Structure'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,47 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 07:54
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0001_initial'),
|
||||
('evolus', '0003_auto_20170915_0949'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='jci',
|
||||
name='parent',
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='jciclosure',
|
||||
unique_together=set([]),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='jciclosure',
|
||||
name='child',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='jciclosure',
|
||||
name='parent',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='document',
|
||||
name='jci',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='document',
|
||||
name='standards',
|
||||
field=models.ManyToManyField(to='jci.Standard'),
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='JCI',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='JCIClosure',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,31 @@
|
|||
"""
|
||||
This module defines the structure and properties of documents.
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
from closuretree.models import ClosureModel
|
||||
|
||||
from jci.models import Standard
|
||||
|
||||
|
||||
class Audience(ClosureModel):
|
||||
name = models.CharField(max_length=50)
|
||||
parent = models.ForeignKey('self', related_name='children', null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Structure(ClosureModel):
|
||||
name = models.CharField(max_length=50)
|
||||
parent = models.ForeignKey('self', related_name='children', null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Document(models.Model):
|
||||
audience = models.ManyToManyField(Audience)
|
||||
standards = models.ManyToManyField(Standard)
|
||||
structure = models.ManyToManyField(Structure)
|
||||
|
||||
def __str__(self):
|
||||
return '{} {}'.format(self.audience, self.structure)
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,7 @@
|
|||
from django.shortcuts import render
|
||||
from .models import Document
|
||||
from .filters import DocumentFilter
|
||||
|
||||
def documents_list(request):
|
||||
f = DocumentFilter(request.GET, queryset=Document.objects.all())
|
||||
return render(request, 'evolus/template.html', {'filter': f })
|
|
@ -0,0 +1,14 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Goal, Standard
|
||||
|
||||
|
||||
class GoalAdmin(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'acronym', 'order')
|
||||
|
||||
class StandardAdmin(admin.ModelAdmin):
|
||||
list_display = ('goal_acronym', 'structure', '__str__')
|
||||
|
||||
|
||||
admin.site.register(Goal, GoalAdmin)
|
||||
admin.site.register(Standard, StandardAdmin)
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class JciConfig(AppConfig):
|
||||
name = 'jci'
|
|
@ -0,0 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 07:54
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Goal',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=50)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Standard',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=50)),
|
||||
('acronym', models.CharField(max_length=50)),
|
||||
('goal', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='goals', to='jci.Goal')),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='jci.Standard')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StandardClosure',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('depth', models.IntegerField()),
|
||||
('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='standardclosure_parents', to='jci.Standard')),
|
||||
('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='standardclosure_children', to='jci.Standard')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'jci_standardclosure',
|
||||
},
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='standardclosure',
|
||||
unique_together=set([('parent', 'child')]),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 07:55
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='standard',
|
||||
name='description',
|
||||
field=models.TextField(default='', max_length=2000),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 07:56
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0002_standard_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='goal',
|
||||
name='name',
|
||||
field=models.CharField(max_length=50, unique=True),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,65 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 08:02
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0003_auto_20170915_0956'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='GoalClosure',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('depth', models.IntegerField()),
|
||||
],
|
||||
options={
|
||||
'db_table': 'jci_goalclosure',
|
||||
},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='standard',
|
||||
name='acronym',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='standard',
|
||||
name='description',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='goal',
|
||||
name='overview',
|
||||
field=models.TextField(default='', max_length=2000),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='goal',
|
||||
name='parent',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='jci.Goal'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='standard',
|
||||
name='goal',
|
||||
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='standards', to='jci.Goal'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='goalclosure',
|
||||
name='child',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='goalclosure_parents', to='jci.Goal'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='goalclosure',
|
||||
name='parent',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='goalclosure_children', to='jci.Goal'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='goalclosure',
|
||||
unique_together=set([('parent', 'child')]),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 08:05
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0004_auto_20170915_1002'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='goal',
|
||||
name='overview',
|
||||
field=models.TextField(blank=True, max_length=2000, null=True),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 08:07
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0005_auto_20170915_1005'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='standard',
|
||||
name='name',
|
||||
field=models.CharField(max_length=255),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 08:13
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0006_auto_20170915_1007'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='goal',
|
||||
name='order',
|
||||
field=models.IntegerField(blank=True, null=True),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-15 08:29
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jci', '0007_goal_order'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='goal',
|
||||
name='acronym',
|
||||
field=models.CharField(blank=True, max_length=10, null=True),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,30 @@
|
|||
from django.db import models
|
||||
from closuretree.models import ClosureModel
|
||||
|
||||
|
||||
class Goal(ClosureModel):
|
||||
name = models.CharField(max_length=50, unique=True)
|
||||
parent = models.ForeignKey('self', related_name='children', null=True, blank=True)
|
||||
acronym = models.CharField(max_length=10, blank=True, null=True)
|
||||
overview = models.TextField(max_length=2000, null=True, blank=True)
|
||||
order = models.IntegerField(blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Standard(ClosureModel):
|
||||
name = models.CharField(max_length=255)
|
||||
parent = models.ForeignKey('self', related_name='children', null=True, blank=True)
|
||||
goal = models.ForeignKey(Goal, related_name='standards')
|
||||
|
||||
@property
|
||||
def goal_acronym(self):
|
||||
return self.goal.get_root().name
|
||||
|
||||
@property
|
||||
def structure(self):
|
||||
return '.'.join([x.order if x.order else x.name for x in self.goal.get_ancestors()])
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
|
@ -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.
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError:
|
||||
# The above import may fail for some other reason. Ensure that the
|
||||
# issue is really that Django is missing to avoid masking other
|
||||
# exceptions on Python 2.
|
||||
try:
|
||||
import django
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
)
|
||||
raise
|
||||
execute_from_command_line(sys.argv)
|
|
@ -1,2 +1,3 @@
|
|||
django<1.12
|
||||
django-closuretree<1.2
|
||||
django-filter==1.0.4
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<form action="" method="get">
|
||||
{{ filter.form.as_p }}
|
||||
<input type="submit" />
|
||||
</form>
|
||||
{% for obj in filter.qs %}
|
||||
{{ obj }}<br />
|
||||
{% endfor %}
|
Loading…
Reference in New Issue