projects

projects.admin

Django administration interface for Project and related models.

projects.constants

Default values and other various configuration for projects, including available theme names and repository types.

projects.forms

class projects.forms.ProjectBackendForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=None, empty_permitted=False)

Get the import backend

class projects.forms.ProjectBasicsForm(*args, **kwargs)

Form for basic project fields

class projects.forms.ProjectTriggerBuildMixin

Mixin to trigger build on form save

This should be replaced with signals instead of calling trigger_build explicitly.

save(commit=True)

Trigger build on commit save

projects.models

class projects.models.EmailHook(*args, **kwargs)

EmailHook(id, project_id, email)

class projects.models.ImportedFile(*args, **kwargs)

ImportedFile(id, project_id, version_id, name, slug, path, md5, commit)

class projects.models.Project(*args, **kwargs)

Project(id, pub_date, modified_date, name, slug, description, repo, repo_type, project_url, canonical_url, version, copyright, theme, suffix, single_version, default_version, default_branch, requirements_file, documentation_type, allow_comments, comment_moderation, analytics_code, path, conf_py_file, featured, skip, mirror, use_virtualenv, python_interpreter, use_system_packages, django_packages_url, privacy_level, version_privacy_level, language, programming_language, main_language_project_id, num_major, num_minor, num_point)

all_active_versions()

A temporary workaround for active_versions filtering out things that were active, but failed to build

artifact_path(type, version='latest')

The path to the build html docs in the project.

Path in the doc_path that we symlink cnames

This has to be at the top-level because Nginx doesn’t know the projects slug.

find(file, version)

A balla API to find files inside of a projects dir.

full_build_path(version='latest')

The path to the build html docs in the project.

full_dash_path(version='latest')

The path to the build dash docs in the project.

full_doc_path(version='latest')

The path to the documentation root in the project.

full_epub_path(version='latest')

The path to the build epub docs in the project.

full_find(file, version)

A balla API to find files inside of a projects dir.

full_json_path(version='latest')

The path to the build json docs in the project.

full_latex_path(version='latest')

The path to the build latex docs in the project.

full_man_path(version='latest')

The path to the build man docs in the project.

full_singlehtml_path(version='latest')

The path to the build singlehtml docs in the project.

get_default_branch()

Get the version representing “latest”

get_default_version()

Get the default version (slug).

Returns self.default_version if the version with that slug actually exists (is built and published). Otherwise returns ‘latest’.

get_docs_url(version_slug=None, lang_slug=None)

Return a url for the docs. Always use http for now, to avoid content warnings.

get_latest_build(finished=True)

Get latest build for project

finished
Return only builds that are in a finished state
get_production_media_path(type, version_slug, include_file=True)

Get file path for media files in production. This is used to see if these files exist so we can offer them for download.

get_production_media_url(type, version_slug, full_path=True)

Get the URL for downloading a specific media file.

rtd_build_path(version='latest')

The destination path where the built docs are copied.

Path in the doc_path for the single_version symlink.

static_metadata_path()

The path to the static metadata JSON settings file

Path in the doc_path that we symlink subprojects

supported_versions(flat=True)

Get the list of supported versions. Returns a list of version strings.

Path in the doc_path that we symlink translations

class projects.models.ProjectRelationship(*args, **kwargs)

ProjectRelationship(id, parent_id, child_id)

class projects.models.WebHook(*args, **kwargs)

WebHook(id, project_id, url)

projects.tasks

Tasks related to projects, including fetching repository code, cleaning conf.py files, and rebuilding documentation.

projects.tasks.create_build(build_pk)

Old placeholder for build creation. Now it just gets it from the database.

projects.tasks.docker_build(version, pdf=True, man=True, epub=True, dash=True, search=True, force=False, intersphinx=True, localmedia=True)

The code that executes inside of docker

projects.tasks.ensure_version(api, project, version_pk)

Ensure we’re using a sane version.

projects.tasks.record_build(api, record, build, results, state, start_time=None)

Record a build by hitting the API.

Returns nothing

projects.tasks.setup_environment(version)

Build the virtualenv and install the project into it.

Always build projects with a virtualenv.

projects.tasks.setup_vcs(version, build, api)

Update the checkout of the repo to make sure it’s the latest. This also syncs versions in the DB.

projects.tasks.update_docs_pull(record=False, pdf=False, man=False, force=False)

A high-level interface that will update all of the projects.

This is mainly used from a cronjob or management command.

projects.tasks.update_documentation_type(version, api)

Automatically determine the doc type for a user.

projects.utils

Utility functions used by projects.

projects.utils.find_file(file)

Find matching filenames in the current directory and its subdirectories, and return a list of matching filenames.

projects.utils.github_paginate(client, url)

Scans trough all github paginates results and returns the concatenated list of results.

Parameters:
  • client – requests client instance
  • url – start url to get the data from.

See https://developer.github.com/v3/#pagination

projects.utils.run(*commands, **kwargs)

Run one or more commands, and return (status, out, err). If more than one command is given, then this is equivalent to chaining them together with &&; if all commands succeed, then (status, out, err) will represent the last successful command. If one command failed, then (status, out, err) will represent the failed command.

projects.utils.safe_write(filename, contents)

Write contents to the given filename. If the filename’s directory does not exist, it is created. Contents are written as UTF-8, ignoring any characters that cannot be encoded as UTF-8.

projects.utils.update_static_metadata(project_pk)

This is here to avoid circular imports in models.py

projects.views

projects.views.public

class projects.views.public.ProjectDetailView(**kwargs)

Display project onboard steps

model

alias of Project

Use elastic search to search in a project.

projects.views.public.file_autocomplete(request, project_slug)

return a json list of version names

projects.views.public.project_badge(request, project_slug, redirect=False)

Return a sweet badge for the project

projects.views.public.project_download_media(request, project_slug, type, version_slug)

Download a specific piece of media. Perform an auth check if serving in private mode.

projects.views.public.project_downloads(request, project_slug)

A detail view for a project with various dataz

projects.views.public.project_versions(request, project_slug)

Shows the available versions and lets the user choose which ones he would like to have built.

projects.views.public.search_autocomplete(request)

return a json list of project names

projects.views.public.version_autocomplete(request, project_slug)

return a json list of version names

projects.views.private

class projects.views.private.ImportDemoView(**kwargs)

View to pass request on to import form to import demo project

form_class

alias of ProjectBasicsForm

get(request, *args, **kwargs)

Process link request as a form post to the project import form

get_form_data()

Get form data to post to import form

get_form_kwargs()

Form kwargs passed in during instantiation

class projects.views.private.ImportView(**kwargs)

On GET, show the source select template, on POST, mock out a wizard

If we are accepting POST data, use the fields to seed the initial data in :py:cls:`ImportWizardView`. The import templates will redirect the form to /dashboard/import

wizard_class

alias of ImportWizardView

class projects.views.private.ImportWizardView(**kwargs)

Project import wizard

done(form_list, **kwargs)

Save form data as object instance

Don’t save form data directly, instead bypass documentation building and other side effects for now, by signalling a save without commit. Then, finish by added the members to the project and saving.

get_form_kwargs(step)

Get args to pass into form instantiation

get_template_names()

Return template names based on step name

is_advanced()

Determine if the user selected the show advanced field

class projects.views.private.ProjectDashboard(**kwargs)

A dashboard! If you aint know what that means you aint need to. Essentially we show you an overview of your content.

model

alias of Project

projects.views.private.project_advanced(request, *args, **kwargs)

Edit an existing project - depending on what type of project is being edited (created or imported) a different form will be displayed

projects.views.private.project_delete(request, *args, **kwargs)

Make a project as deleted on POST, otherwise show a form asking for confirmation of delete.

projects.views.private.project_edit(request, *args, **kwargs)

Edit an existing project - depending on what type of project is being edited (created or imported) a different form will be displayed

projects.views.private.project_import_bitbucket(request, *args, **kwargs)

Show form that prefills import form with data from BitBucket

projects.views.private.project_import_github(request, *args, **kwargs)

Show form that prefills import form with data from GitHub

projects.views.private.project_manage(request, *args, **kwargs)

The management view for a project, where you will have links to edit the projects’ configuration, edit the files associated with that project, etc.

Now redirects to the normal /projects/<slug> view.

projects.views.private.project_versions(request, *args, **kwargs)

Shows the available versions and lets the user choose which ones he would like to have built.