From c91c8934fb31f9a2207f4a6c0bc5ea0ddae9b6af Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 18 Dec 2014 08:37:01 +0100 Subject: First work for an alternate UI for archaeological files (refs #2175) --- archaeological_files_pdl/forms.py | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 archaeological_files_pdl/forms.py (limited to 'archaeological_files_pdl/forms.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 + +# 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 . + +# 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() -- cgit v1.2.3