fix: the video dialog marks the products that already have a published video (DTF-WEB-G, DTF-WEB-H)
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 7m20s
Build and deploy / Secret scan and release gate (push) Successful in 10s
Build and deploy / Publish images (push) Successful in 1m40s
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 7m20s
Build and deploy / Secret scan and release gate (push) Successful in 10s
Build and deploy / Publish images (push) Successful in 1m40s
"Onde aparece" names the products another published video holds and closes them while this one is published; turning Publicar on over a taken product stays off and says which video holds it. The server checks before copying any file and its refusal names that video too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,14 @@ def update_video(video_id: str, body: VideoUpdate, user=Depends(can('manage'))):
|
||||
with db.connect() as c:
|
||||
previous = c.execute('SELECT upload_id,captions_id,video_key,captions_key FROM dtf_local.site_videos WHERE id=%s FOR UPDATE',
|
||||
(video_id,)).fetchone() or {}
|
||||
# One floating video per product page; checked before any copy, and
|
||||
# the refusal names the video that holds the product (DTF-WEB-G).
|
||||
if body.enabled and body.product:
|
||||
other = c.execute('SELECT id FROM dtf_local.site_videos WHERE id<>%s AND product=%s AND enabled',
|
||||
(video_id, body.product)).fetchone()
|
||||
if other:
|
||||
raise HTTPException(409, f'Este produto já tem o vídeo "{CATALOG.get(other["id"], other["id"])}" '
|
||||
'publicado. Tire esse do Site antes, ou escolha outro lugar.')
|
||||
identity = operator_identity(user)
|
||||
keys = []
|
||||
for uid, expected, previous_id, previous_key in (
|
||||
@@ -113,11 +121,6 @@ def update_video(video_id: str, body: VideoUpdate, user=Depends(can('manage'))):
|
||||
CopySource={'Bucket': storage.bucket, 'Key': upload['object_key']},
|
||||
Key=key, ContentType=mime, MetadataDirective='REPLACE')
|
||||
keys.append(key)
|
||||
if body.enabled and body.product:
|
||||
other = c.execute('SELECT id FROM dtf_local.site_videos WHERE id<>%s AND product=%s AND enabled',
|
||||
(video_id, body.product)).fetchone()
|
||||
if other:
|
||||
raise HTTPException(409, 'Já existe um vídeo flutuante ativo para este produto.')
|
||||
c.execute('''INSERT INTO dtf_local.site_videos(id,upload_id,captions_id,video_key,captions_key,product,enabled,updated_by)
|
||||
VALUES(%s,%s,%s,%s,%s,%s,%s,%s)
|
||||
ON CONFLICT (id) DO UPDATE SET upload_id=EXCLUDED.upload_id,captions_id=EXCLUDED.captions_id,
|
||||
|
||||
Reference in New Issue
Block a user