repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
readthedocs.org
readthedocs/api/v2/proxied_urls.py
.py
""" Proxied API URLs. Served from the same domain docs are served, so they can make use of features that require to have access to their cookies. """ from django.urls import path from readthedocs.analytics.proxied_api import AnalyticsView from readthedocs.api.v2.views.proxied import ProxiedEmbedAPI from readthedocs....
22
641
readthedocs.org
readthedocs/api/v2/test/test_tasks.py
.py
from datetime import timedelta from django.test import TestCase from django.utils import timezone from django_dynamic_fixture import get from readthedocs.api.v2.models import BuildAPIKey from readthedocs.api.v2.tasks import delete_old_revoked_build_api_keys from readthedocs.projects.models import Project class Test...
59
1,859
readthedocs.org
readthedocs/api/v2/views/proxied.py
.py
from readthedocs.core.mixins import ProxiedAPIMixin from readthedocs.core.utils.extend import SettingsOverrideObject from readthedocs.embed.views import EmbedAPI class ProxiedEmbedAPIBase(ProxiedAPIMixin, EmbedAPI): pass class ProxiedEmbedAPI(SettingsOverrideObject): _default_class = ProxiedEmbedAPIBase
12
317
readthedocs.org
readthedocs/api/v2/views/core_views.py
.py
"""Utility endpoints relating to canonical urls, embedded content, etc.""" from django.shortcuts import get_object_or_404 from rest_framework import decorators from rest_framework import permissions from rest_framework import status from rest_framework.renderers import JSONRenderer from rest_framework.response import ...
76
2,271
readthedocs.org
readthedocs/api/v2/views/task_views.py
.py
"""Endpoints relating to task/job status, etc.""" import structlog from django.core.cache import cache from django.urls import reverse from rest_framework import decorators from rest_framework import permissions from rest_framework.renderers import JSONRenderer from rest_framework.response import Response from readth...
55
1,681
readthedocs.org
readthedocs/api/v2/views/integrations.py
.py
"""Endpoints integrating with Github, Bitbucket, and other webhooks.""" import hashlib import hmac import json from functools import namedtuple from textwrap import dedent import structlog from django.http import Http404 from django.shortcuts import get_object_or_404 from django.utils.crypto import constant_time_comp...
947
35,152
readthedocs.org
readthedocs/api/v2/views/model_views.py
.py
"""Endpoints for listing Projects, Versions, Builds, etc.""" import json from dataclasses import asdict import structlog from allauth.socialaccount.models import SocialAccount from django.conf import settings from django.core.exceptions import PermissionDenied from django.db.models import BooleanField from django.db....
587
21,942
readthedocs.org
readthedocs/api/v3/apps.py
.py
from django.apps import AppConfig class V3Config(AppConfig): name = "readthedocs.api.v3"
6
95
readthedocs.org
readthedocs/api/v3/filters.py
.py
import django_filters.rest_framework as filters from readthedocs.builds.constants import BUILD_FINAL_STATES from readthedocs.builds.models import Build from readthedocs.builds.models import Version from readthedocs.notifications.models import Notification from readthedocs.oauth.models import RemoteOrganization from re...
96
2,677
readthedocs.org
readthedocs/api/v3/serializers.py
.py
import datetime import urllib from django.conf import settings from django.contrib.auth.models import User from django.db.models import Q from django.urls import reverse from django.utils.translation import gettext as _ from rest_flex_fields import FlexFieldsModelSerializer from rest_flex_fields.serializers import Fle...
1,349
43,307
readthedocs.org
readthedocs/api/v3/views.py
.py
import django_filters.rest_framework as filters from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.db.models import Exists from django.db.models import OuterRef from django.db.models import Prefetch from rest_flex_fields import is_expanded from rest_flex_f...
758
25,743
readthedocs.org
readthedocs/api/v3/routers.py
.py
from rest_framework.routers import APIRootView from rest_framework.routers import DefaultRouter from rest_framework_extensions.routers import NestedRouterMixin class DocsAPIRootView(APIRootView): # Overridden only to add documentation for BrowsableAPIRenderer. # noqa """ Each request requires an `Aut...
24
725
readthedocs.org
readthedocs/api/v3/urls.py
.py
from .routers import DefaultRouterWithNesting from .views import BuildsCreateViewSet from .views import BuildsViewSet from .views import EnvironmentVariablesViewSet from .views import NotificationsBuildViewSet from .views import NotificationsForUserViewSet from .views import NotificationsOrganizationViewSet from .views...
175
4,586
readthedocs.org
readthedocs/api/v3/permissions.py
.py
from rest_framework.permissions import BasePermission from readthedocs.subscriptions.constants import TYPE_EMBED_API from readthedocs.subscriptions.products import get_feature class HasEmbedAPIAccess(BasePermission): """ Check if the project being accessed has access to the Embed API. The embedded API V...
60
2,022
readthedocs.org
readthedocs/api/v3/mixins.py
.py
from django.contrib.auth.models import User from django.shortcuts import get_object_or_404 from rest_framework import status from rest_framework.response import Response from readthedocs.builds.models import Build from readthedocs.builds.models import Version from readthedocs.core.history import safe_update_change_rea...
245
8,122
readthedocs.org
readthedocs/api/v3/proxied_views.py
.py
from readthedocs.core.mixins import ProxiedAPIMixin from readthedocs.core.utils.extend import SettingsOverrideObject from readthedocs.embed.v3.views import EmbedAPIBase class ProxiedEmbedAPIBase(ProxiedAPIMixin, EmbedAPIBase): pass class ProxiedEmbedAPI(SettingsOverrideObject): _default_class = ProxiedEmbed...
12
328
readthedocs.org
readthedocs/api/v3/renderers.py
.py
"""Renders with some extra capabilities we require for our own purposes.""" import json from rest_framework.compat import INDENT_SEPARATORS from rest_framework.compat import LONG_SEPARATORS from rest_framework.compat import SHORT_SEPARATORS from rest_framework.renderers import JSONRenderer class AlphabeticalSortedJ...
58
1,951
readthedocs.org
readthedocs/api/v3/proxied_urls.py
.py
""" Proxied API URLs. Served from the same domain docs are served, so they can make use of features that require to have access to their cookies. """ from django.urls import path from readthedocs.api.v3.proxied_views import ProxiedEmbedAPI from readthedocs.search.api.v3.views import ProxiedSearchAPI api_proxied_ur...
20
500
readthedocs.org
readthedocs/api/v3/tests/test_remoterepositories.py
.py
import django_dynamic_fixture as fixture from allauth.socialaccount.models import SocialAccount from django.urls import reverse from readthedocs.oauth.constants import GITHUB from readthedocs.oauth.models import ( RemoteOrganization, RemoteOrganizationRelation, RemoteRepository, RemoteRepositoryRelatio...
114
3,899
readthedocs.org
readthedocs/api/v3/tests/test_notifications.py
.py
import django_dynamic_fixture as fixture from django.contrib.contenttypes.models import ContentType from django.test import override_settings from django.urls import reverse from readthedocs.notifications.constants import CANCELLED, DISMISSED from readthedocs.notifications.models import Notification from readthedocs.p...
74
2,584
readthedocs.org
readthedocs/api/v3/tests/test_versions.py
.py
from unittest import mock import django_dynamic_fixture as fixture from django.test import override_settings from django.urls import reverse from django_dynamic_fixture import get from readthedocs.builds.constants import EXTERNAL, TAG from readthedocs.builds.models import Version from readthedocs.projects.constants i...
456
16,586
readthedocs.org
readthedocs/api/v3/tests/test_builds.py
.py
from unittest import mock from django.test import override_settings from django.urls import reverse from readthedocs.builds.constants import EXTERNAL from readthedocs.projects.constants import PRIVATE, PUBLIC from readthedocs.subscriptions.constants import TYPE_CONCURRENT_BUILDS from readthedocs.subscriptions.product...
678
25,480
readthedocs.org
readthedocs/api/v3/tests/test_environmentvariables.py
.py
import django_dynamic_fixture as fixture from django.urls import reverse from django_dynamic_fixture import get from readthedocs.projects.models import EnvironmentVariable from readthedocs.projects.validators import MAX_SIZE_ENV_VARS_PER_PROJECT from .mixins import APIEndpointMixin class EnvironmentVariablessEndpoi...
260
9,113
readthedocs.org
readthedocs/api/v3/tests/test_subprojects.py
.py
from django.test import override_settings from django.urls import reverse from readthedocs.projects.constants import PRIVATE from readthedocs.projects.models import Feature, Project from django_dynamic_fixture import get from .mixins import APIEndpointMixin @override_settings( RTD_ALLOW_ORGANIZATIONS=False, ...
446
16,842
readthedocs.org
readthedocs/api/v3/tests/test_users.py
.py
from django.contrib.contenttypes.models import ContentType from django.test import override_settings from django.urls import reverse from django.urls.exceptions import NoReverseMatch from readthedocs.notifications.models import Notification from readthedocs.subscriptions.constants import TYPE_CONCURRENT_BUILDS from re...
164
5,462
readthedocs.org
readthedocs/api/v3/tests/test_filters.py
.py
""" Tests for API v3 filters. These tests verify that the django-filters on our API endpoints correctly filter querysets. See https://github.com/readthedocs/readthedocs.org/issues/8238 """ from unittest import mock from django.test import override_settings from django.urls import reverse from django_dynamic_fixture ...
171
5,849
readthedocs.org
readthedocs/api/v3/tests/mixins.py
.py
import datetime import json from pathlib import Path import django_dynamic_fixture as fixture from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.core.cache import cache from django.test import TestCase from django.test.utils import override_settings from ...
264
9,117
readthedocs.org
readthedocs/api/v3/tests/test_projects.py
.py
from unittest import mock import django_dynamic_fixture as fixture from django.test import override_settings from django.urls import reverse from django_dynamic_fixture import get from readthedocs.oauth.models import RemoteRepository, RemoteRepositoryRelation from readthedocs.projects.constants import PRIVATE, SINGLE...
994
35,490
readthedocs.org
readthedocs/api/v3/tests/test_remoteorganizations.py
.py
from django.urls import reverse from allauth.socialaccount.models import SocialAccount import django_dynamic_fixture as fixture from readthedocs.oauth.constants import GITHUB from readthedocs.oauth.models import ( RemoteOrganization, RemoteOrganizationRelation, ) from .mixins import APIEndpointMixin class R...
66
2,133
readthedocs.org
readthedocs/api/v3/tests/test_organizations.py
.py
import django_dynamic_fixture as fixture from django.contrib.contenttypes.models import ContentType from django.test import override_settings from django.urls import reverse from django.urls.exceptions import NoReverseMatch from readthedocs.notifications.models import Notification from readthedocs.organizations.models...
198
6,953
readthedocs.org
readthedocs/api/v3/tests/test_redirects.py
.py
from django.urls import reverse from django_dynamic_fixture import get from readthedocs.redirects.constants import ( CLEAN_URL_TO_HTML_REDIRECT, EXACT_REDIRECT, HTML_TO_CLEAN_URL_REDIRECT, ) from readthedocs.redirects.models import Redirect from .mixins import APIEndpointMixin class RedirectsEndpointTes...
411
13,556
readthedocs.org
readthedocs/subscriptions/notifications.py
.py
"""Organization level notifications.""" import textwrap from django.utils.translation import gettext_noop as _ from djstripe import models as djstripe from readthedocs.notifications.constants import INFO from readthedocs.notifications.email import EmailNotification from readthedocs.notifications.messages import Mess...
96
2,965
readthedocs.org
readthedocs/subscriptions/utils.py
.py
"""Utilities to interact with subscriptions and stripe.""" import structlog from django.conf import settings from djstripe import models as djstripe from readthedocs.payments.utils import get_stripe_api_key from readthedocs.payments.utils import get_stripe_client log = structlog.get_logger(__name__) def create_st...
71
2,524
readthedocs.org
readthedocs/subscriptions/event_handlers.py
.py
""" Dj-stripe webhook handlers. https://docs.dj-stripe.dev/en/master/usage/webhooks/. """ import requests import structlog from django.conf import settings from django.contrib.auth.models import User from django.contrib.humanize.templatetags import humanize from django.db.models import Sum from django.utils import ti...
390
15,129
readthedocs.org
readthedocs/subscriptions/querysets.py
.py
""" Querysets for djstripe models. Since djstripe is a third-party app, these are injected at runtime at readthedocs/subscriptions/apps.py. """ from datetime import timedelta from django.db import models from django.utils import timezone from djstripe.enums import SubscriptionStatus from readthedocs.core.querysets ...
34
1,034
readthedocs.org
readthedocs/subscriptions/apps.py
.py
"""Subscriptions app.""" from django.apps import AppConfig class SubscriptionsConfig(AppConfig): """App configuration.""" name = "readthedocs.subscriptions" label = "subscriptions" def ready(self): import readthedocs.subscriptions.event_handlers # noqa import readthedocs.subscripti...
37
1,166
readthedocs.org
readthedocs/subscriptions/constants.py
.py
"""Constants for subscriptions.""" from django.utils.translation import gettext_lazy as _ # Days after the subscription has ended to disable the organization DISABLE_AFTER_DAYS = 30 TYPE_CNAME = "cname" TYPE_CDN = "cdn" TYPE_SSL = "ssl" TYPE_SUPPORT = "support" TYPE_PRIVATE_DOCS = "private_docs" TYPE_EMBED_API = "...
43
1,418
readthedocs.org
readthedocs/subscriptions/views.py
.py
"""Subscriptions views.""" from functools import lru_cache import structlog from django.contrib import messages from django.http import Http404 from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.urls import reverse from django.utils.translation import gettext_lazy ...
207
8,273
readthedocs.org
readthedocs/subscriptions/signals.py
.py
"""Subscriptions signals.""" import stripe import structlog from django.db.models.signals import post_save from django.dispatch import receiver from readthedocs.organizations.models import Organization from readthedocs.payments.utils import get_stripe_client log = structlog.get_logger(__name__) # pylint: disable=...
60
1,969
readthedocs.org
readthedocs/subscriptions/urls.py
.py
from django.urls import path from readthedocs.subscriptions.views import DetailSubscription from readthedocs.subscriptions.views import StripeCustomerPortal urlpatterns = [ path( "", DetailSubscription.as_view(), name="subscription_detail", ), path( "portal", Strip...
19
395
readthedocs.org
readthedocs/subscriptions/products.py
.py
""" Read the Docs products. This module contains the dataclasses that represent the products available. The available products are defined in the ``RTD_PRODUCTS`` setting. """ import copy from dataclasses import dataclass from django.conf import settings from readthedocs.subscriptions.constants import FEATURE_TYPES...
156
5,463
readthedocs.org
readthedocs/subscriptions/forms.py
.py
"""Subscriptions forms.""" from django import forms from django.utils.translation import gettext_lazy as _ from djstripe import models as djstripe from readthedocs.subscriptions.products import get_listed_products class PlanForm(forms.Form): """Form to create a subscription after the previous one has ended.""" ...
31
1,075
readthedocs.org
readthedocs/subscriptions/tasks.py
.py
"""Organization tasks.""" import datetime import structlog from django.contrib.auth.models import User from django.db.models import Count from django.utils import timezone from djstripe import models as djstripe from readthedocs.builds.models import Build from readthedocs.core.utils import send_email from readthedoc...
113
3,935
readthedocs.org
readthedocs/subscriptions/tests/test_views.py
.py
from unittest import mock import requests_mock from django.conf import settings from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.urls import reverse from django.utils import timezone from django_dynamic_fixture import get from djstripe import models as djstrip...
226
8,740
readthedocs.org
readthedocs/subscriptions/tests/test_tasks.py
.py
from datetime import timedelta from unittest import mock import django_dynamic_fixture as fixture from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.utils import timezone from django_dynamic_fixture import get from djstripe import models as djstripe from djstrip...
126
3,943
readthedocs.org
readthedocs/subscriptions/tests/test_products.py
.py
from django.test import TestCase from readthedocs.subscriptions.constants import TYPE_AUDIT_LOGS, TYPE_CONCURRENT_BUILDS from readthedocs.subscriptions.products import RTDProductFeature class TestRTDProductFeature(TestCase): def test_add_feature(self): feature_a = RTDProductFeature(TYPE_CONCURRENT_BUILDS...
53
2,073
readthedocs.org
readthedocs/subscriptions/tests/test_event_handlers.py
.py
from unittest import mock from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.utils import timezone from django_dynamic_fixture import get from djstripe import models as djstripe from djstripe import webhooks from djstripe.enums import SubscriptionStatus from re...
541
18,290
readthedocs.org
readthedocs/subscriptions/tests/test_signals.py
.py
from unittest import mock from django.contrib.auth.models import User from django.test import TestCase from django_dynamic_fixture import get from djstripe import models as djstripe from readthedocs.organizations.models import Organization from readthedocs.payments.tests.utils import PaymentMixin class TestSignals(...
77
2,624
readthedocs.org
readthedocs/notifications/email.py
.py
"""Email notifications.""" import structlog from django.conf import settings from django.db import models from django.template import Context from django.template import Template from django.template.loader import render_to_string from readthedocs.core.context_processors import readthedocs_processor from readthedocs....
98
3,077
readthedocs.org
readthedocs/notifications/admin.py
.py
"""Notifications admin.""" from django.contrib import admin from readthedocs.notifications.models import Notification @admin.register(Notification) class NotificationAdmin(admin.ModelAdmin): search_fields = ("message_id",) list_filter = ("state",) list_display = ( "id", "message_id", ...
18
376
readthedocs.org
readthedocs/notifications/exceptions.py
.py
from django.utils.translation import gettext_lazy as _ class NotificationBaseException(Exception): """ The base exception class for notification and messages. This provides the additional ``message_id`` and ``format_values`` attributes that are used for message display and registry lookup. """ ...
18
611
readthedocs.org
readthedocs/notifications/models.py
.py
import structlog from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models from django.urls import reverse from django.utils.translation import gettext_noop as _ from django_extensions.db.models import TimeStampedModel from ...
136
4,745
readthedocs.org
readthedocs/notifications/querysets.py
.py
from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.db import models from django.utils import timezone from readthedocs.core.permissions import AdminPermission from readthedocs.core.querysets import NoReprQuerySet from .constants import CANCELLED from .co...
158
6,029
readthedocs.org
readthedocs/notifications/apps.py
.py
"""Django app configuration for the notifications app.""" from django.apps import AppConfig class NotificationsAppConfig(AppConfig): name = "readthedocs.notifications" verbose_name = "Notifications" def ready(self): import readthedocs.notifications.signals # noqa
12
289
readthedocs.org
readthedocs/notifications/constants.py
.py
"""Notification constants.""" TEXT = "txt" HTML = "html" INFO = 0 WARNING = 1 REQUIREMENT = 2 ERROR = 3 # TODO: use Enum here for these ones # Status UNREAD = "unread" READ = "read" DISMISSED = "dismissed" CANCELLED = "cancelled" # Type ERROR = "error" WARNING = "warning" INFO = "info" NOTE = "note" TIP = "tip"
24
317
readthedocs.org
readthedocs/notifications/signals.py
.py
"""Custom Django signals related to notifications.""" import structlog from allauth.account.models import EmailAddress from django.db.models.signals import post_save from django.dispatch import receiver from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING from readthedocs.notifications.models i...
79
2,786
readthedocs.org
readthedocs/notifications/messages.py
.py
import copy import textwrap import structlog from django.template import Context from django.template import Template from django.utils.translation import gettext_noop as _ from readthedocs.core.context_processors import readthedocs_processor from readthedocs.doc_builder.exceptions import BuildAppError from readthedo...
590
20,275
readthedocs.org
readthedocs/notifications/tests/test_querysets.py
.py
import django_dynamic_fixture as fixture import pytest from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING from readthedocs.notifications.constants import CANCELLED, DISMISSED, READ, UNREAD fr...
154
4,722
readthedocs.org
readthedocs/notifications/tests/test_messages.py
.py
from readthedocs.notifications.constants import INFO from readthedocs.notifications.messages import Message class TestMessage: def test_xss_protection(self): message = Message( id="test", header="XSS: {{header}}", body="XSS: {{body}}", type=INFO, ) ...
33
1,018
readthedocs.org
readthedocs/notifications/tests/test_signals.py
.py
import django_dynamic_fixture as fixture from allauth.account.models import EmailAddress from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.test import TestCase from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING from readthedocs.n...
92
3,458
readthedocs.org
readthedocs/notifications/templatetags/notifications_filters.py
.py
from django import template register = template.Library() @register.filter def to_class_name(value): """Output the name of the class for the given object.""" return value.__class__.__name__
11
202
readthedocs.org
readthedocs/metrics/tasks.py
.py
""" Specific metric tasks for community. Override the base metric tasks to add specific ones only required on community. """ # Disable import error because -ext is not available on pylint # pylint: disable=import-error from readthedocsext.monitoring.metrics.database import AvgBuildTimeMetric from readthedocsext.monit...
45
1,746
readthedocs.org
readthedocs/organizations/utils.py
.py
"""Utilities for organizations.""" import structlog from readthedocs.core.utils import send_email log = structlog.get_logger(__name__) def send_team_add_email(team_member, request): """Send an organization team add email.""" log.info( "Sending team add notification.", team=team_member.team...
31
895
readthedocs.org
readthedocs/organizations/models.py
.py
"""Organizations models.""" from pathlib import Path from uuid import uuid4 import structlog from autoslug import AutoSlugField from django.conf import settings from django.contrib.auth.models import User from django.contrib.contenttypes.fields import GenericRelation from django.contrib.contenttypes.models import Con...
526
15,567
readthedocs.org
readthedocs/organizations/querysets.py
.py
"""Organizations querysets.""" from datetime import timedelta from django.conf import settings from django.db import models from django.db.models import Count from django.db.models import Q from django.utils import timezone from djstripe.enums import InvoiceStatus from djstripe.enums import SubscriptionStatus from r...
151
5,659
readthedocs.org
readthedocs/organizations/apps.py
.py
"""Organizations app.""" from django.apps import AppConfig class OrganizationsConfig(AppConfig): name = "readthedocs.organizations" def ready(self): import readthedocs.organizations.signals # noqa
11
218
readthedocs.org
readthedocs/organizations/filters.py
.py
"""Filters used in the organization dashboard views.""" import structlog from django.db.models import F from django.utils.translation import gettext_lazy as _ from django_filters import ChoiceFilter from django_filters import OrderingFilter from readthedocs.core.filters import FilteredModelChoiceFilter from readthedo...
243
8,276
readthedocs.org
readthedocs/organizations/constants.py
.py
"""Constants for ACL.""" from django.utils.translation import gettext_lazy as _ READ_ONLY_ACCESS = "readonly" ADMIN_ACCESS = "admin" ACCESS_LEVELS = ( (READ_ONLY_ACCESS, _("Read-only")), (ADMIN_ACCESS, _("Admin")), )
13
229
readthedocs.org
readthedocs/organizations/signals.py
.py
"""Organization signals.""" import structlog from allauth.account.signals import user_signed_up from django.db.models.signals import post_save from django.db.models.signals import pre_delete from django.dispatch import receiver from djstripe.enums import SubscriptionStatus from readthedocs.builds.constants import BUI...
82
2,696
readthedocs.org
readthedocs/organizations/managers.py
.py
"""Organizations managers.""" from django.db import models from readthedocs.core.utils.extend import SettingsOverrideObject from .constants import ADMIN_ACCESS from .constants import READ_ONLY_ACCESS class TeamManagerBase(models.Manager): """Manager to control team's access.""" def teams_for_user(self, us...
71
1,816
readthedocs.org
readthedocs/organizations/forms.py
.py
"""Organization forms.""" from django import forms from django.contrib.auth.models import User from django.core.exceptions import NON_FIELD_ERRORS from django.core.exceptions import ValidationError from django.core.validators import EmailValidator from django.utils.translation import gettext_lazy as _ from PIL import ...
308
11,119
readthedocs.org
readthedocs/organizations/urls/public.py
.py
"""URLs that don't require login.""" from django.urls import path from django.urls import re_path from readthedocs.organizations.views import public as views urlpatterns = [ path( "verify-email/", views.OrganizationTemplateView.as_view(template_name="organizations/verify_email.html"), na...
43
1,147
readthedocs.org
readthedocs/organizations/urls/private.py
.py
"""URLs that require login.""" from django.urls import path from django.urls import re_path from readthedocs.core.views import PageNotFoundView from readthedocs.organizations.views import private as views urlpatterns = [ path( "", views.ListOrganization.as_view(), name="organization_list...
97
2,920
readthedocs.org
readthedocs/organizations/tests/test_views.py
.py
import csv from django.core.files.uploadedfile import SimpleUploadedFile import io import itertools from unittest import mock from django.contrib.auth.models import User from django.core.cache import cache from django.test import TestCase from django.test.utils import override_settings from django.urls import reverse ...
623
23,699
readthedocs.org
readthedocs/organizations/tests/test_privacy_urls.py
.py
from django.contrib.auth.models import User from django.test import TestCase, override_settings from django_dynamic_fixture import get from readthedocs.organizations.models import Organization, Team, TeamInvite from readthedocs.rtd_tests.tests.test_privacy_urls import URLAccessMixin class OrganizationMixin(URLAccess...
87
2,983
readthedocs.org
readthedocs/organizations/tests/test_querysets.py
.py
from datetime import timedelta from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.utils import timezone from django_dynamic_fixture import get from djstripe import models as djstripe from djstripe.enums import InvoiceStatus, SubscriptionStatus from readthedocs....
222
7,471
readthedocs.org
readthedocs/organizations/tests/test_access.py
.py
import django_dynamic_fixture as fixture from django.contrib.auth.models import User from django.test import TestCase, override_settings from readthedocs.invitations.models import Invitation from readthedocs.organizations.models import Organization, OrganizationOwner, Team from readthedocs.projects.models import Proje...
239
8,563
readthedocs.org
readthedocs/organizations/tests/test_forms.py
.py
import django_dynamic_fixture as fixture from allauth.account.models import EmailAddress from django_dynamic_fixture import get from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.urls import reverse from readthedocs.invitations.models import Invitation from read...
256
9,787
readthedocs.org
readthedocs/organizations/tests/test_orgs.py
.py
from unittest import mock import django_dynamic_fixture as fixture from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.urls import reverse from django_dynamic_fixture import get from readthedocs.builds.models import Build, Version from readthedocs.invitations.mo...
465
16,780
readthedocs.org
readthedocs/organizations/tests/test_filters.py
.py
import django_dynamic_fixture as fixture import pytest from django.contrib.auth.models import User from django.urls import reverse from pytest_django.asserts import assertQuerySetEqual from readthedocs.organizations.models import Organization, Team from readthedocs.projects.models import Project @pytest.mark.django_...
600
18,910
readthedocs.org
readthedocs/organizations/views/public.py
.py
"""Views that don't require login.""" # pylint: disable=too-many-ancestors import structlog from django.http import HttpResponseRedirect from django.urls import reverse from django.urls import reverse_lazy from django.views.generic.base import TemplateView from vanilla import DetailView from vanilla import GenericView...
130
4,538
readthedocs.org
readthedocs/organizations/views/private.py
.py
"""Views that require login.""" # pylint: disable=too-many-ancestors from django.conf import settings from django.contrib import messages from django.http import HttpResponseBadRequest from django.shortcuts import redirect from django.urls import reverse from django.urls import reverse_lazy from django.utils import ti...
325
11,828
readthedocs.org
readthedocs/organizations/views/base.py
.py
"""Base classes for organization views.""" from functools import lru_cache from django.conf import settings from django.contrib.messages.views import SuccessMessageMixin from django.http import Http404 from django.shortcuts import get_object_or_404 from django.shortcuts import render from django.urls import reverse_l...
283
9,211
readthedocs.org
readthedocs/organizations/templatetags/organizations.py
.py
"""Tags for organization template queries.""" from django import template from django.contrib.auth.models import User from django.core.exceptions import FieldError from readthedocs.core.permissions import AdminPermission from readthedocs.organizations.models import Organization from readthedocs.organizations.models i...
77
2,064
readthedocs.org
readthedocs/builds/version_slug.py
.py
""" Contains logic for handling version slugs. Handling slugs for versions is not too straightforward. We need to allow some characters which are uncommon in usual slugs. They are dots and underscores. Usually we want the slug to be the name of the tag or branch corresponding VCS version. However we need to strip url-...
129
4,236
readthedocs.org
readthedocs/builds/signals_receivers.py
.py
""" Receiver signals for the Builds app. NOTE: Done in a separate file to avoid circular imports. """ import structlog from django.db.models.signals import post_save from django.dispatch import receiver from readthedocs.builds.models import Build from readthedocs.projects.models import Project log = structlog.get_...
25
648
readthedocs.org
readthedocs/builds/admin.py
.py
"""Django admin interface for `~builds.models.Build` and related models.""" from django.contrib import admin from django.contrib import messages from readthedocs.builds.models import Build from readthedocs.builds.models import BuildCommandResult from readthedocs.builds.models import BuildConfig from readthedocs.build...
140
4,277
readthedocs.org
readthedocs/builds/utils.py
.py
"""Utilities for the builds app.""" from contextlib import contextmanager from time import monotonic from django.core.cache import cache from readthedocs.builds.constants import EXTERNAL from readthedocs.builds.constants import GENERIC_EXTERNAL_VERSION_NAME from readthedocs.builds.constants import GITHUB_EXTERNAL_VE...
119
3,962
readthedocs.org
readthedocs/builds/reporting.py
.py
from dataclasses import dataclass from django.conf import settings from django.template.loader import render_to_string from readthedocs.builds.models import Build from readthedocs.filetreediff import get_diff from readthedocs.filetreediff.dataclasses import FileTreeDiff @dataclass class BuildOverview: content: ...
55
1,554
readthedocs.org
readthedocs/builds/storage.py
.py
from django.contrib.staticfiles.storage import StaticFilesStorage as BaseStaticFilesStorage from readthedocs.storage.filesystem import RTDFileSystemStorage class BuildMediaFileSystemStorage(RTDFileSystemStorage): # Root path of the nginx internal redirect # that will serve files from this storage. intern...
16
551
readthedocs.org
readthedocs/builds/automation_actions.py
.py
""" Actions used for the automation rules. Each function will receive the following args: - version: The version object where the action will be applied - action_arg: An additional argument to apply the action """ import structlog from readthedocs.core.utils import trigger_build from readthedocs.projects.constants ...
85
2,192
readthedocs.org
readthedocs/builds/models.py
.py
"""Models for the builds app.""" import datetime import json import os.path import re from functools import partial from io import BytesIO import structlog from django.conf import settings from django.contrib.contenttypes.fields import GenericRelation from django.db import models from django.urls import reverse from ...
1,191
42,139
readthedocs.org
readthedocs/builds/querysets.py
.py
"""Build and Version QuerySet classes.""" import datetime import structlog from django.db import models from django.db.models import Q from django.utils import timezone from readthedocs.builds.constants import BUILD_STATE_CANCELLED from readthedocs.builds.constants import BUILD_STATE_FINISHED from readthedocs.builds...
321
10,896
readthedocs.org
readthedocs/builds/constants_docker.py
.py
""" Define constants here to allow import them without any external dependency. There are situations where we want to have access to these values without Django installed (e.g. common/dockerfiles/tasks.py) Note these constants where previously defined as Django settings in ``readthedocs/settings/base.py``. """ DOCKE...
111
4,097
readthedocs.org
readthedocs/builds/apps.py
.py
"""Django configuration for readthedocs.builds application.""" import structlog from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ log = structlog.get_logger(__name__) class Config(AppConfig): name = "readthedocs.builds" label = "builds" verbose_name = _("Builds") ...
19
450
readthedocs.org
readthedocs/builds/filters.py
.py
"""Filters used in project dashboard.""" import structlog from django.utils.translation import gettext_lazy as _ from django_filters import ChoiceFilter from readthedocs.builds.constants import BUILD_FINAL_STATES from readthedocs.builds.constants import BUILD_STATE_FINISHED from readthedocs.builds.constants import EX...
92
2,939
readthedocs.org
readthedocs/builds/constants.py
.py
"""Constants for the builds app.""" from django.conf import settings from django.utils.translation import gettext_lazy as _ # BUILD_STATE is our *INTERNAL* representation of build states. # This is not to be confused with external representations of 'status' # that are sent back to Git providers. BUILD_STATE_TRIGGER...
196
6,086
readthedocs.org
readthedocs/builds/views.py
.py
"""Views for builds app.""" import textwrap from urllib.parse import urlparse import structlog from django.contrib.auth.decorators import login_required from django.http import HttpResponseForbidden from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.urls import rev...
160
4,956
readthedocs.org
readthedocs/builds/signals.py
.py
"""Build signals.""" import django.dispatch # Useful to know when to purge the footer version_changed = django.dispatch.Signal()
8
132
readthedocs.org
readthedocs/builds/urls.py
.py
"""URL configuration for builds app.""" from django.urls import path from django.views.generic.base import RedirectView urlpatterns = [ path( "<slug:project_slug>/<int:build_pk>/", RedirectView.as_view(pattern_name="builds_detail", permanent=True), name="old_builds_detail", ), pat...
19
486