Skip to main content

Summary

This cube provides a generic but ergonomic widget to link an edited entity to several others for a given relation. It provides:

  • a list of checkbox-(de-)selectable related entities

  • a mecanism to trigger the display of a pop-up window for each possible target entity type of the relation

  • in the pop-up window, the end-user can:

    • search (using facets) entities to be linked to the edited entity,

    • display (in a paginated table) and select them (using a checkbox on each table line)

    • create a new entity to be linked (can be desactivated)

Usage

Select the relation widget for your relation

You can use the two following mecanisms to configure the user interface:

  • either cubicweb.web.uihelper.FormConfig:

    from cubicweb.web import uihelper
    from cubes.relationwidget.views import RelationFacetWidget
    
    class MyEntityConfig(uihelper.FormConfig):
          etype = 'MyEntity'
          # Move `my_relation` into the attribute section:
          rels_as_attrs = ('my_relation', )
          # Edit `my_relation` using RelationFacetWidget:
          widgets = dict(
              my_relation=RelationFacetWidget,
          )
  • or directly via uicfg.autoform_field_kwarg:

    from cubicweb.web.views import uicfg
    from cubes.relationwidget.views import RelationFacetWidget
    
    # edit the relation as attribute.
    uicfg.autoform_section.tag_subject_of(
        ('MyEntity', 'my_relation', '*'),
        formtype=('main', 'muledit'), section='attributes')
    
    # add the RelationFacetWidget for `my_relation`
    uicfg.autoform_field_kwargs.tag_subject_of(
        ('MyEntity', 'my_relation', '*'), {'widget': RelationFacetWidget})

Configure it (optional)

If you want to desactivate the ability to create a new entity to be linked to the edited one, you can do it:

  • for a single relation using uicfg again:

    uicfg.autoform_field_kwargs.tag_subject_of(
    ('MyEntity', 'my_relation', '*'),
    {'widget': RelationFacetWidget(no_creation_form=True)})
  • application-wide by overriding SearchForRelatedEntitiesView.has_creation_form to always return False:

    from cubes.relationwidget.view import SearchForRelatedEntitiesView
    
    class MySearchForRelatedEntitiesView(SearchForRelatedEntitiesView):
    
        @property
        def has_creation_from(self):
            return False
    
    def registration_callback(vreg):
        vreg.register_and_register(MySearchForRelatedEntitiesView,
                                   SearchForRelatedEntitiesView)

There is also a dialog_options dictionary that can be used to configure the bootstrap modal window (see http://getbootstrap.com/javascript/#modals-options):

uicfg.autoform_field_kwargs.tag_subject_of(
('MyEntity', 'my_relation', '*'),
{'widget': RelationFacetWidget(dialog_options={'keyboard': False})})

Metadata

Release files for cubicweb-relationwidget 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cubicweb-relationwidget 0.10.0
File Size Uploaded Provenance Actions
cubicweb-relationwidget-0.10.0.tar.gz 20.5 kB Without provenance Details for cubicweb-relationwidget-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cubicweb-relationwidget 0.10.0
File Interpreter ABI Platform Actions
cubicweb_relationwidget-0.10.0-py3-none-any.whl Python 3 none any Details for cubicweb_relationwidget-0.10.0-py3-none-any.whl

Total release size: 39.9 kB

Release files / cubicweb-relationwidget-0.10.0.tar.gz

Download URL cubicweb-relationwidget-0.10.0.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9f30abcc42d1537eb360cbc20956d6a68b69ff82505ce0d033e0fccfd11557a7
BLAKE2b-256 checksum
How to use checksums
b0cec0c0476b2670e4f78018253ac87631a67729ab739d4000ef487218d22012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / cubicweb_relationwidget-0.10.0-py3-none-any.whl

Download URL cubicweb_relationwidget-0.10.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a582903af208459b69355ea29750b3148a6fe62ae34ceeb5775f0363176b9776
BLAKE2b-256 checksum
How to use checksums
8ede791768ede9a84daba9dd3cefcd3e1cec620b79a1a01966240abae0bcff2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Security for cubicweb-relationwidget 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page