summaryrefslogtreecommitdiff
path: root/archaeological_warehouse
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_warehouse')
-rw-r--r--archaeological_warehouse/admin.py51
-rw-r--r--archaeological_warehouse/ishtar_menu.py40
-rw-r--r--archaeological_warehouse/models.py1
-rw-r--r--archaeological_warehouse/urls.py45
-rw-r--r--archaeological_warehouse/views.py81
5 files changed, 217 insertions, 1 deletions
diff --git a/archaeological_warehouse/admin.py b/archaeological_warehouse/admin.py
new file mode 100644
index 000000000..cf026e86c
--- /dev/null
+++ b/archaeological_warehouse/admin.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2012 É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
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See the file COPYING for details.
+
+from django.conf import settings
+from django.contrib import admin
+
+from ishtar_common.admin import HistorizedObjectAdmin
+
+import models
+
+class WarehouseAdmin(HistorizedObjectAdmin):
+ list_display = ('name', 'warehouse_type', 'town')
+ list_filter = ('warehouse_type',)
+ search_fields = ('name', 'town')
+ model = models.Warehouse
+
+admin.site.register(models.Warehouse, WarehouseAdmin)
+
+class ContainerTypeAdmin(admin.ModelAdmin):
+ list_display = ('label', 'reference', 'length', 'width', 'height',
+ 'volume')
+ model = models.ContainerType
+
+admin.site.register(models.ContainerType, ContainerTypeAdmin)
+
+class ContainerAdmin(admin.ModelAdmin):
+ list_display = ('reference', 'location', 'container_type',)
+ list_filter = ("container_type",)
+ model = models.Container
+
+admin.site.register(models.Container, ContainerAdmin)
+
+basic_models = [models.WarehouseType]
+for model in basic_models:
+ admin.site.register(model)
diff --git a/archaeological_warehouse/ishtar_menu.py b/archaeological_warehouse/ishtar_menu.py
new file mode 100644
index 000000000..1a9d57aaa
--- /dev/null
+++ b/archaeological_warehouse/ishtar_menu.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2012 É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
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See the file COPYING for details.
+
+from django.utils.translation import ugettext_lazy as _
+
+from ishtar_common.menu_base import SectionItem, MenuItem
+
+from archaeological_finds.models import Treatment
+import models
+
+MENU_SECTIONS = [
+ (60, SectionItem('warehouse', _(u"Warehouse"),
+ childs=[
+ MenuItem('warehouse_inventory', _(u"Inventory"),
+ model=models.Warehouse,
+ access_controls=['change_warehouse',]),
+ MenuItem('warehouse_recording', _(u"Recording"),
+ model=Treatment,
+ access_controls=['add_treatment', 'add_own_treatment']),
+ MenuItem('warehouse_lend', _(u"Lending"),
+ model=Treatment,
+ access_controls=['add_treatment', 'add_own_treatment']),
+ ]))
+]
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index fe381e521..877d16487 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -51,7 +51,6 @@ class Warehouse(Address, OwnPerms):
def __unicode__(self):
return u"%s (%s)" % (self.name, unicode(self.warehouse_type))
-
class ContainerType(GeneralType):
length = models.IntegerField(_(u"Length (mm)"), blank=True, null=True)
width = models.IntegerField(_(u"Width (mm)"), blank=True, null=True)
diff --git a/archaeological_warehouse/urls.py b/archaeological_warehouse/urls.py
new file mode 100644
index 000000000..914ee2533
--- /dev/null
+++ b/archaeological_warehouse/urls.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2010-2012 É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
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See the file COPYING for details.
+
+from django.conf.urls.defaults import *
+
+"""
+import forms
+
+# forms
+urlpatterns = patterns('',
+ url(r'treatment_creation/(?P<step>.+)$',
+ forms.treatment_creation_wizard, name='treatment_creation'),
+ url(r'warehouse_packaging/(?P<step>.+)$',
+ forms.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'autocomplete-warehouse/$', 'autocomplete_warehouse',
+ name='autocomplete-warehouse'),
+ url(r'new-container/(?P<parent_name>.+)?/$',
+ 'new_container', name='new-container'),
+ url(r'get-container/$', 'get_container',
+ name='get-container'),
+ url(r'autocomplete-container/?$',
+ 'autocomplete_container', name='autocomplete-container'),
+)
+"""
diff --git a/archaeological_warehouse/views.py b/archaeological_warehouse/views.py
new file mode 100644
index 000000000..16a8e19f5
--- /dev/null
+++ b/archaeological_warehouse/views.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2010-2012 É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
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See the file COPYING for details.
+
+import json
+
+from django.db.models import Q
+from django.http import HttpResponse
+from django.shortcuts import render_to_response
+
+from ishtar_common.views import get_item, show_item, revert_item
+import models
+
+get_container = get_item(models.Container,
+ 'get_container', 'container',
+ extra_request_keys={
+ 'location':'location__pk',
+ 'container_type':'container_type__pk',
+ 'reference':'reference__icontains',
+ })
+
+new_warehouse = new_item(models.Warehouse)
+new_container = new_item(models.Container)
+
+def autocomplete_warehouse(request):
+ if not request.user.has_perm('ishtar_common.view_warehouse',
+ models.Warehouse)\
+ and not request.user.has_perm('ishtar_common.view_own_warehouse',
+ models.Warehouse) :
+ return HttpResponse(mimetype='text/plain')
+ if not request.GET.get('term'):
+ return HttpResponse(mimetype='text/plain')
+ q = request.GET.get('term')
+ query = Q()
+ for q in q.split(' '):
+ extra = Q(name__icontains=q) | \
+ Q(warehouse_type__label__icontains=q)
+ query = query & extra
+ limit = 15
+ 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')
+
+def autocomplete_container(request):
+ if not request.user.has_perm('ishtar_common.view_warehouse',
+ models.Warehouse)\
+ and not request.user.has_perm('ishtar_common.view_own_warehouse',
+ models.Warehouse):
+ return HttpResponse(mimetype='text/plain')
+ if not request.GET.get('term'):
+ return HttpResponse(mimetype='text/plain')
+ q = request.GET.get('term')
+ query = Q()
+ for q in q.split(' '):
+ extra = Q(container_type__label__icontains=q) | \
+ Q(container_type__reference__icontains=q) | \
+ Q(reference__icontains=q) | \
+ Q(location__name=q) | \
+ Q(location__town=q)
+ query = query & extra
+ limit = 15
+ 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')