Bug 38762 - syntax<->frontend behavior is not flexible enough
syntax<->frontend behavior is not flexible enough
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Domain management (Generic)
UCS 5.0
Other Linux
: P5 normal with 9 votes (vote)
: UCS 5.0-1-errata
Assigned To: Florian Best
Dirk Wiesenthal
https://git.knut.univention.de/univen...
:
: 29868 34313 54644 (view as bug list)
Depends on:
Blocks: 53843 54467 54840
  Show dependency treegraph
 
Reported: 2015-06-24 16:00 CEST by Florian Best
Modified: 2022-06-08 17:47 CEST (History)
5 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Cleanup
Max CVSS v3 score:


Attachments
53843_compare.py (4.46 KB, text/x-python)
2022-04-20 00:06 CEST, Florian Best
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2015-06-24 16:00:46 CEST
Instead of:
163 »   if inspect.isclass(syntax) and issubclass(syntax, (udm_syntax.UDM_Objects, udm_syntax.UDM_Attribute)):
170 »   elif isinstance(syntax, (udm_syntax.ldapDnOrNone, udm_syntax.ldapDn)) or inspect.isclass(syntax) and issubclass(syntax, (udm_syntax.ldapDnOrNone, udm_syntax.ldapDn)):
172 »   elif isinstance(syntax, udm_syntax.LDAP_Search):
175 »   elif inspect.isclass(syntax) and issubclass(syntax, udm_syntax.select):
181 »   if getattr(syntax, 'depends', None) is not None:
…(and a lot more at various places)…

we need to be more flexible in the specific syntax classes.
I would suggest to move these code blocks into new methods of the syntax classes:

def get_choices(self);
def get_widget(self);

The current way works for our cases but not for customer adaptions. I had to write specific javascript code because of this lacking functionality.
Comment 1 Florian Best univentionstaff 2017-02-09 14:07:48 CET
*** Bug 29868 has been marked as a duplicate of this bug. ***
Comment 2 Florian Best univentionstaff 2017-04-24 16:52:28 CEST
*** Bug 34313 has been marked as a duplicate of this bug. ***
Comment 3 Florian Best univentionstaff 2019-09-10 18:59:23 CEST
A basis for this has been implemented in Bug #50047, which introduces a type-interface, which should be extended.
Comment 4 Florian Best univentionstaff 2022-04-20 00:06:45 CEST
Created attachment 10939 [details]
53843_compare.py

QA: attached is a script which compares the previous with the new values of all syntax classes.
Comment 5 Florian Best univentionstaff 2022-04-20 16:39:17 CEST
A short overview about the current functions:

widget():
→ defines type and options (given as parameters) for the widget
→ only used in `udm/properties` (and self-service)

choices():
→ only adds additional information for `widget()` and is named wrong.
→ real choices are retrieved via `read_syntax_choices()`

info_syntax_choices():
→ used by `udm/syntax/choices/info`
→ checks if the size limit when getting choices is reached. If yes, the 
  UDM frontend shows different widgets (no ComboBox) and performs a restricted search.
→ happens only for subclasses of `UDM_Objects`. So the request is only triggered by that syntax class.
→ This is a bad workaround we should drop in the future and replace with
  some intelligent mechanism (LDAP pagination, ...).

read_syntax_choices():
→ returns all dynamic choices of the specified syntax
→ is used directly by `udm/syntax/choices`

→ also used by `get_default_values()` via `udm/values` if the syntax wants it

→ also used by `udm/properties` to set a default value for syntaxes which wants a non-empty default value (so the first value of the choices is selected)

→ also used by `get_policy_references()` with a `LDAP_Search` instance to get all policy backreferences
  → via `udm/get` as `$references$` to list all objects/policies which reference this object (via a `LinkList` widget).
  → via UDM REST API to add dynamic reference information to all kind of objects and link between them via certain relations

→ also used by `search_syntax_choices_by_key()` (see below)

search_syntax_choices_by_key():
→ used by `udm/syntax/choices/key`: if size limit is reached for a widget with choices (e.g. ComboBox) returns only the currently set value so that the Javascript widget shows that value as valid.
→ better approach would be to do this via Javascript only
Comment 6 Florian Best univentionstaff 2022-04-20 18:40:31 CEST
The UDM syntax classes have been extended by:

>    @classmethod
>    def get_widget(cls, prop):
→ returning the widget as string, depending on the property

>    def get_widget_options(self, udm_property):
including:
>       def get_widget_choices_options(self, udm_property):
→ returning the type and initialization options for that widget

>    @classmethod
>    def get_choices(cls, lo, options):
→ returning a sorted list of (value, label) tuples of possible choices for this syntax class

>    @classmethod
>    def get_object_property_filter(cls, object_property, object_property_value, allow_asterisks=True):
→ get a LDAP filter suitable for searching for the specified property and value.

>     widget_default_search_pattern = '*'
→ the search pattern which is used by default

>     def parse_command_line(self, value):
→ further string manipulation of arguments passed via CLI.


univention-self-service.yaml
a7412dcaf781 | YAML Bug #38762

univention-self-service (5.0.1-25)
26ad44d94747 | Bug #38762: debian/changelog
57c23f66218b | Bug #38762: move widget() definition/options into UDM syntax classes

univention-management-console-module-udm.yaml
a7412dcaf781 | YAML Bug #38762

univention-management-console-module-udm (10.0.1-25)
26ad44d94747 | Bug #38762: debian/changelog
0f03da8f44b3 | Bug #38762: also search for non-substring values when searching for non specific property
ed1d263e87e9 | Bug #38762: move LDAP filter escaping into syntax classes
559ba27d5ab4 | Bug #38762: move get_object_property_filter() into UDM syntax classes
57c23f66218b | Bug #38762: move widget() definition/options into UDM syntax classes
02618757042e | Bug #38762: replace LDAP_Search of policy references syntax with raw LDAP search
9b1927d95ab4 | Bug #38762: improove performance by getting object directly
d283eac48af4 | Bug #38762: move get_choices() into UDM syntax classes
2e32067b5d37 | Bug #38762: unify common widget options into default_syntax_definition()
13f5e4bf118a | Bug #38762: move UCR variable definitions into other package
3bfb1b2d2edd | Bug #38762: move widget<>syntax mapping into UDM syntax classes

univention-directory-manager-rest.yaml
a7412dcaf781 | YAML Bug #38762

univention-directory-manager-rest (10.0.2-11)
26ad44d94747 | Bug #38762: debian/changelog
559ba27d5ab4 | Bug #38762: move get_object_property_filter() into UDM syntax classes
d283eac48af4 | Bug #38762: move get_choices() into UDM syntax classes

univention-directory-manager-modules.yaml
a7412dcaf781 | YAML Bug #38762

univention-directory-manager-modules (15.0.11-43)
26ad44d94747 | Bug #38762: debian/changelog
a601f5b048fa | Bug #38762: move sorting into common method sort_choices()
f97c09773606 | Bug #38762: move special code for select, MultiSelect and SambaLogonHours into Isyntax.get_widget_choices_options()
dd9ac1745eb1 | Bug #38762: move parse_command_line() handling into UDM syntax class
42c76995c60f | Bug #38762: move _parse_complex_syntax_input() into UDM syntax class
ed1d263e87e9 | Bug #38762: move LDAP filter escaping into syntax classes
5e00baebfc96 | Bug #38762: adjust sizes of extended attribute checkboxes
559ba27d5ab4 | Bug #38762: move get_object_property_filter() into UDM syntax classes
57c23f66218b | Bug #38762: move widget() definition/options into UDM syntax classes
3c6d8402e0e8 | Bug #38762: LDAP_Search: transform instances into classes
d283eac48af4 | Bug #38762: move get_choices() into UDM syntax classes
13f5e4bf118a | Bug #38762: move UCR variable definitions into other package
85e1fbe70fdc | Bug #38762: simplify widget assignment on inheritance
3bfb1b2d2edd | Bug #38762: move widget<>syntax mapping into UDM syntax classes
850802aedc0d | Bug #38762: replace deprecated LDAP_Search syntax with UDM_Attribute
8337fe524d92 | Bug #38762: replace deprecated MailDomain LDAP_Search syntax with UDM_Attribute
bde21b2a5e16 | Bug #38762: remove unused module_search_filter
Comment 9 Florian Best univentionstaff 2022-04-21 19:24:14 CEST
Tests green except for:
* 86_selenium.150_udm_create_modify_delete_objects.master091
* 60_umc.80_udm_license.master091

https://univention-dist-jenkins.k8s.knut.univention.de/job/UCS-5.0/job/UCS-5.0-1/job/AutotestJoin/35/testReport/

I'll look into them closely.
Comment 10 Florian Best univentionstaff 2022-04-21 21:12:33 CEST
(In reply to Florian Best from comment #9)
> Tests green except for:
> * 86_selenium.150_udm_create_modify_delete_objects.master091
This was caused by a broken LDAP filter, which has been fixed by:

6b009e669a fixup! Bug #38762: move get_object_property_filter() into UDM syntax classes

> * 60_umc.80_udm_license.master091
The LDAP-Server has been down during license import. I guess this was just flakyness.

I also added a commit which added the "lookup_filter" to various UDM modules lacking this nice functionality.

7a2371fc16 Bug #38762: add missing lookup_filter definition for various UDM modules
Comment 11 Florian Best univentionstaff 2022-04-22 01:31:12 CEST
Another related change has been added:
The widget which is displayed a search-box is now also configurable via the syntax classes and the default value for the widget as well:

> syntax.search_widget = 'TextBox'
> syntax.widget_default_search_pattern = '*'

I originally planned to merge this at Bug #54467 but it better fits here.


commit 2696e248f2fdd44b6cf7595bf6dd0207ed6bb05a
Author: Florian Best <best@univention.de>
Date:   Fri Feb 18 20:45:28 2022 +0100

    Bug #38762: move search widget and its default value into UDM syntax classes
    
    * get rid of udm/values: it is either not required as we can put the
      same information into "udm/properties" and the request delivers the
      same meta information as udm/syntax/choices.
    * adapt MixedInput so that is capable of every widget not only TextBox, ComboBox and CheckBox.
    
    This change allows e.g. to render date syntaxes as DateBox instead of a
    simple TextBox:
    
    diff --git management/univention-directory-manager-modules/modules/univention/admin/syntax.py management/univention-directory-manager-modules/modules/univention/admin/syntax.py
    index 55cb738396..86ce0f367a 100644
    --- management/univention-directory-manager-modules/modules/univention/admin/syntax.py
    +++ management/univention-directory-manager-modules/modules/univention/admin/syntax.py
    @@ -2717,6 +2717,7 @@ class iso8601Date(simple):
            error_message = _('The given date does not conform to iso8601, example: "2009-01-01".')
    
            widget = 'DateBox'
    +       search_widget = 'DateBox'
            widget_default_search_pattern = '1970-01-01'
    
            type_class = univention.admin.types.DateType
    @@ -2793,6 +2794,7 @@ class date(simple):
            _re_de = re.compile(r'^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]+$')
    
            widget = 'DateBox'
    +       search_widget = 'DateBox'
            widget_default_search_pattern = '1970-01-01'
    
            type_class = univention.admin.types.DateType


univention-management-console-module-udm (10.0.1-26)
2696e248f2fd | Bug #38762: move search widget and its default value into UDM syntax classes

univention-directory-manager-modules (15.0.11-44)
2696e248f2fd | Bug #38762: move search widget and its default value into UDM syntax classes

univention-web.yaml
361ee9fae143 | YAML Bug #38762

univention-web (4.0.2-50)
2696e248f2fd | Bug #38762: move search widget and its default value into UDM syntax classes

univention-directory-manager-rest (10.0.2-11)
3c0ebed1ba78 | Bug #38762: remove unused misleading DefaultValue endpoint
Comment 12 Florian Best univentionstaff 2022-04-22 11:47:33 CEST
*** Bug 54644 has been marked as a duplicate of this bug. ***
Comment 13 Florian Best univentionstaff 2022-05-30 18:40:58 CEST
Two additional fixes have been added:

1. MultiObjectSelect filtering for properties did not work
2. LDAP filter escaping is done for every value, even python string interpolated ones.

univention-management-console-module-udm (10.0.1-26)
fd835042be5e | fixup! Bug #38762: add additional handling for MultiObjectSelect
802fceb7d1f5 | Bug #38762: add additional handling for MultiObjectSelect

univention-directory-manager-modules (15.0.11-49)
5f3bda89c63f | Bug #38762: escape string interpolated LDAP filters
fd835042be5e | fixup! Bug #38762: add additional handling for MultiObjectSelect
Comment 14 Dirk Wiesenthal univentionstaff 2022-06-08 13:03:07 CEST
YAML: OK
Code review: OK
Test for regressions: OK, none found