summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-14 17:13:56 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-14 17:13:56 +0100
commitca55bc46fa05ec4e1bfc8c5450389e83b95ec313 (patch)
tree5c8f1e3f5664f8501d4fe0177187c67375aff3f1
parentea1ad872dec9d6beeafe6ccd4264132f5865079e (diff)
parent2e4847a414f44600dc25fd1152c1bcff173f76de (diff)
downloadIshtar-ca55bc46fa05ec4e1bfc8c5450389e83b95ec313.tar.bz2
Ishtar-ca55bc46fa05ec4e1bfc8c5450389e83b95ec313.zip
Merge branch 'develop' into develop-bootstrap
-rw-r--r--archaeological_context_records/migrations/0014_contextrecord_images.py21
-rw-r--r--archaeological_context_records/models.py4
-rw-r--r--archaeological_finds/migrations/0014_auto_20171110_1717.py26
-rw-r--r--archaeological_finds/models_finds.py5
-rw-r--r--archaeological_finds/models_treatments.py4
-rw-r--r--archaeological_operations/migrations/0013_operation_images.py21
-rw-r--r--archaeological_operations/models.py4
-rw-r--r--ishtar_common/admin.py10
-rw-r--r--ishtar_common/migrations/0021_auto_20171110_1717.py77
-rw-r--r--ishtar_common/models.py50
10 files changed, 217 insertions, 5 deletions
diff --git a/archaeological_context_records/migrations/0014_contextrecord_images.py b/archaeological_context_records/migrations/0014_contextrecord_images.py
new file mode 100644
index 000000000..641309c97
--- /dev/null
+++ b/archaeological_context_records/migrations/0014_contextrecord_images.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-11-10 17:17
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0021_auto_20171110_1717'),
+ ('archaeological_context_records', '0013_auto_20171026_1827'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='contextrecord',
+ name='images',
+ field=models.ManyToManyField(blank=True, to='ishtar_common.IshtarImage', verbose_name='Images'),
+ ),
+ ]
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 925a48597..dde661ee7 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -33,7 +33,7 @@ from ishtar_common.utils import cached_label_changed
from ishtar_common.models import GeneralType, BaseHistorizedItem, \
HistoricalRecords, OwnPerms, ShortMenuItem, Source, GeneralRelationType,\
GeneralRecordRelations, post_delete_record_relation, \
- ImageModel, post_save_cache, ValueGetter, BulkUpdatedItem
+ ImageModel, post_save_cache, ValueGetter, BulkUpdatedItem, IshtarImage
from archaeological_operations.models import Operation, Period, Parcel
@@ -302,6 +302,8 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True)
point = models.PointField(_(u"Point (3D)"), blank=True, null=True, dim=3)
polygon = models.PolygonField(_(u"Polygon"), blank=True, null=True)
+ images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),
+ blank=True)
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
db_index=True)
PARENT_SEARCH_VECTORS = ['operation']
diff --git a/archaeological_finds/migrations/0014_auto_20171110_1717.py b/archaeological_finds/migrations/0014_auto_20171110_1717.py
new file mode 100644
index 000000000..63458bd9b
--- /dev/null
+++ b/archaeological_finds/migrations/0014_auto_20171110_1717.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-11-10 17:17
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0021_auto_20171110_1717'),
+ ('archaeological_finds', '0013_auto_20171026_1828'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='find',
+ name='images',
+ field=models.ManyToManyField(blank=True, to='ishtar_common.IshtarImage', verbose_name='Images'),
+ ),
+ migrations.AddField(
+ model_name='treatment',
+ name='images',
+ field=models.ManyToManyField(blank=True, to='ishtar_common.IshtarImage', verbose_name='Images'),
+ ),
+ ]
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 65850d4dc..4c8855d1d 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -34,7 +34,7 @@ from ishtar_common.utils import cached_label_changed, post_save_point
from ishtar_common.models import GeneralType, HierarchicalType, ImageModel, \
BaseHistorizedItem, ShortMenuItem, LightHistorizedItem, \
HistoricalRecords, OwnPerms, Source, Person, Basket, post_save_cache, \
- ValueGetter, get_current_profile
+ ValueGetter, get_current_profile, IshtarImage
from archaeological_operations.models import AdministrativeAct
from archaeological_context_records.models import ContextRecord, Dating
@@ -750,7 +750,8 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel,
null=True)
appraisal_date = models.DateField(_(u"Appraisal date"), blank=True,
null=True)
-
+ images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),
+ blank=True)
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
db_index=True)
history = HistoricalRecords()
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 03eeed452..6c173959a 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -30,7 +30,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext
from ishtar_common.utils import cached_label_changed, get_current_year
from ishtar_common.models import GeneralType, ImageModel, BaseHistorizedItem, \
OwnPerms, HistoricalRecords, Person, Organization, Source, \
- ValueGetter, post_save_cache, ShortMenuItem, DashboardFormItem
+ ValueGetter, post_save_cache, ShortMenuItem, DashboardFormItem, IshtarImage
from archaeological_warehouse.models import Warehouse, Container
from archaeological_finds.models_finds import Find, FindBasket, TreatmentType
from archaeological_operations.models import ClosedItem, Operation
@@ -115,6 +115,8 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
blank=True, null=True)
target_is_basket = models.BooleanField(_(u"Target a basket"),
default=False)
+ images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),
+ blank=True)
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
db_index=True)
history = HistoricalRecords()
diff --git a/archaeological_operations/migrations/0013_operation_images.py b/archaeological_operations/migrations/0013_operation_images.py
new file mode 100644
index 000000000..e32d9371f
--- /dev/null
+++ b/archaeological_operations/migrations/0013_operation_images.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-11-10 17:17
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0021_auto_20171110_1717'),
+ ('archaeological_operations', '0012_auto_20171026_1827'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='operation',
+ name='images',
+ field=models.ManyToManyField(blank=True, to='ishtar_common.IshtarImage', verbose_name='Images'),
+ ),
+ ]
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index cf648a43a..2f1ea3ea3 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -38,7 +38,7 @@ from ishtar_common.models import GeneralType, BaseHistorizedItem, \
SourceType, Person, Organization, Town, Dashboard, IshtarUser, ValueGetter,\
DocumentTemplate, ShortMenuItem, DashboardFormItem, GeneralRelationType,\
GeneralRecordRelations, post_delete_record_relation, OperationType, \
- ImageModel, post_save_cache, PersonType
+ ImageModel, post_save_cache, PersonType, IshtarImage
class RemainType(GeneralType):
@@ -352,6 +352,8 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
comment = models.TextField(_(u"General comment"), null=True, blank=True)
scientific_documentation_comment = models.TextField(
_(u"Comment about scientific documentation"), null=True, blank=True)
+ images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),
+ blank=True)
cached_label = models.CharField(_(u"Cached name"), max_length=500,
null=True, blank=True, db_index=True)
archaeological_sites = models.ManyToManyField(
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py
index d3292148f..c3ad21710 100644
--- a/ishtar_common/admin.py
+++ b/ishtar_common/admin.py
@@ -426,9 +426,19 @@ class AdministrationScriptAdmin(admin.ModelAdmin):
return ('path',)
return []
+
admin_site.register(models.AdministrationScript, AdministrationScriptAdmin)
+class ImageAdmin(admin.ModelAdmin):
+ list_display = ('name', 'image_type', 'reference', 'internal_reference')
+ list_filter = ('image_type',)
+ search_fields = ('name', 'reference', 'internal_reference')
+
+
+admin_site.register(models.IshtarImage, ImageAdmin)
+
+
class AdministrationTaskAdmin(admin.ModelAdmin):
readonly_fields = ('state', 'creation_date', 'launch_date',
'finished_date', "result", )
diff --git a/ishtar_common/migrations/0021_auto_20171110_1717.py b/ishtar_common/migrations/0021_auto_20171110_1717.py
new file mode 100644
index 000000000..c95f5e1d8
--- /dev/null
+++ b/ishtar_common/migrations/0021_auto_20171110_1717.py
@@ -0,0 +1,77 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-11-10 17:17
+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', '0020_auto_20171030_1708'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ImageType',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.CharField(max_length=100, verbose_name='Label')),
+ ('txt_idx', models.CharField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', max_length=100, unique=True, validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+\\Z'), "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={
+ 'ordering': ('label',),
+ 'verbose_name': 'Image type',
+ 'verbose_name_plural': 'Image types',
+ },
+ bases=(ishtar_common.models.Cached, models.Model),
+ ),
+ migrations.CreateModel(
+ name='IshtarImage',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('image', models.ImageField(blank=True, max_length=255, null=True, upload_to=ishtar_common.models.get_image_path)),
+ ('thumbnail', models.ImageField(blank=True, max_length=255, null=True, upload_to=ishtar_common.models.get_image_path)),
+ ('name', models.CharField(max_length=250, verbose_name='Name')),
+ ('description', models.TextField(blank=True, null=True, verbose_name='Description')),
+ ('authors_raw', models.CharField(blank=True, max_length=250, null=True, verbose_name='Authors (raw)')),
+ ('creation_date', models.DateField(blank=True, null=True, verbose_name='Creation date')),
+ ('reference', models.CharField(blank=True, max_length=250, null=True, verbose_name='Ref.')),
+ ('internal_reference', models.CharField(blank=True, max_length=250, null=True, verbose_name='Internal ref.')),
+ ('authors', models.ManyToManyField(blank=True, to='ishtar_common.Author', verbose_name='Authors')),
+ ('image_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImageType', verbose_name='Type')),
+ ],
+ options={
+ 'ordering': ('name',),
+ 'verbose_name': 'Image',
+ 'verbose_name_plural': 'Images',
+ },
+ ),
+ migrations.CreateModel(
+ name='LicenseType',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.CharField(max_length=100, verbose_name='Label')),
+ ('txt_idx', models.CharField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', max_length=100, unique=True, validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+\\Z'), "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={
+ 'ordering': ('label',),
+ 'verbose_name': 'License type',
+ 'verbose_name_plural': 'License types',
+ },
+ bases=(ishtar_common.models.Cached, models.Model),
+ ),
+ migrations.AddField(
+ model_name='ishtarimage',
+ name='licenses',
+ field=models.ManyToManyField(blank=True, to='ishtar_common.LicenseType', verbose_name='License'),
+ ),
+ ]
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 09aec0cdb..08276fa9f 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -887,6 +887,7 @@ class HistoryError(Exception):
def __str__(self):
return repr(self.value)
+
PRIVATE_FIELDS = ('id', 'history_modifier', 'order')
@@ -1447,6 +1448,7 @@ def get_external_id(key, item):
dct[initial_key] = filtr(dct[initial_key])
return formula.format(**dct)
+
CURRENCY = ((u"€", _(u"Euro")),
(u"$", _(u"US dollar")))
FIND_INDEX_SOURCE = ((u"O", _(u"Operations")),
@@ -1651,6 +1653,7 @@ def cached_globalvar_changed(sender, **kwargs):
cache_key, value = get_cache(GlobalVar, var.slug)
cache.set(cache_key, var.value, settings.CACHE_TIMEOUT)
+
post_save.connect(cached_globalvar_changed, sender=GlobalVar)
@@ -2146,6 +2149,8 @@ class OrganizationType(GeneralType):
verbose_name = _(u"Organization type")
verbose_name_plural = _(u"Organization types")
ordering = ('label',)
+
+
post_save.connect(post_save_cache, sender=OrganizationType)
post_delete.connect(post_save_cache, sender=OrganizationType)
@@ -2577,6 +2582,8 @@ class AuthorType(GeneralType):
verbose_name = _(u"Author type")
verbose_name_plural = _(u"Author types")
ordering = ['order', 'label']
+
+
post_save.connect(post_save_cache, sender=AuthorType)
post_delete.connect(post_save_cache, sender=AuthorType)
@@ -2635,6 +2642,8 @@ class Format(GeneralType):
verbose_name = _(u"Format type")
verbose_name_plural = _(u"Format types")
ordering = ['label']
+
+
post_save.connect(post_save_cache, sender=Format)
post_delete.connect(post_save_cache, sender=Format)
@@ -2696,6 +2705,45 @@ class Source(OwnPerms, ImageModel, models.Model):
return slugify(u"-".join(values))
+class LicenseType(GeneralType):
+ class Meta:
+ verbose_name = _(u"License type")
+ verbose_name_plural = _(u"License types")
+ ordering = ('label',)
+
+
+class ImageType(GeneralType):
+ class Meta:
+ verbose_name = _(u"Image type")
+ verbose_name_plural = _(u"Image types")
+ ordering = ('label',)
+
+
+class IshtarImage(ImageModel):
+ name = models.CharField(_(u"Name"), max_length=250)
+ description = models.TextField(_(u"Description"), blank=True, null=True)
+ licenses = models.ManyToManyField(LicenseType, verbose_name=_(u"License"),
+ blank=True)
+ authors = models.ManyToManyField(Author, verbose_name=_(u"Authors"),
+ blank=True)
+ authors_raw = models.CharField(verbose_name=_(u"Authors (raw)"),
+ blank=True, null=True, max_length=250)
+
+ image_type = models.ForeignKey(ImageType, verbose_name=_(u"Type"),
+ blank=True, null=True)
+ creation_date = models.DateField(blank=True, null=True,
+ verbose_name=_(u"Creation date"))
+ reference = models.CharField(_(u"Ref."), max_length=250, null=True,
+ blank=True)
+ internal_reference = models.CharField(
+ _(u"Internal ref."), max_length=250, null=True, blank=True)
+
+ class Meta:
+ verbose_name = _(u"Image")
+ verbose_name_plural = _(u"Images")
+ ordering = ('name',)
+
+
if settings.COUNTRY == 'fr':
class Arrondissement(models.Model):
name = models.CharField(u"Nom", max_length=30)
@@ -2893,6 +2941,8 @@ class OperationType(GeneralType):
if not key:
return op_type.preventive
return key == op_type.txt_idx
+
+
post_save.connect(post_save_cache, sender=OperationType)
post_delete.connect(post_save_cache, sender=OperationType)