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

Accommodate Typed Relation Display name Fields #810

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rosiel
Copy link
Contributor

@rosiel rosiel commented Aug 8, 2024

Link to Github issue or other discussion

For my new module, Typed Relation with Display name, we need to alter Workbench to allow it to do what's needed to populate and export these new fields.

What does this PR do?

Adds support for Typed Relation field

What changes were made?

Duplicate existing class for TypedRelationField
Duplicate existing function for splitting the field value
Duplicate all invocations that test whether the field is a typed relation field.

Just to note that Workbench fails silently (no logs, no errors, just doesn't write to the field) if the field type is not recognized. While there is documentation for what fields are supported (will need to be updated?) I'm not sure if failing silently is the best option here? Open to discussion, just wanted to mention this.

How to test / verify this PR?

  • Install Typed Relation Display Name module
  • add a Typed Relation Display Name field to Repository Item
  • create a CSV with values such as: (first three equivalent to Typed Relation, since display name is optional)
    • "relators:aut:119"
    • "relators:aut:Rosie Le Faive"
    • "relators:aut:person:Rosie Le Faive"
    • "relators:aut:119~Le Faive, R.A."
    • "relators:aut:Rosie Le Faive~Le Faive, R.A."
    • "relators:aut:person:Rosie Le Faive~Le Faive, R.A."

Interested Parties

@mjordan_


Checklist

  • Before opening this PR, have you opened an issue explaining what you want to to do?
  • Have you included some configuration and/or CSV files useful for testing this PR?
  • Have you written unit or integration tests if applicable?
  • Does the code added in this PR require a version of Python that is higher than the current minimum version?
  • If the changes in this PR require an additional Python library, have you included it in setup.py?
  • If the changes in this PR add a new configuration option, have you provided a default for when the option is not present in the .yml file?

@rosiel
Copy link
Contributor Author

rosiel commented Aug 8, 2024

No tests yet, this is a proof of concept.

target_type = "taxonomy_term"
field_vocabs = get_field_vocabularies(config, field_definitions, field_name)
field_values = []
subvalues = split_typed_relation_display_name_string(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to make this class as short as possible as it inherits from TypedRelationField. This Class could be much shorter if we made the "split into subvalues" function a parameter of the class. In the create() and update() functions, the ONLY difference is using my custom "split_typed_relation_display_name_string" function.

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

Successfully merging this pull request may close these issues.

1 participant