diff --git a/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx b/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx index 074dff359a3..26f4696c407 100644 --- a/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx +++ b/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx @@ -6,6 +6,7 @@ import { backupText } from '../../localization/backup'; import { localityText } from '../../localization/locality'; import { mergingText } from '../../localization/merging'; import { notificationsText } from '../../localization/notifications'; +import { setupToolText } from '../../localization/setupTool'; import { treeText } from '../../localization/tree'; import { StringToJsx } from '../../localization/utils'; import type { IR, RA } from '../../utils/types'; @@ -393,6 +394,11 @@ export const notificationRenderers: IR< > ); }, + 'collection-creation-starting'() { + return ( +
{setupToolText.collectionCreationStarted()}
+ ); + }, default(notification) { console.error('Unknown notification type', { notification }); return{JSON.stringify(notification, null, 2)};
diff --git a/specifyweb/frontend/js_src/lib/localization/setupTool.ts b/specifyweb/frontend/js_src/lib/localization/setupTool.ts
index 1b03c8c40bd..216806f715d 100644
--- a/specifyweb/frontend/js_src/lib/localization/setupTool.ts
+++ b/specifyweb/frontend/js_src/lib/localization/setupTool.ts
@@ -280,4 +280,7 @@ export const setupToolText = createDictionary({
emptyTaxonTree: {
'en-us': 'An empty taxon tree will be created',
},
+ collectionCreationStarted: {
+ 'en-us': 'The newly created collection is being set up. It may take some time for the collection to become available.',
+ }
} as const);
diff --git a/specifyweb/specify/api/crud.py b/specifyweb/specify/api/crud.py
index 4987df5cb75..d0923d3b5d9 100644
--- a/specifyweb/specify/api/crud.py
+++ b/specifyweb/specify/api/crud.py
@@ -4,6 +4,7 @@
import logging
from typing import Any, Dict
from collections.abc import Callable
+import json
from django.db import transaction
from django.core.exceptions import FieldError, FieldDoesNotExist
from django.db.models import Model, F, Q, Subquery
@@ -48,6 +49,7 @@ def create_obj(collection, agent, model, data: dict[str, Any], parent_obj=None,
from specifyweb.backend.setup_tool.api import create_institution, create_division, create_discipline, create_collection
from specifyweb.backend.setup_tool.utils import normalize_keys
from specifyweb.backend.permissions.permissions import PermissionsException
+ from specifyweb.backend.notifications.models import Message
CREATE_MODEL_REDIRECTS: Dict[str, Callable[[dict], dict]] = {
'institution': create_institution,
'division': create_division,
@@ -65,7 +67,12 @@ def create_obj(collection, agent, model, data: dict[str, Any], parent_obj=None,
if not agent.specifyuser.is_admin():
raise PermissionsException("Specifyuser must be an instituion admin")
check_table_permissions(collection, agent, model, "create")
- result = CREATE_MODEL_REDIRECTS[model_name](normalize_keys(data))
+ result = CREATE_MODEL_REDIRECTS[model_name](normalize_keys(data))
+ if model_name == 'collection' and agent.specifyuser is not None:
+ # Send notification to show that the collection is still being created.
+ Message.objects.create(user_id=agent.specifyuser.id, content=json.dumps({
+ 'type': 'collection-creation-starting'
+ }))
return model.objects.filter(id=result[f'{model_name}_id']).first()
data = cleanData(model, data, parent_relationship)