mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
add com_taxa_synonym as an allowed table for species writeHandler
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user