Skip to content

Commit

Permalink
Merge pull request #8119 from 4teamwork/amo/TI-1895/user_predefined_f…
Browse files Browse the repository at this point in the history
…ields_teamraum

Add folder_contents listing in the @listing-custom-fields endpoint
  • Loading branch information
Abdu-moustafa authored Feb 3, 2025
2 parents 20c45a9 + 2aed98a commit 740345a
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 9 deletions.
1 change: 1 addition & 0 deletions changes/TI-1895.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add folder_content listing to the @listing-custom-fields endpoint. [amo]
1 change: 1 addition & 0 deletions changes/TI-1895.other
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Exclude the dossier assignment slot from propertysheets for teamraum deployments. [amo]
12 changes: 11 additions & 1 deletion docs/public/dev-manual/api/listings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,17 @@ Endpoints verwendet werden.
"widget": "date"
}
}
}
},
"folder_contents": {
"properties": {
"hasmeetingaccess_custom_field_boolean": {
"name": "hasmeetingaccess_custom_field_boolean",
"title": "can access meetings",
"type": "boolean",
"widget": null
}
}
}
}


Expand Down
1 change: 1 addition & 0 deletions opengever/api/listing_custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
LISTING_TO_SLOTS = {
u'dossiers': get_dossier_assignment_slots,
u'documents': get_document_assignment_slots,
u'folder_contents': get_document_assignment_slots,
}


Expand Down
59 changes: 57 additions & 2 deletions opengever/api/tests/test_listing_custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,54 @@ def test_listing_custom_fields_fixture_slots(self, browser):
u'widget': None
}
}
},
u'folder_contents': {
u'properties': {
u'choose_custom_field_string': {
u'name': u'choose_custom_field_string',
u'title': u'Choose',
u'type': u'string',
u'widget': None
},
u'choosemulti_custom_field_strings': {
u'name': u'choosemulti_custom_field_strings',
u'title': u'Choose multi',
u'type': u'array',
u'widget': None
},
u'date_custom_field_date': {
u'name': u'date_custom_field_date',
u'title': u'Choose a date',
u'type': u'string',
u'widget': u'date'
},
u'f1_custom_field_string': {
u'name': u'f1_custom_field_string',
u'title': u'Field 1',
u'type': u'string',
u'widget': None
},
u'num_custom_field_int': {
u'name': u'num_custom_field_int',
u'title': u'Number',
u'type': u'integer',
u'widget': None
},
u'textline_custom_field_string': {
u'name': u'textline_custom_field_string',
u'title': u'A line of text',
u'type': u'string',
u'widget': None
},
u'yesorno_custom_field_boolean': {
u'name': u'yesorno_custom_field_boolean',
u'title': u'Yes or no',
u'type': u'boolean',
u'widget': None
}
}
}
},
browser.json
}, browser.json
)

@browsing
Expand Down Expand Up @@ -156,6 +201,16 @@ def test_listing_custom_fields_merges_duplicate_slots(self, browser):
u"widget": None
}
}
},
u"folder_contents": {
u"properties": {
u"yesorno_custom_field_boolean": {
u"name": u"yesorno_custom_field_boolean",
u"title": u"Y/N (regulations)",
u"type": u"boolean",
u"widget": None
}
}
}
},
browser.json
Expand Down
6 changes: 4 additions & 2 deletions opengever/propertysheets/assignment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from opengever.propertysheets import _
from opengever.workspace import is_workspace_feature_enabled
from zope.component import getUtility
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory
Expand All @@ -21,8 +22,9 @@ def __call__(self, context):
for term in get_document_assignment_slots_vocab():
assignment_terms.append(term)

for term in get_dossier_assignment_slots_vocab():
assignment_terms.append(term)
if not is_workspace_feature_enabled():
for term in get_dossier_assignment_slots_vocab():
assignment_terms.append(term)

return SimpleVocabulary(assignment_terms)

Expand Down
9 changes: 5 additions & 4 deletions opengever/propertysheets/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from opengever.propertysheets.default_from_member import attach_member_property_default_factory
from opengever.propertysheets.exceptions import InvalidFieldType
from opengever.propertysheets.exceptions import InvalidFieldTypeDefinition
from opengever.propertysheets.exceptions import InvalidSchemaAssignment
from opengever.propertysheets.helpers import add_current_value_to_allowed_terms
from opengever.propertysheets.helpers import is_choice_field
from opengever.propertysheets.helpers import is_multiple_choice_field
Expand Down Expand Up @@ -198,9 +197,11 @@ def assignments(self, values):
term = assignment_slots.getTermByToken(token)
assignments.append(term.value)
except LookupError:
raise InvalidSchemaAssignment(
"The assignment '{}' is invalid.".format(token)
)
# Missing slots should be ignored without raising an error.
# This allows custom properties to remain usable even if the corresponding slots no longer exist.
# Currently, this mainly occurs during testing or local development
# when switching between Gever and Teamraum.
continue

self._assignments = tuple(assignments)

Expand Down
31 changes: 31 additions & 0 deletions opengever/propertysheets/tests/test_propertysheet_metaschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,34 @@ def test_field_descriptions_are_translated(self, browser):
],
[prop['description'] for prop in field_properties.values()]
)


class TestWorkSpacePropertysheetMetaschemaEndpoint(IntegrationTestCase):
features = ('workspace',)

@browsing
def test_assignment_vocabularies_excluded_dossier_type(self, browser):
self.login(self.propertysheets_manager, browser)

headers = self.api_headers.copy()
headers.update({'Accept-Language': 'de-ch'})

browser.open(
view="@propertysheet-metaschema",
headers=headers,
)

properties = browser.json['properties']
self.assertEqual(
[
u'Dokument',
u'Dokument (Typ: Anfrage)',
u'Dokument (Typ: Antrag)',
u'Dokument (Typ: Bericht)',
u'Dokument (Typ: Offerte)',
u'Dokument (Typ: Protokoll)',
u'Dokument (Typ: Reglement)',
u'Dokument (Typ: Vertrag)',
u'Dokument (Typ: Weisung)',
],
properties['assignments']['items']['enumNames'])

0 comments on commit 740345a

Please sign in to comment.