Skip to content

Commit 5922908

Browse files
authored
Merge pull request #3147 from rtfd/build-cold-storage
Add cold storage option on builds & configurable BuildViewSet
2 parents 60d2609 + 8432aca commit 5922908

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

readthedocs/builds/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BuildCommandResultInline(admin.TabularInline):
1212

1313

1414
class BuildAdmin(admin.ModelAdmin):
15-
fields = ('project', 'version', 'type', 'state', 'error', 'success', 'length')
15+
fields = ('project', 'version', 'type', 'state', 'error', 'success', 'length', 'cold_storage')
1616
list_display = ('project', 'success', 'type', 'state', 'date')
1717
raw_id_fields = ('project', 'version')
1818
inlines = (BuildCommandResultInline,)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9.12 on 2017-10-04 17:27
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('builds', '0002_build_command_initial'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='build',
17+
name='cold_storage',
18+
field=models.BooleanField(default=False, help_text='Build comamnds are stored outside the database.', verbose_name='Cold Storage'),
19+
),
20+
]

readthedocs/builds/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class Build(models.Model):
348348

349349
builder = models.CharField(_('Builder'), max_length=255, null=True, blank=True)
350350

351+
cold_storage = models.BooleanField(_('Cold Storage'), default=False,
352+
help_text='Build comamnds are stored outside the database.')
353+
351354
# Manager
352355

353356
objects = BuildQuerySet.as_manager()

readthedocs/restapi/views/model_views.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from readthedocs.builds.constants import TAG
1414
from readthedocs.builds.models import Build, BuildCommandResult, Version
1515
from readthedocs.core.utils import trigger_build
16+
from readthedocs.core.utils.extend import SettingsOverrideObject
1617
from readthedocs.oauth.services import GitHubService, registry
1718
from readthedocs.oauth.models import RemoteOrganization, RemoteRepository
1819
from readthedocs.projects.models import Project, EmailHook, Domain
@@ -167,7 +168,7 @@ def get_queryset(self):
167168
return self.model.objects.api(self.request.user)
168169

169170

170-
class BuildViewSet(viewsets.ModelViewSet):
171+
class BuildViewSetBase(viewsets.ModelViewSet):
171172
permission_classes = [APIRestrictedPermission]
172173
renderer_classes = (JSONRenderer,)
173174
model = Build
@@ -186,7 +187,17 @@ def get_serializer_class(self):
186187
return BuildSerializer
187188

188189

190+
class BuildViewSet(SettingsOverrideObject):
191+
192+
"""A pluggable class to allow for build cold storage."""
193+
194+
_default_class = BuildViewSetBase
195+
196+
189197
class BuildCommandViewSet(viewsets.ModelViewSet):
198+
199+
"""This is currently a write-only way to update the commands on build."""
200+
190201
permission_classes = [APIRestrictedPermission]
191202
renderer_classes = (JSONRenderer,)
192203
serializer_class = BuildCommandSerializer

0 commit comments

Comments
 (0)