summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2014-12-18 08:37:01 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2014-12-18 08:37:01 +0100
commit2aac28f9a6dd4515b7a2e6079dde09838a1d8658 (patch)
tree7318917802de9bc82b3b9fc2389cbe53a80fba53
parent548adf108e7aa82b7a33df412abdf87d433fabd6 (diff)
downloadIshtar-2aac28f9a6dd4515b7a2e6079dde09838a1d8658.tar.bz2
Ishtar-2aac28f9a6dd4515b7a2e6079dde09838a1d8658.zip
First work for an alternate UI for archaeological files (refs #2175)
-rw-r--r--archaeological_files_pdl/__init__.py0
-rw-r--r--archaeological_files_pdl/forms.py51
-rw-r--r--archaeological_files_pdl/models.py3
-rw-r--r--archaeological_files_pdl/tests.py16
-rw-r--r--archaeological_files_pdl/urls.py27
-rw-r--r--archaeological_files_pdl/views.py48
-rw-r--r--example_project/urls.py2
-rw-r--r--ishtar_common/templates/ishtar/wizard/default_wizard.html6
8 files changed, 150 insertions, 3 deletions
diff --git a/archaeological_files_pdl/__init__.py b/archaeological_files_pdl/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archaeological_files_pdl/__init__.py
diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py
new file mode 100644
index 000000000..87221f24c
--- /dev/null
+++ b/archaeological_files_pdl/forms.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2014 É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 datetime
+
+from django import forms
+from django.core import validators
+from django.utils.translation import ugettext_lazy as _
+
+from ishtar_common.models import Person
+from archaeological_files import models
+
+from ishtar_common.forms import get_now
+
+from ishtar_common import widgets
+
+class FileFormGeneral(forms.Form):
+ form_label = _("General")
+ associated_models = {'in_charge':Person,
+ 'related_file':models.File,
+ 'file_type':models.FileType}
+ file_type = forms.ChoiceField(label=_("File type"), choices=[])
+ year = forms.IntegerField(label=_("Year"),
+ initial=lambda:datetime.datetime.now().year,
+ validators=[validators.MinValueValidator(1900),
+ validators.MaxValueValidator(2100)])
+ creation_date = forms.DateField(label=_(u"Creation date"),
+ initial=get_now, widget=widgets.JQueryDate)
+ reception_date = forms.DateField(label=_(u"Reception date"),
+ initial=get_now, widget=widgets.JQueryDate)
+
+ def __init__(self, *args, **kwargs):
+ super(FileFormGeneral, self).__init__(*args, **kwargs)
+ self.fields['file_type'].choices = models.FileType.get_types()
+ self.fields['file_type'].help_text = models.FileType.get_help()
diff --git a/archaeological_files_pdl/models.py b/archaeological_files_pdl/models.py
new file mode 100644
index 000000000..71a836239
--- /dev/null
+++ b/archaeological_files_pdl/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/archaeological_files_pdl/tests.py b/archaeological_files_pdl/tests.py
new file mode 100644
index 000000000..501deb776
--- /dev/null
+++ b/archaeological_files_pdl/tests.py
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
diff --git a/archaeological_files_pdl/urls.py b/archaeological_files_pdl/urls.py
new file mode 100644
index 000000000..b6878e90b
--- /dev/null
+++ b/archaeological_files_pdl/urls.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2014 É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 *
+
+from archaeological_files_pdl import views
+
+urlpatterns = patterns('',
+ url(r'file_creation/(?P<step>.+)?$',
+ views.file_creation_wizard, name='file_creation'),
+)
diff --git a/archaeological_files_pdl/views.py b/archaeological_files_pdl/views.py
new file mode 100644
index 000000000..7d51c8ec5
--- /dev/null
+++ b/archaeological_files_pdl/views.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2014 É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 archaeological_files.wizards import FileWizard
+from archaeological_operations.wizards import is_preventive, is_not_preventive
+
+from ishtar_common.forms_common import TownFormset
+from archaeological_files_pdl import forms
+from archaeological_files import forms as ref_forms
+from archaeological_operations.forms import ParcelFormSet
+
+from archaeological_files import models
+
+file_creation_wizard = FileWizard.as_view([
+ ('general-file_creation', forms.FileFormGeneral),
+ ('towns-file_creation', TownFormset),
+ ('parcels-file_creation', ParcelFormSet),
+ ('preventive-file_creation', ref_forms.FileFormPreventive),
+ ('research-file_creation', ref_forms.FileFormResearch),
+ ('final-file_creation', ref_forms.FinalForm)],
+ label=_(u"New file"),
+ condition_dict={
+ 'preventive-file_creation':\
+ is_preventive( 'general-file_creation', models.FileType,
+ type_key='file_type'),
+ 'research-file_creation':\
+ is_not_preventive('general-file_creation', models.FileType,
+ type_key='file_type'),
+ },
+ url_name='file_creation',)
diff --git a/example_project/urls.py b/example_project/urls.py
index 1bed62256..e6ea1f37e 100644
--- a/example_project/urls.py
+++ b/example_project/urls.py
@@ -11,7 +11,7 @@ urlpatterns = patterns('',
(r'^accounts/', include('registration.urls')),
)
-APP_LIST = ['archaeological_files', 'archaeological_operations',
+APP_LIST = ['archaeological_files_pdl', 'archaeological_files', 'archaeological_operations',
'archaeological_context_records', 'archaeological_warehouse',
'archaeological_finds']
for app in APP_LIST:
diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html
index 6d295e2c9..3f2f3943e 100644
--- a/ishtar_common/templates/ishtar/wizard/default_wizard.html
+++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html
@@ -40,8 +40,10 @@
{% endif %}
<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
{{ previous_fields|safe }}
-<input type="submit" id="submit_form" name='validate' value="{% trans "Validate" %}"/>
-{% if next_steps %}<input type="submit" id="submit_end_form" name='validate_and_end' value="{% trans "Validate and end" %}"/>{% endif %}
+<div id='validation-bar'>
+ <input type="submit" id="submit_form" name='validate' value="{% trans "Validate" %}"/>
+ {% if next_steps %}<input type="submit" id="submit_end_form" name='validate_and_end' value="{% trans "Validate and end" %}"/>{% endif %}
+</div>
</div>
</form>
{% endblock %}