Compare commits
2
Commits
1c6d9202fc
...
f42649b888
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f42649b888
|
||
|
|
f75a1b0338
|
@@ -122,13 +122,17 @@ def create_submission(
|
|||||||
for response_data in data.responses
|
for response_data in data.responses
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Non-admin submissions always go through manual validation
|
||||||
|
needs_validation = (
|
||||||
|
data.manual_validation_requested or not request.user.is_staff
|
||||||
|
)
|
||||||
|
|
||||||
# Create the submission
|
# Create the submission
|
||||||
submission = Submission.objects.create(
|
submission = Submission.objects.create(
|
||||||
event=request.event,
|
event=request.event,
|
||||||
user=request.user if request.user.is_authenticated else None,
|
user=request.user if request.user.is_authenticated else None,
|
||||||
notes=data.notes,
|
notes=data.notes,
|
||||||
manual_validation_requested=data.manual_validation_requested
|
manual_validation_requested=needs_validation or auto_request_validation,
|
||||||
or auto_request_validation,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
file_index = 0
|
file_index = 0
|
||||||
@@ -148,7 +152,7 @@ def create_submission(
|
|||||||
cost=response_data.cost,
|
cost=response_data.cost,
|
||||||
cycles=response_data.cycles,
|
cycles=response_data.cycles,
|
||||||
area=response_data.area,
|
area=response_data.area,
|
||||||
needs_manual_validation=data.manual_validation_requested,
|
needs_manual_validation=needs_validation,
|
||||||
ocr_confidence_cost=response_data.ocr_confidence_cost,
|
ocr_confidence_cost=response_data.ocr_confidence_cost,
|
||||||
ocr_confidence_cycles=response_data.ocr_confidence_cycles,
|
ocr_confidence_cycles=response_data.ocr_confidence_cycles,
|
||||||
ocr_confidence_area=response_data.ocr_confidence_area,
|
ocr_confidence_area=response_data.ocr_confidence_area,
|
||||||
@@ -158,7 +162,7 @@ def create_submission(
|
|||||||
"validated_cycles": response_data.cycles,
|
"validated_cycles": response_data.cycles,
|
||||||
"validated_area": response_data.area,
|
"validated_area": response_data.area,
|
||||||
}
|
}
|
||||||
if not data.manual_validation_requested
|
if not needs_validation
|
||||||
else {},
|
else {},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# 0015 copied rows with their ids via raw INSERT ... SELECT *, which doesn't
|
||||||
|
# bump postgres sequences -> new inserts collide on the pkey. Resync them.
|
||||||
|
|
||||||
|
from django.core.management.color import no_style
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
MODEL_NAMES = [
|
||||||
|
"SteamAPIKey",
|
||||||
|
"SteamCollection",
|
||||||
|
"SteamCollectionItem",
|
||||||
|
"Submission",
|
||||||
|
"PuzzleResponse",
|
||||||
|
"SubmissionFile",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def reset_sequences(apps, schema_editor):
|
||||||
|
connection = schema_editor.connection
|
||||||
|
models = [apps.get_model("opus_magnum", name) for name in MODEL_NAMES]
|
||||||
|
statements = connection.ops.sequence_reset_sql(no_style(), models)
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
for sql in statements:
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("opus_magnum", "0018_event_required"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(reset_sequences, migrations.RunPython.noop),
|
||||||
|
]
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 6.0.5 on 2026-10-23 21:33
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("opus_magnum", "0019_reset_sequences"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="puzzleresponse",
|
||||||
|
name="area",
|
||||||
|
field=models.IntegerField(
|
||||||
|
blank=True, help_text="Area value from OCR", null=True
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="puzzleresponse",
|
||||||
|
name="cost",
|
||||||
|
field=models.IntegerField(
|
||||||
|
blank=True, help_text="Cost value from OCR", null=True
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="puzzleresponse",
|
||||||
|
name="cycles",
|
||||||
|
field=models.IntegerField(
|
||||||
|
blank=True, help_text="Cycles value from OCR", null=True
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -400,9 +400,9 @@ class PuzzleResponse(models.Model):
|
|||||||
puzzle_name = models.CharField(
|
puzzle_name = models.CharField(
|
||||||
max_length=255, help_text="Puzzle name as detected by OCR"
|
max_length=255, help_text="Puzzle name as detected by OCR"
|
||||||
)
|
)
|
||||||
cost = models.IntegerField(blank=True, help_text="Cost value from OCR")
|
cost = models.IntegerField(null=True, blank=True, help_text="Cost value from OCR")
|
||||||
cycles = models.IntegerField(blank=True, help_text="Cycles value from OCR")
|
cycles = models.IntegerField(null=True, blank=True, help_text="Cycles value from OCR")
|
||||||
area = models.IntegerField(blank=True, help_text="Area value from OCR")
|
area = models.IntegerField(null=True, blank=True, help_text="Area value from OCR")
|
||||||
|
|
||||||
# Validation flags
|
# Validation flags
|
||||||
needs_manual_validation = models.BooleanField(
|
needs_manual_validation = models.BooleanField(
|
||||||
|
|||||||
@@ -398,10 +398,10 @@ SENTRY_DSN = (
|
|||||||
|
|
||||||
import sentry_sdk # noqa
|
import sentry_sdk # noqa
|
||||||
|
|
||||||
# sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
# dsn=SENTRY_DSN,
|
dsn=SENTRY_DSN,
|
||||||
# # Set traces_sample_rate to 1.0 to capture 100%
|
# Set traces_sample_rate to 1.0 to capture 100%
|
||||||
# # of transactions for tracing.
|
# of transactions for tracing.
|
||||||
# traces_sample_rate=1.0,
|
traces_sample_rate=0.1,
|
||||||
# environment=SENTRY_ENVIRONMENT,
|
environment=SENTRY_ENVIRONMENT,
|
||||||
# )
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user