add com_taxa_synonym as an allowed table for species writeHandler

This commit is contained in:
juhanikat
2025-09-08 10:57:46 +03:00
parent 48ec4b5f43
commit 6f65cd2c3f
3 changed files with 5 additions and 6 deletions
+1 -2
View File
@@ -15,7 +15,6 @@ import Prisma from '../../prisma/generated/now_test_client'
import { AccessError } from '../middlewares/authorizer'
import { fixBigInt } from '../utils/common'
import { logDb, nowDb } from '../utils/db'
import { logger } from '../utils/logger'
import { getReferenceDetails } from './reference'
const getIdsOfUsersProjects = async (user: User) => {
@@ -274,7 +273,7 @@ export const filterDuplicateLocalitySpecies = async (
return !(localityDetailsSpeciesIds.includes(localitySpecies.species_id) && localitySpecies.rowState === 'new')
}
// if localitySpecies doesn't have species_id (i.e. it was created with the "add new species" button in Species tab),
// it will never be filtered out. However, once the taxonomy check for the "add new species" button is working,
// it will never be filtered out. However, due to the taxonomy check for the "add new species" button,
// it should not let the user create a duplicate species in this way.
return true
})
+3 -3
View File
@@ -49,9 +49,9 @@ export const writeLocality = async (
try {
await writeHandler.start()
const filteredLocality = await filterDuplicateLocalitySpecies(locality, user)
if (updateOrAdd === 'update' && filteredLocality) {
locality.now_ls = filteredLocality
const filteredLocalities = await filterDuplicateLocalitySpecies(locality, user)
if (updateOrAdd === 'update' && filteredLocalities && filteredLocalities.length > 0) {
locality.now_ls = filteredLocalities
}
if (updateOrAdd === 'add') {
+1 -1
View File
@@ -11,7 +11,7 @@ const getSpeciesWriteHandler = (type: ActionType) => {
dbName: NOW_DB_NAME,
table: 'com_species',
idColumn: 'species_id',
allowedColumns: getFieldsOfTables(['com_species', 'now_ls', 'now_sau', 'now_lau']),
allowedColumns: getFieldsOfTables(['com_species', 'now_ls', 'now_sau', 'now_lau', 'com_taxa_synonym']),
type,
})
}