id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8,000 | stack_context.py | CouchPotato_CouchPotatoServer/libs/tornado/stack_context.py | #!/usr/bin/env python
#
# Copyright 2010 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | 13,174 | Python | .tac | 305 | 34.314754 | 94 | 0.643125 | CouchPotato/CouchPotatoServer | 3,869 | 1,214 | 1,266 | GPL-3.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,001 | manage.py | mdn_kuma/manage.py | #!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kuma.settings.local")
try:
from django.core.management import execute_from_command_line
except I... | 666 | Python | .py | 18 | 31.111111 | 74 | 0.677019 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,002 | conf.py | mdn_kuma/docs/conf.py | #
# Kuma documentation build configuration file, created by
# sphinx-quickstart on Mon Aug 5 15:41:51 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have ... | 8,656 | Python | .py | 208 | 39.225962 | 80 | 0.703447 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,003 | conftest.py | mdn_kuma/kuma/conftest.py | import pytest
import requests_mock
from django.contrib.auth.models import Group
from django.core.cache import caches
from django.urls import set_urlconf
from django.utils import timezone
from django.utils.translation import activate
from kuma.users.models import UserProfile
@pytest.fixture(autouse=True)
def clear_ca... | 2,954 | Python | .py | 79 | 33.329114 | 79 | 0.744129 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,004 | celery.py | mdn_kuma/kuma/celery.py | import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kuma.settings.local")
app = Celery("kuma")
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - names... | 1,004 | Python | .py | 24 | 39.083333 | 70 | 0.752577 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,005 | urls.py | mdn_kuma/kuma/urls.py | from django.conf import settings
from django.contrib import admin
from django.urls import include, path, re_path
from django.views.decorators.cache import never_cache
from django.views.generic import RedirectView
from kuma.attachments import views as attachment_views
from kuma.core import views as core_views
from kuma... | 2,136 | Python | .py | 59 | 31.322034 | 108 | 0.672147 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,006 | __init__.py | mdn_kuma/kuma/__init__.py | # This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ("celery_app",)
| 174 | Python | .py | 4 | 42.25 | 54 | 0.745562 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,007 | wsgi.py | mdn_kuma/kuma/wsgi.py | """
WSGI config for kuma project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTING... | 392 | Python | .py | 10 | 37.6 | 78 | 0.800532 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,008 | models.py | mdn_kuma/kuma/plus/models.py | from uuid import uuid4
from django.db import models
class LandingPageSurvey(models.Model):
uuid = models.UUIDField(default=uuid4, editable=False, primary_key=True)
# An insecure random string so that when a survey is submitted with more information
# it can not easily be guessed and the ratelimit will ma... | 651 | Python | .py | 13 | 45.384615 | 88 | 0.755521 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,009 | apps.py | mdn_kuma/kuma/plus/apps.py | from django.apps import AppConfig
class PlusConfig(AppConfig):
name = "kuma.plus"
verbose_name = "Plus"
| 114 | Python | .py | 4 | 25 | 33 | 0.740741 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,010 | admin.py | mdn_kuma/kuma/plus/admin.py | from django.contrib import admin
from .models import LandingPageSurvey
class HasResponseFilter(admin.SimpleListFilter):
title = "Has response"
parameter_name = "has_response"
def lookups(self, request, model_admin):
return (
("true", "Has response"),
("false", "No respons... | 1,253 | Python | .py | 41 | 23.536585 | 59 | 0.614488 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,011 | 0001_initial.py | mdn_kuma/kuma/plus/migrations/0001_initial.py | # Generated by Django 3.2.5 on 2021-07-09 21:00
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
... | 1,471 | Python | .py | 40 | 22.4 | 81 | 0.496489 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,012 | 0002_auto_20210723_1901.py | mdn_kuma/kuma/plus/migrations/0002_auto_20210723_1901.py | # Generated by Django 3.2.5 on 2021-07-23 19:01
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("plus", "0001_initial"),
]
operations = [
migrations.RemoveField(
model_name="landingpagesurvey",
name="email",
),
... | 551 | Python | .py | 20 | 19.1 | 47 | 0.572243 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,013 | models.py | mdn_kuma/kuma/users/models.py | import json
from django.contrib.auth import get_user_model
from django.db import models
class UserProfile(models.Model):
class SubscriptionType(models.TextChoices):
"""Choices for MDN Subscription Types, add new subscription plans to be supported here"""
MDN_PLUS_5M = "mdn_plus_5m", "MDN Plus 5M... | 2,830 | Python | .py | 65 | 35.892308 | 97 | 0.66315 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,014 | checks.py | mdn_kuma/kuma/users/checks.py | from urllib.parse import urljoin, urlparse
from django.conf import settings
from django.core.checks import Error, Warning
from kuma.core.utils import requests_retry_session
MISSING_OIDC_RP_CLIENT_ID_ERROR = "kuma.users.E001"
MISSING_OIDC_RP_CLIENT_SECRET_ERROR = "kuma.users.E002"
MISSING_OIDC_CONFIGURATION_ERROR = "... | 3,540 | Python | .py | 82 | 33.792683 | 128 | 0.611095 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,015 | tasks.py | mdn_kuma/kuma/users/tasks.py | import json
from celery import task
from django.contrib.auth import get_user_model
from kuma.users.auth import KumaOIDCAuthenticationBackend
from kuma.users.models import AccountEvent, UserProfile
from kuma.users.utils import get_valid_subscription_type_or_none
@task
def process_event_delete_user(event_id):
eve... | 2,991 | Python | .py | 82 | 29.658537 | 69 | 0.68144 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,016 | apps.py | mdn_kuma/kuma/users/apps.py | from django.apps import AppConfig
from django.core.checks import register
from django.utils.translation import gettext_lazy as _
class UsersConfig(AppConfig):
name = "kuma.users"
verbose_name = _("Users")
def ready(self):
self.register_checks()
def register_checks(self):
from .checks... | 383 | Python | .py | 11 | 29.727273 | 54 | 0.72752 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,017 | auth.py | mdn_kuma/kuma/users/auth.py | import time
import requests
from django.conf import settings
from django.contrib.auth import get_user_model
from mozilla_django_oidc.auth import OIDCAuthenticationBackend
from kuma.users.utils import get_valid_subscription_type_or_none
from .models import UserProfile
class KumaOIDCAuthenticationBackend(OIDCAuthent... | 4,910 | Python | .py | 119 | 32.680672 | 86 | 0.63108 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,018 | utils.py | mdn_kuma/kuma/users/utils.py | from kuma.users.models import UserProfile
# Finds union of valid subscription id's from input and UserProfile.SubscriptionType.values
# Should only be mdn_plus + one of 'SubscriptionType.values'
def get_valid_subscription_type_or_none(input):
subscription_types = list(set(input) & set(UserProfile.SubscriptionType... | 633 | Python | .py | 10 | 58.4 | 91 | 0.762903 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,019 | middleware.py | mdn_kuma/kuma/users/middleware.py | import time
from django.conf import settings
from django.contrib.auth import logout
from django.core.exceptions import MiddlewareNotUsed
from mozilla_django_oidc.middleware import SessionRefresh
from kuma.users.auth import KumaOIDCAuthenticationBackend
class ValidateAccessTokenMiddleware(SessionRefresh):
"""Val... | 1,572 | Python | .py | 36 | 33.916667 | 76 | 0.651148 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,020 | views.py | mdn_kuma/kuma/users/views.py | import json
import requests
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.exceptions import SuspiciousOperation
from django.http import Http404, HttpResponse
from django.utils.decorators import method_decorator
from django.utils.encoding import force_bytes
from django... | 6,984 | Python | .py | 162 | 32.845679 | 83 | 0.625055 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,021 | 0004_remove_userprofile_fxa_uid.py | mdn_kuma/kuma/users/migrations/0004_remove_userprofile_fxa_uid.py | # Generated by Django 3.2.7 on 2021-10-20 07:25
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("users", "0003_auto_20211014_1214"),
]
operations = [
migrations.RemoveField(
model_name="userprofile",
name="fxa_uid",
... | 332 | Python | .py | 12 | 20.916667 | 47 | 0.612698 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,022 | 0005_userprofile_is_subscriber.py | mdn_kuma/kuma/users/migrations/0005_userprofile_is_subscriber.py | # Generated by Django 3.2.7 on 2021-12-15 12:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0004_remove_userprofile_fxa_uid"),
]
operations = [
migrations.AddField(
model_name="userprofile",
name="is... | 405 | Python | .py | 13 | 23.923077 | 53 | 0.630491 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,023 | 0003_auto_20211014_1214.py | mdn_kuma/kuma/users/migrations/0003_auto_20211014_1214.py | # Generated by Django 3.2.7 on 2021-10-14 12:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0002_auto_20210922_1159"),
]
operations = [
migrations.RemoveField(
model_name="userprofile",
name="claims"... | 711 | Python | .py | 22 | 23.454545 | 75 | 0.583333 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,024 | 0001_initial.py | mdn_kuma/kuma/users/migrations/0001_initial.py | # Generated by Django 3.2.5 on 2021-08-05 12:47
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
ope... | 1,569 | Python | .py | 44 | 20.886364 | 72 | 0.472679 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,025 | 0007_userprofile_subscription_type.py | mdn_kuma/kuma/users/migrations/0007_userprofile_subscription_type.py | # Generated by Django 3.2.10 on 2022-03-03 13:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0006_accountevent"),
]
operations = [
migrations.AddField(
model_name="userprofile",
name="subscription_ty... | 772 | Python | .py | 24 | 19.791667 | 53 | 0.454913 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,026 | 0006_accountevent.py | mdn_kuma/kuma/users/migrations/0006_accountevent.py | # Generated by Django 3.2.10 on 2021-12-27 09:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0005_userprofile_is_subscriber"),
]
operations = [
migrations.CreateModel(
name="AccountEvent",
fields=[
... | 2,117 | Python | .py | 56 | 19.285714 | 87 | 0.377432 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,027 | 0002_auto_20210922_1159.py | mdn_kuma/kuma/users/migrations/0002_auto_20210922_1159.py | # Generated by Django 3.2.7 on 2021-09-22 11:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0001_initial"),
]
operations = [
migrations.RemoveField(
model_name="userprofile",
name="is_subscriber",
... | 648 | Python | .py | 21 | 22.190476 | 87 | 0.585209 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,028 | test_auth.py | mdn_kuma/kuma/users/tests/test_auth.py | from django.test import RequestFactory
from kuma.users.auth import logout_url
# TODO: Check which new tests are needed.
def test_logout_url(settings):
request = RequestFactory().get("/some/path")
request.session = {}
url = logout_url(request)
assert url == "/"
request = RequestFactory().get("/so... | 720 | Python | .py | 20 | 31.5 | 59 | 0.675793 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,029 | test_tasks.py | mdn_kuma/kuma/users/tests/test_tasks.py | import pytest
from kuma.users.models import AccountEvent, UserProfile
from kuma.users.tasks import process_event_subscription_state_change
@pytest.mark.django_db
def test_process_event_subscription_state_change(wiki_user):
profile = UserProfile.objects.create(user=wiki_user)
assert profile.subscription_type... | 3,381 | Python | .py | 76 | 38.513158 | 97 | 0.725221 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,030 | test_views.py | mdn_kuma/kuma/users/tests/test_views.py | import urllib
import pytest
from django.urls import reverse
@pytest.mark.django_db
@pytest.mark.parametrize(
"email", (None, "ringo@beatles.com"), ids=("without-email", "with-email")
)
def test_no_prompt_login(client, settings, email):
params = {}
if email:
params.update(email=email)
response... | 737 | Python | .py | 21 | 30.714286 | 77 | 0.71669 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,031 | test_checks.py | mdn_kuma/kuma/users/tests/test_checks.py | from kuma.users.checks import (
MISSING_OIDC_CONFIGURATION_ERROR,
MISSING_OIDC_RP_CLIENT_ID_ERROR,
MISSING_OIDC_RP_CLIENT_SECRET_ERROR,
oidc_config_check,
)
def test_happy_path_config_check(mock_requests, settings):
mock_requests.register_uri(
"GET",
settings.OIDC_CONFIGURATION_URL... | 2,616 | Python | .py | 62 | 34.806452 | 88 | 0.668765 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,032 | pytest.py | mdn_kuma/kuma/settings/pytest.py | from .local import *
DEBUG = False
ENABLE_RESTRICTIONS_BY_HOST = False
TEMPLATES[0]["OPTIONS"]["debug"] = True # Enable recording of templates
CELERY_TASK_ALWAYS_EAGER = True
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
ES_LIVE_INDEX = config("ES_LIVE_INDEX", default=False, cast=bool)
# Always make sure we never test a... | 2,797 | Python | .py | 66 | 39.969697 | 87 | 0.74871 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,033 | prod.py | mdn_kuma/kuma/settings/prod.py | from .common import *
ATTACHMENT_HOST = config("ATTACHMENT_HOST", default="mdn.mozillademos.org")
ALLOW_ROBOTS = config("ALLOW_ROBOTS", default=True, cast=bool)
# Email
DEFAULT_FROM_EMAIL = config(
"DEFAULT_FROM_EMAIL", default="no-reply@developer.mozilla.org"
)
SERVER_EMAIL = config("SERVER_EMAIL", default="mdn-... | 802 | Python | .py | 17 | 45.352941 | 83 | 0.741977 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,034 | local.py | mdn_kuma/kuma/settings/local.py | from .common import *
# Settings for Docker Development
INTERNAL_IPS = ("127.0.0.1",)
# Default DEBUG to True, and recompute derived settings
DEBUG = config("DEBUG", default=True, cast=bool)
DEBUG_PROPAGATE_EXCEPTIONS = config(
"DEBUG_PROPAGATE_EXCEPTIONS", default=DEBUG, cast=bool
)
PROTOCOL = config("PROTOCOL... | 465 | Python | .py | 11 | 40.545455 | 64 | 0.753333 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,035 | common.py | mdn_kuma/kuma/settings/common.py | import json
from collections import namedtuple
from email.utils import parseaddr
from pathlib import Path
import dj_database_url
import sentry_sdk
from decouple import Csv, config
from sentry_sdk.integrations.django import DjangoIntegration
DEBUG = config("DEBUG", default=False, cast=bool)
DEV = config("DEV", cast=bo... | 21,063 | Python | .py | 502 | 38.585657 | 127 | 0.723161 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,036 | admin_urls.py | mdn_kuma/kuma/api/admin_urls.py | from django.urls import path
from kuma.api.v1.api import admin_api
from kuma.api.v1.plus.notifications import admin_router
admin_api.add_router("/", admin_router)
urlpatterns = [
path("", admin_api.urls),
]
| 214 | Python | .py | 7 | 28.571429 | 55 | 0.764706 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,037 | urls.py | mdn_kuma/kuma/api/urls.py | from django.urls import include, re_path
urlpatterns = [
re_path("^v1/", include("kuma.api.v1.urls")),
]
| 110 | Python | .py | 4 | 25.25 | 49 | 0.685714 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,038 | apps.py | mdn_kuma/kuma/api/apps.py | from django.apps import AppConfig
from django.conf import settings
from elasticsearch_dsl.connections import connections
class APIConfig(AppConfig):
"""
The Django App Config class to store information about the API app
and do startup time things.
"""
name = "kuma.api"
verbose_name = "API"
... | 500 | Python | .py | 15 | 27.8 | 70 | 0.70894 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,039 | pagination.py | mdn_kuma/kuma/api/v1/pagination.py | from __future__ import annotations
from typing import Generic, TypeVar
from django.conf import settings
from django.db.models import QuerySet
from django.http import HttpRequest
from django.middleware.csrf import get_token
from ninja import Field
from ninja.pagination import LimitOffsetPagination
from ninja.schema im... | 1,679 | Python | .py | 43 | 34.55814 | 78 | 0.766996 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,040 | urls.py | mdn_kuma/kuma/api/v1/urls.py | from django.urls import path
from . import search
from .api import api
from .plus.bookmarks import router as bookmarks_router
from .plus.landing_page import router as landing_page_router
from .plus.notifications import notifications_router, watch_router
from .views import settings_router
api.add_router("/settings", s... | 722 | Python | .py | 17 | 40.588235 | 72 | 0.769231 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,041 | api.py | mdn_kuma/kuma/api/v1/api.py | from django.http import HttpResponse
from django.utils.cache import add_never_cache_headers
from ninja import NinjaAPI
from ratelimit.exceptions import Ratelimited
from .auth import admin_auth, profile_auth
class NoCacheNinjaAPI(NinjaAPI):
def create_response(self, *args, **kwargs) -> HttpResponse:
respo... | 761 | Python | .py | 17 | 41.176471 | 83 | 0.764946 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,042 | auth.py | mdn_kuma/kuma/api/v1/auth.py | from __future__ import annotations
from typing import Any
from django.conf import settings
from django.http import HttpRequest
from ninja.security import HttpBearer, SessionAuth
from kuma.users.auth import KumaOIDCAuthenticationBackend, is_authorized_request
from kuma.users.models import UserProfile
class NotASubs... | 2,083 | Python | .py | 54 | 31.055556 | 85 | 0.686783 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,043 | decorators.py | mdn_kuma/kuma/api/v1/decorators.py | from functools import wraps
from django.http import HttpResponseForbidden
from .auth import NotASubscriber, is_subscriber
def allow_CORS_GET(func):
"""Decorator to allow CORS for GET requests"""
@wraps(func)
def inner(request, *args, **kwargs):
response = func(request, *args, **kwargs)
... | 1,115 | Python | .py | 28 | 33.214286 | 65 | 0.679368 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,044 | smarter_schema.py | mdn_kuma/kuma/api/v1/smarter_schema.py | """
Since "Model" word would be very confusing when used in django context, this
module basically makes an alias for it named "Schema" and adds extra whistles to
be able to work with django querysets and managers.
The schema is a bit smarter than a standard pydantic Model because it can handle
dotted attributes and re... | 4,392 | Python | .py | 106 | 32.075472 | 82 | 0.610329 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,045 | forms.py | mdn_kuma/kuma/api/v1/forms.py | from django import forms
from django.conf import settings
class AccountSettingsForm(forms.Form):
locale = forms.ChoiceField(
required=False,
# The `settings.LANGUAGES` looks like this:
# [('en-US', 'English (US)'), ...]
# But the valid choices actually come from Yari which is the... | 582 | Python | .py | 13 | 38.076923 | 73 | 0.66843 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,046 | views.py | mdn_kuma/kuma/api/v1/views.py | from typing import Literal, Optional, Union
from django.conf import settings
from django.middleware.csrf import get_token
from ninja import Router, Schema
from kuma.api.v1.auth import profile_auth
from kuma.api.v1.forms import AccountSettingsForm
from kuma.api.v1.plus.notifications import Ok
from kuma.users.models im... | 3,187 | Python | .py | 89 | 30.258427 | 84 | 0.697364 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,047 | bookmarks.py | mdn_kuma/kuma/api/v1/plus/bookmarks.py | from datetime import datetime
from typing import Optional, Union
from django.conf import settings
from django.db.models import Case, CharField, F, Q, When
from django.db.models.functions import Cast
from django.middleware.csrf import get_token
from django.utils import timezone
from ninja import Field, Form, Query, Rou... | 7,783 | Python | .py | 206 | 30.436893 | 97 | 0.659411 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,048 | landing_page.py | mdn_kuma/kuma/api/v1/plus/landing_page.py | from uuid import UUID
from django.middleware.csrf import get_token
from django.shortcuts import get_object_or_404
from ninja import Form, Router
from pydantic import Json
from ratelimit.decorators import ratelimit
from kuma.api.v1.plus.notifications import Ok
from kuma.plus.models import LandingPageSurvey
router = R... | 1,325 | Python | .py | 28 | 43.357143 | 87 | 0.732558 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,049 | notifications.py | mdn_kuma/kuma/api/v1/plus/notifications.py | from __future__ import annotations
import datetime
import json
from typing import Optional
# import requests
import requests
from django.conf import settings
from django.db.models import Q
from django.middleware.csrf import get_token
from ninja import Field, Router
from ninja.pagination import paginate
from sentry_sd... | 12,696 | Python | .py | 346 | 30.231214 | 88 | 0.663515 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,050 | test_notifications.py | mdn_kuma/kuma/api/v1/tests/test_notifications.py | import json
from django.core.serializers.json import DjangoJSONEncoder
from django.urls import reverse
from model_bakery import baker
from kuma.notifications import models
def test_notifications_anonymous(client):
response = client.get(reverse("api-v1:plus.notifications"))
assert response.status_code == 401... | 6,560 | Python | .py | 157 | 35.394904 | 77 | 0.647697 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,051 | test_search.py | mdn_kuma/kuma/api/v1/tests/test_search.py | from unittest.mock import patch
import pytest
from elasticmock import FakeElasticsearch
from kuma.core.urlresolvers import reverse
@pytest.mark.django_db
def test_search_validation_problems(user_client, settings):
url = reverse("api.v1.search")
# locale invalid
response = user_client.get(url, {"q": "x"... | 4,372 | Python | .py | 99 | 37.212121 | 84 | 0.614427 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,052 | test_watched_items.py | mdn_kuma/kuma/api/v1/tests/test_watched_items.py | import json
from django.urls import reverse
from model_bakery import baker
from kuma.notifications import models
def test_unwatch_manys(user_client, wiki_user):
url = reverse("api-v1:watching")
user_watched_items = []
for i in range(10):
mock_watch = baker.make(models.Watch, users=[wiki_user])
... | 1,436 | Python | .py | 42 | 26.714286 | 75 | 0.61039 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,053 | test_landing_page.py | mdn_kuma/kuma/api/v1/tests/test_landing_page.py | import pytest
from kuma.core.urlresolvers import reverse
from kuma.plus.models import LandingPageSurvey
@pytest.mark.django_db
def test_ping_landing_page_survey_bad_request(client):
url = reverse("api-v1:plus.landing_page.survey")
# Not a valid UUID
response = client.get(url, {"uuid": "xxx"})
assert... | 1,394 | Python | .py | 33 | 37.454545 | 86 | 0.691568 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,054 | test_forms.py | mdn_kuma/kuma/api/v1/tests/test_forms.py | from django.test import RequestFactory
from kuma.api.v1.search.forms import SearchForm
def test_search_form_locale_happy_path():
"""The way the form handles 'locale' is a bit overly complicated.
These unit tests focuses exclusively on that and when the form is valid."""
initial = {"page": 1, "size": 10}... | 2,198 | Python | .py | 44 | 45.022727 | 83 | 0.6922 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,055 | test_bookmarks.py | mdn_kuma/kuma/api/v1/tests/test_bookmarks.py | import copy
from urllib.parse import urlencode
import pytest
from kuma.core.urlresolvers import reverse
from kuma.users.models import UserProfile
@pytest.mark.django_db
def test_bookmarked_anonymous(client):
response = client.get(reverse("api-v1:collections"))
assert response.status_code == 401
assert "... | 11,384 | Python | .py | 289 | 32.211073 | 94 | 0.610502 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,056 | test_views.py | mdn_kuma/kuma/api/v1/tests/test_views.py | import pytest
from django.contrib.auth.models import User
from kuma.core.tests import assert_no_cache_header
from kuma.core.urlresolvers import reverse
@pytest.mark.parametrize("http_method", ["put", "post", "delete", "options", "head"])
def test_whoami_disallowed_methods(client, http_method):
"""HTTP methods ot... | 3,893 | Python | .py | 98 | 35.112245 | 85 | 0.688842 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,057 | test_subscriptions.py | mdn_kuma/kuma/api/v1/tests/test_subscriptions.py | import json
import pytest
from django.urls import reverse
from kuma.users import models
@pytest.mark.django_db
def test_subscriptions(subscriber_client, wiki_user):
response = subscriber_client.get(reverse("api-v1:whoami"))
assert response.status_code == 200
assert json.loads(response.content) == {
... | 1,219 | Python | .py | 32 | 32.15625 | 84 | 0.687553 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,058 | __init__.py | mdn_kuma/kuma/api/v1/search/__init__.py | from django import http
from django.conf import settings
from django.utils.cache import patch_cache_control
from elasticsearch import exceptions
from elasticsearch_dsl import Q, Search, query
from redo import retrying
from kuma.api.v1.decorators import allow_CORS_GET
from .forms import SearchForm
# This is the numbe... | 11,058 | Python | .py | 259 | 33.204633 | 113 | 0.607023 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,059 | forms.py | mdn_kuma/kuma/api/v1/search/forms.py | from django import forms
from django.conf import settings
from django.utils.datastructures import MultiValueDict
class TypedMultipleValueField(forms.TypedMultipleChoiceField):
"""Unlike TypedMultipleChoiceField we don't care what the individual values
are as long as they're not empty."""
def valid_value(... | 2,559 | Python | .py | 47 | 47.340426 | 85 | 0.680817 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,060 | test_admin.py | mdn_kuma/kuma/api/tests/test_admin.py | import json
from django.conf import settings
from django.urls import reverse
from model_bakery import baker
from kuma.notifications import models
def test_admin_update_content(user_client, wiki_user):
# Prepare: Watch page.
page_title = "<dialog>: The Dialog element"
page_url = "/en-us/docs/web/html/ele... | 1,416 | Python | .py | 37 | 31.945946 | 79 | 0.665693 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,061 | urls.py | mdn_kuma/kuma/version/urls.py | from django.urls import re_path
from . import views
urlpatterns = [
# Serve the revision hashes.
re_path(r"^media/revision.txt$", views.revision_hash, name="version.kuma"),
]
| 185 | Python | .py | 6 | 28.166667 | 79 | 0.728814 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,062 | views.py | mdn_kuma/kuma/version/views.py | from django.conf import settings
from django.http import HttpResponse
from django.views.decorators.cache import never_cache
from django.views.decorators.http import require_safe
@never_cache
@require_safe
def revision_hash(request):
"""
Return the kuma revision hash.
"""
return HttpResponse(
s... | 390 | Python | .py | 13 | 26.692308 | 72 | 0.770667 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,063 | test_views.py | mdn_kuma/kuma/version/tests/test_views.py | import pytest
from kuma.core.tests import assert_no_cache_header
from kuma.core.urlresolvers import reverse
@pytest.mark.parametrize("method", ["get", "head"])
def test_revision_hash(client, db, method, settings):
settings.REVISION_HASH = "the_revision_hash"
response = getattr(client, method)(reverse("versio... | 834 | Python | .py | 17 | 45.176471 | 81 | 0.721675 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,064 | urlresolvers.py | mdn_kuma/kuma/core/urlresolvers.py | from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.urls import LocalePrefixPattern, URLResolver
from django.urls import reverse as django_reverse
from django.utils import translation
from .i18n import get_language
class KumaLocalePrefixPattern(LocalePrefixPattern):
... | 2,462 | Python | .py | 59 | 35.372881 | 88 | 0.708072 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,065 | tasks.py | mdn_kuma/kuma/core/tasks.py | from datetime import datetime, timedelta
from celery.task import task
from django.contrib.sessions.models import Session
from ..notifications.models import Notification, NotificationData
from .decorators import skip_in_maintenance_mode
LOCK_ID = "clean-sessions-lock"
LOCK_EXPIRE = 60 * 5
def get_expired_sessions(n... | 2,259 | Python | .py | 62 | 31.903226 | 89 | 0.615737 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,066 | apps.py | mdn_kuma/kuma/core/apps.py | from django.apps import AppConfig
from django.conf import settings
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from kuma.celery import app
class CoreConfig(AppConfig):
"""
The Django App Config class to store information about the core app
an... | 1,265 | Python | .py | 29 | 37.37931 | 92 | 0.70114 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,067 | i18n.py | mdn_kuma/kuma/core/i18n.py | """
Customizations of Django i18n functions for Kuma.
Django language code is lower case, like 'en-us'.
Kuma language code is mixed case, like 'en-US'.
"""
from functools import lru_cache
from django.apps import apps
from django.conf import settings
from django.conf.locale import LANG_INFO
from django.utils import t... | 8,362 | Python | .py | 182 | 39.82967 | 86 | 0.715164 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,068 | utils.py | mdn_kuma/kuma/core/utils.py | import logging
from smtplib import SMTPConnectError, SMTPServerDisconnected
from urllib.parse import ParseResult, parse_qsl, urlparse, urlsplit, urlunsplit
import requests
from django.conf import settings
from django.core.mail import EmailMultiAlternatives, get_connection
from django.http import QueryDict
from django.... | 6,497 | Python | .py | 162 | 34.049383 | 103 | 0.696128 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,069 | admin.py | mdn_kuma/kuma/core/admin.py | # from django.contrib import admin
# from rest_framework.authtoken.admin import TokenAdmin
# from kuma.core.models import IPBan
class DisabledDeleteActionMixin(object):
def get_actions(self, request):
"""
Remove the built-in delete action, since it bypasses the model
delete() method (bad... | 1,145 | Python | .py | 28 | 35.107143 | 77 | 0.692864 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,070 | validators.py | mdn_kuma/kuma/core/validators.py | # see also: http://github.com/tav/scripts/raw/master/validate_jsonp.py
# Placed into the Public Domain by tav <tav@espians.com>
"""Validate Javascript Identifiers for use as JSON-P callback parameters."""
import re
from unicodedata import category
# ------------------------------------------------------------------... | 4,328 | Python | .py | 135 | 24.437037 | 88 | 0.468172 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,071 | exceptions.py | mdn_kuma/kuma/core/exceptions.py | class ProgrammingError(Exception):
"""Somebody made a mistake in the code."""
class DateTimeFormatError(Exception):
"""Called by the datetimeformat function when receiving invalid format."""
pass
class FixtureMissingError(Exception):
"""Raise this if a fixture is missing"""
| 296 | Python | .py | 7 | 38.285714 | 78 | 0.760563 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,072 | decorators.py | mdn_kuma/kuma/core/decorators.py | from functools import partial, wraps
from django.conf import settings
from django.shortcuts import redirect
from .utils import add_shared_cache_control
def shared_cache_control(func=None, **kwargs):
"""
Decorator to set Cache-Control header for shared caches like CDNs.
This duplicates Django's cache-co... | 2,378 | Python | .py | 56 | 35.910714 | 78 | 0.693275 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,073 | views.py | mdn_kuma/kuma/core/views.py | from django.http import HttpResponse
from kuma.core.decorators import shared_cache_control
@shared_cache_control(s_maxage=60 * 60 * 24 * 30)
def humans_txt(request):
"""We no longer maintain an actual /humans.txt endpoint but to avoid the
sad 404 we instead now just encourage people to go and use the GitHub
... | 436 | Python | .py | 8 | 51.125 | 80 | 0.764706 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,074 | test_utils.py | mdn_kuma/kuma/core/tests/test_utils.py | import pytest
from django.core import mail
from django.core.mail.backends.locmem import EmailBackend
from requests.exceptions import ConnectionError
from kuma.core.utils import (
EmailMultiAlternativesRetrying,
order_params,
requests_retry_session,
send_mail_retrying,
)
@pytest.mark.parametrize(
... | 2,925 | Python | .py | 79 | 30.556962 | 85 | 0.658174 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,075 | logging_urls.py | mdn_kuma/kuma/core/tests/logging_urls.py | from django.core.exceptions import SuspiciousOperation
from django.urls import re_path
from kuma.core.urlresolvers import i18n_patterns
def suspicious(request):
raise SuspiciousOperation("Raising exception to test logging.")
urlpatterns = i18n_patterns(re_path(r"^suspicious/$", suspicious, name="suspicious"))
| 320 | Python | .py | 6 | 50.833333 | 85 | 0.822006 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,076 | __init__.py | mdn_kuma/kuma/core/tests/__init__.py | import os
from functools import wraps
from unittest import mock
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.cache import cache
from django.test import TestCase
from django.utils.translation import trans_real
def assert_no_cache_header(response):
assert "max-ag... | 2,912 | Python | .py | 67 | 37.119403 | 78 | 0.706217 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,077 | test_validators.py | mdn_kuma/kuma/core/tests/test_validators.py | from django.test import TestCase
from ..validators import valid_javascript_identifier, valid_jsonp_callback_value
class ValidatorTest(TestCase):
def test_valid_javascript_identifier(self):
"""
The function ``valid_javascript_identifier`` validates a given identifier
according to the lates... | 2,406 | Python | .py | 39 | 52.769231 | 85 | 0.705731 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,078 | test_settings.py | mdn_kuma/kuma/core/tests/test_settings.py | """Check that settings are consistent."""
import pytest
from django.conf import settings
def test_accepted_locales():
"""Check for a consistent ACCEPTED_LOCALES."""
assert len(settings.ACCEPTED_LOCALES) == len(set(settings.ACCEPTED_LOCALES))
assert settings.ACCEPTED_LOCALES[0] == settings.LANGUAGE_CODE
... | 880 | Python | .py | 21 | 38.047619 | 86 | 0.747356 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,079 | test_views.py | mdn_kuma/kuma/core/tests/test_views.py | import logging
from django.core import mail
from django.test import override_settings
from django.utils.log import AdminEmailHandler
from . import KumaTestCase
@override_settings(
DEBUG=False,
DEBUG_PROPAGATE_EXCEPTIONS=False,
ADMINS=(("admin", "admin@example.com"),),
ROOT_URLCONF="kuma.core.tests.l... | 1,263 | Python | .py | 32 | 33.4375 | 57 | 0.699673 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,080 | test_decorators.py | mdn_kuma/kuma/core/tests/test_decorators.py | import pytest
from django.http import HttpResponse
from django.views.decorators.cache import never_cache
from ..decorators import (
redirect_in_maintenance_mode,
shared_cache_control,
skip_in_maintenance_mode,
)
from . import assert_no_cache_header
def simple_view(request):
return HttpResponse()
@p... | 3,002 | Python | .py | 72 | 36.486111 | 81 | 0.66964 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,081 | models.py | mdn_kuma/kuma/documenturls/models.py | import requests
from django.db import models
from django.db.models.signals import pre_save
from django.dispatch import receiver
from redo import retrying
def download_url(url, retry_options=None):
retry_options = retry_options or {
"retry_exceptions": (requests.exceptions.Timeout,),
"sleeptime": 2... | 3,184 | Python | .py | 71 | 38.352113 | 87 | 0.696284 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,082 | apps.py | mdn_kuma/kuma/documenturls/apps.py | from django.apps import AppConfig
class DocumentURLsConfig(AppConfig):
name = "kuma.documenturls"
verbose_name = "Document URLs"
| 139 | Python | .py | 4 | 31.25 | 36 | 0.781955 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,083 | admin.py | mdn_kuma/kuma/documenturls/admin.py | from django.contrib import admin
from .models import DocumentURL, DocumentURLCheck
@admin.register(DocumentURL)
class DocumentURLAdmin(admin.ModelAdmin):
list_display = (
"uri",
"absolute_url",
"is_valid",
"modified",
)
readonly_fields = (
"metadata",
"inva... | 1,074 | Python | .py | 41 | 19.902439 | 71 | 0.599609 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,084 | 0001_initial.py | mdn_kuma/kuma/documenturls/migrations/0001_initial.py | # Generated by Django 3.2.5 on 2021-07-12 19:04
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="DocumentURL",
fields=[
... | 2,240 | Python | .py | 62 | 19.870968 | 86 | 0.433241 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,085 | models.py | mdn_kuma/kuma/notifications/models.py | from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
class NotificationData(models.Model):
title = models.CharField(max_length=256)
text = models.CharField(max_length=256)
type = models.CharField(
max_length=32,
choices=(("content", "con... | 2,927 | Python | .py | 73 | 32.945205 | 100 | 0.674903 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,086 | browsers.py | mdn_kuma/kuma/notifications/browsers.py | browsers = {
"chrome": {
"name": "Chrome",
"preview_name": "Canary",
},
"chrome_android": {
"name": "Chrome Android",
},
"deno": {
"name": "Deno",
},
"edge": {
"name": "Edge",
},
"firefox": {
"name": "Firefox",
"preview_name": "... | 944 | Python | .py | 48 | 13.333333 | 38 | 0.435268 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,087 | apps.py | mdn_kuma/kuma/notifications/apps.py | from django.apps import AppConfig
class NotificationsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "kuma.notifications"
| 163 | Python | .py | 4 | 37.25 | 56 | 0.796178 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,088 | utils.py | mdn_kuma/kuma/notifications/utils.py | import re
from collections import defaultdict
from kuma.documenturls.models import DocumentURL
from kuma.notifications.browsers import browsers
from kuma.notifications.models import Notification, NotificationData, Watch
def publish_bcd_notification(path, text, data=None):
# This traverses down the path to see if... | 5,243 | Python | .py | 133 | 28.714286 | 85 | 0.558332 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,089 | admin.py | mdn_kuma/kuma/notifications/admin.py | from django.contrib import admin
from kuma.notifications.models import Notification, NotificationData, Watch
@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
...
@admin.register(NotificationData)
class NotificationDataAdmin(admin.ModelAdmin):
...
@admin.register(Watch)
class Watch... | 353 | Python | .py | 11 | 29.363636 | 75 | 0.81791 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,090 | 0002_auto_20211105_1529.py | mdn_kuma/kuma/notifications/migrations/0002_auto_20211105_1529.py | # Generated by Django 3.2.7 on 2021-11-05 15:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("notifications", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="watch",
field=models.SlugField(... | 691 | Python | .py | 24 | 19.583333 | 47 | 0.554381 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,091 | 0004_notificationdata_data.py | mdn_kuma/kuma/notifications/migrations/0004_notificationdata_data.py | # Generated by Django 3.2.7 on 2021-12-13 15:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("notifications", "0003_watch_title"),
]
operations = [
migrations.AddField(
model_name="notificationdata",
name="data... | 390 | Python | .py | 13 | 22.769231 | 49 | 0.612903 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,092 | 0008_default_watch.py | mdn_kuma/kuma/notifications/migrations/0008_default_watch.py | # Generated by Django 3.2.7 on 2022-01-06 03:06
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("notifications", "0007_wa... | 1,409 | Python | .py | 42 | 19.666667 | 74 | 0.48091 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,093 | 0001_initial.py | mdn_kuma/kuma/notifications/migrations/0001_initial.py | # Generated by Django 3.2.7 on 2021-11-05 15:19
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
ope... | 3,992 | Python | .py | 119 | 16.159664 | 69 | 0.385053 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,094 | 0005_auto_20211215_2004.py | mdn_kuma/kuma/notifications/migrations/0005_auto_20211215_2004.py | # Generated by Django 3.2.7 on 2021-12-15 20:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("notifications", "0004_notificationdata_data"),
]
operations = [
migrations.DeleteModel(
name="CompatibilityData",
),
... | 940 | Python | .py | 30 | 21.233333 | 71 | 0.551381 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,095 | 0006_auto_20220105_0138.py | mdn_kuma/kuma/notifications/migrations/0006_auto_20220105_0138.py | # Generated by Django 3.2.7 on 2022-01-05 01:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("notifications", "0005_auto_20211215_2004"),
]
operations = [
migrations.AddField(
model_name="userwatch",
name="brow... | 729 | Python | .py | 23 | 22.652174 | 53 | 0.593438 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,096 | 0010_notification_deleted.py | mdn_kuma/kuma/notifications/migrations/0010_notification_deleted.py | # Generated by Django 3.2.10 on 2022-01-27 14:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("notifications", "0009_notificationdata_page_url"),
]
operations = [
migrations.AddField(
model_name="notification",
... | 408 | Python | .py | 13 | 24.153846 | 60 | 0.638462 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,097 | 0003_watch_title.py | mdn_kuma/kuma/notifications/migrations/0003_watch_title.py | # Generated by Django 3.2.7 on 2021-11-06 13:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("notifications", "0002_auto_20211105_1529"),
]
operations = [
migrations.AddField(
model_name="watch",
name="title",
... | 438 | Python | .py | 14 | 23.642857 | 64 | 0.613365 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,098 | 0007_watch_users.py | mdn_kuma/kuma/notifications/migrations/0007_watch_users.py | # Generated by Django 3.2.7 on 2022-01-05 19:37
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("notifications", "0006_auto_20220105_0138"),
]
op... | 573 | Python | .py | 17 | 25.823529 | 78 | 0.640653 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |
8,099 | 0009_notificationdata_page_url.py | mdn_kuma/kuma/notifications/migrations/0009_notificationdata_page_url.py | # Generated by Django 3.2.7 on 2022-01-18 12:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("notifications", "0008_default_watch"),
]
operations = [
migrations.AddField(
model_name="notificationdata",
name="pa... | 431 | Python | .py | 14 | 23.142857 | 48 | 0.614078 | mdn/kuma | 1,929 | 679 | 0 | MPL-2.0 | 9/5/2024, 5:10:17 PM (Europe/Amsterdam) |