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,700 | get_categories_query_values.py | rafalp_Misago/misago/categories/hooks/get_categories_query_values.py | from typing import Protocol
from ...plugins.hooks import FilterHook
class GetCategoriesQueryValuesHookAction(Protocol):
"""
A standard Misago function used to retrieve a set of arguments for the `values`
call on the categories queryset.
# Return value
A Python `set` with names of the `Category`... | 1,684 | Python | .py | 39 | 37.923077 | 88 | 0.727049 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,701 | get_category_data.py | rafalp_Misago/misago/categories/hooks/get_category_data.py | from typing import Any, Protocol
from ...plugins.hooks import FilterHook
class GetCategoryDataHookAction(Protocol):
"""
A standard Misago function used to build a `dict` with category result from queryset's
result.
# Arguments
## `result: dict[str, Any]`
A `dict` with category data returne... | 1,971 | Python | .py | 50 | 33.78 | 90 | 0.684628 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,702 | urls.py | rafalp_Misago/misago/apiv2/urls.py | from django.urls import include, path
app_name = "apiv2"
urlpatterns = [
path("", include("misago.apiv2.notifications.urls")),
path("", include("misago.apiv2.threads.urls")),
]
| 187 | Python | .py | 6 | 28.5 | 57 | 0.703911 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,703 | decorators.py | rafalp_Misago/misago/apiv2/decorators.py | from functools import wraps
from django.core.exceptions import PermissionDenied
from django.utils.translation import pgettext
def require_auth(f):
@wraps(f)
def auth_only_view(request, *args, **kwargs):
if request.user.is_anonymous:
if request.method in ("GET", "HEAD", "OPTIONS"):
... | 655 | Python | .py | 16 | 31.375 | 81 | 0.619874 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,704 | pagination.py | rafalp_Misago/misago/apiv2/pagination/pagination.py | from dataclasses import dataclass
from typing import Any, List, Optional
from django.http import Http404
from rest_framework.exceptions import ValidationError
class PaginationError(ValidationError):
pass
@dataclass
class PaginationResult:
items: List[Any]
has_next: bool
has_previous: bool
first... | 4,282 | Python | .py | 138 | 24.442029 | 82 | 0.619372 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,705 | __init__.py | rafalp_Misago/misago/apiv2/pagination/__init__.py | from .pagination import PaginationError, PaginationResult, paginate_queryset
__all__ = ["PaginationError", "PaginationResult", "paginate_queryset"]
| 149 | Python | .py | 2 | 73 | 76 | 0.80137 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,706 | conftest.py | rafalp_Misago/misago/apiv2/pagination/tests/conftest.py | import pytest
from ....notifications.models import Notification
@pytest.fixture
def notifications(user):
objects = Notification.objects.bulk_create(
[Notification(user=user, verb=f"test_{i}") for i in range(15)]
)
return sorted([obj.id for obj in objects])
| 281 | Python | .py | 8 | 31.125 | 70 | 0.732342 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,707 | test_paginate_queryset_with_before.py | rafalp_Misago/misago/apiv2/pagination/tests/test_paginate_queryset_with_before.py | from unittest.mock import Mock
import pytest
from django.http import Http404
from ....notifications.models import Notification
from ..pagination import paginate_queryset
def test_pagination_with_before_returns_items_up_to_max_limit(notifications):
request = Mock(GET={"before": notifications[10]})
page = pag... | 3,000 | Python | .py | 61 | 44.57377 | 83 | 0.703538 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,708 | test_paginate_queryset.py | rafalp_Misago/misago/apiv2/pagination/tests/test_paginate_queryset.py | from unittest.mock import Mock
from ....notifications.models import Notification
from ..pagination import paginate_queryset
def test_pagination_returns_all_items(notifications):
request = Mock(GET={})
page = paginate_queryset(request, Notification.objects, "id", 20)
assert len(page.items) == 15
asse... | 3,215 | Python | .py | 71 | 40.577465 | 81 | 0.699325 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,709 | test_paginate_queryset_with_after.py | rafalp_Misago/misago/apiv2/pagination/tests/test_paginate_queryset_with_after.py | from unittest.mock import Mock
import pytest
from django.http import Http404
from ....notifications.models import Notification
from ..pagination import paginate_queryset
def test_pagination_with_after_returns_items_up_to_max_limit(notifications):
request = Mock(GET={"after": notifications[4]})
page = pagina... | 3,289 | Python | .py | 67 | 44.462687 | 86 | 0.704795 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,710 | test_query_values_validation.py | rafalp_Misago/misago/apiv2/pagination/tests/test_query_values_validation.py | from unittest.mock import Mock
import pytest
from ....notifications.models import Notification
from ..pagination import PaginationError, paginate_queryset
def test_pagination_raises_error_if_after_is_not_a_number():
request = Mock(GET={"after": "str"})
with pytest.raises(PaginationError) as excinfo:
... | 3,247 | Python | .py | 59 | 49.525424 | 76 | 0.725971 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,711 | urls.py | rafalp_Misago/misago/apiv2/threads/urls.py | from django.urls import path
from .views import watch_private_thread, watch_thread
urlpatterns = [
path(
"private-threads/<int:thread_id>/watch/",
watch_private_thread,
name="private-thread-watch",
),
path("threads/<int:thread_id>/watch/", watch_thread, name="thread-watch"),
]
| 316 | Python | .py | 10 | 26.8 | 78 | 0.677632 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,712 | views.py | rafalp_Misago/misago/apiv2/threads/views.py | from django.http import HttpRequest, JsonResponse, Http404
from django.shortcuts import get_object_or_404
from rest_framework import serializers
from rest_framework.decorators import api_view
from ...categories.models import Category
from ...notifications.models import WatchedThread
from ...notifications.threads impor... | 2,611 | Python | .py | 58 | 39.724138 | 87 | 0.748817 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,713 | test_thread_watch.py | rafalp_Misago/misago/apiv2/threads/tests/test_thread_watch.py | from django.urls import reverse
from ....acl.test import patch_user_acl
from ....notifications.models import WatchedThread
from ....notifications.threads import ThreadNotifications
def test_thread_watch_api_doesnt_create_watched_thread_for_disabled_notifications(
user, thread, user_client
):
response = user_... | 10,091 | Python | .py | 233 | 37.261803 | 88 | 0.705702 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,714 | serializers.py | rafalp_Misago/misago/apiv2/notifications/serializers.py | from django.contrib.auth import get_user_model
from rest_framework import serializers
from ...notifications.models import Notification
from ...notifications.registry import registry
User = get_user_model()
class NotificationActorSerializer(serializers.ModelSerializer):
class Meta:
model = User
f... | 1,251 | Python | .py | 36 | 26.138889 | 68 | 0.610788 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,715 | urls.py | rafalp_Misago/misago/apiv2/notifications/urls.py | from django.urls import path
from .views import notifications, notifications_read_all
urlpatterns = [
path(
"notifications/",
notifications,
name="notifications",
),
path(
"notifications/read-all/",
notifications_read_all,
name="notifications-read-all",
... | 325 | Python | .py | 14 | 17.5 | 56 | 0.640777 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,716 | views.py | rafalp_Misago/misago/apiv2/notifications/views.py | from typing import List
from django.http import HttpRequest, HttpResponse, JsonResponse
from rest_framework.decorators import api_view
from ...conf import settings
from ...notifications.models import Notification
from ...notifications.permissions import allow_use_notifications
from ..pagination import paginate_querys... | 3,782 | Python | .py | 95 | 31.347368 | 81 | 0.656676 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,717 | test_notifications.py | rafalp_Misago/misago/apiv2/notifications/tests/test_notifications.py | from django.urls import reverse
from ....notifications.models import Notification
def test_notifications_api_returns_403_error_if_client_is_no_authenticated(db, client):
response = client.get(reverse("misago:apiv2:notifications"))
assert response.status_code == 403
def test_notifications_api_returns_empty_... | 7,454 | Python | .py | 168 | 39.160714 | 88 | 0.720769 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,718 | test_notifications_read_all.py | rafalp_Misago/misago/apiv2/notifications/tests/test_notifications_read_all.py | from django.urls import reverse
from ....notifications.models import Notification
def test_notifications_read_all_api_returns_403_error_if_client_is_no_authenticated(
db, client
):
response = client.post(reverse("misago:apiv2:notifications-read-all"))
assert response.status_code == 403
def test_notific... | 2,339 | Python | .py | 57 | 36.368421 | 85 | 0.746566 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,719 | models.py | rafalp_Misago/misago/themes/models.py | from django.db import models
from django.utils.translation import pgettext
from mptt.models import MPTTModel, TreeForeignKey
from .uploadto import (
generate_theme_dirname,
upload_build_css_to,
upload_source_css_to,
upload_media_to,
upload_media_thumbnail_to,
)
class Theme(MPTTModel):
parent ... | 3,432 | Python | .py | 84 | 34.392857 | 88 | 0.683609 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,720 | apps.py | rafalp_Misago/misago/themes/apps.py | from django.apps import AppConfig
class MisagoThemesConfig(AppConfig):
name = "misago.themes"
label = "misago_themes"
verbose_name = "Misago Theming"
def ready(self):
# pylint: disable=unused-import
from .admin import tasks
| 259 | Python | .py | 8 | 27 | 39 | 0.705645 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,721 | context_processors.py | rafalp_Misago/misago/themes/context_processors.py | from .activetheme import get_active_theme
from .cache import get_theme_cache, set_theme_cache
def theme(request):
active_theme = get_theme_cache(request.cache_versions)
if active_theme is None:
active_theme = get_active_theme()
set_theme_cache(request.cache_versions, active_theme)
return ... | 344 | Python | .py | 8 | 38.125 | 61 | 0.735736 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,722 | uploadto.py | rafalp_Misago/misago/themes/uploadto.py | from django.utils.crypto import get_random_string
def generate_theme_dirname():
return get_random_string(8)
def upload_source_css_to(instance, filename):
filename = add_hash_to_filename(instance.source_hash, filename)
return "themes/%s/css/%s" % (instance.theme.dirname, filename)
def upload_build_css_... | 1,040 | Python | .py | 19 | 50.368421 | 85 | 0.730426 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,723 | cache.py | rafalp_Misago/misago/themes/cache.py | from django.core.cache import cache
from . import THEME_CACHE
from ..cache.versions import invalidate_cache
def get_theme_cache(cache_versions):
key = get_cache_key(cache_versions)
return cache.get(key)
def set_theme_cache(cache_versions, theme):
key = get_cache_key(cache_versions)
cache.set(key, t... | 488 | Python | .py | 13 | 34 | 63 | 0.748927 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,724 | activetheme.py | rafalp_Misago/misago/themes/activetheme.py | from .models import Theme
def get_active_theme():
active_theme = Theme.objects.get(is_active=True)
themes = active_theme.get_ancestors(include_self=True)
themes = themes.prefetch_related("css")
include_defaults = False
styles = []
for theme in themes:
if theme.is_default:
... | 715 | Python | .py | 19 | 27.947368 | 67 | 0.606368 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,725 | 0002_create_default_theme_and_cache_version.py | rafalp_Misago/misago/themes/migrations/0002_create_default_theme_and_cache_version.py | # Generated by Django 1.11.16 on 2018-12-26 16:11
from django.db import migrations
from .. import THEME_CACHE
from ...cache.operations import StartCacheVersioning
def create_default_theme(apps, schema_editor):
Theme = apps.get_model("misago_themes", "Theme")
Theme.objects.create(
name="default",
... | 655 | Python | .py | 21 | 25.333333 | 54 | 0.670382 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,726 | 0001_initial.py | rafalp_Misago/misago/themes/migrations/0001_initial.py | # Generated by Django 1.11.17 on 2019-01-03 21:15
from django.db import migrations, models
import django.db.models.deletion
import misago.themes.uploadto
import mptt.fields
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
... | 5,816 | Python | .py | 148 | 21.864865 | 88 | 0.437677 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,727 | 0003_auto_20190518_1659.py | rafalp_Misago/misago/themes/migrations/0003_auto_20190518_1659.py | # Generated by Django 2.2.1 on 2019-05-18 16:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("misago_themes", "0002_create_default_theme_and_cache_version")]
operations = [
migrations.AlterField(
model_name="theme",
name="le... | 729 | Python | .py | 21 | 25.52381 | 85 | 0.610795 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,728 | test_adding_hash_to_filename.py | rafalp_Misago/misago/themes/tests/test_adding_hash_to_filename.py | from ..uploadto import add_hash_to_filename
def test_hash_is_added_before_file_extension():
filename = add_hash_to_filename("hash", "test.jpg")
assert filename == "test.hash.jpg"
def test_hash_is_added_before_file_extension_in_filename_with_multiple_dots():
filename = add_hash_to_filename("hash", "test.... | 547 | Python | .py | 10 | 50.7 | 78 | 0.723164 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,729 | conftest.py | rafalp_Misago/misago/themes/tests/conftest.py | import pytest
from ..models import Theme
@pytest.fixture
def default_theme(db):
return Theme.objects.get(is_default=True)
@pytest.fixture
def theme(db):
return Theme.objects.create(name="Custom theme")
@pytest.fixture
def other_theme(db):
return Theme.objects.create(name="Other theme")
@pytest.fixt... | 452 | Python | .py | 17 | 23.411765 | 52 | 0.762911 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,730 | test_styles_are_included_on_page.py | rafalp_Misago/misago/themes/tests/test_styles_are_included_on_page.py | from ...test import assert_contains
def test_active_theme_styles_are_included_in_page_html(client, active_theme):
css = active_theme.css.create(name="test", url="https://cdn.example.com/style.css")
response = client.get("/")
assert_contains(response, 'link href="%s" rel="stylesheet"' % css.url)
| 310 | Python | .py | 5 | 58.2 | 87 | 0.716172 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,731 | test_context_processors.py | rafalp_Misago/misago/themes/tests/test_context_processors.py | from unittest.mock import Mock
import pytest
from .. import THEME_CACHE
from ..context_processors import theme as context_processor
@pytest.fixture
def mock_request(cache_versions):
return Mock(cache_versions=cache_versions)
def test_theme_data_is_included_in_template_context(db, mock_request):
assert con... | 1,958 | Python | .py | 44 | 40.295455 | 76 | 0.745915 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,732 | test_getting_active_theme.py | rafalp_Misago/misago/themes/tests/test_getting_active_theme.py | from django.core.files.base import ContentFile
from ..activetheme import get_active_theme
from ..models import Theme
def test_active_theme_data_can_be_obtained(db):
assert get_active_theme()
def test_if_active_theme_is_default_theme_include_defaults_flag_is_set(db):
assert get_active_theme()["include_defau... | 2,976 | Python | .py | 66 | 39.969697 | 86 | 0.703678 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,733 | exporter.py | rafalp_Misago/misago/themes/admin/exporter.py | import json
import os
import shutil
from tempfile import TemporaryDirectory
from django.http import FileResponse
from ...core.utils import slugify
def export_theme(theme):
with TemporaryDirectory() as tmp_dir:
export_dir = create_export_directory(tmp_dir, theme)
manifest = create_theme_manifest... | 2,993 | Python | .py | 78 | 31.333333 | 88 | 0.64147 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,734 | importer.py | rafalp_Misago/misago/themes/admin/importer.py | import json
import os
from tempfile import TemporaryDirectory
from zipfile import BadZipFile, ZipFile
from django.core.files.uploadedfile import UploadedFile
from django.utils.translation import pgettext, pgettext_lazy
from ..models import Theme
from .css import create_css
from .forms import (
ThemeCssUrlManifest... | 6,983 | Python | .py | 182 | 30.362637 | 87 | 0.646161 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,735 | tasks.py | rafalp_Misago/misago/themes/admin/tasks.py | import requests
from celery import shared_task
from requests.exceptions import RequestException
from ..cache import clear_theme_cache
from ..models import Theme, Css
from .css import get_theme_media_map, rebuild_css
@shared_task
def update_remote_css_size(pk):
try:
css = Css.objects.get(pk=pk, url__isnul... | 1,342 | Python | .py | 43 | 25.162791 | 75 | 0.671318 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,736 | __init__.py | rafalp_Misago/misago/themes/admin/__init__.py | from django.urls import path
from django.utils.translation import pgettext_lazy
from .views import (
ActivateTheme,
DeleteTheme,
DeleteThemeCss,
DeleteThemeMedia,
EditTheme,
EditThemeCss,
EditThemeCssLink,
MoveThemeCssDown,
MoveThemeCssUp,
NewTheme,
NewThemeCss,
NewTheme... | 3,110 | Python | .py | 94 | 21.361702 | 81 | 0.495352 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,737 | validators.py | rafalp_Misago/misago/themes/admin/validators.py | import re
from django.forms import ValidationError
from django.utils.translation import pgettext
FILENAME_CONTENT = re.compile(r"([a-zA-Z0-9]|\.|_|-)+")
FILENAME_TANGIBILITY = re.compile(r"[a-zA-Z0-9]")
def validate_css_name(filename):
if not filename.lower().endswith(".css"):
raise ValidationError(
... | 1,518 | Python | .py | 39 | 29.794872 | 105 | 0.614966 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,738 | media.py | rafalp_Misago/misago/themes/admin/media.py | import io
from PIL import Image
from django.core.files.images import ImageFile
from ...core.utils import get_file_hash
IMAGE_TYPES = ("image/gif", "image/png", "image/jpeg", "image/bmp", "image/webp")
THUMBNAIL_SIZE = (32, 32)
def create_media(theme, media):
if media_exists(theme, media):
delete_media(... | 1,644 | Python | .py | 53 | 25.169811 | 81 | 0.655414 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,739 | css.py | rafalp_Misago/misago/themes/admin/css.py | import json
import re
from django.core.files.base import ContentFile
from ...core.utils import get_file_hash
def create_css(theme, css):
order = None
if css_exists(theme, css):
order = get_css_order(theme, css)
delete_css(theme, css)
save_css(theme, css, order)
def css_exists(theme, cs... | 3,459 | Python | .py | 95 | 30.452632 | 83 | 0.656014 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,740 | forms.py | rafalp_Misago/misago/themes/admin/forms.py | import re
from django import forms
from django.core.files.base import ContentFile
from django.utils.translation import pgettext, pgettext_lazy
from mptt.forms import TreeNodeChoiceField
from ...core.utils import get_file_hash
from ..models import Theme, Css
from .css import css_needs_rebuilding, create_css, get_next_... | 9,361 | Python | .py | 229 | 32.497817 | 98 | 0.639974 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,741 | views.py | rafalp_Misago/misago/themes/admin/views.py | from django.contrib import messages
from django.db.models import ObjectDoesNotExist
from django.shortcuts import redirect
from django.utils.translation import pgettext, pgettext_lazy
from ...admin.views import generic
from ..cache import clear_theme_cache
from ..models import Theme, Css
from .css import move_css_down,... | 14,262 | Python | .py | 320 | 36.009375 | 112 | 0.651564 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,742 | conftest.py | rafalp_Misago/misago/themes/admin/tests/conftest.py | import os
import pytest
from django.urls import reverse
from ...models import Theme
@pytest.fixture
def default_theme(db):
return Theme.objects.get(is_default=True)
@pytest.fixture
def theme(db):
return Theme.objects.create(name="Custom theme")
@pytest.fixture
def other_theme(db):
return Theme.objec... | 2,785 | Python | .py | 71 | 34.957746 | 87 | 0.704765 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,743 | test_uploading_media.py | rafalp_Misago/misago/themes/admin/tests/test_uploading_media.py | import os
import pytest
from django.core.files.uploadedfile import UploadedFile
from django.urls import reverse
from ....test import assert_has_error_message
TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
@pytest.fixture
def png_file():
return os.path.join(TESTS_DIR, "images", "test.png")
@pytest.fix... | 5,370 | Python | .py | 138 | 33.746377 | 88 | 0.688575 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,744 | test_reordering_css.py | rafalp_Misago/misago/themes/admin/tests/test_reordering_css.py | import pytest
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_has_error_message
from ... import THEME_CACHE
from ..css import get_next_css_order
FIRST = 0
MIDDLE = 1
LAST = 2
@pytest.fixture
def css_list(theme):
return [
theme.css.create(na... | 6,081 | Python | .py | 154 | 35.006494 | 88 | 0.708227 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,745 | test_browsing_theme_assets.py | rafalp_Misago/misago/themes/admin/tests/test_browsing_theme_assets.py | import pytest
from django.urls import reverse
from ....test import assert_contains, assert_not_contains, assert_has_error_message
@pytest.fixture
def assets_client(admin_client):
def get_theme_assets(theme):
url = reverse("misago:admin:themes:assets", kwargs={"pk": theme.pk})
return admin_client.... | 2,136 | Python | .py | 47 | 41.255319 | 88 | 0.760522 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,746 | test_deleting_themes.py | rafalp_Misago/misago/themes/admin/tests/test_deleting_themes.py | from pathlib import Path
import pytest
from django.core.files.base import ContentFile
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_has_error_message
from ... import THEME_CACHE
from ...models import Theme, Css, Media
@pytest.fixture
def delete_link(... | 5,011 | Python | .py | 114 | 39.570175 | 88 | 0.742109 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,747 | test_creating_and_deleting_css_links.py | rafalp_Misago/misago/themes/admin/tests/test_creating_and_deleting_css_links.py | import pytest
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_contains, assert_has_error_message
from ... import THEME_CACHE
@pytest.fixture
def create_link(theme):
return reverse("misago:admin:themes:new-css-link", kwargs={"pk": theme.pk})
@pytes... | 6,266 | Python | .py | 149 | 37.724832 | 87 | 0.712589 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,748 | test_getting_remote_css_size.py | rafalp_Misago/misago/themes/admin/tests/test_getting_remote_css_size.py | import responses
from ..tasks import update_remote_css_size
@responses.activate
def test_task_uses_response_body_to_set_css_size(css_link):
content = "html {}"
content_bytes = content.encode()
responses.add(
responses.GET,
css_link.url,
headers={
"Content-Type": "text... | 903 | Python | .py | 26 | 29.115385 | 70 | 0.689017 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,749 | test_uploading_css.py | rafalp_Misago/misago/themes/admin/tests/test_uploading_css.py | import os
import pytest
from django.core.files.uploadedfile import UploadedFile
from django.urls import reverse
from ....test import assert_has_error_message
TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
@pytest.fixture
def css_file():
return os.path.join(TESTS_DIR, "css", "test.css")
@pytest.fixtur... | 7,380 | Python | .py | 187 | 33.850267 | 88 | 0.67116 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,750 | test_changing_active_theme.py | rafalp_Misago/misago/themes/admin/tests/test_changing_active_theme.py | import pytest
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_has_error_message
from ... import THEME_CACHE
from ...models import Theme
@pytest.fixture
def activate_link(theme):
return reverse("misago:admin:themes:activate", kwargs={"pk": theme.pk})... | 1,550 | Python | .py | 37 | 37.837838 | 85 | 0.752667 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,751 | test_exporting_themes.py | rafalp_Misago/misago/themes/admin/tests/test_exporting_themes.py | from django.urls import reverse
from ....test import assert_has_error_message
def test_exporting_default_theme_sets_error_message(admin_client, default_theme):
export_link = reverse("misago:admin:themes:export", kwargs={"pk": default_theme.pk})
response = admin_client.post(export_link)
assert_has_error_m... | 627 | Python | .py | 14 | 40.571429 | 88 | 0.75 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,752 | test_deleting_assets.py | rafalp_Misago/misago/themes/admin/tests/test_deleting_assets.py | from pathlib import Path
import pytest
from django.core.files.base import ContentFile
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_has_success_message
from ... import THEME_CACHE
@pytest.fixture
def delete_css(admin_client):
def delete_assets(th... | 4,234 | Python | .py | 97 | 39.484536 | 83 | 0.726383 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,753 | test_importing_themes.py | rafalp_Misago/misago/themes/admin/tests/test_importing_themes.py | import os
import pytest
from django.urls import reverse
from ....test import assert_contains
from ...models import Theme
import_link = reverse("misago:admin:themes:import")
class MockThemeExport:
def __init__(self, response):
self.name = "theme-export.zip"
self.content_type = response["content-... | 6,576 | Python | .py | 144 | 40.979167 | 84 | 0.731186 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,754 | test_creating_and_deleting_css_files.py | rafalp_Misago/misago/themes/admin/tests/test_creating_and_deleting_css_files.py | import pytest
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_contains, assert_has_error_message
from ... import THEME_CACHE
@pytest.fixture
def create_link(theme):
return reverse("misago:admin:themes:new-css-file", kwargs={"pk": theme.pk})
@pytes... | 12,124 | Python | .py | 291 | 37.223368 | 87 | 0.705832 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,755 | test_building_css_files.py | rafalp_Misago/misago/themes/admin/tests/test_building_css_files.py | import pytest
from ....cache.test import assert_invalidates_cache
from ... import THEME_CACHE
from ..css import change_css_source, get_theme_media_map, rebuild_css
from ..tasks import build_single_theme_css, build_theme_css
@pytest.fixture
def assert_snapshot_match(snapshot, theme):
def _assert_snapshot_match(re... | 5,379 | Python | .py | 117 | 41.649573 | 87 | 0.724899 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,756 | test_creating_and_editing_themes.py | rafalp_Misago/misago/themes/admin/tests/test_creating_and_editing_themes.py | import pytest
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ....test import assert_contains, assert_has_error_message
from ... import THEME_CACHE
from ...models import Theme
@pytest.fixture
def create_link():
return reverse("misago:admin:themes:new")
@pytest.fixture
d... | 7,412 | Python | .py | 168 | 39.708333 | 88 | 0.715958 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,757 | test_css_name_validation.py | rafalp_Misago/misago/themes/admin/tests/test_css_name_validation.py | import pytest
from django.forms import ValidationError
from ..validators import validate_css_name
def test_validation_fails_if_name_is_missing_css_extension():
with pytest.raises(ValidationError):
validate_css_name("filename")
def test_extension_validation_is_case_insensitive():
validate_css_name("... | 1,029 | Python | .py | 22 | 42 | 70 | 0.758065 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,758 | apps.py | rafalp_Misago/misago/htmx/apps.py | from django.apps import AppConfig
class MisagoHTMXConfig(AppConfig):
name = "misago.htmx"
label = "misago_htmx"
verbose_name = "Misago HTMX utils"
| 161 | Python | .py | 5 | 28.4 | 38 | 0.74026 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,759 | request.py | rafalp_Misago/misago/htmx/request.py | from django.http import HttpRequest
def is_request_htmx(request: HttpRequest) -> bool:
return request.headers.get("hx-request") == "true"
| 144 | Python | .py | 3 | 45 | 54 | 0.755396 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,760 | tests.py | rafalp_Misago/misago/htmx/tests.py | from .request import is_request_htmx
def test_is_request_htmx_returns_true_for_htmx_request(rf):
request = rf.get("/", headers={"hx-request": "true"})
assert is_request_htmx(request)
def test_is_request_htmx_returns_false_for_non_htmx_request(rf):
request = rf.get("/", headers={})
assert not is_requ... | 338 | Python | .py | 7 | 44.428571 | 64 | 0.715596 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,761 | models.py | rafalp_Misago/misago/menus/models.py | from django.db import models
from django.utils.translation import pgettext_lazy
class MenuItem(models.Model):
MENU_BOTH = "both"
MENU_NAVBAR = "navbar"
MENU_FOOTER = "footer"
MENU_CHOICES = [
(MENU_BOTH, pgettext_lazy("menu choice", "Navbar and footer")),
(MENU_NAVBAR, pgettext_lazy("m... | 916 | Python | .py | 23 | 34.086957 | 71 | 0.673423 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,762 | apps.py | rafalp_Misago/misago/menus/apps.py | from django.apps import AppConfig
class MisagoMenusConfig(AppConfig):
name = "misago.menus"
label = "misago_menus"
verbose_name = "Misago Menus"
| 159 | Python | .py | 5 | 28 | 35 | 0.743421 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,763 | context_processors.py | rafalp_Misago/misago/menus/context_processors.py | from typing import List
from .menuitems import get_footer_menu_items, get_navbar_menu_items
from .models import MenuItem
def menus(request):
navbar_items = get_navbar_menu_items(request.cache_versions)
footer_items = get_footer_menu_items(request.cache_versions)
navbarItemsJson = serialize_items(navbar_... | 1,217 | Python | .py | 35 | 26.428571 | 67 | 0.617221 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,764 | cache.py | rafalp_Misago/misago/menus/cache.py | from django.core.cache import cache
from ..cache.versions import invalidate_cache
from . import MENU_ITEMS_CACHE
def get_menus_cache(cache_versions):
key = get_cache_key(cache_versions)
return cache.get(key)
def set_menus_cache(cache_versions, menus):
key = get_cache_key(cache_versions)
cache.set(k... | 508 | Python | .py | 13 | 35.538462 | 73 | 0.751029 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,765 | menu.py | rafalp_Misago/misago/menus/menu.py | from dataclasses import dataclass
from typing import Callable, Optional
from django.http import HttpRequest
from django.urls import reverse
class Menu:
__slots__ = ("items",)
def __init__(self):
self.items: list["MenuItem"] = []
def add_item(
self,
*,
key: str,
u... | 3,084 | Python | .py | 90 | 24.633333 | 88 | 0.560458 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,766 | menuitems.py | rafalp_Misago/misago/menus/menuitems.py | from .cache import set_menus_cache, get_menus_cache
from .models import MenuItem
def get_navbar_menu_items(cache_versions):
return get_items(cache_versions).get(MenuItem.MENU_NAVBAR)
def get_footer_menu_items(cache_versions):
return get_items(cache_versions).get(MenuItem.MENU_FOOTER)
def get_items(cache_v... | 890 | Python | .py | 21 | 37.571429 | 71 | 0.736289 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,767 | 0001_initial.py | rafalp_Misago/misago/menus/migrations/0001_initial.py | # Generated by Django 2.2.3 on 2019-09-15 19:15
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="MenuItem",
fields=[
(
"id",
... | 1,459 | Python | .py | 39 | 20.589744 | 87 | 0.410601 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,768 | 0002_cache_version.py | rafalp_Misago/misago/menus/migrations/0002_cache_version.py | # Generated by Django 1.11.16 on 2018-12-02 15:54
from django.db import migrations
from .. import MENU_ITEMS_CACHE
from ...cache.operations import StartCacheVersioning
class Migration(migrations.Migration):
dependencies = [("misago_menus", "0001_initial"), ("misago_cache", "0001_initial")]
operations = [Sta... | 357 | Python | .py | 7 | 48.285714 | 87 | 0.768786 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,769 | conftest.py | rafalp_Misago/misago/menus/tests/conftest.py | import pytest
from ..menuitems import get_footer_menu_items, get_navbar_menu_items
from ..models import MenuItem
@pytest.fixture
def navar_menu_item(db):
return MenuItem.objects.create(
title="Top Menu Item",
url="https://navbar_menu_item.com",
menu=MenuItem.MENU_NAVBAR,
)
@pytest.f... | 1,396 | Python | .py | 44 | 26.613636 | 84 | 0.699776 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,770 | test_menu.py | rafalp_Misago/misago/menus/tests/test_menu.py | from unittest.mock import Mock
import pytest
from ..menu import Menu
@pytest.fixture
def menu():
return Menu()
def test_add_item_adds_item(menu):
menu.add_item(
key="test",
url_name="misago:account-details",
label="Test",
)
assert len(menu.items) == 1
assert menu.items... | 4,429 | Python | .py | 146 | 23.363014 | 87 | 0.59854 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,771 | test_menus_rendering.py | rafalp_Misago/misago/menus/tests/test_menus_rendering.py | from django.urls import reverse
from ...test import assert_contains
def test_custom_menu_items_are_rendered_in_navbar(client, navar_menu_item):
response = client.get(reverse("misago:index"))
assert_contains(response, navar_menu_item.url)
def test_custom_menu_items_are_rendered_in_footer(client, footer_menu... | 615 | Python | .py | 11 | 52.090909 | 79 | 0.768844 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,772 | test_context_processor.py | rafalp_Misago/misago/menus/tests/test_context_processor.py | from unittest.mock import Mock
from ..context_processors import menus
def test_context_processor_adds_navbar_menu_to_context(
navbar_menu_items, cache_versions
):
result = menus(Mock(cache_versions=cache_versions))
assert isinstance(result, dict)
assert len(navbar_menu_items) == len(result["navbar_me... | 581 | Python | .py | 14 | 37.857143 | 63 | 0.758007 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,773 | ordering.py | rafalp_Misago/misago/menus/admin/ordering.py | from ..models import MenuItem
def get_next_free_order():
last = MenuItem.objects.last()
if last:
return last.order + 1
return 0
| 150 | Python | .py | 6 | 20.333333 | 34 | 0.669014 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,774 | __init__.py | rafalp_Misago/misago/menus/admin/__init__.py | from django.urls import path
from django.utils.translation import pgettext_lazy
from .views import (
DeleteMenuItem,
EditMenuItem,
MenuItemsList,
MoveDownMenuItem,
MoveUpMenuItem,
NewMenuItem,
)
class MisagoAdminExtension:
def register_urlpatterns(self, urlpatterns):
# Menu items
... | 1,341 | Python | .py | 34 | 30.441176 | 88 | 0.599386 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,775 | forms.py | rafalp_Misago/misago/menus/admin/forms.py | from django import forms
from django.utils.translation import pgettext_lazy
from ...admin.forms import YesNoSwitch
from ..models import MenuItem
from ..cache import clear_menus_cache
class MenuItemForm(forms.ModelForm):
title = forms.CharField(label=pgettext_lazy("admin menu item form", "Title"))
url = forms... | 1,934 | Python | .py | 51 | 30.156863 | 122 | 0.624068 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,776 | views.py | rafalp_Misago/misago/menus/admin/views.py | from django.contrib import messages
from django.utils.translation import pgettext_lazy
from ...admin.views import generic
from ..models import MenuItem
from ..cache import clear_menus_cache
from .forms import MenuItemForm
from .ordering import get_next_free_order
class MenuItemAdmin(generic.AdminBaseMixin):
root... | 4,110 | Python | .py | 97 | 33.536082 | 88 | 0.637503 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,777 | conftest.py | rafalp_Misago/misago/menus/admin/tests/conftest.py | import pytest
from django.urls import reverse
from ...models import MenuItem
@pytest.fixture
def list_url():
return reverse("misago:admin:settings:menu-items:index")
@pytest.fixture
def menu_item(db):
return MenuItem.objects.create(
menu=MenuItem.MENU_NAVBAR,
title="Test TMLA",
url=... | 589 | Python | .py | 22 | 21.636364 | 60 | 0.676786 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,778 | test_ordering_menu_links.py | rafalp_Misago/misago/menus/admin/tests/test_ordering_menu_links.py | from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ... import MENU_ITEMS_CACHE
def test_top_menu_item_can_be_moved_down(admin_client, menu_item, other_menu_item):
menu_item.order = 0
menu_item.save()
other_menu_item.order = 1
other_menu_item.save()
admin_cl... | 2,718 | Python | .py | 75 | 30.533333 | 87 | 0.673298 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,779 | test_admin_views.py | rafalp_Misago/misago/menus/admin/tests/test_admin_views.py | import pytest
from django.urls import reverse
from ....test import assert_contains
from ...models import MenuItem
def test_nav_contains_menus_item(admin_client, list_url):
response = admin_client.get(list_url)
assert_contains(response, reverse("misago:admin:settings:menu-items:index"))
def test_empty_list_... | 2,881 | Python | .py | 70 | 34.785714 | 87 | 0.665949 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,780 | results.py | rafalp_Misago/misago/moderation/results.py | from dataclasses import dataclass
class ModerationResult:
pass
@dataclass(frozen=True)
class ModerationTemplateResult:
context: dict
template_name: str
def update_context(self, context: dict):
self.context.update(context)
class ModerationBulkResult:
updated: set[int]
def __init__... | 378 | Python | .py | 13 | 24.384615 | 44 | 0.739496 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,781 | threads.py | rafalp_Misago/misago/moderation/threads.py | from django.contrib import messages
from django.forms import ValidationError
from django.http import HttpRequest
from django.utils.translation import pgettext, pgettext_lazy
from ..categories.models import Category
from ..threads.models import Thread
from .forms import MoveThreads
from .results import ModerationResult... | 4,075 | Python | .py | 96 | 32.739583 | 88 | 0.631606 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,782 | forms.py | rafalp_Misago/misago/moderation/forms.py | from django import forms
from django.http import HttpRequest
from django.utils.translation import pgettext_lazy
from ..categories.proxy import CategoriesProxy
from ..permissions.enums import CategoryPermission
from ..permissions.proxy import UserPermissionsProxy
from ..threads.models import Thread
def get_category_c... | 2,247 | Python | .py | 58 | 31.965517 | 85 | 0.679853 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,783 | apps.py | rafalp_Misago/misago/forumindex/apps.py | from django.apps import AppConfig
class MisagoForumIndexConfig(AppConfig):
name = "misago.forumindex"
label = "misago_forumindex"
verbose_name = "Misago Forum Index"
| 180 | Python | .py | 5 | 32.2 | 40 | 0.768786 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,784 | menus.py | rafalp_Misago/misago/forumindex/menus.py | from dataclasses import replace
from django.http import HttpRequest
from django.urls import reverse
from django.utils.translation import pgettext_lazy
from ..menus.menu import BoundMenuItem, Menu
main_menu = Menu()
main_menu.add_item(
key="threads",
url_name="misago:threads",
label=pgettext_lazy("main ... | 911 | Python | .py | 24 | 34.166667 | 76 | 0.734018 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,785 | views.py | rafalp_Misago/misago/forumindex/views.py | from typing import Tuple
from django.http import Http404
from django.utils.translation import pgettext_lazy
from ..categories.views import index as categories
from ..threads.views.list import threads
IndexView = Tuple[str, callable]
class IndexViews:
views: dict[str, IndexView] = {}
def __init__(self):
... | 1,169 | Python | .py | 34 | 29.647059 | 69 | 0.68125 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,786 | test_forum_index_view.py | rafalp_Misago/misago/forumindex/tests/test_forum_index_view.py | from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains
@override_dynamic_settings(index_view="categories")
def test_forum_index_displays_categories(db, client):
response = client.get(reverse("misago:index"))
assert_contains(response, "page-categ... | 1,771 | Python | .py | 33 | 50.272727 | 76 | 0.769588 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,787 | test_index_views.py | rafalp_Misago/misago/forumindex/tests/test_index_views.py | import pytest
from ..views import IndexViews
index_views = IndexViews()
index_views.add_index_view("threads", "Threads", lambda: "threads")
index_views.add_index_view("categories", "Categories", lambda: "categories")
def test_index_views_get_choices_returns_django_form_choices_tuple():
choices = index_views.get... | 705 | Python | .py | 17 | 37.176471 | 76 | 0.708824 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,788 | test_get_main_menu_items.py | rafalp_Misago/misago/forumindex/tests/test_get_main_menu_items.py | from unittest.mock import Mock
from ..menus import get_main_menu_items
def test_get_main_menu_items_returns_categories_as_first_item():
main_menu = get_main_menu_items(
Mock(path_info="/", settings=Mock(index_view="categories"))
)
assert main_menu[0].key == "categories"
assert main_menu[1].k... | 874 | Python | .py | 20 | 38.6 | 83 | 0.682464 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,789 | privatethreads.py | rafalp_Misago/misago/middleware/privatethreads.py | from typing import TYPE_CHECKING
from django.http import HttpRequest
from ..categories.enums import CategoryTree
from ..categories.models import Category
from ..readtracker.privatethreads import get_unread_private_threads
from ..readtracker.tracker import annotate_categories_read_time
if TYPE_CHECKING:
from ..us... | 1,331 | Python | .py | 31 | 36.548387 | 88 | 0.725369 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,790 | apps.py | rafalp_Misago/misago/middleware/apps.py | from django.apps import AppConfig
class MisagoMiddlewareConfig(AppConfig):
name = "misago.middleware"
label = "misago_middleware"
verbose_name = "Misago Middleware"
| 179 | Python | .py | 5 | 32 | 40 | 0.773256 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,791 | permissions.py | rafalp_Misago/misago/middleware/permissions.py | from ..permissions.proxy import UserPermissionsProxy
def permissions_middleware(get_response):
def middleware(request):
request.user_permissions = UserPermissionsProxy(
request.user, request.cache_versions
)
return get_response(request)
return middleware
| 303 | Python | .py | 8 | 30.875 | 56 | 0.735395 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,792 | categories.py | rafalp_Misago/misago/middleware/categories.py | from ..categories.proxy import CategoriesProxy
def categories_middleware(get_response):
def middleware(request):
request.categories = CategoriesProxy(
request.user_permissions, request.cache_versions
)
return get_response(request)
return middleware
| 297 | Python | .py | 8 | 30.125 | 60 | 0.729825 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,793 | htmx.py | rafalp_Misago/misago/middleware/htmx.py | from ..htmx.request import is_request_htmx
def htmx_middleware(get_response):
def middleware(request):
request.is_htmx = is_request_htmx(request)
return get_response(request)
return middleware
| 220 | Python | .py | 6 | 31.166667 | 50 | 0.734597 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,794 | test_sync_user_unread_private_threads.py | rafalp_Misago/misago/middleware/tests/test_sync_user_unread_private_threads.py | from datetime import timedelta
from unittest.mock import Mock
from django.utils import timezone
from ...categories.proxy import CategoriesProxy
from ...permissions.proxy import UserPermissionsProxy
from ...threads.models import ThreadParticipant
from ...threads.test import post_thread
from ...readtracker.models impor... | 3,164 | Python | .py | 78 | 35.358974 | 89 | 0.749837 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,795 | cursor.py | rafalp_Misago/misago/pagination/cursor.py | from dataclasses import dataclass
from typing import Any, List
from django.http import Http404
class PaginationError(Http404):
pass
class EmptyPageError(PaginationError):
last_cursor: int | None
def __init__(self, last_cursor: int | None):
self.last_cursor = last_cursor
@dataclass
class Curs... | 3,571 | Python | .py | 107 | 26.084112 | 82 | 0.616012 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,796 | apps.py | rafalp_Misago/misago/pagination/apps.py | from django.apps import AppConfig
class MisagoPaginationConfig(AppConfig):
name = "misago.pagination"
label = "misago_pagination"
verbose_name = "Misago pagination utils"
| 185 | Python | .py | 5 | 33.2 | 44 | 0.775281 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,797 | redirect.py | rafalp_Misago/misago/pagination/redirect.py | from urllib.parse import urlencode
from django.http import HttpRequest, HttpResponseRedirect
from django.shortcuts import redirect
from .cursor import EmptyPageError
def redirect_to_last_page(
request: HttpRequest, empty_page_error: EmptyPageError
) -> HttpResponseRedirect:
last_page_url = request.path_info... | 637 | Python | .py | 16 | 35.1875 | 64 | 0.749593 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,798 | conftest.py | rafalp_Misago/misago/pagination/tests/conftest.py | import pytest
from ...notifications.models import Notification
@pytest.fixture
def notifications(user):
objects = Notification.objects.bulk_create(
[Notification(user=user, verb=f"test_{i}") for i in range(15)]
)
return sorted([obj.id for obj in objects])
| 280 | Python | .py | 8 | 31 | 70 | 0.735075 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,799 | test_redirect_to_last_page.py | rafalp_Misago/misago/pagination/tests/test_redirect_to_last_page.py | from unittest.mock import Mock
from ..cursor import EmptyPageError
from ..redirect import redirect_to_last_page
def test_redirect_to_last_page_builds_redirect_without_cursor_for_first_page():
request = Mock(
path_info="/path-info/",
GET=Mock(dict=Mock(return_value={"cursor": 100})),
)
red... | 1,613 | Python | .py | 35 | 40.6 | 79 | 0.688818 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |