forked from readthedocs/readthedocs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request readthedocs#8418 from readthedocs/humitos/assets-c…
…leanup
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
readthedocs/organizations/migrations/0006_add_assets_cleaned.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 2.2.24 on 2021-08-17 14:54 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('organizations', '0005_historicalorganization_historicalteam'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='historicalorganization', | ||
name='artifacts_cleaned', | ||
field=models.BooleanField(default=False, help_text='Artifacts are cleaned out from storage', verbose_name='Artifacts Cleaned'), | ||
), | ||
migrations.AddField( | ||
model_name='organization', | ||
name='artifacts_cleaned', | ||
field=models.BooleanField(default=False, help_text='Artifacts are cleaned out from storage', verbose_name='Artifacts Cleaned'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Organization's tasks related.""" | ||
|
||
import logging | ||
|
||
from readthedocs.builds.models import Build | ||
from readthedocs.worker import app | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@app.task(queue='web') | ||
def mark_organization_assets_not_cleaned(build_pk): | ||
"""Mark an organization as `artifacts_cleaned=False`.""" | ||
try: | ||
build = Build.objects.get(pk=build_pk) | ||
except Build.DoesNotExist: | ||
log.info("Build does not exist. build=%s", build_pk) | ||
return | ||
|
||
organization = build.project.organizations.first() | ||
if organization: | ||
log.info("Marking organization as not cleaned. organization=%s", organization.slug) | ||
organization.artifacts_cleaned = False | ||
organization.save() |