Skip to content

Add cold storage option on builds & configurable BuildViewSet #3147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion readthedocs/builds/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BuildCommandResultInline(admin.TabularInline):


class BuildAdmin(admin.ModelAdmin):
fields = ('project', 'version', 'type', 'state', 'error', 'success', 'length')
fields = ('project', 'version', 'type', 'state', 'error', 'success', 'length', 'cold_storage')
list_display = ('project', 'success', 'type', 'state', 'date')
raw_id_fields = ('project', 'version')
inlines = (BuildCommandResultInline,)
Expand Down
66 changes: 66 additions & 0 deletions readthedocs/builds/migrations/0003_add-cold-storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-10-04 17:27
from __future__ import unicode_literals

from django.db import migrations, models
import readthedocs.builds.version_slug


class Migration(migrations.Migration):

dependencies = [
('builds', '0002_build_command_initial'),
]

operations = [
migrations.AddField(
model_name='build',
name='cold_storage',
field=models.BooleanField(default=False, help_text='Build comamnds are stored outside the database.', verbose_name='Cold Storage'),
),
migrations.AlterField(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this was added automatically, I think small updates that we haven't migrated on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, i get some of these too. Lets remove them from here and figure out which of these migrations are required now. We might need to roll a fresh db locally to figure that out.

model_name='build',
name='error',
field=models.TextField(blank=True, default='', verbose_name='Error'),
),
migrations.AlterField(
model_name='build',
name='output',
field=models.TextField(blank=True, default='', verbose_name='Output'),
),
migrations.AlterField(
model_name='build',
name='state',
field=models.CharField(choices=[('triggered', 'Triggered'), ('cloning', 'Cloning'), ('installing', 'Installing'), ('building', 'Building'), ('finished', 'Finished')], default='finished', max_length=55, verbose_name='State'),
),
migrations.AlterField(
model_name='build',
name='type',
field=models.CharField(choices=[('html', 'HTML'), ('pdf', 'PDF'), ('epub', 'Epub'), ('man', 'Manpage'), ('dash', 'Dash')], default='html', max_length=55, verbose_name='Type'),
),
migrations.AlterField(
model_name='version',
name='privacy_level',
field=models.CharField(choices=[('public', 'Public'), ('protected', 'Protected'), ('private', 'Private')], default='public', help_text='Level of privacy for this Version.', max_length=20, verbose_name='Privacy Level'),
),
migrations.AlterField(
model_name='version',
name='slug',
field=readthedocs.builds.version_slug.VersionSlugField(db_index=True, max_length=255, populate_from='verbose_name', verbose_name='Slug'),
),
migrations.AlterField(
model_name='version',
name='type',
field=models.CharField(choices=[('branch', 'Branch'), ('tag', 'Tag'), ('unknown', 'Unknown')], default='unknown', max_length=20, verbose_name='Type'),
),
migrations.AlterField(
model_name='versionalias',
name='from_slug',
field=models.CharField(default='', max_length=255, verbose_name='From slug'),
),
migrations.AlterField(
model_name='versionalias',
name='to_slug',
field=models.CharField(blank=True, default='', max_length=255, verbose_name='To slug'),
),
]
3 changes: 3 additions & 0 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ class Build(models.Model):

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

cold_storage = models.BooleanField(_('Cold Storage'), default=False,
help_text='Build comamnds are stored outside the database.')

# Manager

objects = BuildQuerySet.as_manager()
Expand Down
10 changes: 9 additions & 1 deletion readthedocs/restapi/views/model_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from readthedocs.builds.constants import TAG
from readthedocs.builds.models import Build, BuildCommandResult, Version
from readthedocs.core.utils import trigger_build
from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.oauth.services import GitHubService, registry
from readthedocs.oauth.models import RemoteOrganization, RemoteRepository
from readthedocs.projects.models import Project, EmailHook, Domain
Expand Down Expand Up @@ -166,7 +167,7 @@ def get_queryset(self):
return self.model.objects.api(self.request.user)


class BuildViewSet(viewsets.ModelViewSet):
class BuildViewSetBase(viewsets.ModelViewSet):
permission_classes = [APIRestrictedPermission]
renderer_classes = (JSONRenderer,)
model = Build
Expand All @@ -185,7 +186,14 @@ def get_serializer_class(self):
return BuildSerializer


class BuildViewSet(SettingsOverrideObject):
_default_class = BuildViewSetBase


class BuildCommandViewSet(viewsets.ModelViewSet):

"""This is currently a write-only way to update the commands on build."""

permission_classes = [APIRestrictedPermission]
renderer_classes = (JSONRenderer,)
serializer_class = BuildCommandSerializer
Expand Down