Skip to content

Minor improves to import_project_from_live management command #3301

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 1 commit into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 19 additions & 3 deletions readthedocs/core/management/commands/update_repos.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# -*- coding: utf-8 -*-
"""
Custom management command to rebuild documentation for all projects.

Invoked via ``./manage.py update_repos``.
"""

from __future__ import absolute_import

import logging
from optparse import make_option

from django.core.management.base import BaseCommand

from readthedocs.builds.models import Build, Version
from readthedocs.core.utils import trigger_build
from readthedocs.projects import tasks
from readthedocs.projects.models import Project
from readthedocs.builds.models import Version
from readthedocs.core.utils import trigger_build


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -54,9 +58,21 @@ def handle(self, *args, **options):
for version in Version.objects.filter(project__slug=slug,
active=True,
uploaded=False):

build_pk = None
if record:
build = Build.objects.create(
project=version.project,
version=version,
type='html',
state='triggered',
)
build_pk = build.pk

tasks.UpdateDocsTask().run(
pk=version.project_id,
record=False,
build_pk=build_pk,
record=record,
version_pk=version.pk
)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,49 +51,19 @@ def handle(self, *args, **options):
except Project.DoesNotExist:
project = Project(slug=slug)

copy_attributes = (
'pub_date',
'modified_date',
'name',
'description',
'repo',
'repo_type',
'project_url',
exclude_attributes = (
'absolute_url',
'analytics_code',
'canonical_url',
'version',
'copyright',
'theme',
'suffix',
'single_version',
'default_version',
'default_branch',
'requirements_file',
'documentation_type',
'allow_comments',
'comment_moderation',
# 'analytics_code' is left out on purpose.
'enable_epub_build',
'enable_pdf_build',
'conf_py_file',
'skip',
'mirror',
'install_project',
'python_interpreter',
'use_system_packages',
'django_packages_url',
'privacy_level',
'version_privacy_level',
'language',
'num_major',
'num_minor',
'num_point',
'users',
)

for attribute in copy_attributes:
setattr(project, attribute, project_data[attribute])
for attribute in project_data:
if attribute not in exclude_attributes:
setattr(project, attribute, project_data[attribute])
project.user = user1
project.save()
if user1:
project.users.add(user1)

call_command('update_repos', project.slug, version='all')
call_command('update_repos', project.slug, record=True, version='all')