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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
17,900 | test_google_form.py | rafalp_Misago/misago/socialauth/admin/tests/test_google_form.py | import pytest
from django.urls import reverse
from ...models import SocialAuthProvider
admin_link = reverse(
"misago:admin:settings:socialauth:edit", kwargs={"pk": "google-oauth2"}
)
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(
provider="google-oauth2", is_active=True... | 1,727 | Python | .py | 43 | 34.255814 | 78 | 0.69009 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,901 | test_editing_provider.py | rafalp_Misago/misago/socialauth/admin/tests/test_editing_provider.py | from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_contains
from ... import SOCIALAUTH_CACHE
from ...models import SocialAuthProvider
def test_form_displays_for_enabled_provider(admin_client, provider):
response = admin_client.get(
reverse("mis... | 3,216 | Python | .py | 75 | 36.72 | 88 | 0.679512 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,902 | test_github_form.py | rafalp_Misago/misago/socialauth/admin/tests/test_github_form.py | import pytest
from django.urls import reverse
from ...models import SocialAuthProvider
admin_link = reverse("misago:admin:settings:socialauth:edit", kwargs={"pk": "github"})
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(provider="github", is_active=True, order=0)
def test_github_... | 1,665 | Python | .py | 39 | 36.692308 | 88 | 0.692595 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,903 | test_disabling_providers.py | rafalp_Misago/misago/socialauth/admin/tests/test_disabling_providers.py | import pytest
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ... import SOCIALAUTH_CACHE
@pytest.fixture
def admin_link(provider):
return reverse(
"misago:admin:settings:socialauth:disable", kwargs={"pk": provider.pk}
)
def test_provider_can_be_disabled(adm... | 1,466 | Python | .py | 35 | 37.2 | 87 | 0.74048 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,904 | test_twitter_form.py | rafalp_Misago/misago/socialauth/admin/tests/test_twitter_form.py | import pytest
from django.urls import reverse
from ...models import SocialAuthProvider
admin_link = reverse("misago:admin:settings:socialauth:edit", kwargs={"pk": "twitter"})
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(
provider="twitter", is_active=True, order=0
)
... | 1,690 | Python | .py | 41 | 35.170732 | 87 | 0.689571 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,905 | test_facebook_form.py | rafalp_Misago/misago/socialauth/admin/tests/test_facebook_form.py | import pytest
from django.urls import reverse
from ...models import SocialAuthProvider
admin_link = reverse("misago:admin:settings:socialauth:edit", kwargs={"pk": "facebook"})
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(
provider="facebook", is_active=True, order=0
)
... | 1,701 | Python | .py | 41 | 35.439024 | 88 | 0.691651 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,906 | test_ordering_providers.py | rafalp_Misago/misago/socialauth/admin/tests/test_ordering_providers.py | from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ... import SOCIALAUTH_CACHE
def test_top_provider_can_be_moved_down(admin_client, provider, other_provider):
provider.order = 0
provider.save()
other_provider.order = 1
other_provider.save()
admin_client.po... | 4,526 | Python | .py | 123 | 31.219512 | 88 | 0.699036 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,907 | test_discord_form.py | rafalp_Misago/misago/socialauth/admin/tests/test_discord_form.py | import pytest
from django.urls import reverse
from ...models import SocialAuthProvider
admin_link = reverse("misago:admin:settings:socialauth:edit", kwargs={"pk": "discord"})
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(
provider="discord", is_active=True, order=0
)
... | 1,690 | Python | .py | 41 | 35.170732 | 87 | 0.689571 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,908 | daterelative.py | rafalp_Misago/misago/formats/daterelative.py | from datetime import datetime, timedelta
from math import floor
from django.utils import timezone
from django.utils.formats import date_format
from django.utils.translation import npgettext, pgettext
def date_relative(value: datetime) -> str:
now = timezone.now()
delta = abs((now - value).total_seconds())
... | 3,701 | Python | .py | 96 | 29.958333 | 73 | 0.56467 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,909 | apps.py | rafalp_Misago/misago/formats/apps.py | from django.apps import AppConfig
class MisagoFormatsConfig(AppConfig):
name = "misago.formats"
label = "misago_formats"
verbose_name = "Misago Formats"
| 167 | Python | .py | 5 | 29.6 | 37 | 0.75625 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,910 | misago_formats.py | rafalp_Misago/misago/formats/templatetags/misago_formats.py | from django import template
from ..daterelative import date_relative, date_relative_short
register = template.Library()
register.filter(is_safe=False, expects_localtime=True)(date_relative)
register.filter(is_safe=False, expects_localtime=True)(date_relative_short)
| 269 | Python | .py | 5 | 52.2 | 75 | 0.831418 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,911 | test_date_relative_short.py | rafalp_Misago/misago/formats/tests/test_date_relative_short.py | from datetime import timedelta
from django.utils import timezone
from freezegun import freeze_time
from ..daterelative import date_relative_short
def test_date_relative_short_formats_recent_date():
assert date_relative_short(timezone.now()) == "now"
def test_date_relative_short_formats_date_few_minutes_ago():... | 1,162 | Python | .py | 23 | 47 | 60 | 0.745778 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,912 | test_date_relative.py | rafalp_Misago/misago/formats/tests/test_date_relative.py | from datetime import timedelta
from django.utils import timezone
from freezegun import freeze_time
from ..daterelative import date_relative
def test_date_relative_formats_recent_date():
assert date_relative(timezone.now()) == "moment ago"
def test_date_relative_formats_date_few_seconds_ago():
timestamp = ... | 3,266 | Python | .py | 64 | 47.40625 | 70 | 0.731207 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,913 | apps.py | rafalp_Misago/misago/postgres/apps.py | from django.apps import AppConfig
class MisagoPostgresConfig(AppConfig):
name = "misago.postgres"
label = "misago_postgres"
| 134 | Python | .py | 4 | 30 | 38 | 0.78125 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,914 | delete.py | rafalp_Misago/misago/postgres/delete.py | from typing import Type
from django.db.models import Model
from .execute import execute_rowcount
def delete_one(obj: Model) -> int:
"""Deletes an object from the database, bypassing all Django ORM logic.
Returns a number of deleted rows.
"""
table = obj._meta.db_table
pkey = obj._meta.pk.column... | 1,773 | Python | .py | 39 | 39.128205 | 89 | 0.647264 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,915 | execute.py | rafalp_Misago/misago/postgres/execute.py | from typing import Any
from django.db import connection
def execute_fetch_all(query: str, params: dict | list | None = None) -> list[tuple]:
"""Executes a raw query and returns all rows."""
with connection.cursor() as cursor:
cursor.execute(query, params)
return cursor.fetchall()
def execut... | 809 | Python | .py | 17 | 41.941176 | 84 | 0.686624 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,916 | test_execute.py | rafalp_Misago/misago/postgres/tests/test_execute.py | from ..execute import execute_fetch_all, execute_fetch_one
def test_query_is_executed_and_all_results_are_returned(user, other_user):
results = execute_fetch_all("SELECT id FROM misago_users_user;")
assert len(results) == 2
results_flat = [row[0] for row in results]
assert user.id in results_flat
... | 542 | Python | .py | 10 | 49.9 | 79 | 0.73055 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,917 | test_delete.py | rafalp_Misago/misago/postgres/tests/test_delete.py | import pytest
from django.core.exceptions import ObjectDoesNotExist
from ...cache.models import CacheVersion
from ..delete import delete_all, delete_one
def test_one_object_is_deleted_from_database(db):
cache_version = CacheVersion.objects.create(cache="test", version="test")
result = delete_one(cache_versi... | 3,093 | Python | .py | 58 | 47.982759 | 83 | 0.731626 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,918 | urls.py | rafalp_Misago/misago/auth/urls.py | from django.urls import path
from .views import login
urlpatterns = [path("login/", login, name="login")]
| 109 | Python | .py | 3 | 34.333333 | 51 | 0.757282 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,919 | apps.py | rafalp_Misago/misago/auth/apps.py | from django.apps import AppConfig
class MisagoAuthConfig(AppConfig):
name = "misago.auth"
label = "misago_auth"
verbose_name = "Misago Auth"
| 155 | Python | .py | 5 | 27.2 | 34 | 0.736486 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,920 | loginurl.py | rafalp_Misago/misago/auth/loginurl.py | from django.conf import settings
from django.urls import NoReverseMatch, reverse
def get_login_url():
try:
return reverse(settings.LOGIN_URL)
except NoReverseMatch:
return settings.LOGIN_URL
| 217 | Python | .py | 7 | 26.285714 | 47 | 0.754808 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,921 | nextpage.py | rafalp_Misago/misago/auth/nextpage.py | from urllib.parse import urlparse
from django.http import HttpRequest
from django.urls import Resolver404, resolve
from django.utils.http import url_has_allowed_host_and_scheme
NEXT_PAGE = "next"
def get_next_page_url(request: HttpRequest) -> str | None:
redirect_to = request.POST.get(NEXT_PAGE, request.GET.get... | 1,286 | Python | .py | 37 | 28.972973 | 78 | 0.683657 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,922 | decorators.py | rafalp_Misago/misago/auth/decorators.py | from functools import wraps
from typing import Callable
from django.core.exceptions import PermissionDenied
from django.utils.translation import pgettext
from .views import is_misago_login_page_disabled, login
def login_required(f_or_message: Callable | str):
if isinstance(f_or_message, str):
def _oute... | 1,204 | Python | .py | 27 | 36 | 78 | 0.676976 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,923 | views.py | rafalp_Misago/misago/auth/views.py | from django.conf import settings
from django.contrib import auth
from django.http import Http404, HttpRequest, HttpResponse
from django.shortcuts import redirect, render
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.views import View
from django.views.decorators.cache ... | 3,293 | Python | .py | 71 | 39.112676 | 87 | 0.688458 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,924 | test_get_login_url.py | rafalp_Misago/misago/auth/tests/test_get_login_url.py | from django.urls import reverse
from django.test import override_settings
from ..loginurl import get_login_url
@override_settings(LOGIN_URL="misago:login")
def test_get_login_url_returns_reversed_url():
assert get_login_url() == reverse("misago:login")
@override_settings(LOGIN_URL="/other/login/")
def test_get... | 401 | Python | .py | 9 | 42.111111 | 53 | 0.762274 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,925 | test_login_required_decorator.py | rafalp_Misago/misago/auth/tests/test_login_required_decorator.py | from django.test import override_settings
from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains, assert_not_contains
def test_require_login_decorator_displays_login_form_to_guests(db, client):
response = client.get(reverse("misago:account-preferenc... | 1,630 | Python | .py | 37 | 40.162162 | 92 | 0.757269 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,926 | test_login_view.py | rafalp_Misago/misago/auth/tests/test_login_view.py | from urllib.parse import quote_plus
from django.test import override_settings
from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains, assert_not_contains
from ...users.models import Ban
def test_login_view_displays_login_form_to_guests(db, client):
... | 7,926 | Python | .py | 201 | 33.547264 | 86 | 0.688666 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,927 | test_next_page_url.py | rafalp_Misago/misago/auth/tests/test_next_page_url.py | from urllib.parse import quote_plus
from django.urls import reverse
from ..nextpage import clean_next_page_url, get_next_page_url
def test_get_next_page_url_returns_clean_url_from_post(rf):
request = rf.get(
reverse("misago:login"),
{"next": reverse("misago:account-preferences")},
)
ass... | 2,472 | Python | .py | 46 | 48.673913 | 87 | 0.711194 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,928 | rest_permissions.py | rafalp_Misago/misago/core/rest_permissions.py | from django.core.exceptions import PermissionDenied
from django.utils.translation import pgettext
from rest_framework.permissions import SAFE_METHODS, BasePermission
class IsAuthenticatedOrReadOnly(BasePermission):
def has_permission(self, request, view):
if request.user.is_anonymous and request.method no... | 485 | Python | .py | 10 | 41.2 | 76 | 0.741525 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,929 | viewmodel.py | rafalp_Misago/misago/core/viewmodel.py | class ViewModel:
def __getattr__(self, name):
return getattr(self._model, name)
def unwrap(self):
return self._model
| 142 | Python | .py | 5 | 22.4 | 41 | 0.632353 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,930 | apirouter.py | rafalp_Misago/misago/core/apirouter.py | from rest_framework.routers import DefaultRouter, DynamicRoute, Route
class MisagoApiRouter(DefaultRouter):
include_root_view = False
include_format_suffixes = False
routes = [
# List route.
Route(
url=r"^{prefix}{trailing_slash}$",
mapping={"get": "list", "post": ... | 1,488 | Python | .py | 44 | 23.022727 | 76 | 0.51839 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,931 | serializers.py | rafalp_Misago/misago/core/serializers.py | class MutableFields:
@classmethod
def subset_fields(cls, *fields):
fields_in_name = [f.title().replace("_", "") for f in fields]
name = "%s%sSubset" % (cls.__name__, "".join(fields_in_name)[:100])
class Meta(cls.Meta):
pass
Meta.fields = list(fields)
return... | 1,357 | Python | .py | 33 | 31.606061 | 75 | 0.554539 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,932 | exceptionhandler.py | rafalp_Misago/misago/core/exceptionhandler.py | from urllib.parse import urlencode
from django.core.exceptions import PermissionDenied
from django.http import (
Http404,
HttpResponse,
HttpResponsePermanentRedirect,
JsonResponse,
)
from django.urls import reverse
from rest_framework.views import exception_handler as rest_exception_handler
from social... | 3,877 | Python | .py | 89 | 38.337079 | 83 | 0.752399 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,933 | apipatch.py | rafalp_Misago/misago/core/apipatch.py | from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.http import Http404
from rest_framework.response import Response
ALLOWED_OPS = ("add", "remove", "replace")
class InvalidAction(Exception):
pass
class ApiPatch:
def __init__(self):
self._actions = []
... | 3,288 | Python | .py | 79 | 29.772152 | 86 | 0.557403 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,934 | page.py | rafalp_Misago/misago/core/page.py | class Page:
"""
Misago page utility
Allows for adding custom views to "sectioned" pages like
User Control Panel, Users List or Threads Lists
"""
def __init__(self, name):
self._finalized = False
self.name = name
self._unsorted_list = []
self._sorted_list = []
... | 4,451 | Python | .py | 118 | 24.576271 | 84 | 0.521104 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,935 | slugify.py | rafalp_Misago/misago/core/slugify.py | from django.template.defaultfilters import slugify as django_slugify
from unidecode import unidecode
def default(string):
string = str(string)
string = unidecode(string)
return django_slugify(string.replace("_", " ").strip())
| 240 | Python | .py | 6 | 36.666667 | 68 | 0.762931 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,936 | apps.py | rafalp_Misago/misago/core/apps.py | from django.apps import AppConfig
class MisagoCoreConfig(AppConfig):
name = "misago.core"
label = "misago_core"
verbose_name = "Misago Core"
| 155 | Python | .py | 5 | 27.2 | 34 | 0.736486 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,937 | context_processors.py | rafalp_Misago/misago/core/context_processors.py | from django.utils.translation import get_language
from .. import __version__
from ..hooks import context_processors as context_processors_hooks
from .momentjs import get_locale_url
def misago_version(request):
return {"MISAGO_VERSION": __version__}
def request_path(request):
return {"request_path": request... | 1,172 | Python | .py | 30 | 34.066667 | 82 | 0.717584 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,938 | cursorpagination.py | rafalp_Misago/misago/core/cursorpagination.py | from django.core.paginator import EmptyPage, InvalidPage
def get_page(queryset, order_by, per_page, start=0):
if start < 0:
raise InvalidPage()
object_list = list(_slice_queryset(queryset, order_by, per_page, start))
if start and not object_list:
raise EmptyPage()
next_cursor = None
... | 1,249 | Python | .py | 32 | 31.9375 | 76 | 0.628524 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,939 | utils.py | rafalp_Misago/misago/core/utils.py | import hashlib
from datetime import datetime, timedelta
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.urls import resolve, reverse
from django.utils import html, timezone
from django.utils.encoding import force_str
from django.utils.fun... | 5,567 | Python | .py | 146 | 31.39726 | 87 | 0.666667 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,940 | __init__.py | rafalp_Misago/misago/core/__init__.py | from django.conf import settings
from django.core.checks import register, Critical
SUPPORTED_ENGINES = [
"django.db.backends.postgresql",
"django.db.backends.postgresql_psycopg2",
]
@register()
def check_db_engine(app_configs, **kwargs):
errors = []
try:
if settings.DATABASES["default"]["ENG... | 568 | Python | .py | 17 | 27.882353 | 81 | 0.694139 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,941 | validators.py | rafalp_Misago/misago/core/validators.py | import re
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.utils.translation import pgettext_lazy
from .utils import slugify
class validate_sluggable:
def __init__(self, error_short=None, error_long=None):
self.error_short = error_short or ... | 1,609 | Python | .py | 40 | 33.7 | 195 | 0.65617 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,942 | middleware.py | rafalp_Misago/misago/core/middleware.py | from . import exceptionhandler
from .utils import is_request_to_misago
class ExceptionHandlerMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
return self.get_response(request)
def process_exception(self, request, exception):
... | 885 | Python | .py | 19 | 39.684211 | 85 | 0.714452 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,943 | momentjs.py | rafalp_Misago/misago/core/momentjs.py | from ..conf import settings
MOMENT_STATIC_PATH = "misago/momentjs/%s.js"
def get_locale_url(language, *, static_path_template=None, locales=None):
locales = locales or settings.MISAGO_MOMENT_JS_LOCALES
clean_language = clean_language_name(language, locales)
if clean_language:
static_path_template... | 800 | Python | .py | 20 | 34.6 | 73 | 0.715026 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,944 | shortcuts.py | rafalp_Misago/misago/core/shortcuts.py | from django.http import Http404
from rest_framework.response import Response
def paginate(
object_list,
page,
per_page,
orphans=0,
allow_empty_first_page=True,
allow_explicit_first_page=False,
paginator=None,
):
from django.core.paginator import Paginator, EmptyPage, InvalidPage
fr... | 2,112 | Python | .py | 66 | 25.272727 | 71 | 0.647233 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,945 | exceptions.py | rafalp_Misago/misago/core/exceptions.py | # pylint: disable=super-init-not-called
from django.core.exceptions import PermissionDenied
from django.db.models import Model
from social_core.exceptions import AuthException
class AjaxError(Exception):
"""You've tried to do something over AJAX but misago blurped"""
def __init__(self, message=None, code=406... | 1,154 | Python | .py | 27 | 37.333333 | 84 | 0.714928 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,946 | errorpages.py | rafalp_Misago/misago/core/errorpages.py | from django.http import JsonResponse
from django.shortcuts import render
from django.utils.translation import pgettext
from social_core import exceptions as social_exceptions
from ..admin.views.errorpages import admin_csrf_failure, admin_error_page
from ..socialauth.providers import providers
from .exceptions import S... | 5,016 | Python | .py | 126 | 31.928571 | 146 | 0.655819 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,947 | deprecations.py | rafalp_Misago/misago/core/deprecations.py | """
Utility module useful for refactors,
Defines utility function for easy raising of warnings in deprecated functions.
This function is set to use stacklevel 3 as default making following code in test.py:
def depreacted_function():
warn("This function is deprecated")
def other_function():
deprecated_funct... | 601 | Python | .py | 15 | 37.2 | 85 | 0.80662 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,948 | decorators.py | rafalp_Misago/misago/core/decorators.py | from rest_framework import serializers
from .errorpages import not_allowed
def require_POST(f):
def decorator(request, *args, **kwargs):
if not request.method == "POST":
return not_allowed(request)
return f(request, *args, **kwargs)
return decorator
def require_dict_data(f):
... | 601 | Python | .py | 16 | 31.25 | 77 | 0.690972 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,949 | views.py | rafalp_Misago/misago/core/views.py | from django.shortcuts import redirect
def forum_index(request):
return # blow up as this view is normally non-reachable!
def home_redirect(*args, **kwargs):
return redirect("misago:index")
| 202 | Python | .py | 5 | 37 | 61 | 0.761658 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,950 | mail.py | rafalp_Misago/misago/core/mail.py | from django.core import mail as djmail
from django.template.loader import render_to_string
from django.utils.translation import get_language
from ..conf import settings
from .utils import get_host_from_address
def build_mail(recipient, subject, template, sender=None, context=None):
context = context.copy() if co... | 1,643 | Python | .py | 39 | 35.794872 | 82 | 0.697103 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,951 | misago_json.py | rafalp_Misago/misago/core/templatetags/misago_json.py | import json
from django import template
from django.utils.safestring import mark_safe
from ..utils import encode_json_html
register = template.Library()
@register.filter
def as_json(value):
json_dump = json.dumps(value)
# fixes XSS as described in #651
return mark_safe(encode_json_html(json_dump))
| 316 | Python | .py | 10 | 28.9 | 49 | 0.780731 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,952 | misago_absoluteurl.py | rafalp_Misago/misago/core/templatetags/misago_absoluteurl.py | from django import template
from django.urls import NoReverseMatch, reverse
register = template.Library()
@register.simple_tag(takes_context=True)
def absoluteurl(context, url_or_name, *args, **kwargs):
address = context["settings"].forum_address
if not address:
return None
absolute_url_prefix =... | 636 | Python | .py | 16 | 34.125 | 68 | 0.697068 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,953 | misago_batch.py | rafalp_Misago/misago/core/templatetags/misago_batch.py | from django import template
register = template.Library()
@register.filter
def batch(items, size):
batch_size = 0
batch_items = []
for item in items:
batch_size += 1
batch_items.append(item)
if batch_size == size:
yield batch_items
batch_size = 0
... | 783 | Python | .py | 29 | 19.551724 | 56 | 0.582773 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,954 | misago_stringutils.py | rafalp_Misago/misago/core/templatetags/misago_stringutils.py | from django import template
register = template.Library()
@register.filter
def isdescriptionshort(string):
string_lowered = string.lower()
return string_lowered.count("<p") == 1 and not string_lowered.count("<br")
| 225 | Python | .py | 6 | 34.666667 | 78 | 0.759259 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,955 | misago_capture.py | rafalp_Misago/misago/core/templatetags/misago_capture.py | """
Capture tag: renders its contents as template, and stores them in value
Syntax:
{% capture trimmed as loremipsum %}
<a href="{% url 'misago:terms-of-service' %}">{% trans "guidelines" %}</a>
{% endcapture %} # renders block contents to context variable loremipsum
"""
from django import template
register = templa... | 1,568 | Python | .py | 39 | 34.230769 | 79 | 0.676761 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,956 | misago_pagetitle.py | rafalp_Misago/misago/core/templatetags/misago_pagetitle.py | from django import template
from django.utils.translation import pgettext
register = template.Library()
@register.simple_tag
def pagetitle(title, **kwargs):
if "page" in kwargs and kwargs["page"] > 1:
title += " (%s)" % (
pgettext("page title pagination", "page: %(page)s")
% {"pag... | 440 | Python | .py | 13 | 27.846154 | 63 | 0.606635 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,957 | misago_shorthands.py | rafalp_Misago/misago/core/templatetags/misago_shorthands.py | from django import template
register = template.Library()
@register.filter
def iftrue(test, value):
return value if test else ""
@register.filter
def iffalse(test, value):
return "" if test else value
| 214 | Python | .py | 8 | 24.125 | 32 | 0.766169 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,958 | 0001_initial.py | rafalp_Misago/misago/core/migrations/0001_initial.py | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="CacheVersion",
fields=[
(
"id",
models.AutoField(
... | 743 | Python | .py | 24 | 16.791667 | 68 | 0.436364 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,959 | 0002_basic_settings.py | rafalp_Misago/misago/core/migrations/0002_basic_settings.py | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("misago_core", "0001_initial"), ("misago_conf", "0001_initial")]
operations = []
| 181 | Python | .py | 4 | 41.5 | 85 | 0.718391 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,960 | 0003_delete_cacheversion.py | rafalp_Misago/misago/core/migrations/0003_delete_cacheversion.py | # Generated by Django 1.11.17 on 2019-01-08 19:49
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("misago_core", "0002_basic_settings")]
operations = [migrations.DeleteModel(name="CacheVersion")]
| 248 | Python | .py | 5 | 46.4 | 62 | 0.7625 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,961 | test_empty_file_can_be_hashed.py | rafalp_Misago/misago/core/tests/test_empty_file_can_be_hashed.py | from ..utils import HASH_LENGTH, get_file_hash
def test_empty_file_hash_is_zeroes(mocker):
empty_file = mocker.Mock(size=0)
assert get_file_hash(empty_file) == "0" * HASH_LENGTH
| 188 | Python | .py | 4 | 43.5 | 57 | 0.71978 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,962 | test_exceptionhandlers.py | rafalp_Misago/misago/core/tests/test_exceptionhandlers.py | import json
from django.core import exceptions as django_exceptions
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.test import TestCase
from .. import exceptionhandler
from ...users.models import Ban
from ..exceptions import Banned
INVALID_EXCEPTIONS = [
django_ex... | 5,208 | Python | .py | 103 | 43.640777 | 86 | 0.715271 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,963 | test_templatetags.py | rafalp_Misago/misago/core/tests/test_templatetags.py | from django.template import Context, Template
from django.test import TestCase
from ..templatetags.misago_batch import batch, batchnonefilled
class CaptureTests(TestCase):
def setUp(self):
self.context = Context({"unsafe_name": "The<hr>Html"})
def test_capture(self):
"""capture content to va... | 5,199 | Python | .py | 150 | 27.193333 | 87 | 0.56666 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,964 | test_common_middleware_redirect.py | rafalp_Misago/misago/core/tests/test_common_middleware_redirect.py | from ...users.test import AuthenticatedUserTestCase
class CommonMiddlewareRedirectTests(AuthenticatedUserTestCase):
def test_slashless_redirect(self):
"""
Regression test for https://github.com/rafalp/Misago/issues/450
there shouldn't be crash when request path lacks trailing slash
... | 533 | Python | .py | 10 | 46 | 84 | 0.723077 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,965 | test_exceptionhandler_middleware.py | rafalp_Misago/misago/core/tests/test_exceptionhandler_middleware.py | from django.http import Http404
from django.test.client import RequestFactory
from django.urls import reverse
from ...acl.useracl import get_user_acl
from ...categories.proxy import CategoriesProxy
from ...conf.dynamicsettings import DynamicSettings
from ...conftest import get_cache_versions
from ...permissions.proxy ... | 1,786 | Python | .py | 39 | 41.794872 | 83 | 0.783084 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,966 | test_serializers.py | rafalp_Misago/misago/core/tests/test_serializers.py | from django.test import TestCase
from rest_framework import serializers
from ...categories.models import Category
from ...threads import test
from ...threads.models import Thread
from ..serializers import MutableFields
class Serializer(serializers.ModelSerializer, MutableFields):
url = serializers.SerializerMeth... | 2,918 | Python | .py | 69 | 32.681159 | 79 | 0.635465 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,967 | test_page.py | rafalp_Misago/misago/core/tests/test_page.py | from django.test import TestCase
from ..page import Page
class SiteTests(TestCase):
def setUp(self):
self.page = Page("test")
def test_pages(self):
"""add_section adds section to page"""
self.page.add_section(
link="misago:user-posts", name="Posts", after="misago:user-thr... | 896 | Python | .py | 20 | 36.55 | 82 | 0.645905 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,968 | test_context_processors.py | rafalp_Misago/misago/core/tests/test_context_processors.py | from django.test import TestCase
from django.utils import translation
from .. import context_processors
class MockRequest:
path = "/"
def __init__(self, secure, host):
self.secure = secure
self.host = host
def is_secure(self):
return self.secure
def get_host(self):
... | 1,944 | Python | .py | 48 | 31.0625 | 87 | 0.630122 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,969 | test_frontendcontext_middleware.py | rafalp_Misago/misago/core/tests/test_frontendcontext_middleware.py | from django.http import HttpResponse
from ..middleware import FrontendContextMiddleware
class MockRequest:
pass
def get_response(*_):
return HttpResponse("OK!")
def test_frontend_middleware_sets_frontend_context_dict_on_request():
request = MockRequest()
FrontendContextMiddleware(get_response)(re... | 369 | Python | .py | 10 | 33.2 | 69 | 0.786932 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,970 | test_utils.py | rafalp_Misago/misago/core/tests/test_utils.py | from django.core.exceptions import PermissionDenied
from django.test import TestCase
from django.test.client import RequestFactory
from django.urls import Resolver404, reverse
from django.utils.functional import lazy, lazystr
from ..utils import (
clean_ids_list,
clean_return_path,
format_plaintext_for_htm... | 11,607 | Python | .py | 299 | 28.80602 | 86 | 0.569764 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,971 | test_body_css_class.py | rafalp_Misago/misago/core/tests/test_body_css_class.py | from django.urls import reverse
from ...test import assert_contains, assert_not_contains
def test_body_has_misago_anonymous_css_class_if_user_is_anonymous(db, client):
response = client.get(reverse("misago:index"))
assert_contains(response, 'class="misago-anonymous')
assert_not_contains(response, 'class=... | 612 | Python | .py | 10 | 57.3 | 87 | 0.773869 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,972 | test_errorpages.py | rafalp_Misago/misago/core/tests/test_errorpages.py | from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.test import Client, TestCase, override_settings
from django.test.client import RequestFactory
from django.urls import reverse
from ...acl.useracl import get_user_acl
from ...categories.proxy import CategoriesProxy
from ...c... | 6,768 | Python | .py | 120 | 49.25 | 88 | 0.71144 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,973 | test_apipatch.py | rafalp_Misago/misago/core/tests/test_apipatch.py | from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.test import TestCase
from ..apipatch import ApiPatch, InvalidAction
class MockRequest:
def __init__(self, data=None):
self.data = data
class MockObject:
def __init__(self, pk):
self.id = pk
... | 8,686 | Python | .py | 202 | 31.915842 | 88 | 0.551916 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,974 | test_deprecations.py | rafalp_Misago/misago/core/tests/test_deprecations.py | import warnings
from django.test import TestCase
from ..deprecations import RemovedInMisagoWarning, warn
class DeprecationsTests(TestCase):
def test_deprecations_warn(self):
"""deprecation utility raises warning"""
with warnings.catch_warnings(record=True) as warning:
warn("test warn... | 528 | Python | .py | 11 | 40.363636 | 84 | 0.720703 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,975 | test_context_processors_hook.py | rafalp_Misago/misago/core/tests/test_context_processors_hook.py | from ..context_processors import hooks
def test_context_processors_hook_can_inject_context(mocker):
plugin = mocker.Mock(return_value={"plugin": True})
mocker.patch("misago.core.context_processors.context_processors_hooks", [plugin])
context = hooks(None)
assert context == {"plugin": True}
| 309 | Python | .py | 6 | 47.5 | 85 | 0.744186 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,976 | test_validators.py | rafalp_Misago/misago/core/tests/test_validators.py | import pytest
from django.core.exceptions import ValidationError
from ..validators import validate_image_square, validate_sluggable
def test_sluggable_validator_raises_error_if_result_slug_will_be_empty():
validator = validate_sluggable()
with pytest.raises(ValidationError):
validator("!#@! !@#@")
... | 1,473 | Python | .py | 30 | 44.2 | 83 | 0.743357 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,977 | test_mail.py | rafalp_Misago/misago/core/tests/test_mail.py | from django.core import mail
from django.test import TestCase
from django.urls import reverse
from ...cache.versions import get_cache_versions
from ...conf.dynamicsettings import DynamicSettings
from ...conf.test import override_dynamic_settings
from ...users.test import create_test_user
from ..mail import build_mail,... | 2,610 | Python | .py | 60 | 34.316667 | 88 | 0.623669 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,978 | test_cursor_pagination.py | rafalp_Misago/misago/core/tests/test_cursor_pagination.py | import pytest
from ..cursorpagination import CursorPage, EmptyPage, InvalidPage, get_page
@pytest.fixture
def mock_objects(mocker):
return [mocker.Mock(post=i) for i in range(1, 12)]
@pytest.fixture
def mock_queryset(mocker, mock_objects):
return mocker.Mock(filter=mocker.Mock(return_value=mock_objects))
... | 2,635 | Python | .py | 58 | 41.241379 | 82 | 0.720866 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,979 | test_absoluteurl_templatetag.py | rafalp_Misago/misago/core/tests/test_absoluteurl_templatetag.py | from unittest.mock import Mock
import pytest
from ..templatetags.misago_absoluteurl import absoluteurl
@pytest.fixture
def context():
return {"settings": Mock(forum_address="http://test.com/")}
def test_path_is_prefixed_with_forum_address(context):
assert absoluteurl(context, "/path/") == "http://test.com... | 618 | Python | .py | 13 | 44.230769 | 69 | 0.74958 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,980 | test_jsi18n.py | rafalp_Misago/misago/core/tests/test_jsi18n.py | import os
from django.conf import settings
from django.test import TestCase
from django.urls import reverse
from django.utils import translation
MISAGO_DIR = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
LOCALES_DIR = os.path.join(MISAGO_DIR, "locale")
class JsI18nUrlTests(TestC... | 1,352 | Python | .py | 32 | 32.78125 | 85 | 0.623762 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,981 | test_views.py | rafalp_Misago/misago/core/tests/test_views.py | from django.test import TestCase, override_settings
from django.urls import reverse
class CoreViewsTests(TestCase):
def test_js_catalog_view_returns_200(self):
"""js catalog view has no show-stoppers"""
response = self.client.get("/django-i18n.js")
self.assertEqual(response.status_code, 20... | 961 | Python | .py | 19 | 44 | 79 | 0.708333 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,982 | test_shortcuts.py | rafalp_Misago/misago/core/tests/test_shortcuts.py | from django.http import Http404
from django.test import TestCase, override_settings
from django.urls import reverse
from ..shortcuts import get_int_or_404
@override_settings(ROOT_URLCONF="misago.core.testproject.urls")
class PaginateTests(TestCase):
def test_valid_page_handling(self):
"""Valid page numbe... | 6,185 | Python | .py | 158 | 27.556962 | 86 | 0.52714 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,983 | test_checks.py | rafalp_Misago/misago/core/tests/test_checks.py | import warnings
from django.test import TestCase
from .. import SUPPORTED_ENGINES, check_db_engine
INVALID_ENGINES = [
"django.db.backends.sqlite3",
"django.db.backends.mysql",
"django.db.backends.oracle",
]
class TestCheckDBEngine(TestCase):
def test_valid_engines(self):
"""check passes va... | 1,037 | Python | .py | 25 | 31.68 | 78 | 0.62251 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,984 | test_decorators.py | rafalp_Misago/misago/core/tests/test_decorators.py | from django.test import TestCase, override_settings
from django.urls import reverse
@override_settings(ROOT_URLCONF="misago.core.testproject.urls")
class RequirePostTests(TestCase):
def test_require_POST_success(self):
"""require_POST decorator allowed POST request"""
response = self.client.post(r... | 646 | Python | .py | 12 | 47.916667 | 67 | 0.733756 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,985 | test_momentjs.py | rafalp_Misago/misago/core/tests/test_momentjs.py | from django.test import override_settings
from ..momentjs import clean_language_name, get_locale_url
def test_django_language_code_is_cleaned_for_moment_js():
assert clean_language_name("en", ["en"]) == "en"
def test_two_part_django_language_code_is_cleaned_for_moment_js():
assert clean_language_name("en_u... | 1,493 | Python | .py | 25 | 55.24 | 86 | 0.706694 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,986 | progressbar.py | rafalp_Misago/misago/core/management/progressbar.py | import time
def show_progress(command, step, total, since=None):
progress = step * 100 // total
filled = progress // 2
blank = 50 - filled
template = "\r%(step)s (%(progress)s%%) [%(progressbar)s]%(estimation)s"
variables = {
"step": str(step).rjust(len(str(total))),
"progress": s... | 980 | Python | .py | 24 | 35 | 76 | 0.611814 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,987 | models.py | rafalp_Misago/misago/core/testproject/models.py | class Model:
def __init__(self, pk, slug):
self.id, self.pk = pk, pk
self.slug = slug
| 106 | Python | .py | 4 | 20.5 | 33 | 0.539216 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,988 | serializers.py | rafalp_Misago/misago/core/testproject/serializers.py | from rest_framework import serializers
class MockSerializer(serializers.Serializer):
id = serializers.SerializerMethodField()
class Meta:
fields = ["id"]
def get_id(self, obj):
return obj * 2
| 224 | Python | .py | 7 | 26.428571 | 45 | 0.704225 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,989 | urls.py | rafalp_Misago/misago/core/testproject/urls.py | from django.urls import include, path
# Setup Django admin to work with Misago auth
from django.contrib import admin
from django.utils import timezone
from django.views.decorators.cache import cache_page
from django.views.decorators.http import last_modified
from django.views.i18n import JavaScriptCatalog
from . impo... | 3,443 | Python | .py | 94 | 30.138298 | 86 | 0.660389 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,990 | urlswitherrorhandlers.py | rafalp_Misago/misago/core/testproject/urlswitherrorhandlers.py | from .urls import * # pylint: disable=wildcard-import, unused-wildcard-import
handler403 = "misago.core.testproject.views.mock_custom_403_error_page"
handler404 = "misago.core.testproject.views.mock_custom_404_error_page"
| 224 | Python | .py | 3 | 73.333333 | 78 | 0.804545 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,991 | validators.py | rafalp_Misago/misago/core/testproject/validators.py | from rest_framework import serializers
def test_post_validator(context, data):
title_match = "casino" in data.get("title", "").lower()
post_match = "casino" in data.get("post", "").lower()
if title_match or post_match:
raise serializers.ValidationError("Don't discuss gambling!")
| 303 | Python | .py | 6 | 45.666667 | 68 | 0.70068 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,992 | views.py | rafalp_Misago/misago/core/testproject/views.py | from django.core.exceptions import PermissionDenied
from django.http import Http404, HttpResponse
from rest_framework.decorators import api_view
from social_core.backends.github import GithubOAuth2
from social_core.exceptions import AuthFailed, NotAllowedToDisconnect, WrongBackend
from .. import errorpages
from ...use... | 3,320 | Python | .py | 85 | 35.4 | 83 | 0.743799 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,993 | signals.py | rafalp_Misago/misago/threads/signals.py | from django.contrib.auth import get_user_model
from django.db import transaction
from django.db.models import Q
from django.db.models.signals import pre_delete
from django.dispatch import Signal, receiver
from django.utils.translation import pgettext
from ..categories.models import Category
from ..categories.signals i... | 9,747 | Python | .py | 221 | 37.755656 | 86 | 0.711555 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,994 | filters.py | rafalp_Misago/misago/threads/filters.py | from dataclasses import dataclass
from django.http import HttpRequest
from django.db.models import F, Q, QuerySet
from django.utils.translation import pgettext_lazy
from ..readtracker.models import ReadCategory, ReadThread
from ..readtracker.readtime import get_default_read_time
class ThreadsFilter:
name: str
... | 2,788 | Python | .py | 71 | 31.478873 | 84 | 0.658355 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,995 | enums.py | rafalp_Misago/misago/threads/enums.py | from enum import IntEnum, StrEnum
from django.utils.translation import pgettext_lazy
class ThreadWeight(IntEnum):
NOT_PINNED = 0
PINNED_IN_CATEGORY = 1
PINNED_GLOBALLY = 2
class ThreadsListsPolling(IntEnum):
DISABLED = 0
ENABLED_FOR_USERS = 1
ENABLED = 2
@classmethod
def get_choice... | 915 | Python | .py | 31 | 18.387097 | 81 | 0.513667 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,996 | paginator.py | rafalp_Misago/misago/threads/paginator.py | from math import ceil
from django.core.paginator import Paginator
class PostsPaginator(Paginator):
"""Paginator that makes last item on page repeat as first item on next page."""
def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True):
per_page = int(per_page) - 1
i... | 1,057 | Python | .py | 23 | 38.217391 | 86 | 0.63778 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,997 | test.py | rafalp_Misago/misago/threads/test.py | from datetime import timedelta
from django.contrib.auth import get_user_model
from django.utils import timezone
from ..acl.test import patch_user_acl
from ..categories.models import Category
from ..core.utils import slugify
from ..users.test import create_test_user
from .checksums import update_post_checksum
from .mo... | 9,165 | Python | .py | 264 | 26.996212 | 80 | 0.627899 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,998 | filtersearch.py | rafalp_Misago/misago/threads/filtersearch.py | from django.utils.module_loading import import_string
from .. import hooks
from ..conf import settings
filters_list = settings.MISAGO_POST_SEARCH_FILTERS
SEARCH_FILTERS = list(map(import_string, filters_list))
def filter_search(search, filters=None):
filters = filters or SEARCH_FILTERS
for search_filter in... | 499 | Python | .py | 12 | 37.416667 | 55 | 0.765073 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,999 | anonymize.py | rafalp_Misago/misago/threads/anonymize.py | from django.urls import reverse
ANONYMIZABLE_EVENTS = (
"added_participant",
"changed_owner",
"owner_left",
"removed_owner",
"participant_left",
"removed_participant",
)
def anonymize_event(user, event):
if event.event_type not in ANONYMIZABLE_EVENTS:
raise ValueError('event of ty... | 933 | Python | .py | 26 | 29.846154 | 87 | 0.646667 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |