Skip to content

Commit 46d63ef

Browse files
committed
Handle Build as a dict (APIBuild)
1 parent 623d715 commit 46d63ef

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

readthedocs/organizations/signals.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,5 @@ def mark_organization_assets_not_cleaned(sender, build, **kwargs):
9090
trigger a Celery task that will be executed in the web and mark the
9191
organization assets as not cleaned.
9292
"""
93-
organization = build.project.organizations.first()
94-
if build.state == BUILD_STATE_FINISHED and build.success and organization:
95-
mark_organization_assets_not_cleaned_task.delay(build)
93+
if build['state'] == BUILD_STATE_FINISHED:
94+
mark_organization_assets_not_cleaned_task.delay(build['id'])

readthedocs/organizations/tasks.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77

88

99
@app.task(queue='web')
10-
def mark_organization_assets_not_cleaned(organization):
11-
log.info("Marking organization as not cleaned. organization=%s", organization.slug)
12-
organization.artifacts_cleaned = False
13-
organization.save()
10+
def mark_organization_assets_not_cleaned(build_pk):
11+
try:
12+
build = Build.objects.get(pk=build_pk)
13+
except Build.DoesNotExist:
14+
log.info("Build does not exist. build=%s", build_pk)
15+
return
16+
17+
organization = build.project.organizations.first()
18+
if organization:
19+
log.info("Marking organization as not cleaned. organization=%s", organization.slug)
20+
organization.artifacts_cleaned = False
21+
organization.save()

0 commit comments

Comments
 (0)