diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-02-02 22:30:40 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-02-02 22:30:40 +0100 |
commit | b2461dbc86d2df117873dab712efd64671a857d6 (patch) | |
tree | 7d5f888ce6a43a7c2ce9f18ca4e0afd03e783a3a /archaeological_operations/forms.py | |
parent | 056c35c776c2ae6f2d9add152731d1e7a94164f4 (diff) | |
download | Ishtar-b2461dbc86d2df117873dab712efd64671a857d6.tar.bz2 Ishtar-b2461dbc86d2df117873dab712efd64671a857d6.zip |
Add remains and periods to archaeological sites (refs #2251)
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r-- | archaeological_operations/forms.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index f411b20d0..0a8f9d94d 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2015 É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 @@ -644,12 +644,22 @@ PeriodFormset.form_label = _("Periods") class ArchaeologicalSiteForm(forms.Form): reference = forms.CharField(label=_(u"Reference"), max_length=20) name = forms.CharField(label=_(u"Name"), max_length=200, required=False) + periods = forms.MultipleChoiceField(label=_("Periods"), + choices=[], widget=forms.CheckboxSelectMultiple) + remains = forms.MultipleChoiceField(label=_("Remains"), + choices=[], widget=forms.CheckboxSelectMultiple) def __init__(self, *args, **kwargs): self.limits = {} if 'limits' in kwargs: limits = kwargs.pop('limits') super(ArchaeologicalSiteForm, self).__init__(*args, **kwargs) + self.fields['periods'].choices = \ + models.Period.get_types(empty_first=False) + self.fields['periods'].help_text = models.Period.get_help() + self.fields['remains'].choices = \ + models.RemainType.get_types(empty_first=False) + self.fields['remains'].help_text = models.RemainType.get_help() def clean_reference(self): reference = self.cleaned_data['reference'] @@ -661,7 +671,14 @@ class ArchaeologicalSiteForm(forms.Form): def save(self, user): dct = self.cleaned_data dct['history_modifier'] = user - return models.ArchaeologicalSite.objects.create(**dct) + periods = dct.pop('periods') + remains = dct.pop('remains') + item = models.ArchaeologicalSite.objects.create(**dct) + for period in periods: + item.periods.add(period) + for remain in remains: + item.remains.add(remain) + return item class ArchaeologicalSiteSelectionForm(forms.Form): form_label = _("Associated archaelogical sites") |