general: create models
This commit is contained in:
parent
2084024edc
commit
6d8284d9dd
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AlternativeTerm',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('term', models.CharField(max_length=300)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['term'],
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Term',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('term', models.CharField(max_length=300)),
|
||||
('tabellio_id', models.CharField(max_length=10)),
|
||||
('historical_note', models.TextField(blank=True)),
|
||||
('scope_note', models.TextField(blank=True)),
|
||||
('creation_timestamp', models.DateTimeField(auto_now_add=True)),
|
||||
('last_update_timestamp', models.DateTimeField(auto_now=True)),
|
||||
('broader', models.ManyToManyField(related_name='narrower', to='thesaurus.Term')),
|
||||
('related', models.ManyToManyField(related_name='related_rel_+', to='thesaurus.Term')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['term'],
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='alternativeterm',
|
||||
name='primary_term',
|
||||
field=models.ForeignKey(to='thesaurus.Term'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -1,3 +1,43 @@
|
|||
# pfwb_thesaurus - thesaurus system
|
||||
# Copyright (C) 2016 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Term(models.Model):
|
||||
class Meta:
|
||||
ordering = ['term']
|
||||
|
||||
term = models.CharField(max_length=300)
|
||||
tabellio_id = models.CharField(max_length=10)
|
||||
|
||||
broader = models.ManyToManyField('self', symmetrical=False,
|
||||
related_name='narrower')
|
||||
related = models.ManyToManyField('self', symmetrical=True)
|
||||
|
||||
historical_note = models.TextField(blank=True)
|
||||
scope_note = models.TextField(blank=True)
|
||||
|
||||
creation_timestamp = models.DateTimeField(auto_now_add=True)
|
||||
last_update_timestamp = models.DateTimeField(auto_now=True)
|
||||
|
||||
|
||||
class AlternativeTerm(models.Model):
|
||||
primary_term = models.ForeignKey(Term)
|
||||
term = models.CharField(max_length=300)
|
||||
|
||||
class Meta:
|
||||
ordering = ['term']
|
||||
|
|
Reference in New Issue