Skip to content

Commit 10b3191

Browse files
humitosagjohnson
authored andcommitted
Minor improves to import_project_from_live management command (#3301)
* record the build * exclude attributes from API response * call UpdateDocsTask with `build_id` to avoid failing
1 parent d18ddc9 commit 10b3191

File tree

2 files changed

+27
-41
lines changed

2 files changed

+27
-41
lines changed

readthedocs/core/management/commands/update_repos.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1+
# -*- coding: utf-8 -*-
12
"""
23
Custom management command to rebuild documentation for all projects.
34
45
Invoked via ``./manage.py update_repos``.
56
"""
67

78
from __future__ import absolute_import
9+
810
import logging
911
from optparse import make_option
1012

1113
from django.core.management.base import BaseCommand
14+
15+
from readthedocs.builds.models import Build, Version
16+
from readthedocs.core.utils import trigger_build
1217
from readthedocs.projects import tasks
1318
from readthedocs.projects.models import Project
14-
from readthedocs.builds.models import Version
15-
from readthedocs.core.utils import trigger_build
19+
1620

1721
log = logging.getLogger(__name__)
1822

@@ -54,9 +58,21 @@ def handle(self, *args, **options):
5458
for version in Version.objects.filter(project__slug=slug,
5559
active=True,
5660
uploaded=False):
61+
62+
build_pk = None
63+
if record:
64+
build = Build.objects.create(
65+
project=version.project,
66+
version=version,
67+
type='html',
68+
state='triggered',
69+
)
70+
build_pk = build.pk
71+
5772
tasks.UpdateDocsTask().run(
5873
pk=version.project_id,
59-
record=False,
74+
build_pk=build_pk,
75+
record=record,
6076
version_pk=version.pk
6177
)
6278
else:

readthedocs/projects/management/commands/import_project_from_live.py

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,49 +51,19 @@ def handle(self, *args, **options):
5151
except Project.DoesNotExist:
5252
project = Project(slug=slug)
5353

54-
copy_attributes = (
55-
'pub_date',
56-
'modified_date',
57-
'name',
58-
'description',
59-
'repo',
60-
'repo_type',
61-
'project_url',
54+
exclude_attributes = (
55+
'absolute_url',
56+
'analytics_code',
6257
'canonical_url',
63-
'version',
64-
'copyright',
65-
'theme',
66-
'suffix',
67-
'single_version',
68-
'default_version',
69-
'default_branch',
70-
'requirements_file',
71-
'documentation_type',
72-
'allow_comments',
73-
'comment_moderation',
74-
# 'analytics_code' is left out on purpose.
75-
'enable_epub_build',
76-
'enable_pdf_build',
77-
'conf_py_file',
78-
'skip',
79-
'mirror',
80-
'install_project',
81-
'python_interpreter',
82-
'use_system_packages',
83-
'django_packages_url',
84-
'privacy_level',
85-
'version_privacy_level',
86-
'language',
87-
'num_major',
88-
'num_minor',
89-
'num_point',
58+
'users',
9059
)
9160

92-
for attribute in copy_attributes:
93-
setattr(project, attribute, project_data[attribute])
61+
for attribute in project_data:
62+
if attribute not in exclude_attributes:
63+
setattr(project, attribute, project_data[attribute])
9464
project.user = user1
9565
project.save()
9666
if user1:
9767
project.users.add(user1)
9868

99-
call_command('update_repos', project.slug, version='all')
69+
call_command('update_repos', project.slug, record=True, version='all')

0 commit comments

Comments
 (0)