diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/forms_common.py | 62 | ||||
| -rw-r--r-- | ishtar_common/models.py | 7 | 
2 files changed, 67 insertions, 2 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index e2597175b..872571aad 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -1915,7 +1915,9 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):          "source_type": models.SourceType,          "support_type": models.SupportType,          "publisher": models.Organization, +        "rights_owner": models.Organization,          "format_type": models.Format, +        "shooting_angle": models.ShootingAngle,      }      pk = forms.IntegerField(label="", required=False, widget=forms.HiddenInput) @@ -1934,6 +1936,9 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):          model=models.Format, label=_("Format"), choices=[], required=False      )      scale = forms.CharField(label=_("Scale"), max_length=30, required=False) +    shooting_angle = widgets.ModelChoiceField( +        model=models.ShootingAngle, label=_("Shooting angle"), choices=[], required=False +    )      container_id = forms.IntegerField(          label=_("Current container"),          widget=widgets.JQueryAutoComplete( @@ -1988,6 +1993,19 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):      licenses = widgets.Select2MultipleField(          label=_("Rights of use / licenses"), required=False, model=models.LicenseType      ) +    rights_owner = forms.IntegerField( +        label=_("Rights owner"), +        widget=widgets.JQueryAutoComplete( +            reverse_lazy("autocomplete-organization"), +            associated_model=models.Organization, +            new=True, +            ), +        validators=[models.valid_id(models.Organization)], +        required=False, +    ) +    copyright = forms.CharField( +        label=_("Copyright"), widget=forms.Textarea, required=False +    )      tags = widgets.Select2MultipleField(          label=_("Tags"),          required=False, @@ -2076,6 +2094,7 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):      TYPES = [          FieldType("source_type", models.SourceType),          FieldType("support_type", models.SupportType), +        FieldType("shooting_angle", models.ShootingAngle),          FieldType("format_type", models.Format),          FieldType("language", models.Language),          FieldType("licences", models.LicenseType, is_multiple=True), @@ -2092,6 +2111,7 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):              "format_type",              "support_type",              "scale", +            "shooting_angle",              "image",              "associated_file",              "associated_url", @@ -2102,10 +2122,12 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):              "creation_date",              "publisher",              "publishing_year", -            "language",              "isbn",              "issn",              "licenses", +            "rights_owner", +            "copyright", +            "language",              "source",              "source_free_input",              "source_page_range", @@ -2133,6 +2155,7 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):          # field name, permission, options          ("tags", ("ishtar_common.add_documenttag",), {"new": True}),          ("authors", ("ishtar_common.add_author",), {"new": True}), +        ("rights_owner", ("ishtar_common.add_organization",), {"new": True}),          ("publisher", ("ishtar_common.add_organization",), {"new": True}),          ("container", ("archaeological_warehouse.add_container",), {"new": True}),          ("container_ref", ("archaeological_warehouse.add_container",), {"new": True}), @@ -2281,6 +2304,14 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):          except models.Organization.DoesNotExist:              return +    def clean_rights_owner(self): +        if not self.cleaned_data.get("rights_owner", None): +            return +        try: +            return models.Organization.objects.get(pk=self.cleaned_data["rights_owner"]) +        except models.Organization.DoesNotExist: +            return +      def save(self, commit=True):          if not self.cleaned_data.get("authors", None):              self.cleaned_data["authors"] = [] @@ -2368,6 +2399,15 @@ class DocumentSelect(HistorySelect):      isbn = forms.CharField(label=_("ISBN"))      issn = forms.CharField(label=_("ISSN"))      licenses = forms.ChoiceField(label=_("Rights of use / licenses"), choices=[]) +    rights_owner = forms.IntegerField( +        label=_("Rights owner"), +        widget=widgets.JQueryAutoComplete( +            reverse_lazy("autocomplete-organization"), +            associated_model=models.Organization, +        ), +        validators=[models.valid_id(models.Organization)], +    ) +    copyright = forms.CharField(label=_("Copyright"))      comment = forms.CharField(label=_("Comment"))      additional_information = forms.CharField(label=_("Additional informations")) @@ -2521,17 +2561,22 @@ class DocumentFormMultiSelection(LockForm, MultiSearchForm):  class QADocumentFormMulti(QAForm):      form_admin_name = _("Document - Quick action - Modify")      form_slug = "document-quickaction-modify" -    base_models = ["qa_source_type"] +    base_models = ["qa_source_type", "qa_rights_owner"]      associated_models = {          "qa_source_type": models.SourceType,          "qa_authors": models.Author,          "qa_tags": models.DocumentTag, +        "qa_rights_owner": models.Organization, +        "qa_licenses": models.LicenseType,      }      MULTI = True      REPLACE_FIELDS = [          "qa_source_type",          "qa_creation_date", +        "qa_rights_owner", +        "qa_licenses", +        "qa_copyright",      ]      qa_source_type = forms.ChoiceField(label=_("Source type"), required=False)      qa_authors = widgets.ModelJQueryAutocompleteField( @@ -2544,11 +2589,17 @@ class QADocumentFormMulti(QAForm):      qa_support_type = forms.ChoiceField(label=_("Medium"), choices=[], required=False)      qa_scale = forms.CharField(label=_("Scale"), max_length=30, required=False)      qa_tags = forms.ChoiceField(label=_("Tags"), choices=[], required=False) +    qa_licenses = forms.ChoiceField(label=_("Rights of use / licenses"), choices=[], required=False) +    qa_rights_owner = widgets.ModelJQueryAutocompleteField( +        model=models.Organization, label=_("Rights owner"), new=True, required=False +    ) +    qa_copyright = forms.CharField(label=_("Copyright"), required=False)      TYPES = [          FieldType("qa_source_type", models.SourceType),          FieldType("qa_format_type", models.Format),          FieldType("qa_support_type", models.SupportType), +        FieldType("qa_licenses", models.LicenseType),          FieldType("qa_tags", models.DocumentTag),      ] @@ -2559,6 +2610,13 @@ class QADocumentFormMulti(QAForm):              return ""          return value +    def _get_qa_rights_owner(self, value): +        try: +            value = models.Organization.objects.get(pk=value).cached_label +        except models.Organization.DoesNotExist: +            return "" +        return value +  class QADocumentDuplicateForm(IshtarForm):      qa_title = forms.CharField(label=_("Title"), max_length=500, required=False) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index bd457e970..aa7fda851 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -4210,6 +4210,13 @@ class Document(              pgettext_lazy("key for text search", "license"),              "licenses__label__iexact",          ), +        "rights_owner": SearchAltName( +            pgettext_lazy("key for text search", "rights-owner"), +            "rights_owner__name__iexact", +        ), +        "copyright": SearchAltName( +            pgettext_lazy("key for text search", "copyright"), "copyright__iexact" +        ),          "scale": SearchAltName(              pgettext_lazy("key for text search", "scale"), "scale__iexact"          ),  | 
