Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the widget attached to the contenttype fields generic #155

Open
algomaster99 opened this issue May 13, 2021 · 1 comment
Open

Make the widget attached to the contenttype fields generic #155

algomaster99 opened this issue May 13, 2021 · 1 comment
Labels
challenge Should pose considerable difficulty

Comments

@algomaster99
Copy link
Member

Is your feature request related to a problem? Please describe.
A long standing issue in Django had a direct consequence on our project. Contenttype fields, entity_content_type and entity_object_id, (default names suggested by the Django framework) did not have a good widget attached to them so one had to manually query the database to find the instance ID in order to populate the fields.

In 2019, a PR was submitted and merged which added a workaround to select entity_content_type using a dropdown list and the entity_object_id from a popup window. Being a workaround, it also brought some limitations with it.

  1. Under-the-hood JavaScript written to render the popup window only gets triggered when the fields are named entity_content_type and entity_object_id. This posed problems in apps like noticeboard where the field names are different - persona_content_type.
  2. The code is not reusable which undermines the philosophy of Omniport.

Describe the solution you'd like
To convert this workaround into a concrete solution, I suggest making a Django Widget or a model field in a different repository (let's keep it under @IMGIITRoorkee only). Further, we can publish the package to PyPI. Eventually, solving both of the problems listed above.

The widget or the model field should add the following functionality:

  1. Convert the entity_content_type (the name can by anything) field from a text field to dropdown list.
  2. Clicking an option in the list should trigger a pop-up which would contain all instances of the selected model in contenttype.
  3. The instances in the pop-up window should be paginated so that the request doesn't timeout.
  4. It should also have a search functionality so that the maintainers do not spend too much time finding the instance they are looking for.
  5. Support for adding custom styles to the widget. Not a priority at all.
  6. Upon clicking an instance, the pop-up should close and write its primary key to the entity_object_id (again, name can be anything) field.

There can be more features or the implementation might be different but that is subjected to the discussion under this ticket.

Additional context
PRs related to the previous work on this.

  1. [WIP] Enable selection of contenttype object omniport-backend-formula-one#3
  2. Trigger a popup when a ContentType is selected omniport-backend-formula-one#5
  3. Trigger function to populate contenttype objects in concerned forms #81

Want to take up?
Definitely up for reviewing or answering more questions.

@algomaster99 algomaster99 added the challenge Should pose considerable difficulty label May 13, 2021
@algomaster99
Copy link
Member Author

@pradumangoyal told me about an existing package which does this. However, while skimming through the codebase, I could not find functionality for pagination or search. But I may be wrong and in that case, feel free to close the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge Should pose considerable difficulty
Projects
None yet
Development

No branches or pull requests

1 participant