diff options
Diffstat (limited to 'archaeological_warehouse')
44 files changed, 1018 insertions, 546 deletions
diff --git a/archaeological_warehouse/__init__.py b/archaeological_warehouse/__init__.py index e69de29bb..7a5abf267 100644 --- a/archaeological_warehouse/__init__.py +++ b/archaeological_warehouse/__init__.py @@ -0,0 +1 @@ +default_app_config = 'ishtar_common.apps.ArchaeologicalWarehouseConfig' diff --git a/archaeological_warehouse/admin.py b/archaeological_warehouse/admin.py index 911809d0f..deaffde94 100644 --- a/archaeological_warehouse/admin.py +++ b/archaeological_warehouse/admin.py @@ -17,8 +17,11 @@ # See the file COPYING for details. +from ajax_select import make_ajax_form + from django.contrib import admin +from ishtar_common.apps import admin_site from ishtar_common.admin import HistorizedObjectAdmin, GeneralTypeAdmin import models @@ -29,8 +32,15 @@ class WarehouseAdmin(HistorizedObjectAdmin): list_filter = ('warehouse_type',) search_fields = ('name', 'town') model = models.Warehouse + form = make_ajax_form(model, { + 'town': 'town', + 'person_in_charge': 'person' + }) + readonly_fields = HistorizedObjectAdmin.readonly_fields + [ + 'imports' + ] -admin.site.register(models.Warehouse, WarehouseAdmin) +admin_site.register(models.Warehouse, WarehouseAdmin) class ContainerTypeAdmin(admin.ModelAdmin): @@ -38,16 +48,24 @@ class ContainerTypeAdmin(admin.ModelAdmin): 'volume') model = models.ContainerType -admin.site.register(models.ContainerType, ContainerTypeAdmin) +admin_site.register(models.ContainerType, ContainerTypeAdmin) -class ContainerAdmin(admin.ModelAdmin): +class ContainerAdmin(HistorizedObjectAdmin): list_display = ('reference', 'location', 'container_type',) list_filter = ("container_type",) model = models.Container + readonly_fields = HistorizedObjectAdmin.readonly_fields + [ + 'imports', 'history_date' + ] + form = make_ajax_form(model, { + 'location': 'warehouse', + 'responsible': 'warehouse' + }) + -admin.site.register(models.Container, ContainerAdmin) +admin_site.register(models.Container, ContainerAdmin) general_models = [models.WarehouseType, models.WarehouseDivision] for model in general_models: - admin.site.register(model, GeneralTypeAdmin) + admin_site.register(model, GeneralTypeAdmin) diff --git a/archaeological_warehouse/fixtures/initial_data-fr.json b/archaeological_warehouse/fixtures/initial_data-fr.json index d67f8b0a1..9800f1c9b 100644 --- a/archaeological_warehouse/fixtures/initial_data-fr.json +++ b/archaeological_warehouse/fixtures/initial_data-fr.json @@ -1,272 +1,248 @@ [ - { - "pk": 8, - "model": "archaeological_warehouse.containertype", - "fields": { - "comment": "Bac norme Europe plein 20002 - 200X150X118", - "available": true, - "reference": "20002", - "label": "Bac norme Europe plein 20002", - "volume": 3.0, - "width": 150, - "length": 200, - "height": 118, - "txt_idx": "20002" - } - }, - { - "pk": 4, - "model": "archaeological_warehouse.containertype", - "fields": { - "comment": "Caisse Alibert grise standard, a pr\u00e9ciser et d\u00e9cliner en fonction des mod\u00e8les.", - "available": true, - "reference": "a pr\u00e9ciser", - "label": "Caisse Alibert standard", - "volume": 0.0, - "width": 0, - "length": null, - "height": 0, - "txt_idx": "stand_alibert_bin" - } - }, - { - "pk": 5, - "model": "archaeological_warehouse.containertype", - "fields": { - "comment": "", - "available": true, - "reference": "Curver UNIBOX 20 L", - "label": "Curver UNIBOX 20 L", - "volume": 25.0, - "width": 350, - "length": null, - "height": 165, - "txt_idx": "curver_unibox_20" - } - }, - { - "pk": 6, - "model": "archaeological_warehouse.containertype", - "fields": { - "comment": "", - "available": true, - "reference": "Curver UNIBOX 29 L", - "label": "Curver UNIBOX 29 L", - "volume": 37.0, - "width": 355, - "length": null, - "height": 245, - "txt_idx": "curver_unibox_29" - } - }, - { - "pk": 7, - "model": "archaeological_warehouse.containertype", - "fields": { - "comment": "", - "available": true, - "reference": "Curver UNIBOX 48 L", - "label": "Curver UNIBOX 48 L", - "volume": 63.0, - "width": 432, - "length": null, - "height": 280, - "txt_idx": "curver_unibox_48" - } - }, - { - "pk": 9, - "model": "archaeological_warehouse.containertype", - "fields": { - "comment": "Bo\u00eetes herm\u00e9tiques Miflex 8L", - "available": true, - "reference": "Miflex 8L", - "label": "Miflex 8L", - "volume": null, - "width": 21, - "length": 29, - "height": 15, - "txt_idx": "Miflex_8L" - } - }, - { - "pk": 6, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "Pour le stockage de documents papier, rapports la plupart du temps.", - "available": true, - "txt_idx": "library", - "label": "Biblioth\u00e8que" - } - }, - { - "pk": 2, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "Ce d\u00e9p\u00f4t est un centre de conservation et d'\u00e9tude. Il est d'ordinaire en convention avec l'\u00c9tat.", - "available": true, - "txt_idx": "cce", - "label": "CCE" - } - }, - { - "pk": 7, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "Lieu de stockage de documents vari\u00e9s, photos, relev\u00e9s, jusqu'aux rapports.", - "available": true, - "txt_idx": "documentation_center", - "label": "Centre de documentation" - } - }, - { - "pk": 4, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "Ce d\u00e9p\u00f4t poss\u00e8de une convention avec l'\u00c9tat pour conserver du mobilier qui est sous sa garde.", - "available": true, - "txt_idx": "conventioned_warehouse", - "label": "D\u00e9p\u00f4t conventionn\u00e9" - } - }, - { - "pk": 5, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "Ce d\u00e9p\u00f4t est sous la responsabilit\u00e9 directe de l'\u00c9tat. Il peut en \u00eatre locataire ou propri\u00e9taire.", - "available": true, - "txt_idx": "state_warehouse", - "label": "D\u00e9p\u00f4t de l'\u00c9tat" - } - }, - { - "pk": 3, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "Mobilier pr\u00e9sent dans un lieu de mani\u00e8re ill\u00e9gale : pas de convention, voire de responsabilit\u00e9 exprim\u00e9e...", - "available": true, - "txt_idx": "illegal_warehouse", - "label": "D\u00e9p\u00f4t non conventionn\u00e9" - } - }, - { - "pk": 1, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "Le mobilier arch\u00e9ologique reste dans ce d\u00e9p\u00f4t le temps d'un traitement puis part ailleurs...", - "available": true, - "txt_idx": "restoration_laboratory", - "label": "Laboratoire de restauration" - } - }, - { - "pk": 8, - "model": "archaeological_warehouse.warehousetype", - "fields": { - "comment": "", - "available": true, - "txt_idx": "museum", - "label": "Mus\u00e9e" - } - }, - { - "pk": 1, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "building", - "label": "B\u00e2timent" - } - }, - { - "pk": 2, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "floor", - "label": "\u00c9tage" - } - }, - { - "pk": 3, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "room", - "label": "Salle" - } - }, - { - "pk": 4, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "span", - "label": "Trav\u00e9e" - } - }, - { - "pk": 5, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "shelf", - "label": "\u00c9tag\u00e8re" - } - }, - { - "pk": 6, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "place", - "label": "Lieu dans la salle" - } - }, - { - "pk": 7, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "alley", - "label": "All\u00e9e" - } - }, - { - "pk": 8, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "rank", - "label": "Rang" - } - }, - { - "pk": 9, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "space", - "label": "Espace" - } - }, - { - "pk": 10, - "model": "archaeological_warehouse.warehousedivision", - "fields": { - "comment": "", - "available": true, - "txt_idx": "level", - "label": "Niveau" - } +{ + "model": "archaeological_warehouse.containertype", + "fields": { + "label": "Caisse Alibert standard", + "txt_idx": "stand_alibert_bin", + "comment": "Caisse Alibert grise standard, a pr\u00e9ciser et d\u00e9cliner en fonction des mod\u00e8les.", + "available": true, + "length": null, + "width": 0, + "height": 0, + "volume": 0.0, + "reference": "a pr\u00e9ciser" } -]
\ No newline at end of file +}, +{ + "model": "archaeological_warehouse.containertype", + "fields": { + "label": "Curver UNIBOX 20 L", + "txt_idx": "curver_unibox_20", + "comment": "", + "available": true, + "length": null, + "width": 350, + "height": 165, + "volume": 25.0, + "reference": "Curver UNIBOX 20 L" + } +}, +{ + "model": "archaeological_warehouse.containertype", + "fields": { + "label": "Curver UNIBOX 29 L", + "txt_idx": "curver_unibox_29", + "comment": "", + "available": true, + "length": null, + "width": 355, + "height": 245, + "volume": 37.0, + "reference": "Curver UNIBOX 29 L" + } +}, +{ + "model": "archaeological_warehouse.containertype", + "fields": { + "label": "Curver UNIBOX 48 L", + "txt_idx": "curver_unibox_48", + "comment": "", + "available": true, + "length": null, + "width": 432, + "height": 280, + "volume": 63.0, + "reference": "Curver UNIBOX 48 L" + } +}, +{ + "model": "archaeological_warehouse.containertype", + "fields": { + "label": "Bac norme Europe plein 20002", + "txt_idx": "20002", + "comment": "Bac norme Europe plein 20002 - 200X150X118", + "available": true, + "length": 200, + "width": 150, + "height": 118, + "volume": 3.0, + "reference": "20002" + } +}, +{ + "model": "archaeological_warehouse.containertype", + "fields": { + "label": "Miflex 8L", + "txt_idx": "Miflex_8L", + "comment": "Bo\u00eetes herm\u00e9tiques Miflex 8L", + "available": true, + "length": 29, + "width": 21, + "height": 15, + "volume": null, + "reference": "Miflex 8L" + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "Laboratoire de restauration", + "txt_idx": "restoration_laboratory", + "comment": "Le mobilier arch\u00e9ologique reste dans ce d\u00e9p\u00f4t le temps d'un traitement puis part ailleurs...", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "CCE", + "txt_idx": "cce", + "comment": "Ce d\u00e9p\u00f4t est un centre de conservation et d'\u00e9tude. Il est d'ordinaire en convention avec l'\u00c9tat.", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "D\u00e9p\u00f4t non conventionn\u00e9", + "txt_idx": "illegal_warehouse", + "comment": "Mobilier pr\u00e9sent dans un lieu de mani\u00e8re ill\u00e9gale : pas de convention, voire de responsabilit\u00e9 exprim\u00e9e...", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "D\u00e9p\u00f4t conventionn\u00e9", + "txt_idx": "conventioned_warehouse", + "comment": "Ce d\u00e9p\u00f4t poss\u00e8de une convention avec l'\u00c9tat pour conserver du mobilier qui est sous sa garde.", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "D\u00e9p\u00f4t de l'\u00c9tat", + "txt_idx": "state_warehouse", + "comment": "Ce d\u00e9p\u00f4t est sous la responsabilit\u00e9 directe de l'\u00c9tat. Il peut en \u00eatre locataire ou propri\u00e9taire.", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "Biblioth\u00e8que", + "txt_idx": "library", + "comment": "Pour le stockage de documents papier, rapports la plupart du temps.", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "Centre de documentation", + "txt_idx": "documentation_center", + "comment": "Lieu de stockage de documents vari\u00e9s, photos, relev\u00e9s, jusqu'aux rapports.", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousetype", + "fields": { + "label": "Mus\u00e9e", + "txt_idx": "museum", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "B\u00e2timent", + "txt_idx": "building", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "\u00c9tage", + "txt_idx": "floor", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "Salle", + "txt_idx": "room", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "Trav\u00e9e", + "txt_idx": "span", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "\u00c9tag\u00e8re", + "txt_idx": "shelf", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "Lieu dans la salle", + "txt_idx": "place", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "All\u00e9e", + "txt_idx": "alley", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "Rang", + "txt_idx": "rank", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "Espace", + "txt_idx": "space", + "comment": "", + "available": true + } +}, +{ + "model": "archaeological_warehouse.warehousedivision", + "fields": { + "label": "Niveau", + "txt_idx": "level", + "comment": "", + "available": true + } +} +] diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 94e31b759..f020864ff 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,8 @@ # See the file COPYING for details. +from collections import OrderedDict + from django import forms from django.conf import settings from django.forms.formsets import formset_factory @@ -212,9 +214,13 @@ class ContainerModifyForm(ContainerForm): def __init__(self, *args, **kwargs): super(ContainerModifyForm, self).__init__(*args, **kwargs) - self.fields.keyOrder.pop(self.fields.keyOrder.index('index')) - self.fields.keyOrder.insert( - self.fields.keyOrder.index("location") + 1, 'index') + fields = OrderedDict() + idx = self.fields.pop('index') + for key, value in self.fields.items(): + fields[key] = value + if key == 'location': + fields['index'] = idx + self.fields = fields def clean(self): # manage unique ID diff --git a/archaeological_warehouse/lookups.py b/archaeological_warehouse/lookups.py new file mode 100644 index 000000000..57d3a892d --- /dev/null +++ b/archaeological_warehouse/lookups.py @@ -0,0 +1,49 @@ +from ajax_select import register, LookupChannel + +from django.db.models import Q +from django.utils.encoding import force_text +from django.utils.html import escape + +from archaeological_warehouse import models + + +@register('container') +class ContainerLookup(LookupChannel): + model = models.Container + + def get_query(self, q, request): + query = Q() + for term in q.strip().split(' '): + subquery = ( + Q(reference__icontains=term) | + Q(container_type__label__icontains=term) | + Q(cached_label__icontains=term) | + Q(responsible__name__icontains=term) + ) + query &= subquery + return self.model.objects.filter(query).order_by( + 'cached_label')[:20] + + def format_match(self, obj): + return escape(force_text(obj.cached_label)) + + def format_item_display(self, item): + return u"<span class='ajax-label'>%s</span>" % item.cached_label + + +@register('warehouse') +class WarehouseLookup(LookupChannel): + model = models.Warehouse + + def get_query(self, q, request): + query = Q() + for term in q.strip().split(' '): + subquery = ( + Q(warehouse_type__label=term) | + Q(name__icontains=term) + ) + query &= subquery + return self.model.objects.filter(query).order_by('name')[:20] + + def format_item_display(self, item): + return u"<span class='ajax-label'>%s</span>" % item.name diff --git a/archaeological_warehouse/migrations/0001_initial.py b/archaeological_warehouse/migrations/0001_initial.py index 6c3b14e75..13abc0afa 100644 --- a/archaeological_warehouse/migrations/0001_initial.py +++ b/archaeological_warehouse/migrations/0001_initial.py @@ -1,229 +1,182 @@ # -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding model 'WarehouseType' - db.create_table('archaeological_warehouse_warehousetype', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('label', self.gf('django.db.models.fields.CharField')(max_length=100)), - ('txt_idx', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30)), - ('comment', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), - ('available', self.gf('django.db.models.fields.BooleanField')(default=False)), - )) - db.send_create_signal('archaeological_warehouse', ['WarehouseType']) - - # Adding model 'Warehouse' - db.create_table('archaeological_warehouse_warehouse', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('history_modifier', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', to=orm['auth.User'])), - ('address', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), - ('address_complement', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), - ('postal_code', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)), - ('town', self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True)), - ('country', self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True)), - ('phone', self.gf('django.db.models.fields.CharField')(max_length=18, null=True, blank=True)), - ('mobile_phone', self.gf('django.db.models.fields.CharField')(max_length=18, null=True, blank=True)), - ('name', self.gf('django.db.models.fields.CharField')(max_length=40)), - ('warehouse_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['archaeological_warehouse.WarehouseType'])), - ('person_in_charge', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['ishtar_common.Person'], null=True, blank=True)), - ('comment', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), - )) - db.send_create_signal('archaeological_warehouse', ['Warehouse']) - - # Adding model 'ContainerType' - db.create_table('archaeological_warehouse_containertype', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('label', self.gf('django.db.models.fields.CharField')(max_length=100)), - ('txt_idx', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30)), - ('comment', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), - ('available', self.gf('django.db.models.fields.BooleanField')(default=False)), - ('length', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), - ('width', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), - ('height', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), - ('volume', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), - ('reference', self.gf('django.db.models.fields.CharField')(max_length=30)), - )) - db.send_create_signal('archaeological_warehouse', ['ContainerType']) +from __future__ import unicode_literals - # Adding model 'Container' - db.create_table('archaeological_warehouse_container', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('history_modifier', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', to=orm['auth.User'])), - ('history_date', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)), - ('location', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['archaeological_warehouse.Warehouse'])), - ('container_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['archaeological_warehouse.ContainerType'])), - ('reference', self.gf('django.db.models.fields.CharField')(max_length=40)), - ('comment', self.gf('django.db.models.fields.TextField')()), - )) - db.send_create_signal('archaeological_warehouse', ['Container']) - - - def backwards(self, orm): - # Deleting model 'WarehouseType' - db.delete_table('archaeological_warehouse_warehousetype') - - # Deleting model 'Warehouse' - db.delete_table('archaeological_warehouse_warehouse') - - # Deleting model 'ContainerType' - db.delete_table('archaeological_warehouse_containertype') +from django.db import models, migrations +import datetime +import django.core.validators +import django.db.models.deletion +from django.conf import settings +import re +import ishtar_common.models - # Deleting model 'Container' - db.delete_table('archaeological_warehouse_container') +class Migration(migrations.Migration): - models = { - 'archaeological_warehouse.container': { - 'Meta': {'object_name': 'Container'}, - 'comment': ('django.db.models.fields.TextField', [], {}), - 'container_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['archaeological_warehouse.ContainerType']"}), - 'history_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'location': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['archaeological_warehouse.Warehouse']"}), - 'reference': ('django.db.models.fields.CharField', [], {'max_length': '40'}) - }, - 'archaeological_warehouse.containertype': { - 'Meta': {'object_name': 'ContainerType'}, - 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'length': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), - 'reference': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}), - 'volume': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), - 'width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) - }, - 'archaeological_warehouse.warehouse': { - 'Meta': {'object_name': 'Warehouse'}, - 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), - 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}), - 'person_in_charge': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Person']", 'null': 'True', 'blank': 'True'}), - 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), - 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), - 'town': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), - 'warehouse_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['archaeological_warehouse.WarehouseType']"}) - }, - 'archaeological_warehouse.warehousetype': { - 'Meta': {'object_name': 'WarehouseType'}, - 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'auth.group': { - 'Meta': {'object_name': 'Group'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'ishtar_common.organization': { - 'Meta': {'object_name': 'Organization'}, - 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), - 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'organization_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.OrganizationType']"}), - 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), - 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), - 'town': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}) - }, - 'ishtar_common.organizationtype': { - 'Meta': {'object_name': 'OrganizationType'}, - 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'ishtar_common.person': { - 'Meta': {'object_name': 'Person'}, - 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'attached_to': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Organization']", 'null': 'True', 'blank': 'True'}), - 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), - 'email': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}), - 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'person_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.PersonType']"}), - 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), - 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), - 'surname': ('django.db.models.fields.CharField', [], {'max_length': '20'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '2'}), - 'town': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}) - }, - 'ishtar_common.persontype': { - 'Meta': {'object_name': 'PersonType'}, - 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'rights': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['ishtar_common.WizardStep']", 'symmetrical': 'False'}), - 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'ishtar_common.wizard': { - 'Meta': {'ordering': "['url_name']", 'object_name': 'Wizard'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'url_name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}) - }, - 'ishtar_common.wizardstep': { - 'Meta': {'ordering': "['wizard', 'order']", 'object_name': 'WizardStep'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'order': ('django.db.models.fields.IntegerField', [], {}), - 'url_name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'wizard': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Wizard']"}) - } - } + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] - complete_apps = ['archaeological_warehouse']
\ No newline at end of file + operations = [ + migrations.CreateModel( + name='Collection', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('history_date', models.DateTimeField(default=datetime.datetime.now)), + ('name', models.CharField(max_length=200, null=True, verbose_name='Name', blank=True)), + ('description', models.TextField(null=True, verbose_name='Description', blank=True)), + ], + options={ + 'ordering': ('name',), + 'verbose_name': 'Collection', + 'verbose_name_plural': 'Collection', + }, + ), + migrations.CreateModel( + name='Container', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('image', models.ImageField(max_length=255, null=True, upload_to=b'upload/', blank=True)), + ('thumbnail', models.ImageField(max_length=255, null=True, upload_to=b'upload/thumbs/', blank=True)), + ('history_date', models.DateTimeField(default=datetime.datetime.now)), + ('reference', models.CharField(max_length=40, verbose_name='Container ref.')), + ('comment', models.TextField(null=True, verbose_name='Comment', blank=True)), + ('cached_label', models.CharField(max_length=500, null=True, verbose_name='Localisation', blank=True)), + ('cached_location', models.CharField(max_length=500, null=True, verbose_name='Cached location', blank=True)), + ('index', models.IntegerField(default=0, verbose_name='ID')), + ('external_id', models.TextField(null=True, verbose_name='External ID', blank=True)), + ('auto_external_id', models.BooleanField(default=False, verbose_name='External ID is set automatically')), + ], + options={ + 'ordering': ('cached_label',), + 'verbose_name': 'Container', + 'verbose_name_plural': 'Containers', + }, + ), + migrations.CreateModel( + name='ContainerLocalisation', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('reference', models.CharField(default=b'', max_length=200, verbose_name='Reference')), + ], + options={ + 'ordering': ('container', 'division__order'), + 'verbose_name': 'Container localisation', + 'verbose_name_plural': 'Container localisations', + }, + ), + migrations.CreateModel( + name='ContainerType', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('label', models.CharField(max_length=100, verbose_name='Label')), + ('txt_idx', models.CharField(unique=True, max_length=100, verbose_name='Textual ID', validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+$'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')])), + ('comment', models.TextField(null=True, verbose_name='Comment', blank=True)), + ('available', models.BooleanField(default=True, verbose_name='Available')), + ('length', models.IntegerField(null=True, verbose_name='Length (mm)', blank=True)), + ('width', models.IntegerField(null=True, verbose_name='Width (mm)', blank=True)), + ('height', models.IntegerField(null=True, verbose_name='Height (mm)', blank=True)), + ('volume', models.FloatField(null=True, verbose_name='Volume (l)', blank=True)), + ('reference', models.CharField(max_length=30, verbose_name='Ref.')), + ], + options={ + 'ordering': ('label',), + 'verbose_name': 'Container type', + 'verbose_name_plural': 'Container types', + }, + bases=(ishtar_common.models.Cached, models.Model), + ), + migrations.CreateModel( + name='Warehouse', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('address', models.TextField(null=True, verbose_name='Address', blank=True)), + ('address_complement', models.TextField(null=True, verbose_name='Address complement', blank=True)), + ('postal_code', models.CharField(max_length=10, null=True, verbose_name='Postal code', blank=True)), + ('town', models.CharField(max_length=70, null=True, verbose_name='Town', blank=True)), + ('country', models.CharField(max_length=30, null=True, verbose_name='Country', blank=True)), + ('alt_address', models.TextField(null=True, verbose_name='Other address: address', blank=True)), + ('alt_address_complement', models.TextField(null=True, verbose_name='Other address: address complement', blank=True)), + ('alt_postal_code', models.CharField(max_length=10, null=True, verbose_name='Other address: postal code', blank=True)), + ('alt_town', models.CharField(max_length=70, null=True, verbose_name='Other address: town', blank=True)), + ('alt_country', models.CharField(max_length=30, null=True, verbose_name='Other address: country', blank=True)), + ('phone', models.CharField(max_length=18, null=True, verbose_name='Phone', blank=True)), + ('phone_desc', models.CharField(max_length=300, null=True, verbose_name='Phone description', blank=True)), + ('phone2', models.CharField(max_length=18, null=True, verbose_name='Phone description 2', blank=True)), + ('phone_desc2', models.CharField(max_length=300, null=True, verbose_name='Phone description 2', blank=True)), + ('phone3', models.CharField(max_length=18, null=True, verbose_name='Phone 3', blank=True)), + ('phone_desc3', models.CharField(max_length=300, null=True, verbose_name='Phone description 3', blank=True)), + ('raw_phone', models.TextField(null=True, verbose_name='Raw phone', blank=True)), + ('mobile_phone', models.CharField(max_length=18, null=True, verbose_name='Mobile phone', blank=True)), + ('email', models.EmailField(max_length=300, null=True, verbose_name='Email', blank=True)), + ('alt_address_is_prefered', models.BooleanField(default=False, verbose_name='Alternative address is prefered')), + ('name', models.CharField(max_length=200, verbose_name='Name')), + ('comment', models.TextField(null=True, verbose_name='Comment', blank=True)), + ('external_id', models.TextField(null=True, verbose_name='External ID', blank=True)), + ('auto_external_id', models.BooleanField(default=False, verbose_name='External ID is set automatically')), + ], + options={ + 'verbose_name': 'Warehouse', + 'verbose_name_plural': 'Warehouses', + 'permissions': (('view_warehouse', 'Peut voir tous les D\xe9p\xf4ts'), ('view_own_warehouse', 'Peut voir son propre D\xe9p\xf4t'), ('add_own_warehouse', 'Peut ajouter son propre D\xe9p\xf4t'), ('change_own_warehouse', 'Peut modifier son propre D\xe9p\xf4t'), ('delete_own_warehouse', 'Peut supprimer son propre D\xe9p\xf4t')), + }, + bases=(models.Model, ishtar_common.models.DashboardFormItem, ishtar_common.models.OwnPerms), + ), + migrations.CreateModel( + name='WarehouseDivision', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('label', models.CharField(max_length=100, verbose_name='Label')), + ('txt_idx', models.CharField(unique=True, max_length=100, verbose_name='Textual ID', validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+$'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')])), + ('comment', models.TextField(null=True, verbose_name='Comment', blank=True)), + ('available', models.BooleanField(default=True, verbose_name='Available')), + ], + options={ + 'verbose_name': 'Warehouse division type', + 'verbose_name_plural': 'Warehouse division types', + }, + bases=(ishtar_common.models.Cached, models.Model), + ), + migrations.CreateModel( + name='WarehouseDivisionLink', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('order', models.IntegerField(default=10, verbose_name='Order')), + ('division', models.ForeignKey(to='archaeological_warehouse.WarehouseDivision')), + ('warehouse', models.ForeignKey(to='archaeological_warehouse.Warehouse')), + ], + options={ + 'ordering': ('warehouse', 'order'), + }, + ), + migrations.CreateModel( + name='WarehouseType', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('label', models.CharField(max_length=100, verbose_name='Label')), + ('txt_idx', models.CharField(unique=True, max_length=100, verbose_name='Textual ID', validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+$'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')])), + ('comment', models.TextField(null=True, verbose_name='Comment', blank=True)), + ('available', models.BooleanField(default=True, verbose_name='Available')), + ], + options={ + 'ordering': ('label',), + 'verbose_name': 'Warehouse type', + 'verbose_name_plural': 'Warehouse types', + }, + bases=(ishtar_common.models.Cached, models.Model), + ), + migrations.AddField( + model_name='warehouse', + name='associated_divisions', + field=models.ManyToManyField(to='archaeological_warehouse.WarehouseDivision', verbose_name='Divisions', through='archaeological_warehouse.WarehouseDivisionLink', blank=True), + ), + migrations.AddField( + model_name='warehouse', + name='history_creator', + field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Creator', blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + migrations.AddField( + model_name='warehouse', + name='history_modifier', + field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Last editor', blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + ] diff --git a/archaeological_warehouse/migrations/0002_auto_20170414_2123.py b/archaeological_warehouse/migrations/0002_auto_20170414_2123.py new file mode 100644 index 000000000..5b9c92785 --- /dev/null +++ b/archaeological_warehouse/migrations/0002_auto_20170414_2123.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_warehouse', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('ishtar_common', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='warehouse', + name='imports', + field=models.ManyToManyField(related_name='imported_archaeological_warehouse_warehouse', to='ishtar_common.Import', blank=True), + ), + migrations.AddField( + model_name='warehouse', + name='person_in_charge', + field=models.ForeignKey(related_name='warehouse_in_charge', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Person in charge', blank=True, to='ishtar_common.Person', null=True), + ), + migrations.AddField( + model_name='warehouse', + name='warehouse_type', + field=models.ForeignKey(verbose_name='Warehouse type', to='archaeological_warehouse.WarehouseType'), + ), + migrations.AddField( + model_name='containerlocalisation', + name='container', + field=models.ForeignKey(related_name='division', verbose_name='Container', to='archaeological_warehouse.Container'), + ), + migrations.AddField( + model_name='containerlocalisation', + name='division', + field=models.ForeignKey(verbose_name='Division', to='archaeological_warehouse.WarehouseDivisionLink'), + ), + migrations.AddField( + model_name='container', + name='container_type', + field=models.ForeignKey(verbose_name='Container type', to='archaeological_warehouse.ContainerType'), + ), + migrations.AddField( + model_name='container', + name='history_creator', + field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Creator', blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + migrations.AddField( + model_name='container', + name='history_modifier', + field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Last editor', blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + migrations.AddField( + model_name='container', + name='imports', + field=models.ManyToManyField(related_name='imported_archaeological_warehouse_container', to='ishtar_common.Import', blank=True), + ), + migrations.AddField( + model_name='container', + name='location', + field=models.ForeignKey(related_name='containers', verbose_name='Location (warehouse)', to='archaeological_warehouse.Warehouse'), + ), + migrations.AddField( + model_name='container', + name='responsible', + field=models.ForeignKey(related_name='owned_containers', verbose_name='Responsible warehouse', to='archaeological_warehouse.Warehouse'), + ), + migrations.AddField( + model_name='collection', + name='history_creator', + field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Creator', blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + migrations.AddField( + model_name='collection', + name='history_modifier', + field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='Last editor', blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + migrations.AddField( + model_name='collection', + name='imports', + field=models.ManyToManyField(related_name='imported_archaeological_warehouse_collection', to='ishtar_common.Import', blank=True), + ), + migrations.AddField( + model_name='collection', + name='warehouse', + field=models.ForeignKey(related_name='collections', verbose_name='Warehouse', to='archaeological_warehouse.Warehouse'), + ), + migrations.AlterUniqueTogether( + name='warehousedivisionlink', + unique_together=set([('warehouse', 'division')]), + ), + migrations.AlterUniqueTogether( + name='containerlocalisation', + unique_together=set([('container', 'division')]), + ), + migrations.AlterUniqueTogether( + name='container', + unique_together=set([('index', 'location')]), + ), + ] diff --git a/archaeological_warehouse/migrations/0003_auto_20170802_1557.py b/archaeological_warehouse/migrations/0003_auto_20170802_1557.py new file mode 100644 index 000000000..90d67bc46 --- /dev/null +++ b/archaeological_warehouse/migrations/0003_auto_20170802_1557.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_warehouse', '0002_auto_20170414_2123'), + ] + + operations = [ + migrations.AlterModelOptions( + name='warehouse', + options={'verbose_name': 'Warehouse', 'verbose_name_plural': 'Warehouses', 'permissions': (('view_warehouse', 'Can view all Warehouses'), ('view_own_warehouse', 'Can view own Warehouse'), ('add_own_warehouse', 'Can add own Warehouse'), ('change_own_warehouse', 'Can change own Warehouse'), ('delete_own_warehouse', 'Can delete own Warehouse'))}, + ), + ] diff --git a/archaeological_warehouse/migrations/0004_auto_20170804_2024.py b/archaeological_warehouse/migrations/0004_auto_20170804_2024.py new file mode 100644 index 000000000..e585da67c --- /dev/null +++ b/archaeological_warehouse/migrations/0004_auto_20170804_2024.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import re +import django.core.validators + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_warehouse', '0003_auto_20170802_1557'), + ] + + operations = [ + migrations.AlterField( + model_name='containertype', + name='txt_idx', + field=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.', unique=True, max_length=100, verbose_name='Textual ID', validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+$'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')]), + ), + migrations.AlterField( + model_name='warehousedivision', + name='txt_idx', + field=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.', unique=True, max_length=100, verbose_name='Textual ID', validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+$'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')]), + ), + migrations.AlterField( + model_name='warehousetype', + name='txt_idx', + field=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.', unique=True, max_length=100, verbose_name='Textual ID', validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+$'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')]), + ), + ] diff --git a/archaeological_warehouse/migrations/0005_auto_20170826_1152.py b/archaeological_warehouse/migrations/0005_auto_20170826_1152.py new file mode 100644 index 000000000..036345796 --- /dev/null +++ b/archaeological_warehouse/migrations/0005_auto_20170826_1152.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2017-08-26 11:52 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models +import re + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_warehouse', '0004_auto_20170804_2024'), + ] + + operations = [ + migrations.AlterField( + model_name='containertype', + name='txt_idx', + field=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'), + ), + migrations.AlterField( + model_name='warehousedivision', + name='txt_idx', + field=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'), + ), + migrations.AlterField( + model_name='warehousetype', + name='txt_idx', + field=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'), + ), + ] diff --git a/archaeological_warehouse/migrations/0006_auto_20170829_1639.py b/archaeological_warehouse/migrations/0006_auto_20170829_1639.py new file mode 100644 index 000000000..0d22d1571 --- /dev/null +++ b/archaeological_warehouse/migrations/0006_auto_20170829_1639.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2017-08-29 16:39 +from __future__ import unicode_literals + +from django.db import migrations, models +import ishtar_common.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_warehouse', '0005_auto_20170826_1152'), + ] + + operations = [ + migrations.AlterField( + model_name='container', + name='image', + field=models.ImageField(blank=True, max_length=255, null=True, upload_to=ishtar_common.models.get_image_path), + ), + migrations.AlterField( + model_name='container', + name='thumbnail', + field=models.ImageField(blank=True, max_length=255, null=True, upload_to=ishtar_common.models.get_image_path), + ), + ] diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 96814339c..1804d70d6 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -21,10 +21,10 @@ import datetime from django.conf import settings from django.contrib.gis.db import models -from django.db.models import Q, Count +from django.db.models import Q from django.db.models.signals import post_save, post_delete from django.template.defaultfilters import slugify -from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils.translation import ugettext_lazy as _ from ishtar_common.utils import cached_label_changed @@ -65,11 +65,11 @@ class Warehouse(Address, DashboardFormItem, OwnPerms): verbose_name = _(u"Warehouse") verbose_name_plural = _(u"Warehouses") permissions = ( - ("view_warehouse", ugettext(u"Can view all Warehouses")), - ("view_own_warehouse", ugettext(u"Can view own Warehouse")), - ("add_own_warehouse", ugettext(u"Can add own Warehouse")), - ("change_own_warehouse", ugettext(u"Can change own Warehouse")), - ("delete_own_warehouse", ugettext(u"Can delete own Warehouse")), + ("view_warehouse", u"Can view all Warehouses"), + ("view_own_warehouse", u"Can view own Warehouse"), + ("add_own_warehouse", u"Can add own Warehouse"), + ("change_own_warehouse", u"Can change own Warehouse"), + ("delete_own_warehouse", u"Can delete own Warehouse"), ) def __unicode__(self): @@ -81,8 +81,8 @@ class Warehouse(Address, DashboardFormItem, OwnPerms): slugify(unicode(self)) @classmethod - def get_query_owns(cls, user): - return Q(person_in_charge__ishtaruser=user.ishtaruser) + def get_query_owns(cls, ishtaruser): + return Q(person_in_charge__ishtaruser=ishtaruser) @property def number_of_finds(self): @@ -310,10 +310,10 @@ class Container(LightHistorizedItem, ImageModel): return cached_label @classmethod - def get_query_owns(cls, user): - return Q(history_creator=user) | \ - Q(location__person_in_charge__ishtaruser=user.ishtaruser) | \ - Q(responsible__person_in_charge__ishtaruser=user.ishtaruser) + def get_query_owns(cls, ishtaruser): + return Q(history_creator=ishtaruser.user_ptr) | \ + Q(location__person_in_charge__ishtaruser=ishtaruser) | \ + Q(responsible__person_in_charge__ishtaruser=ishtaruser) @property def associated_filename(self): @@ -328,6 +328,43 @@ class Container(LightHistorizedItem, ImageModel): def precise_location(self): return self.location.name + u" - " + self.divisions_lbl + def get_localisations(self): + """ + Get precise localisation of the container in the warehouse. + + :return: tuple of strings with localisations + """ + return tuple(( + loca.reference + for loca in ContainerLocalisation.objects.filter( + container=self).order_by('division__order') + )) + + def set_localisation(self, place, value): + """ + Set the reference for the localisation number "place" (starting from 0) + :param place: the number of the localisation + :param value: the reference to be set + :return: the container location object or None if the place does not + exist + """ + q = WarehouseDivisionLink.objects.filter( + warehouse=self.location).order_by('order') + for idx, division_link in enumerate(q.all()): + if idx == place: + break + else: + return + dct = {'container': self, 'division': division_link} + if not value: + if ContainerLocalisation.objects.filter(**dct).count(): + c = ContainerLocalisation.objects.filter(**dct).all()[0] + c.delete() + return + dct['defaults'] = {'reference': value} + obj, created = ContainerLocalisation.objects.update_or_create(**dct) + return obj + @property def divisions_lbl(self): locas = [ diff --git a/archaeological_warehouse/old_migrations/0001_initial.py b/archaeological_warehouse/old_migrations/0001_initial.py new file mode 100644 index 000000000..6c3b14e75 --- /dev/null +++ b/archaeological_warehouse/old_migrations/0001_initial.py @@ -0,0 +1,229 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'WarehouseType' + db.create_table('archaeological_warehouse_warehousetype', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('label', self.gf('django.db.models.fields.CharField')(max_length=100)), + ('txt_idx', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30)), + ('comment', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + ('available', self.gf('django.db.models.fields.BooleanField')(default=False)), + )) + db.send_create_signal('archaeological_warehouse', ['WarehouseType']) + + # Adding model 'Warehouse' + db.create_table('archaeological_warehouse_warehouse', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('history_modifier', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', to=orm['auth.User'])), + ('address', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + ('address_complement', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + ('postal_code', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)), + ('town', self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True)), + ('country', self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True)), + ('phone', self.gf('django.db.models.fields.CharField')(max_length=18, null=True, blank=True)), + ('mobile_phone', self.gf('django.db.models.fields.CharField')(max_length=18, null=True, blank=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=40)), + ('warehouse_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['archaeological_warehouse.WarehouseType'])), + ('person_in_charge', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['ishtar_common.Person'], null=True, blank=True)), + ('comment', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + )) + db.send_create_signal('archaeological_warehouse', ['Warehouse']) + + # Adding model 'ContainerType' + db.create_table('archaeological_warehouse_containertype', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('label', self.gf('django.db.models.fields.CharField')(max_length=100)), + ('txt_idx', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30)), + ('comment', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + ('available', self.gf('django.db.models.fields.BooleanField')(default=False)), + ('length', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), + ('width', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), + ('height', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), + ('volume', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)), + ('reference', self.gf('django.db.models.fields.CharField')(max_length=30)), + )) + db.send_create_signal('archaeological_warehouse', ['ContainerType']) + + # Adding model 'Container' + db.create_table('archaeological_warehouse_container', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('history_modifier', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', to=orm['auth.User'])), + ('history_date', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)), + ('location', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['archaeological_warehouse.Warehouse'])), + ('container_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['archaeological_warehouse.ContainerType'])), + ('reference', self.gf('django.db.models.fields.CharField')(max_length=40)), + ('comment', self.gf('django.db.models.fields.TextField')()), + )) + db.send_create_signal('archaeological_warehouse', ['Container']) + + + def backwards(self, orm): + # Deleting model 'WarehouseType' + db.delete_table('archaeological_warehouse_warehousetype') + + # Deleting model 'Warehouse' + db.delete_table('archaeological_warehouse_warehouse') + + # Deleting model 'ContainerType' + db.delete_table('archaeological_warehouse_containertype') + + # Deleting model 'Container' + db.delete_table('archaeological_warehouse_container') + + + models = { + 'archaeological_warehouse.container': { + 'Meta': {'object_name': 'Container'}, + 'comment': ('django.db.models.fields.TextField', [], {}), + 'container_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['archaeological_warehouse.ContainerType']"}), + 'history_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'location': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['archaeological_warehouse.Warehouse']"}), + 'reference': ('django.db.models.fields.CharField', [], {'max_length': '40'}) + }, + 'archaeological_warehouse.containertype': { + 'Meta': {'object_name': 'ContainerType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'length': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'reference': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}), + 'volume': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) + }, + 'archaeological_warehouse.warehouse': { + 'Meta': {'object_name': 'Warehouse'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}), + 'person_in_charge': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Person']", 'null': 'True', 'blank': 'True'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'warehouse_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['archaeological_warehouse.WarehouseType']"}) + }, + 'archaeological_warehouse.warehousetype': { + 'Meta': {'object_name': 'WarehouseType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'ishtar_common.organization': { + 'Meta': {'object_name': 'Organization'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'organization_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.OrganizationType']"}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.organizationtype': { + 'Meta': {'object_name': 'OrganizationType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'ishtar_common.person': { + 'Meta': {'object_name': 'Person'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'attached_to': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Organization']", 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'person_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.PersonType']"}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'surname': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '2'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.persontype': { + 'Meta': {'object_name': 'PersonType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'rights': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['ishtar_common.WizardStep']", 'symmetrical': 'False'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'ishtar_common.wizard': { + 'Meta': {'ordering': "['url_name']", 'object_name': 'Wizard'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'url_name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}) + }, + 'ishtar_common.wizardstep': { + 'Meta': {'ordering': "['wizard', 'order']", 'object_name': 'WizardStep'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'order': ('django.db.models.fields.IntegerField', [], {}), + 'url_name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'wizard': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Wizard']"}) + } + } + + complete_apps = ['archaeological_warehouse']
\ No newline at end of file diff --git a/archaeological_warehouse/migrations/0002_auto__add_field_warehouse_history_creator__add_field_container_history.py b/archaeological_warehouse/old_migrations/0002_auto__add_field_warehouse_history_creator__add_field_container_history.py index 75bd47a45..75bd47a45 100644 --- a/archaeological_warehouse/migrations/0002_auto__add_field_warehouse_history_creator__add_field_container_history.py +++ b/archaeological_warehouse/old_migrations/0002_auto__add_field_warehouse_history_creator__add_field_container_history.py diff --git a/archaeological_warehouse/migrations/0003_auto__add_field_warehouse_email.py b/archaeological_warehouse/old_migrations/0003_auto__add_field_warehouse_email.py index bcfabba98..bcfabba98 100644 --- a/archaeological_warehouse/migrations/0003_auto__add_field_warehouse_email.py +++ b/archaeological_warehouse/old_migrations/0003_auto__add_field_warehouse_email.py diff --git a/archaeological_warehouse/migrations/0004_auto__chg_field_warehouse_history_creator__chg_field_warehouse_person_.py b/archaeological_warehouse/old_migrations/0004_auto__chg_field_warehouse_history_creator__chg_field_warehouse_person_.py index 66d7c4926..66d7c4926 100644 --- a/archaeological_warehouse/migrations/0004_auto__chg_field_warehouse_history_creator__chg_field_warehouse_person_.py +++ b/archaeological_warehouse/old_migrations/0004_auto__chg_field_warehouse_history_creator__chg_field_warehouse_person_.py diff --git a/archaeological_warehouse/migrations/0005_auto__chg_field_warehouse_town.py b/archaeological_warehouse/old_migrations/0005_auto__chg_field_warehouse_town.py index c8f67c425..c8f67c425 100644 --- a/archaeological_warehouse/migrations/0005_auto__chg_field_warehouse_town.py +++ b/archaeological_warehouse/old_migrations/0005_auto__chg_field_warehouse_town.py diff --git a/archaeological_warehouse/migrations/0006_auto.py b/archaeological_warehouse/old_migrations/0006_auto.py index fae8058d6..fae8058d6 100644 --- a/archaeological_warehouse/migrations/0006_auto.py +++ b/archaeological_warehouse/old_migrations/0006_auto.py diff --git a/archaeological_warehouse/migrations/0007_auto__chg_field_warehousetype_txt_idx__chg_field_containertype_txt_idx.py b/archaeological_warehouse/old_migrations/0007_auto__chg_field_warehousetype_txt_idx__chg_field_containertype_txt_idx.py index a823623b9..a823623b9 100644 --- a/archaeological_warehouse/migrations/0007_auto__chg_field_warehousetype_txt_idx__chg_field_containertype_txt_idx.py +++ b/archaeological_warehouse/old_migrations/0007_auto__chg_field_warehousetype_txt_idx__chg_field_containertype_txt_idx.py diff --git a/archaeological_warehouse/migrations/0008_auto__add_field_warehouse_alt_address__add_field_warehouse_alt_address.py b/archaeological_warehouse/old_migrations/0008_auto__add_field_warehouse_alt_address__add_field_warehouse_alt_address.py index b543a501e..b543a501e 100644 --- a/archaeological_warehouse/migrations/0008_auto__add_field_warehouse_alt_address__add_field_warehouse_alt_address.py +++ b/archaeological_warehouse/old_migrations/0008_auto__add_field_warehouse_alt_address__add_field_warehouse_alt_address.py diff --git a/archaeological_warehouse/migrations/0009_auto__chg_field_warehouse_phone_desc3__chg_field_warehouse_phone_desc2.py b/archaeological_warehouse/old_migrations/0009_auto__chg_field_warehouse_phone_desc3__chg_field_warehouse_phone_desc2.py index 008faea54..008faea54 100644 --- a/archaeological_warehouse/migrations/0009_auto__chg_field_warehouse_phone_desc3__chg_field_warehouse_phone_desc2.py +++ b/archaeological_warehouse/old_migrations/0009_auto__chg_field_warehouse_phone_desc3__chg_field_warehouse_phone_desc2.py diff --git a/archaeological_warehouse/migrations/0010_auto__add_warehousedivisionlink__add_warehousedivision__chg_field_ware.py b/archaeological_warehouse/old_migrations/0010_auto__add_warehousedivisionlink__add_warehousedivision__chg_field_ware.py index 306ebe290..306ebe290 100644 --- a/archaeological_warehouse/migrations/0010_auto__add_warehousedivisionlink__add_warehousedivision__chg_field_ware.py +++ b/archaeological_warehouse/old_migrations/0010_auto__add_warehousedivisionlink__add_warehousedivision__chg_field_ware.py diff --git a/archaeological_warehouse/migrations/0011_auto__add_containerlocalisation__add_unique_containerlocalisation_cont.py b/archaeological_warehouse/old_migrations/0011_auto__add_containerlocalisation__add_unique_containerlocalisation_cont.py index 0b63f4d5b..0b63f4d5b 100644 --- a/archaeological_warehouse/migrations/0011_auto__add_containerlocalisation__add_unique_containerlocalisation_cont.py +++ b/archaeological_warehouse/old_migrations/0011_auto__add_containerlocalisation__add_unique_containerlocalisation_cont.py diff --git a/archaeological_warehouse/migrations/0012_auto__add_field_container_cached_label.py b/archaeological_warehouse/old_migrations/0012_auto__add_field_container_cached_label.py index 2ffeaa231..2ffeaa231 100644 --- a/archaeological_warehouse/migrations/0012_auto__add_field_container_cached_label.py +++ b/archaeological_warehouse/old_migrations/0012_auto__add_field_container_cached_label.py diff --git a/archaeological_warehouse/migrations/0013_auto__add_collection.py b/archaeological_warehouse/old_migrations/0013_auto__add_collection.py index 52c7e841e..52c7e841e 100644 --- a/archaeological_warehouse/migrations/0013_auto__add_collection.py +++ b/archaeological_warehouse/old_migrations/0013_auto__add_collection.py diff --git a/archaeological_warehouse/migrations/0014_auto__add_field_container_cached_location__add_field_container_index.py b/archaeological_warehouse/old_migrations/0014_auto__add_field_container_cached_location__add_field_container_index.py index 4e267e1ac..4e267e1ac 100644 --- a/archaeological_warehouse/migrations/0014_auto__add_field_container_cached_location__add_field_container_index.py +++ b/archaeological_warehouse/old_migrations/0014_auto__add_field_container_cached_location__add_field_container_index.py diff --git a/archaeological_warehouse/migrations/0015_auto_increment_existing_indexes.py b/archaeological_warehouse/old_migrations/0015_auto_increment_existing_indexes.py index 138c2165d..138c2165d 100644 --- a/archaeological_warehouse/migrations/0015_auto_increment_existing_indexes.py +++ b/archaeological_warehouse/old_migrations/0015_auto_increment_existing_indexes.py diff --git a/archaeological_warehouse/migrations/0016_auto__add_unique_container_index_location.py b/archaeological_warehouse/old_migrations/0016_auto__add_unique_container_index_location.py index 055497078..055497078 100644 --- a/archaeological_warehouse/migrations/0016_auto__add_unique_container_index_location.py +++ b/archaeological_warehouse/old_migrations/0016_auto__add_unique_container_index_location.py diff --git a/archaeological_warehouse/migrations/0017_auto__chg_field_container_comment.py b/archaeological_warehouse/old_migrations/0017_auto__chg_field_container_comment.py index bb6d2585e..bb6d2585e 100644 --- a/archaeological_warehouse/migrations/0017_auto__chg_field_container_comment.py +++ b/archaeological_warehouse/old_migrations/0017_auto__chg_field_container_comment.py diff --git a/archaeological_warehouse/migrations/0018_generate_cache_lbl_for_containers.py b/archaeological_warehouse/old_migrations/0018_generate_cache_lbl_for_containers.py index 2e3e62c23..2e3e62c23 100644 --- a/archaeological_warehouse/migrations/0018_generate_cache_lbl_for_containers.py +++ b/archaeological_warehouse/old_migrations/0018_generate_cache_lbl_for_containers.py diff --git a/archaeological_warehouse/migrations/0019_auto__add_field_container_responsible.py b/archaeological_warehouse/old_migrations/0019_auto__add_field_container_responsible.py index 21612d227..21612d227 100644 --- a/archaeological_warehouse/migrations/0019_auto__add_field_container_responsible.py +++ b/archaeological_warehouse/old_migrations/0019_auto__add_field_container_responsible.py diff --git a/archaeological_warehouse/migrations/0020_generate_cache_lbl_for_containers.py b/archaeological_warehouse/old_migrations/0020_generate_cache_lbl_for_containers.py index 4c6e08dbe..4c6e08dbe 100644 --- a/archaeological_warehouse/migrations/0020_generate_cache_lbl_for_containers.py +++ b/archaeological_warehouse/old_migrations/0020_generate_cache_lbl_for_containers.py diff --git a/archaeological_warehouse/migrations/0021_auto__chg_field_container_responsible.py b/archaeological_warehouse/old_migrations/0021_auto__chg_field_container_responsible.py index 65df3991b..65df3991b 100644 --- a/archaeological_warehouse/migrations/0021_auto__chg_field_container_responsible.py +++ b/archaeological_warehouse/old_migrations/0021_auto__chg_field_container_responsible.py diff --git a/archaeological_warehouse/migrations/0022_auto__chg_field_containertype_volume.py b/archaeological_warehouse/old_migrations/0022_auto__chg_field_containertype_volume.py index 4c0d67711..4c0d67711 100644 --- a/archaeological_warehouse/migrations/0022_auto__chg_field_containertype_volume.py +++ b/archaeological_warehouse/old_migrations/0022_auto__chg_field_containertype_volume.py diff --git a/archaeological_warehouse/migrations/0023_auto__add_field_container_external_id__add_field_container_auto_extern.py b/archaeological_warehouse/old_migrations/0023_auto__add_field_container_external_id__add_field_container_auto_extern.py index 05fd10ffd..05fd10ffd 100644 --- a/archaeological_warehouse/migrations/0023_auto__add_field_container_external_id__add_field_container_auto_extern.py +++ b/archaeological_warehouse/old_migrations/0023_auto__add_field_container_external_id__add_field_container_auto_extern.py diff --git a/archaeological_warehouse/migrations/0024_generate_cache_lbl_for_containers.py b/archaeological_warehouse/old_migrations/0024_generate_cache_lbl_for_containers.py index 51449c167..51449c167 100644 --- a/archaeological_warehouse/migrations/0024_generate_cache_lbl_for_containers.py +++ b/archaeological_warehouse/old_migrations/0024_generate_cache_lbl_for_containers.py diff --git a/archaeological_warehouse/migrations/0025_auto__add_field_container_image__add_field_container_thumbnail.py b/archaeological_warehouse/old_migrations/0025_auto__add_field_container_image__add_field_container_thumbnail.py index cc1f02807..cc1f02807 100644 --- a/archaeological_warehouse/migrations/0025_auto__add_field_container_image__add_field_container_thumbnail.py +++ b/archaeological_warehouse/old_migrations/0025_auto__add_field_container_image__add_field_container_thumbnail.py diff --git a/archaeological_warehouse/migrations/0026_generate_cache_lbl_for_containers.py b/archaeological_warehouse/old_migrations/0026_generate_cache_lbl_for_containers.py index 85df1bf21..85df1bf21 100644 --- a/archaeological_warehouse/migrations/0026_generate_cache_lbl_for_containers.py +++ b/archaeological_warehouse/old_migrations/0026_generate_cache_lbl_for_containers.py diff --git a/archaeological_warehouse/old_migrations/__init__.py b/archaeological_warehouse/old_migrations/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/archaeological_warehouse/old_migrations/__init__.py diff --git a/archaeological_warehouse/templates/ishtar/wizard/wizard_containerlocalisation.html b/archaeological_warehouse/templates/ishtar/wizard/wizard_containerlocalisation.html index 41be02748..4d0a63c17 100644 --- a/archaeological_warehouse/templates/ishtar/wizard/wizard_containerlocalisation.html +++ b/archaeological_warehouse/templates/ishtar/wizard/wizard_containerlocalisation.html @@ -1,6 +1,5 @@ {% extends "ishtar/wizard/default_wizard.html" %} {% load i18n %} -{% load url from future %} {% block form_head %} {% if not wizard.form.fields %} <p class="alert"> diff --git a/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html b/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html index 83dbfc0fe..cceabb4a0 100644 --- a/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html +++ b/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html @@ -1,6 +1,5 @@ {% extends "ishtar/wizard/default_wizard.html" %} {% load i18n %} -{% load url from future %} {% block form_head %} {% if wizard.form.readonly %} <p class="alert"> diff --git a/archaeological_warehouse/urls.py b/archaeological_warehouse/urls.py index ec3aa1beb..5be9183d2 100644 --- a/archaeological_warehouse/urls.py +++ b/archaeological_warehouse/urls.py @@ -17,38 +17,35 @@ # See the file COPYING for details. -from django.conf.urls.defaults import * +from django.conf.urls import url from ishtar_common.wizards import check_rights -import views +from archaeological_warehouse import views + from archaeological_warehouse import models # be careful: each check_rights must be relevant with ishtar_menu # forms -urlpatterns = patterns( - '', +urlpatterns = [ url(r'warehouse_packaging/(?P<step>.+)?$', views.warehouse_packaging_wizard, name='warehouse_packaging'), -) -urlpatterns += patterns( - 'archaeological_warehouse.views', url(r'new-warehouse/(?P<parent_name>.+)?/$', - 'new_warehouse', name='new-warehouse'), - url(r'^show-warehouse(?:/(?P<pk>.+))?/(?P<type>.+)?$', 'show_warehouse', + views.new_warehouse, name='new-warehouse'), + url(r'^show-warehouse(?:/(?P<pk>.+))?/(?P<type>.+)?$', views.show_warehouse, name=models.Warehouse.SHOW_URL), - url(r'autocomplete-warehouse/$', 'autocomplete_warehouse', + url(r'autocomplete-warehouse/$', views.autocomplete_warehouse, name='autocomplete-warehouse'), url(r'new-container/(?P<parent_name>.+)?/$', - 'new_container', name='new-container'), - url(r'get-container/(?P<type>.+)?$', 'get_container', + views.new_container, name='new-container'), + url(r'get-container/(?P<type>.+)?$', views.get_container, name='get-container'), - url(r'get-warehouse/(?P<type>.+)?$', 'get_warehouse', + url(r'get-warehouse/(?P<type>.+)?$', views.get_warehouse, name='get-warehouse'), url(r'autocomplete-container/?$', - 'autocomplete_container', name='autocomplete-container'), - url(r'^show-container(?:/(?P<pk>.+))?/(?P<type>.+)?$', 'show_container', + views.autocomplete_container, name='autocomplete-container'), + url(r'^show-container(?:/(?P<pk>.+))?/(?P<type>.+)?$', views.show_container, name=models.Container.SHOW_URL), url(r'^warehouse_search/(?P<step>.+)?$', check_rights(['view_warehouse', 'view_own_warehouse'])( @@ -85,4 +82,4 @@ urlpatterns += patterns( name='container_deletion'), url(r'container-modify/(?P<pk>.+)/$', views.container_modify, name='container_modify'), -)
\ No newline at end of file +]
\ No newline at end of file diff --git a/archaeological_warehouse/views.py b/archaeological_warehouse/views.py index 677539a3f..60d31c09d 100644 --- a/archaeological_warehouse/views.py +++ b/archaeological_warehouse/views.py @@ -48,9 +48,9 @@ def autocomplete_warehouse(request): models.Warehouse)\ and not request.user.has_perm( 'ishtar_common.view_own_warehouse', models.Warehouse): - return HttpResponse(mimetype='text/plain') + return HttpResponse(content_type='text/plain') if not request.GET.get('term'): - return HttpResponse(mimetype='text/plain') + return HttpResponse(content_type='text/plain') q = request.GET.get('term') query = Q() for q in q.split(' '): @@ -61,7 +61,7 @@ def autocomplete_warehouse(request): warehouses = models.Warehouse.objects.filter(query)[:limit] data = json.dumps([{'id': warehouse.pk, 'value': unicode(warehouse)} for warehouse in warehouses]) - return HttpResponse(data, mimetype='text/plain') + return HttpResponse(data, content_type='text/plain') def autocomplete_container(request): @@ -69,9 +69,9 @@ def autocomplete_container(request): models.Warehouse)\ and not request.user.has_perm( 'ishtar_common.view_own_warehouse', models.Warehouse): - return HttpResponse(mimetype='text/plain') + return HttpResponse(content_type='text/plain') if not request.GET.get('term'): - return HttpResponse(mimetype='text/plain') + return HttpResponse(content_type='text/plain') q = request.GET.get('term') query = Q() for q in q.split(' '): @@ -85,7 +85,7 @@ def autocomplete_container(request): containers = models.Container.objects.filter(query)[:limit] data = json.dumps([{'id': container.pk, 'value': unicode(container)} for container in containers]) - return HttpResponse(data, mimetype='text/plain') + return HttpResponse(data, content_type='text/plain') warehouse_packaging_wizard = PackagingWizard.as_view([ ('seleccontainer-packaging', ContainerFormSelection), diff --git a/archaeological_warehouse/wizards.py b/archaeological_warehouse/wizards.py index 571e56b1b..6678e6c36 100644 --- a/archaeological_warehouse/wizards.py +++ b/archaeological_warehouse/wizards.py @@ -17,8 +17,7 @@ # See the file COPYING for details. -from django.shortcuts import render_to_response -from django.template import RequestContext +from django.shortcuts import render from ishtar_common.forms import reverse_lazy from ishtar_common.wizards import Wizard, DeletionWizard @@ -50,8 +49,7 @@ class PackagingWizard(TreatmentWizard): extra_args_for_new=extra_args_for_new) packaging = TreatmentType.objects.get(txt_idx='packaging') treatment.treatment_types.add(packaging) - res = render_to_response('ishtar/wizard/wizard_done.html', {}, - context_instance=RequestContext(self.request)) + res = render(self.request, 'ishtar/wizard/wizard_done.html', {}) return return_object and (obj, res) or res @@ -141,9 +139,7 @@ class ContainerWizard(Wizard): self.current_object = container # force evaluation of lazy urls dct['wizard_done_window'] = unicode(self.wizard_done_window) - return render_to_response( - self.wizard_done_template, dct, - context_instance=RequestContext(self.request)) + return render(self.request, self.wizard_done_template, dct) class ContainerModificationWizard(ContainerWizard): |
