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

Load Specify 7 specific tables into datamodel #2835

Closed
melton-jason opened this issue Jan 17, 2023 · 1 comment
Closed

Load Specify 7 specific tables into datamodel #2835

melton-jason opened this issue Jan 17, 2023 · 1 comment
Labels
1 - Request Improvements or extensions to existing behavior res:duplicate Duplicate of an existing issue

Comments

@melton-jason
Copy link
Contributor

Add a block for

  • spdataset

For more context, this is regarding adding a deletion blocker to SpecifyUser. This operation is not currently supported with how I extended deletion blockers, but I will add a way to support adding reverse relationships so this can be added.

Spatasets will more complicated than any other table(s) to work with on the backend. Many of Specify's internal helper functions rely on the datamodel being loaded when Specify starts up (this happens in load_datamodel.py). The issue is that to get the list of tables and fields in the database, Specify 7 reads the specify_datamodel.xml in the Specify 6 config directory (as seen below), and as far as I know the spdataset table is not included within that file.

def load_datamodel() -> Datamodel:
datamodeldef = ElementTree.parse(os.path.join(settings.SPECIFY_CONFIG_DIR, 'specify_datamodel.xml'))
datamodel = Datamodel()
datamodel.tables = [make_table(tabledef) for tabledef in datamodeldef.findall('table')]
add_collectingevents_to_locality(datamodel)
flag_dependent_fields(datamodel)
flag_system_tables(datamodel)
return datamodel

We could manually use SQL to get the correct information, but that will only be a short-term solution (which may be fine for now). Preferably, we would want to engineer a way to load/register these Specify 7 specific tables in the internal specify datamodel. (If such a way already exists and I am overlooking it, then feel free to point it out. I have checked all attributes on specify.models and spdataset does not exist)

From #2806 (comment)

It would be nice to have a proper solution to adding these tables into the Specify datamodel, this would be beneficial both for backend use (as described above) and for frontend use.
Currently in Specify 7, users are not allowed to query on these tables that are not loaded into the datamodel, which may become an issue if tables are added solely in Specify 7.

@melton-jason melton-jason added 1 - Request Improvements or extensions to existing behavior pri:unknown labels Jan 17, 2023
@maxpatiiuk
Copy link
Member

Duplicate of #2813. @melton-jason can you merge two issues into one and close one of them as a duplicate?

@melton-jason melton-jason closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
@melton-jason melton-jason added the res:duplicate Duplicate of an existing issue label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Request Improvements or extensions to existing behavior res:duplicate Duplicate of an existing issue
Projects
None yet
Development

No branches or pull requests

2 participants