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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
18,300 | operations.py | rafalp_Misago/misago/cache/operations.py | from django.db.migrations import RunPython
class StartCacheVersioning(RunPython):
def __init__(self, cache):
code = start_cache_versioning(cache)
reverse_code = stop_cache_versioning(cache)
super().__init__(code, reverse_code)
class StopCacheVersioning(RunPython):
def __init__(self, ... | 930 | Python | .py | 21 | 37.857143 | 69 | 0.70634 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,301 | 0003_categories.py | rafalp_Misago/misago/cache/migrations/0003_categories.py | # Generated by Django 4.2.10 on 2024-06-17 17:06
from django.db import migrations
from ..enums import CacheName
from ..operations import StartCacheVersioning
class Migration(migrations.Migration):
dependencies = [
("misago_cache", "0002_new_permissions"),
]
operations = [
StartCacheVers... | 356 | Python | .py | 11 | 28 | 51 | 0.735294 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,302 | 0002_new_permissions.py | rafalp_Misago/misago/cache/migrations/0002_new_permissions.py | # Generated by Django 4.2.8 on 2023-12-28 14:45
from django.db import migrations
from ..enums import CacheName
from ..operations import StartCacheVersioning
class Migration(migrations.Migration):
dependencies = [
("misago_cache", "0001_initial"),
]
operations = [
StartCacheVersioning(Ca... | 448 | Python | .py | 13 | 29.384615 | 52 | 0.737209 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,303 | 0001_initial.py | rafalp_Misago/misago/cache/migrations/0001_initial.py | # Generated by Django 1.11.16 on 2018-11-25 15:15
from django.db import migrations, models
from .. import utils
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="CacheVersion",
fields=[
(
... | 693 | Python | .py | 23 | 17.782609 | 88 | 0.479699 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,304 | conftest.py | rafalp_Misago/misago/cache/tests/conftest.py | import pytest
from ..models import CacheVersion
@pytest.fixture
def cache_version(db):
return CacheVersion.objects.create(cache="test_cache")
| 149 | Python | .py | 5 | 27.4 | 58 | 0.815603 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,305 | test_invalidate_caches_management_command.py | rafalp_Misago/misago/cache/tests/test_invalidate_caches_management_command.py | from unittest.mock import Mock
from django.core.management import call_command
def test_management_command_invalidates_all_caches(mocker):
invalidate_all_caches = mocker.patch("misago.cache.versions.invalidate_all_caches")
call_command("invalidateversionedcaches", stdout=Mock())
invalidate_all_caches.ass... | 338 | Python | .py | 6 | 52.833333 | 87 | 0.808511 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,306 | test_assert_invalidates_cache.py | rafalp_Misago/misago/cache/tests/test_assert_invalidates_cache.py | import pytest
from ..models import CacheVersion
from ..test import assert_invalidates_cache
from ..versions import invalidate_cache
def test_assertion_fails_if_specified_cache_is_not_invaldiated(cache_version):
with pytest.raises(AssertionError):
with assert_invalidates_cache(cache_version.cache):
... | 784 | Python | .py | 16 | 43.5625 | 78 | 0.772668 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,307 | test_cache_versions_middleware.py | rafalp_Misago/misago/cache/tests/test_cache_versions_middleware.py | from unittest.mock import Mock
import pytest
from ..middleware import cache_versions_middleware
@pytest.fixture
def get_response():
return Mock()
@pytest.fixture
def request_mock():
return Mock()
def test_middleware_sets_attr_on_request(db, get_response, request_mock):
middleware = cache_versions_mi... | 609 | Python | .py | 17 | 32.352941 | 73 | 0.785223 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,308 | test_invalidating_caches.py | rafalp_Misago/misago/cache/tests/test_invalidating_caches.py | from ..models import CacheVersion
from ..versions import invalidate_all_caches, invalidate_cache
def test_invalidating_cache_updates_cache_version_in_database(cache_version):
invalidate_cache(cache_version.cache)
updated_cache_version = CacheVersion.objects.get(cache=cache_version.cache)
assert cache_vers... | 624 | Python | .py | 10 | 58.6 | 82 | 0.808197 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,309 | invalidateversionedcaches.py | rafalp_Misago/misago/cache/management/commands/invalidateversionedcaches.py | from django.core.management.base import BaseCommand
from ...versions import invalidate_all_caches
class Command(BaseCommand):
help = "Invalidates versioned caches"
def handle(self, *args, **options):
invalidate_all_caches()
self.stdout.write("Invalidated all versioned caches.")
| 307 | Python | .py | 7 | 38.857143 | 62 | 0.75 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,310 | test.py | rafalp_Misago/misago/graphql/test.py | import json
class GraphQLTestClient:
def __init__(self, client, url):
self.client = client
self.url = url
def query(self, query, variables=None):
data = {"query": query}
if variables:
data["variables"] = variables
response = self.client.post(
se... | 525 | Python | .py | 15 | 26.866667 | 71 | 0.599606 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,311 | apps.py | rafalp_Misago/misago/graphql/apps.py | from django.apps import AppConfig
class MisagoGraphQLConfig(AppConfig):
name = "misago.graphql"
label = "misago_graphql"
verbose_name = "Misago GraphQL"
| 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) |
18,312 | conftest.py | rafalp_Misago/misago/graphql/admin/conftest.py | import pytest
from django.urls import reverse
@pytest.fixture
def admin_graphql_link():
return reverse("misago:admin:graphql:index")
| 139 | Python | .py | 5 | 25.6 | 48 | 0.810606 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,313 | versioncheck.py | rafalp_Misago/misago/graphql/admin/versioncheck.py | import requests
from ariadne import QueryType
from django.core.cache import cache
from django.utils.translation import pgettext
from requests.exceptions import RequestException
from ... import __released__, __version__
from .status import Status
CACHE_KEY = "misago_admin_version_check"
CACHE_LENGTH = 3600 * 4 # 4 ho... | 2,895 | Python | .py | 77 | 29.415584 | 199 | 0.621207 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,314 | status.py | rafalp_Misago/misago/graphql/admin/status.py | from enum import IntEnum
from ariadne import EnumType
class Status(IntEnum):
ERROR = 0
WARNING = 1
SUCCESS = 2
status = EnumType("Status", Status)
| 164 | Python | .py | 7 | 20 | 35 | 0.736842 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,315 | analytics.py | rafalp_Misago/misago/graphql/admin/analytics.py | from datetime import timedelta
from ariadne import QueryType
from django.contrib.auth import get_user_model
from django.core.cache import cache
from django.utils import timezone
from ...threads.models import Attachment, Post, Thread
from ...users.models import DataDownload, DeletedUser
CACHE_KEY = "misago_admin_anal... | 2,802 | Python | .py | 75 | 30.2 | 84 | 0.631054 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,316 | __init__.py | rafalp_Misago/misago/graphql/admin/__init__.py | from ariadne_django.views import GraphQLView
from django.urls import path
from .schema import schema
class MisagoAdminExtension:
def register_urlpatterns(self, urlpatterns):
# GraphQL API
urlpatterns.namespace("graphql/", "graphql")
urlpatterns.patterns(
"graphql", path("", Gr... | 378 | Python | .py | 10 | 31.7 | 81 | 0.709589 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,317 | schema.py | rafalp_Misago/misago/graphql/admin/schema.py | import os
from ariadne import QueryType, load_schema_from_path, make_executable_schema
from .analytics import analytics
from .status import status
from .versioncheck import version_check
FILE_PATH = os.path.dirname(os.path.abspath(__file__))
SCHEMA_PATH = os.path.join(FILE_PATH, "schema.graphql")
type_defs = load_s... | 428 | Python | .py | 9 | 46.111111 | 78 | 0.8 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,318 | conftest.py | rafalp_Misago/misago/graphql/admin/tests/conftest.py | import pytest
from django.urls import reverse
from ...test import GraphQLTestClient
@pytest.fixture
def admin_graphql_client(admin_client):
return GraphQLTestClient(admin_client, reverse("misago:admin:graphql:index"))
| 225 | Python | .py | 6 | 35.333333 | 81 | 0.828704 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,319 | test_analytics.py | rafalp_Misago/misago/graphql/admin/tests/test_analytics.py | from datetime import timedelta
import pytest
from ariadne import gql
from django.utils import timezone
from ....threads.models import Attachment, AttachmentType
from ....threads.test import post_thread
from ....users.datadownloads import request_user_data_download
from ....users.deletesrecord import record_user_delet... | 9,841 | Python | .py | 220 | 38.427273 | 87 | 0.682674 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,320 | test_version_check.py | rafalp_Misago/misago/graphql/admin/tests/test_version_check.py | from unittest.mock import ANY, Mock
import pytest
from ariadne import gql
from requests.exceptions import RequestException
from .... import __version__
from ..versioncheck import CACHE_KEY, CACHE_LENGTH, get_latest_version, resolve_version
test_query = gql("{ version { status message description } }")
def mock_req... | 3,208 | Python | .py | 60 | 49.45 | 87 | 0.732331 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,321 | __init__.py | rafalp_Misago/misago/testutils/__init__.py | from .permissions import (
grant_category_group_permissions,
remove_category_group_permissions,
)
__all__ = [
"grant_category_group_permissions",
"remove_category_group_permissions",
]
| 202 | Python | .py | 8 | 22.125 | 40 | 0.735751 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,322 | permissions.py | rafalp_Misago/misago/testutils/permissions.py | from ..categories.models import Category
from ..permissions.enums import CategoryPermission
from ..permissions.models import CategoryGroupPermission
from ..users.models import Group
def grant_category_group_permissions(
category: Category, user_group: Group, *permissions: CategoryPermission
):
CategoryGroupPe... | 713 | Python | .py | 17 | 35.764706 | 88 | 0.75 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,323 | models.py | rafalp_Misago/misago/plugins/models.py | from typing import Any
from django.contrib.postgres.indexes import GinIndex
from django.db import models
class PluginDataModel(models.Model):
plugin_data = models.JSONField(default=dict)
class Meta:
abstract = True
indexes = [GinIndex(fields=["plugin_data"])]
| 288 | Python | .py | 8 | 31.5 | 52 | 0.753623 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,324 | manifest.py | rafalp_Misago/misago/plugins/manifest.py | from dataclasses import dataclass
from typing import Optional
@dataclass(frozen=True)
class MisagoPlugin:
"""
A frozen dataclass with plugin's metadata.
# Optional arguments
## `name: str`
A string with the plugin name. Limited to 100 characters.
## `description: str`
A string with th... | 2,523 | Python | .py | 66 | 32.212121 | 85 | 0.664327 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,325 | urlpatterns.py | rafalp_Misago/misago/plugins/urlpatterns.py | from importlib.util import find_spec
from django.urls import URLResolver, include, path
def discover_plugins_urlpatterns(plugins: list[str]) -> list[URLResolver]:
urlpatterns: list[URLResolver] = []
for plugin in plugins:
if plugin_has_urls(plugin):
urlpatterns.append(path("", include(f"{... | 450 | Python | .py | 10 | 39.8 | 74 | 0.714286 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,326 | enums.py | rafalp_Misago/misago/plugins/enums.py | from enum import Enum
class PluginOutlet(Enum):
"""Enum with standard plugin outlets defined by Misago.
Members values are descriptions of outlets locations, used by the docs generator.
"""
TEST = "Used in some tests."
ADMIN_DASHBOARD_START = "On the Admin dashboard page, above all other conten... | 3,366 | Python | .py | 68 | 43.514706 | 88 | 0.696924 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,327 | discover.py | rafalp_Misago/misago/plugins/discover.py | import importlib
import re
import sys
from pathlib import Path
from typing import Dict, List
def discover_plugins(plugins_path: str | None) -> List[str]:
if not plugins_path:
return []
plugins_path_obj = Path(plugins_path)
if not plugins_path_obj.is_dir():
return []
plugins_apps = di... | 3,260 | Python | .py | 74 | 35.5 | 81 | 0.639759 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,328 | outlets.py | rafalp_Misago/misago/plugins/outlets.py | from functools import wraps
from typing import Dict, List, Protocol
from django.http import HttpRequest
from django.template import Context
from django.utils.safestring import SafeString, mark_safe
from .enums import PluginOutlet
from .hooks import ActionHook
class PluginOutletHookAction(Protocol):
def __call__... | 2,946 | Python | .py | 70 | 36.171429 | 87 | 0.713432 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,329 | metadata.py | rafalp_Misago/misago/plugins/metadata.py | import re
from dataclasses import dataclass
from importlib import import_module
from pathlib import Path
from types import ModuleType
from typing import Dict, List, Optional
from urllib.parse import urlparse
from django.conf import settings
from django.utils.translation import pgettext_lazy
from .manifest import Misa... | 5,955 | Python | .py | 161 | 29.15528 | 120 | 0.651373 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,330 | hooks.py | rafalp_Misago/misago/plugins/hooks.py | from functools import reduce
from typing import Any, Generic, List, TypeVar, cast
Action = TypeVar("Action")
Filter = TypeVar("Filter")
class ActionHook(Generic[Action]):
__slots__ = ("_actions_first", "_actions_last", "_cache")
_actions_first: List[Action]
_actions_last: List[Action]
_cache: List[A... | 2,461 | Python | .py | 59 | 34.067797 | 73 | 0.622792 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,331 | misago_plugins.py | rafalp_Misago/misago/plugins/templatetags/misago_plugins.py | from typing import List
from django import template
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from ..outlets import template_outlets
register = template.Library()
PLUGINOUTLET_SYNTAX_ERROR = 'pluginoutlet tag syntax is "pluginoutlet OUTLET_NAME"'
@register.tag(... | 2,842 | Python | .py | 69 | 33.855072 | 83 | 0.682945 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,332 | test_plugins_metadata_loader.py | rafalp_Misago/misago/plugins/tests/test_plugins_metadata_loader.py | import pytest
from django.conf import settings
from ..metadata import PluginsMetadataLoader
@pytest.fixture
def plugins_metadata():
return PluginsMetadataLoader(settings.INSTALLED_PLUGINS)
def test_plugins_metadata_loader_returns_metadata_dict(plugins_metadata):
metadata = plugins_metadata.get_metadata()
... | 2,820 | Python | .py | 56 | 45.910714 | 88 | 0.775793 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,333 | conftest.py | rafalp_Misago/misago/plugins/tests/conftest.py | import pytest
from django.template import Context, Template
from ..outlets import PluginOutletHook, template_outlets
@pytest.fixture
def patch_outlets():
try:
org_outlets = template_outlets.copy()
for key in template_outlets:
template_outlets[key] = PluginOutletHook()
yield te... | 817 | Python | .py | 24 | 26.75 | 69 | 0.64631 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,334 | test_plugin_metadata_creation.py | rafalp_Misago/misago/plugins/tests/test_plugin_metadata_creation.py | from .. import discover
from ..manifest import MisagoPlugin
from ..metadata import (
clean_plugin_color,
clean_plugin_icon,
clean_plugin_str,
clean_plugin_url,
create_plugin_metadata,
)
def test_plugin_metadata_is_created_without_manifest():
metadata = create_plugin_metadata("plugin_package", ... | 9,647 | Python | .py | 207 | 41.410628 | 84 | 0.710678 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,335 | test_template_tags.py | rafalp_Misago/misago/plugins/tests/test_template_tags.py | from django.template import Context, Template
from django.utils.safestring import mark_safe
from ..outlets import PluginOutlet, append_outlet_action, prepend_outlet_action
def strong_action(request, context):
body = context.get("value") or "none"
return mark_safe(f"<strong>{body}</strong>")
def em_action(r... | 3,055 | Python | .py | 70 | 38.8 | 87 | 0.733039 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,336 | test_read_pip_install_file.py | rafalp_Misago/misago/plugins/tests/test_read_pip_install_file.py | from pathlib import Path
from tempfile import TemporaryDirectory
from ..discover import read_pip_install_file
def test_empty_pip_install_file_is_read_to_empty_list():
with TemporaryDirectory() as plugins_dir:
pip_install_path = Path(plugins_dir) / "pip-install.txt"
with open(pip_install_path, "w"... | 3,115 | Python | .py | 59 | 44.864407 | 74 | 0.658858 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,337 | test_action_hook.py | rafalp_Misago/misago/plugins/tests/test_action_hook.py | import pytest
from ..hooks import ActionHook
class MockActionHook(ActionHook):
def __call__(self, base: str):
return super().__call__(base)
def lowercase_action(base: str) -> str:
return base.lower()
def uppercase_action(base: str) -> str:
return base.upper()
def reverse_action(base: str) -... | 1,298 | Python | .py | 33 | 35.212121 | 76 | 0.727053 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,338 | test_discover_plugins.py | rafalp_Misago/misago/plugins/tests/test_discover_plugins.py | from pathlib import Path
from tempfile import TemporaryDirectory
import pytest
from ..discover import discover_plugins
@pytest.fixture
def sys_mock(mocker):
mock = mocker.patch("misago.plugins.discover.sys")
mock.path = []
return mock
def test_discover_plugins_returns_empty_list_if_plugins_path_is_emp... | 6,806 | Python | .py | 130 | 45.476923 | 88 | 0.69604 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,339 | test_template_outlet_action.py | rafalp_Misago/misago/plugins/tests/test_template_outlet_action.py | from ..outlets import PluginOutlet, append_outlet_action, template_outlet_action
@template_outlet_action
def noop_action(request, context):
return None
def test_noop_template_action_renders_nothing(
patch_outlets, render_outlet_template, snapshot
):
append_outlet_action(PluginOutlet.TEST, noop_action)
... | 1,259 | Python | .py | 28 | 41.392857 | 83 | 0.778507 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,340 | test_discover_plugins_urls.py | rafalp_Misago/misago/plugins/tests/test_discover_plugins_urls.py | from ..urlpatterns import discover_plugins_urlpatterns
def test_discover_plugins_urlpatterns_discovers_apps_with_urls():
urlpatterns = discover_plugins_urlpatterns(["misago.threads", "misago.users"])
assert len(urlpatterns) == 2
def test_discover_plugins_urlpatterns_skips_apps_without_urls():
urlpattern... | 397 | Python | .py | 7 | 52.857143 | 82 | 0.784974 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,341 | test_filter_hook.py | rafalp_Misago/misago/plugins/tests/test_filter_hook.py | import pytest
from ..hooks import FilterHook
ACTION = 0
FIRST_FILTER = 1
SECOND_FILTER = 2
class MockFilterHook(FilterHook):
def __call__(self, action):
return super().__call__(action, [])
def action(data):
return [ACTION]
def first_filter(action, data):
return [action(data), FIRST_FILTER]
... | 1,318 | Python | .py | 36 | 32.722222 | 68 | 0.734499 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,342 | __init__.py | rafalp_Misago/misago/plugins/admin/__init__.py | from django.urls import path
from django.utils.translation import pgettext_lazy
from .views import plugins_list
class MisagoAdminExtension:
def register_urlpatterns(self, urlpatterns):
urlpatterns.namespace("plugins/", "plugins")
urlpatterns.patterns("plugins", path("", plugins_list, name="index... | 562 | Python | .py | 14 | 32.5 | 77 | 0.668508 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,343 | views.py | rafalp_Misago/misago/plugins/admin/views.py | from ...admin.views import render
from ..metadata import plugins_metadata
def plugins_list(request):
return render(
request,
"misago/admin/plugins/list.html",
{"plugins": plugins_metadata.get_metadata().values()},
)
| 250 | Python | .py | 8 | 26 | 62 | 0.683333 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,344 | test_plugins_list.py | rafalp_Misago/misago/plugins/admin/tests/test_plugins_list.py | from django.urls import reverse
from ....test import assert_contains
def test_plugins_list_contains_plugins(admin_client):
response = admin_client.get(reverse("misago:admin:plugins:index"))
assert_contains(response, "Example plugin")
assert_contains(response, "empty_manifest_plugin")
assert_contains... | 1,255 | Python | .py | 23 | 50 | 78 | 0.764321 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,345 | models.py | rafalp_Misago/misago/acl/models.py | from django.db import models
from django.utils.translation import pgettext
from .cache import clear_acl_cache
def permissions_default():
return {}
class BaseRole(models.Model):
name = models.CharField(max_length=255)
special_role = models.CharField(max_length=255, null=True, blank=True)
permissions... | 761 | Python | .py | 22 | 28.727273 | 74 | 0.675824 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,346 | test.py | rafalp_Misago/misago/acl/test.py | from contextlib import ContextDecorator, ExitStack, contextmanager
from unittest.mock import patch
from .useracl import get_user_acl
__all__ = ["patch_user_acl"]
class patch_user_acl(ContextDecorator, ExitStack):
"""Testing utility that patches get_user_acl results
Can be used as decorator or context manag... | 1,510 | Python | .py | 40 | 30 | 84 | 0.634615 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,347 | useracl.py | rafalp_Misago/misago/acl/useracl.py | import copy
from . import buildacl
from .cache import get_acl_cache, set_acl_cache
from .providers import providers
def get_user_acl(user, cache_versions):
user_acl = get_acl_cache(user, cache_versions)
if user_acl is None:
user_acl = buildacl.build_acl(user.get_roles())
set_acl_cache(user, c... | 956 | Python | .py | 23 | 36.782609 | 62 | 0.710583 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,348 | apps.py | rafalp_Misago/misago/acl/apps.py | from django.apps import AppConfig
from .providers import providers
class MisagoACLsConfig(AppConfig):
name = "misago.acl"
label = "misago_acl"
verbose_name = "Misago ACL framework"
def ready(self):
providers.load()
| 243 | Python | .py | 8 | 25.875 | 41 | 0.727273 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,349 | buildacl.py | rafalp_Misago/misago/acl/buildacl.py | from .providers import providers
def build_acl(roles):
"""build ACL for given roles"""
acl = {}
for extension, module in providers.list():
try:
acl = module.build_acl(acl, roles, extension)
except AttributeError:
message = "%s has to define build_acl function" % ex... | 386 | Python | .py | 11 | 27.545455 | 71 | 0.638814 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,350 | objectacl.py | rafalp_Misago/misago/acl/objectacl.py | from .providers import providers
def add_acl_to_obj(user_acl, obj):
"""add valid ACL to obj (iterable of objects or single object)"""
if hasattr(obj, "__iter__"):
for item in obj:
_add_acl_to_obj(user_acl, item)
else:
_add_acl_to_obj(user_acl, obj)
def _add_acl_to_obj(user_ac... | 508 | Python | .py | 13 | 33.076923 | 69 | 0.640816 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,351 | cache.py | rafalp_Misago/misago/acl/cache.py | from django.core.cache import cache
from . import ACL_CACHE
from ..cache.versions import invalidate_cache
def get_acl_cache(user, cache_versions):
key = get_cache_key(user, cache_versions)
return cache.get(key)
def set_acl_cache(user, cache_versions, user_acl):
key = get_cache_key(user, cache_versions)... | 517 | Python | .py | 13 | 36.230769 | 66 | 0.735354 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,352 | middleware.py | rafalp_Misago/misago/acl/middleware.py | from . import useracl
def user_acl_middleware(get_response):
"""Sets request.user_acl attribute with dict containing current user acl."""
def middleware(request):
request.user_acl = useracl.get_user_acl(request.user, request.cache_versions)
return get_response(request)
return middleware
| 320 | Python | .py | 7 | 40.142857 | 85 | 0.7411 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,353 | providers.py | rafalp_Misago/misago/acl/providers.py | from importlib import import_module
from ..conf import settings
_NOT_INITIALIZED_ERROR = (
"PermissionProviders instance has to load providers with load() "
"before get_obj_type_annotators(), get_user_acl_serializers(), "
"list() or dict() methods will be available."
)
_ALREADY_INITIALIZED_ERROR = (
... | 2,592 | Python | .py | 56 | 38.714286 | 73 | 0.683625 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,354 | panels.py | rafalp_Misago/misago/acl/panels.py | from debug_toolbar.panels import Panel
from django.utils.translation import pgettext_lazy
class MisagoACLPanel(Panel):
"""panel that displays current user's ACL"""
title = pgettext_lazy("debug toolbar", "Misago User ACL")
template = "misago/acl_debug.html"
@property
def nav_subtitle(self):
... | 897 | Python | .py | 22 | 32.681818 | 81 | 0.657439 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,355 | algebra.py | rafalp_Misago/misago/acl/algebra.py | def _roles_acls(key_name, roles):
acls = []
for role in roles:
role_permissions = role.permissions.get(key_name)
if role_permissions:
acls.append(role_permissions)
return acls
def sum_acls(result_acl, acls=None, roles=None, key=None, **permissions):
if acls and roles:
... | 1,634 | Python | .py | 49 | 25.183673 | 82 | 0.598089 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,356 | decorators.py | rafalp_Misago/misago/acl/decorators.py | from django.core.exceptions import PermissionDenied
from django.http import Http404
def return_boolean(f):
def decorator(*args, **kwargs):
try:
f(*args, **kwargs)
except (Http404, PermissionDenied):
return False
else:
return True
return decorator
| 318 | Python | .py | 11 | 21.454545 | 51 | 0.641447 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,357 | 0002_acl_version_tracker.py | rafalp_Misago/misago/acl/migrations/0002_acl_version_tracker.py | from django.db import migrations
class Migration(migrations.Migration):
"""Superseded by 0004"""
dependencies = [("misago_acl", "0001_initial"), ("misago_core", "0001_initial")]
operations = []
| 210 | Python | .py | 5 | 37.8 | 84 | 0.696517 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,358 | 0004_cache_version.py | rafalp_Misago/misago/acl/migrations/0004_cache_version.py | # -*- coding: utf-8 -*-
from django.db import migrations
from .. import ACL_CACHE
from ...cache.operations import StartCacheVersioning
class Migration(migrations.Migration):
dependencies = [
("misago_acl", "0003_default_roles"),
("misago_cache", "0001_initial"),
]
operations = [StartCach... | 344 | Python | .py | 10 | 30.2 | 52 | 0.7 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,359 | 0003_default_roles.py | rafalp_Misago/misago/acl/migrations/0003_default_roles.py | from django.db import migrations
pgettext_lazy = lambda c, s: s
def create_default_roles(apps, schema_editor):
Role = apps.get_model("misago_acl", "Role")
Role.objects.create(
name=pgettext_lazy("role name", "Member"),
special_role="authenticated",
permissions={
# account... | 7,060 | Python | .py | 192 | 23.838542 | 76 | 0.497446 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,360 | 0001_initial.py | rafalp_Misago/misago/acl/migrations/0001_initial.py | from django.db import migrations, models
from ..models import permissions_default
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="Role",
fields=[
(
"id",
... | 954 | Python | .py | 29 | 18.482759 | 79 | 0.451087 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,361 | test_getting_user_acl.py | rafalp_Misago/misago/acl/tests/test_getting_user_acl.py | from ..useracl import get_user_acl
def test_getter_returns_authenticated_user_acl(cache_versions, user):
acl = get_user_acl(user, cache_versions)
assert acl
assert acl["user_id"] == user.id
assert acl["is_authenticated"] is True
assert acl["is_anonymous"] is False
def test_user_acl_excludes_adm... | 3,158 | Python | .py | 68 | 41.911765 | 88 | 0.728908 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,362 | test_user_acl_middleware.py | rafalp_Misago/misago/acl/tests/test_user_acl_middleware.py | from unittest.mock import Mock
from ..middleware import user_acl_middleware
def test_middleware_sets_attr_on_request(cache_versions, user):
get_response = Mock()
request = Mock(user=user, cache_versions=cache_versions)
middleware = user_acl_middleware(get_response)
middleware(request)
assert requ... | 597 | Python | .py | 14 | 38.428571 | 63 | 0.762976 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,363 | test_user_acl_context_processor.py | rafalp_Misago/misago/acl/tests/test_user_acl_context_processor.py | from unittest.mock import Mock
from ..context_processors import user_acl
def test_context_processor_adds_request_user_acl_to_context():
test_acl = {"test": True}
context = user_acl(Mock(user_acl=test_acl))
assert context == {"user_acl": test_acl}
| 262 | Python | .py | 6 | 40.166667 | 62 | 0.727273 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,364 | test_providers.py | rafalp_Misago/misago/acl/tests/test_providers.py | import pytest
from ...conf import settings
from ..providers import PermissionProviders
def test_providers_are_not_loaded_on_container_init():
providers = PermissionProviders()
assert not providers._initialized
assert not providers._providers
assert not providers._annotators
assert not providers.... | 2,333 | Python | .py | 58 | 35.155172 | 75 | 0.758805 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,365 | test_acl_algebra.py | rafalp_Misago/misago/acl/tests/test_acl_algebra.py | from .. import algebra
def test_greatest_value_is_returned():
assert algebra.greater(1, 3) == 3
assert algebra.greater(4, 2) == 4
assert algebra.greater(2, 2) == 2
assert algebra.greater(True, False) is True
def test_greatest_or_zero_value_is_returned():
assert algebra.greater_or_zero(1, 3) == 3... | 2,071 | Python | .py | 63 | 25.698413 | 88 | 0.569925 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,366 | test_patching_user_acl.py | rafalp_Misago/misago/acl/tests/test_patching_user_acl.py | from .. import useracl
from ..test import patch_user_acl
def callable_acl_patch(user, user_acl):
user_acl["patched_for_user_id"] = user.id
@patch_user_acl({"is_patched": True})
def test_decorator_patches_all_users_acls_in_test(cache_versions, user):
user_acl = useracl.get_user_acl(user, cache_versions)
... | 2,530 | Python | .py | 50 | 45.28 | 87 | 0.700407 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,367 | test_serializing_user_acl.py | rafalp_Misago/misago/acl/tests/test_serializing_user_acl.py | import json
from ..useracl import get_user_acl, serialize_user_acl
def test_user_acl_is_serializeable(cache_versions, user):
acl = get_user_acl(user, cache_versions)
assert serialize_user_acl(acl)
def test_user_acl_is_json_serializeable(cache_versions, user):
acl = get_user_acl(user, cache_versions)
... | 401 | Python | .py | 9 | 40.777778 | 62 | 0.75969 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,368 | test.py | rafalp_Misago/misago/acl/admin/test.py | from .forms import get_permissions_forms
def mock_role_form_data(model, data):
"""
In order for form to don't fail submission, all permission fields need
to receive values. This function populates data dict with default values
for permissions, making form validation pass
"""
for form in get_pe... | 622 | Python | .py | 16 | 30.25 | 76 | 0.630795 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,369 | __init__.py | rafalp_Misago/misago/acl/admin/__init__.py | from django.urls import path
from django.utils.translation import pgettext_lazy
from .views import DeleteRole, EditRole, NewRole, RolesList, RoleUsers
class MisagoAdminExtension:
def register_urlpatterns(self, urlpatterns):
# Permissions section
urlpatterns.namespace("permissions/", "permissions"... | 986 | Python | .py | 23 | 33.652174 | 74 | 0.612735 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,370 | forms.py | rafalp_Misago/misago/acl/admin/forms.py | from django import forms
from django.utils.translation import pgettext_lazy
from ..models import Role
from ..providers import providers
class RoleForm(forms.ModelForm):
name = forms.CharField(label=pgettext_lazy("admin role form", "Role name"))
class Meta:
model = Role
fields = ["name"]
de... | 1,118 | Python | .py | 29 | 29.758621 | 82 | 0.640408 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,371 | views.py | rafalp_Misago/misago/acl/admin/views.py | from django.contrib import messages
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.translation import pgettext_lazy
from ...admin.views import generic
from ..models import Role
from .forms import RoleForm, get_permissions_forms
class RoleAdmin(generic.AdminBaseMixin):
roo... | 3,201 | Python | .py | 65 | 39.276923 | 88 | 0.640218 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,372 | test_mock_role_admin_form_data.py | rafalp_Misago/misago/acl/admin/tests/test_mock_role_admin_form_data.py | from ...models import Role
from ..test import mock_role_form_data
def test_factory_for_change_role_permissions_form_data():
test_data = mock_role_form_data(Role(), {"can_fly": 1})
assert "can_fly" in test_data
| 220 | Python | .py | 5 | 41 | 59 | 0.71831 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,373 | test_admin_views.py | rafalp_Misago/misago/acl/admin/tests/test_admin_views.py | import pytest
from django.urls import reverse
from ....admin.test import AdminTestCase
from ....cache.test import assert_invalidates_cache
from ....test import assert_contains
from ... import ACL_CACHE
from ...models import Role
from ..test import mock_role_form_data
admin_link = reverse("misago:admin:permissions:ind... | 2,951 | Python | .py | 71 | 36.323944 | 80 | 0.702143 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,374 | signals.py | rafalp_Misago/misago/readtracker/signals.py | from django.dispatch import Signal, receiver
from ..categories.signals import delete_category_content, move_category_content
from ..threads.signals import merge_thread, move_thread
thread_read = Signal()
@receiver(delete_category_content)
def delete_category_threads(sender, **kwargs):
sender.readthread_set.all(... | 889 | Python | .py | 19 | 43.789474 | 79 | 0.783721 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,375 | models.py | rafalp_Misago/misago/readtracker/models.py | from django.conf import settings
from django.db import models
from django.utils import timezone
class ReadCategory(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
category = models.ForeignKey("misago_categories.Category", on_delete=models.CASCADE)
read_time = mo... | 1,020 | Python | .py | 22 | 39.636364 | 88 | 0.710685 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,376 | privatethreads.py | rafalp_Misago/misago/readtracker/privatethreads.py | from datetime import datetime
from django.http import HttpRequest
from django.db.models import F, Q
from ..categories.models import Category
from ..permissions.privatethreads import filter_private_threads_queryset
from .readtime import get_default_read_time
from .tracker import annotate_threads_read_time
def unread... | 1,196 | Python | .py | 32 | 31.75 | 80 | 0.711073 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,377 | apps.py | rafalp_Misago/misago/readtracker/apps.py | from django.apps import AppConfig
class MisagoReadTrackerConfig(AppConfig):
name = "misago.readtracker"
label = "misago_readtracker"
verbose_name = "Misago Read Tracker"
def ready(self):
from . import signals as _
| 241 | Python | .py | 7 | 29.571429 | 41 | 0.727273 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,378 | threads.py | rafalp_Misago/misago/readtracker/threads.py | from datetime import datetime
from django.http import HttpRequest
from django.db.models import F, Q
from ..categories.models import Category
from ..permissions.threads import filter_category_threads_queryset
from ..threads.models import Thread
from .readtime import get_default_read_time
from .tracker import annotate_... | 1,057 | Python | .py | 26 | 34.461538 | 81 | 0.706055 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,379 | tracker.py | rafalp_Misago/misago/readtracker/tracker.py | from datetime import datetime
from typing import TYPE_CHECKING, Iterable
from django.http import HttpRequest
from django.db.models import OuterRef
from ..categories.models import Category
from ..threads.models import Post, Thread
from .readtime import get_default_read_time
from .models import ReadCategory, ReadThread... | 4,806 | Python | .py | 132 | 29.333333 | 88 | 0.669334 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,380 | readtime.py | rafalp_Misago/misago/readtracker/readtime.py | from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Optional
from django.utils import timezone
from ..conf.dynamicsettings import DynamicSettings
if TYPE_CHECKING:
from ..users.models import User
def get_default_read_time(
settings: DynamicSettings,
user: Optional["User"] = None,... | 548 | Python | .py | 14 | 35.357143 | 80 | 0.766603 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,381 | 0002_postread.py | rafalp_Misago/misago/readtracker/migrations/0002_postread.py | # Generated by Django 1.11.5 on 2017-10-07 14:32
import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("misago_categories", "0006_moderation_queue_roles"),
mig... | 2,065 | Python | .py | 60 | 18.033333 | 76 | 0.425075 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,382 | 0003_migrate_reads_to_posts.py | rafalp_Misago/misago/readtracker/migrations/0003_migrate_reads_to_posts.py | # Generated by Django 1.11.5 on 2017-10-07 14:49
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("misago_readtracker", "0002_postread")]
operations = []
| 205 | Python | .py | 5 | 37.8 | 60 | 0.746193 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,383 | 0001_initial.py | rafalp_Misago/misago/readtracker/migrations/0001_initial.py | import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("misago_threads", "0001_initial"),
]
operation... | 2,636 | Python | .py | 80 | 15.7 | 68 | 0.383229 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,384 | 0005_new_tracker.py | rafalp_Misago/misago/readtracker/migrations/0005_new_tracker.py | # Generated by Django 4.2.10 on 2024-08-27 16:36
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
("misago_threads", "0014_plugin_data"),
("misago_catego... | 3,256 | Python | .py | 94 | 18.43617 | 87 | 0.431422 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,385 | 0004_auto_20171015_2010.py | rafalp_Misago/misago/readtracker/migrations/0004_auto_20171015_2010.py | # Generated by Django 1.11.5 on 2017-10-15 20:10
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("misago_readtracker", "0003_migrate_reads_to_posts")]
operations = [
migrations.RemoveField(model_name="categoryread", name="category"),
migrations.RemoveF... | 692 | Python | .py | 13 | 46.769231 | 75 | 0.715976 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,386 | conftest.py | rafalp_Misago/misago/readtracker/tests/conftest.py | from unittest.mock import Mock
import pytest
@pytest.fixture
def read_thread(user, thread):
save_read(user, thread.first_post)
return thread
@pytest.fixture
def anonymous_request_mock(dynamic_settings, anonymous_user, anonymous_user_acl):
return Mock(
settings=dynamic_settings, user=anonymous_u... | 502 | Python | .py | 14 | 32.357143 | 83 | 0.777547 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,387 | test_get_unread_posts.py | rafalp_Misago/misago/readtracker/tests/test_get_unread_posts.py | from datetime import timedelta
from unittest.mock import Mock
from django.utils import timezone
from ..models import ReadCategory, ReadThread
from ..tracker import annotate_threads_read_time, get_unread_posts
def test_get_unread_posts_returns_empty_set_for_anonymous_user(
dynamic_settings, default_category, thr... | 4,489 | Python | .py | 105 | 37.638095 | 86 | 0.728591 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,388 | test_unread_private_threads_exist.py | rafalp_Misago/misago/readtracker/tests/test_unread_private_threads_exist.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 ..models import ReadThread
... | 2,901 | Python | .py | 68 | 37.235294 | 84 | 0.753201 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,389 | test_annotate_threads_read_time.py | rafalp_Misago/misago/readtracker/tests/test_annotate_threads_read_time.py | from django.utils import timezone
from ...threads.models import Thread
from ..models import ReadCategory, ReadThread
from ..tracker import annotate_threads_read_time
def test_annotate_threads_read_time_is_noop_for_anonymous_user(anonymous_user, thread):
queryset = annotate_threads_read_time(anonymous_user, Threa... | 1,854 | Python | .py | 44 | 37.136364 | 87 | 0.732961 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,390 | test_get_unread_categories.py | rafalp_Misago/misago/readtracker/tests/test_get_unread_categories.py | from datetime import timedelta
from unittest.mock import Mock
from django.utils import timezone
from ...categories.models import Category
from ..models import ReadCategory
from ..tracker import annotate_categories_read_time, get_unread_categories
def test_get_unread_categories_returns_empty_set_for_anonymous_user(
... | 5,007 | Python | .py | 111 | 40.099099 | 89 | 0.752834 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,391 | test_get_unread_threads.py | rafalp_Misago/misago/readtracker/tests/test_get_unread_threads.py | from datetime import timedelta
from unittest.mock import Mock
from django.utils import timezone
from ..models import ReadCategory, ReadThread
from ..tracker import annotate_threads_read_time, get_unread_threads
def test_get_unread_threads_returns_empty_set_for_anonymous_user(
dynamic_settings, default_category,... | 4,222 | Python | .py | 99 | 37.545455 | 86 | 0.740269 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,392 | test_min_read_time.py | rafalp_Misago/misago/readtracker/tests/test_min_read_time.py | from datetime import timedelta
from unittest.mock import Mock
from django.utils import timezone
from ...conf.test import override_dynamic_settings
from ..readtime import get_default_read_time
def test_default_read_time_for_empty_user_is_relative_to_current_time(dynamic_settings):
default_read_time = get_default... | 1,729 | Python | .py | 34 | 46.617647 | 88 | 0.759644 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,393 | test_is_category_read.py | rafalp_Misago/misago/readtracker/tests/test_is_category_read.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.test import post_thread
from ..models import ReadThread
from ..threads import is_category_read
def tes... | 7,061 | Python | .py | 175 | 34.428571 | 98 | 0.727486 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,394 | test_mark_category_read.py | rafalp_Misago/misago/readtracker/tests/test_mark_category_read.py | from datetime import timedelta
from django.utils import timezone
from ..models import ReadCategory, ReadThread
from ..tracker import mark_category_read
def test_mark_category_read_creates_read_category(user, default_category):
default_category.last_post_on = timezone.now()
default_category.save()
mark_... | 2,441 | Python | .py | 68 | 30.338235 | 89 | 0.719163 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,395 | test_clearreadtracker_command.py | rafalp_Misago/misago/readtracker/tests/test_clearreadtracker_command.py | from datetime import timedelta
from io import StringIO
import pytest
from django.core import management
from django.utils import timezone
from ...conf.test import override_dynamic_settings
from ..management.commands import clearreadtracker
from ..models import ReadCategory, ReadThread
def call_command() -> list[str... | 3,084 | Python | .py | 95 | 25.831579 | 80 | 0.610924 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,396 | test_annotate_categories_read_time.py | rafalp_Misago/misago/readtracker/tests/test_annotate_categories_read_time.py | from django.utils import timezone
from ...categories.models import Category
from ..models import ReadCategory
from ..tracker import annotate_categories_read_time
def test_annotate_categories_read_time_is_noop_for_anonymous_user(db, anonymous_user):
queryset = annotate_categories_read_time(anonymous_user, Categor... | 1,138 | Python | .py | 24 | 42.75 | 86 | 0.755898 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,397 | test_mark_thread_read.py | rafalp_Misago/misago/readtracker/tests/test_mark_thread_read.py | from datetime import timedelta
from django.utils import timezone
from ..models import ReadThread
from ..tracker import mark_thread_read
def test_mark_thread_read_creates_read_thread_for_thread_without_read_time(
user, default_category, thread
):
read_time = timezone.now()
thread.read_time = None
ma... | 1,461 | Python | .py | 44 | 27.681818 | 80 | 0.696148 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,398 | test_get_unread_private_threads.py | rafalp_Misago/misago/readtracker/tests/test_get_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, reply_thread
from ..models impo... | 7,654 | Python | .py | 181 | 36.403315 | 87 | 0.738439 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,399 | clearreadtracker.py | rafalp_Misago/misago/readtracker/management/commands/clearreadtracker.py | from django.core.management.base import BaseCommand
from ....conf.shortcuts import get_dynamic_settings
from ...readtime import get_default_read_time
from ...models import ReadCategory, ReadThread
class Command(BaseCommand):
help = "Deletes expired read times from the database"
def handle(self, *args, **opt... | 1,064 | Python | .py | 21 | 43.190476 | 77 | 0.67343 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |