summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-05-27 15:48:31 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:20 +0100
commit0984023102759aef68cf53c0ac7b9d15c050c3c4 (patch)
tree5e7e449571279a9344cf907a48b76b1e53c1f44e
parent05bb01474227af8bc7cd3c60ae384fdd469e1f60 (diff)
downloadIshtar-0984023102759aef68cf53c0ac7b9d15c050c3c4.tar.bz2
Ishtar-0984023102759aef68cf53c0ac7b9d15c050c3c4.zip
Documentation - db: add new fields
-rw-r--r--ishtar_common/admin.py3
-rw-r--r--ishtar_common/migrations/0205_auto_20200527_1500.py110
-rw-r--r--ishtar_common/models.py49
3 files changed, 158 insertions, 4 deletions
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py
index ac88cfdc6..67b2ff41c 100644
--- a/ishtar_common/admin.py
+++ b/ishtar_common/admin.py
@@ -913,7 +913,8 @@ class GeneralTypeAdmin(ImportActionAdmin, ImportJSONActionAdmin):
general_models = [models.OrganizationType, models.SourceType,
models.AuthorType, models.TitleType, models.Format,
- models.SupportType, models.PersonType, models.LicenseType]
+ models.SupportType, models.PersonType, models.LicenseType,
+ models.DocumentTag, models.Language]
for model in general_models:
admin_site.register(model, GeneralTypeAdmin)
diff --git a/ishtar_common/migrations/0205_auto_20200527_1500.py b/ishtar_common/migrations/0205_auto_20200527_1500.py
new file mode 100644
index 000000000..deed0ad90
--- /dev/null
+++ b/ishtar_common/migrations/0205_auto_20200527_1500.py
@@ -0,0 +1,110 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.27 on 2020-05-27 15:00
+from __future__ import unicode_literals
+
+import django.core.validators
+from django.db import migrations, models
+import django.db.models.deletion
+import ishtar_common.models
+import re
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0204_auto_20200514_1124'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='DocumentTag',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.TextField(verbose_name='Label')),
+ ('txt_idx', models.TextField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', unique=True, validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+\\Z', 32), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')], verbose_name='Textual ID')),
+ ('comment', models.TextField(blank=True, null=True, verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ],
+ options={
+ 'verbose_name': 'Document tag',
+ 'verbose_name_plural': 'Document tags',
+ 'ordering': ('label',),
+ },
+ bases=(ishtar_common.models.Cached, models.Model),
+ ),
+ migrations.CreateModel(
+ name='Language',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.TextField(verbose_name='Label')),
+ ('txt_idx', models.TextField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', unique=True, validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+\\Z', 32), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')], verbose_name='Textual ID')),
+ ('comment', models.TextField(blank=True, null=True, verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ('iso_code', models.CharField(blank=True, max_length=2, null=True, verbose_name='ISO code')),
+ ],
+ options={
+ 'verbose_name': 'Language',
+ 'verbose_name_plural': 'Languages',
+ },
+ bases=(ishtar_common.models.Cached, models.Model),
+ ),
+ migrations.AlterModelOptions(
+ name='sourcetype',
+ options={'ordering': ['label'], 'verbose_name': 'Document type', 'verbose_name_plural': 'Document types'},
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='isbn',
+ field=models.CharField(blank=True, max_length=13, null=True, verbose_name='ISBN'),
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='issn',
+ field=models.CharField(blank=True, max_length=8, null=True, verbose_name='ISSN'),
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='publisher',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Organization', verbose_name='Publisher'),
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='source',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Document', verbose_name='Source'),
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='source_free_input',
+ field=models.CharField(blank=True, max_length=500, null=True, verbose_name='Source - free input'),
+ ),
+ migrations.AddField(
+ model_name='sourcetype',
+ name='coins_genre',
+ field=models.CharField(blank=True, max_length=100, verbose_name='COInS export - genre'),
+ ),
+ migrations.AddField(
+ model_name='sourcetype',
+ name='coins_type',
+ field=models.CharField(default='document', max_length=100, verbose_name='COInS export - type'),
+ ),
+ migrations.AddField(
+ model_name='sourcetype',
+ name='is_localized',
+ field=models.BooleanField(default=False, help_text='Setting a language for this type of document is relevant', verbose_name='Is localized'),
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='language',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Language', verbose_name='Language'),
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='tags',
+ field=models.ManyToManyField(blank=True, to='ishtar_common.DocumentTag', verbose_name='Tags'),
+ ),
+ migrations.AddField(
+ model_name='ishtarsiteprofile',
+ name='default_language',
+ field=models.ForeignKey(blank=True, help_text='If set, by default the selected language will be set for localized documents.', null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Language', verbose_name='Default language for documentation'),
+ ),
+ ]
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 4b9253b03..b3a19c42f 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2819,6 +2819,14 @@ def get_external_id(key, item):
return value
+class Language(GeneralType):
+ iso_code = models.CharField(_("ISO code"), null=True, blank=True,
+ max_length=2)
+ class Meta:
+ verbose_name = _("Language")
+ verbose_name_plural = _("Languages")
+
+
CURRENCY = (("€", _("Euro")),
("$", _("US dollar")))
FIND_INDEX_SOURCE = (("O", _("Operations")),
@@ -3022,6 +3030,13 @@ class IshtarSiteProfile(models.Model, Cached):
help_text=_("Spatial Reference System used for display when no SRS is "
"defined")
)
+ default_language = models.ForeignKey(
+ Language,
+ verbose_name=_("Default language for documentation"),
+ blank=True, null=True,
+ help_text=_("If set, by default the selected language will be set for "
+ "localized documents.")
+ )
objects = SlugModelManager()
class Meta:
@@ -3309,7 +3324,6 @@ class GlobalVar(models.Model, Cached):
return str(self.slug)
-
def cached_globalvar_changed(sender, **kwargs):
if not kwargs['instance']:
return
@@ -5251,9 +5265,18 @@ post_save.connect(author_post_save, sender=Author)
class SourceType(HierarchicalType):
+ coins_type = models.CharField(_("COInS export - type"), default='document',
+ max_length=100)
+ coins_genre = models.CharField(_("COInS export - genre"), blank=True,
+ max_length=100)
+ is_localized = models.BooleanField(
+ _("Is localized"), default=False,
+ help_text=_("Setting a language for this type of document is relevant")
+ )
+
class Meta:
- verbose_name = _("Source type")
- verbose_name_plural = _("Source types")
+ verbose_name = _("Document type")
+ verbose_name_plural = _("Document types")
ordering = ['label']
@@ -5291,6 +5314,13 @@ class LicenseType(GeneralType):
ordering = ('label',)
+class DocumentTag(GeneralType):
+ class Meta:
+ verbose_name = _("Document tag")
+ verbose_name_plural = _("Document tags")
+ ordering = ('label',)
+
+
post_save.connect(post_save_cache, sender=LicenseType)
post_delete.connect(post_save_cache, sender=LicenseType)
@@ -5499,8 +5529,21 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
source_type = models.ForeignKey(SourceType, verbose_name=_("Type"),
on_delete=models.SET_NULL,
null=True, blank=True)
+ publisher = models.ForeignKey(Organization, verbose_name=_("Publisher"),
+ blank=True, null=True)
licenses = models.ManyToManyField(LicenseType, verbose_name=_("License"),
blank=True)
+ tags = models.ManyToManyField(DocumentTag, verbose_name=_("Tags"),
+ blank=True)
+ language = models.ForeignKey(
+ Language, verbose_name=_("Language"), blank=True, null=True)
+ issn = models.CharField(_("ISSN"), blank=True, null=True, max_length=8)
+ isbn = models.CharField(_("ISBN"), blank=True, null=True, max_length=13)
+ source = models.ForeignKey("Document", verbose_name=_("Source"),
+ blank=True, null=True)
+ source_free_input = models.CharField(
+ verbose_name=_("Source - free input"), blank=True, null=True,
+ max_length=500)
support_type = models.ForeignKey(SupportType, verbose_name=_("Support"),
on_delete=models.SET_NULL,
blank=True, null=True, )