diff options
-rw-r--r-- | ishtar/furnitures/admin.py | 3 | ||||
-rw-r--r-- | ishtar/furnitures/forms.py | 17 | ||||
-rw-r--r-- | ishtar/furnitures/models.py | 23 |
3 files changed, 40 insertions, 3 deletions
diff --git a/ishtar/furnitures/admin.py b/ishtar/furnitures/admin.py index 3a5b980d8..8a47ea429 100644 --- a/ishtar/furnitures/admin.py +++ b/ishtar/furnitures/admin.py @@ -201,7 +201,8 @@ basic_models = [models.PersonType, models.IshtarUser, models.FileType, models.SourceType, models.MaterialType, models.ParcelOwner, models.WarehouseType, models.ActType, models.AuthorType, models.OrganizationType, models.TreatmentType, - models.RemainType, models.PermitType, models.Unit] + models.RemainType, models.PermitType, models.Unit, + models.ActivityType, models.IdentificationType] if settings.COUNTRY == 'fr': basic_models += [models.Arrondissement, models.Canton, models.SaisineType] diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index bf01fb501..0f93a94bc 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -381,9 +381,10 @@ class Wizard(NamedUrlSessionFormWizard): m2m_items[key] = getattr(obj, key+'s').all() if value not in m2m_items[key]: if type(value) == dict: - if issubclass(obj.__class__, models.BaseHistorizedItem): + model = getattr(obj, key+'s').model + if issubclass(model, models.BaseHistorizedItem): value['history_modifier'] = request.user - value = getattr(obj, key+'s').model.objects.create(**value) + value = model.objects.create(**value) value.save() getattr(obj, key+'s').add(value) obj.save() @@ -1921,12 +1922,18 @@ DatingFormSet.form_label = _("Dating") class RecordFormInterpretation(forms.Form): form_label = _("Interpretation") + associated_models = {'activity':models.ActivityType, + 'identification':models.IdentificationType,} has_furniture = forms.NullBooleanField(label=_(u"Has furniture?"), required=False) filling = forms.CharField(label=_(u"Filling"), widget=forms.Textarea, required=False) interpretation = forms.CharField(label=_(u"Interpretation"), widget=forms.Textarea, required=False) + activity = forms.ChoiceField(label=_("Activity"), required=False, + choices=[]) + identification = forms.ChoiceField(label=_("Identification"), + required=False, choices=[]) taq = forms.IntegerField(label=_(u"TAQ"), required=False) taq_estimated = forms.IntegerField(label=_(u"Estimated TAQ"), required=False) @@ -1934,6 +1941,12 @@ class RecordFormInterpretation(forms.Form): tpq_estimated = forms.IntegerField(label=_(u"Estimated TPQ"), required=False) + def __init__(self, *args, **kwargs): + super(RecordFormInterpretation, self).__init__(*args, **kwargs) + self.fields['activity'].choices = models.ActivityType.get_types() + self.fields['identification'].choices = \ + models.IdentificationType.get_types() + record_search_wizard = SearchWizard([ ('general-record_search', RecordFormSelection)], url_name='record_search',) diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index f9e9080df..44e0e9391 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -681,6 +681,25 @@ class Unit(GeneralType): def __unicode__(self): return self.label +class ActivityType(GeneralType): + order = models.IntegerField(_(u"Order")) + + class Meta: + verbose_name = _(u"Type Activity") + verbose_name_plural = _(u"Types Activity") + + def __unicode__(self): + return self.label + +class IdentificationType(GeneralType): + order = models.IntegerField(_(u"Order")) + class Meta: + verbose_name = _(u"Type Identification") + verbose_name_plural = _(u"Types Identification") + + def __unicode__(self): + return self.label + class ContextRecord(BaseHistorizedItem, OwnPerms): TABLE_COLS = ['parcel.town', 'parcel.operation.year', 'parcel.operation.operation_code', @@ -716,6 +735,10 @@ class ContextRecord(BaseHistorizedItem, OwnPerms): " created before this date")) tpq_estimated = models.IntegerField(_(u"Estimated TPQ"), blank=True, null=True, help_text=_("Estimation of a \"Terminus Post Quem\"")) + identification = models.ForeignKey(IdentificationType, blank=True, + null=True, verbose_name=_(u"Identification"),) + activity = models.ForeignKey(ActivityType,blank=True, null=True, + verbose_name=_(u"Activity"),) history = HistoricalRecords() class Meta: |