Skip to content

Commit fcfbc80

Browse files
committed
feat: Add unique constraint for spectrum owner and subtype; update URL for slug-based submission
1 parent adb7782 commit fcfbc80

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

backend/proteins/migrations/0060_spectrum_optimized_storage.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,20 @@ class Migration(migrations.Migration):
319319
violation_error_message="Subtype is not valid for the spectrum category",
320320
),
321321
),
322+
# Ensure unique (owner, subtype) combination
323+
ConditionalAddConstraint(
324+
model_name="spectrum",
325+
constraint=models.UniqueConstraint(
326+
name="spectrum_unique_owner_subtype",
327+
fields=[
328+
"owner_fluor",
329+
"owner_filter",
330+
"owner_light",
331+
"owner_camera",
332+
"subtype",
333+
],
334+
),
335+
),
322336
# Step 6: Add covering index for metadata-only queries
323337
ConditionalAddIndex(
324338
model_name="spectrum",

backend/proteins/urls.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@
6565
),
6666
name="submit-spectra",
6767
),
68+
# Slug-based submission uses legacy form (pre-selects the protein)
69+
re_path(
70+
r"^spectra/submit/(?P<slug>[-\w]+)/$",
71+
(
72+
login_required(
73+
views.SpectrumCreateView.as_view(),
74+
message="You must be logged in to submit spectra",
75+
)
76+
if CONTRIBS_OPEN
77+
else disabled
78+
),
79+
name="submit-spectra",
80+
),
6881
path(
6982
"spectra/submitted/",
7083
views.spectrum_submitted_v2,

0 commit comments

Comments
 (0)