Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -393,6 +394,11 @@ export const notificationRenderers: IR<
</>
);
},
'collection-creation-starting'() {
return (
<p>{setupToolText.collectionCreationStarted()}</p>
);
},
default(notification) {
console.error('Unknown notification type', { notification });
return <pre>{JSON.stringify(notification, null, 2)}</pre>;
Expand Down
3 changes: 3 additions & 0 deletions specifyweb/frontend/js_src/lib/localization/setupTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
9 changes: 8 additions & 1 deletion specifyweb/specify/api/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
Loading