readthedocs.core

readthedocs.core.admin

Django admin interface for core models.

class readthedocs.core.admin.UserAdminExtra(model, admin_site)

Admin configuration for User.

class readthedocs.core.admin.UserProfileAdmin(model, admin_site)
class readthedocs.core.admin.UserProjectFilter(request, params, model, model_admin)

Filter users based on project properties.

lookups(request, model_admin)

Must be overridden to return a list of tuples (value, verbose value)

queryset(request, queryset)

Add filters to queryset filter.

PROJECT_ACTIVE and PROJECT_BUILT look for versions on projects, PROJECT_RECENT looks for projects with builds in the last year

class readthedocs.core.admin.UserProjectInline(parent_model, admin_site)
model

alias of readthedocs.projects.models.Project_users

readthedocs.core.forms

Forms for core app.

class readthedocs.core.forms.FacetField(choices=(), required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)

For filtering searches on a facet.

Has validation for the format of facet values.

valid_value(value)

Although this is a choice field, no choices need to be supplied.

Instead, we just validate that the value is in the correct format for facet filtering (facet_name:value)

readthedocs.core.middleware

Middleware for core app.

class readthedocs.core.middleware.FooterNoSessionMiddleware

Middleware that doesn’t create a session on logged out doc views.

This will reduce the size of our session table drastically.

process_response(request, response)

If request.session was modified, or if the configuration is to save the session every time, save the changes and set a session cookie or delete the session cookie if the session has been emptied.

class readthedocs.core.middleware.ProxyMiddleware

Middleware that sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, if the.

latter is set. This is useful if you’re sitting behind a reverse proxy that causes each request’s REMOTE_ADDR to be set to 127.0.0.1. Note that this does NOT validate HTTP_X_FORWARDED_FOR. If you’re not behind a reverse proxy that sets HTTP_X_FORWARDED_FOR automatically, do not use this middleware. Anybody can spoof the value of HTTP_X_FORWARDED_FOR, and because this sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, that means anybody can “fake” their IP address. Only use this when you can absolutely trust the value of HTTP_X_FORWARDED_FOR.

class readthedocs.core.middleware.SingleVersionMiddleware

Reset urlconf for requests for ‘single_version’ docs.

In settings.MIDDLEWARE_CLASSES, SingleVersionMiddleware must follow after SubdomainMiddleware.

class readthedocs.core.middleware.SubdomainMiddleware

Middleware to display docs for non-dashboard domains.

process_request(request)

Process requests for unhandled domains.

If the request is not for our PUBLIC_DOMAIN, or if PUBLIC_DOMAIN is not set and the request is for a subdomain on PRODUCTION_DOMAIN, process the request as a request a documentation project.

readthedocs.core.models

Models for the core app.

class readthedocs.core.models.UserProfile(*args, **kwargs)

Additional information about a User.

exception DoesNotExist
exception MultipleObjectsReturned
get_contribution_details()

Get the line to put into commits to attribute the author.

Returns a tuple (name, email)

readthedocs.core.views

Core views, including the main homepage,

documentation and header rendering, and server errors.

exception readthedocs.core.views.NoProjectException
readthedocs.core.views.server_error_404(request, exception, template_name='404.html')

A simple 404 handler so we get media.

readthedocs.core.views.server_error_500(request, template_name='500.html')

A simple 500 handler so we get media.

readthedocs.core.management.commands

This is where custom manage.py commands are defined.

Rebuild documentation for all projects

Clean up stable build paths per project version

Import a project’s programming language from GitHub

This builds a basic management command that will set a projects language to the most used one in GitHub.

Requires a GITHUB_AUTH_TOKEN to be set in the environment, which should contain a proper GitHub Oauth Token for rate limiting.

Resync GitHub project for user

Trigger build for project slug

Reindex Elastic Search indexes

Generate metadata for all projects

Update symlinks for projects

Build documentation using the API and not hitting a database.

Usage:

./manage.py update_api <slug>

Custom management command to rebuild documentation for all projects.

Invoked via ./manage.py update_repos.

class readthedocs.core.management.commands.update_repos.Command(stdout=None, stderr=None, no_color=False)

Management command for rebuilding documentation on projects

Rebuild documentation for all projects