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,500 | test_google_site_verification.py | rafalp_Misago/misago/conf/admin/tests/test_google_site_verification.py | import pytest
from django.core.files.uploadedfile import SimpleUploadedFile
from django.urls import reverse
from ...models import Setting
admin_link = reverse("misago:admin:settings:analytics:index")
@pytest.fixture
def setting(db):
return Setting.objects.get(setting="google_site_verification")
@pytest.fixtu... | 2,055 | Python | .py | 39 | 48.589744 | 87 | 0.771429 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,501 | test_blank_avatar_validation.py | rafalp_Misago/misago/conf/admin/tests/test_blank_avatar_validation.py | from io import BytesIO
import pytest
from PIL import Image
from django.core.files.uploadedfile import SimpleUploadedFile
from django.urls import reverse
from ... import settings
from ...models import Setting
admin_link = reverse("misago:admin:settings:users:index")
def create_image(width, height):
image = Ima... | 2,733 | Python | .py | 73 | 32.09589 | 77 | 0.696015 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,502 | test_change_settings_views.py | rafalp_Misago/misago/conf/admin/tests/test_change_settings_views.py | import pytest
from django import forms
from django.urls import reverse
from ....cache.test import assert_invalidates_cache
from ... import SETTINGS_CACHE
from ..forms import SettingsForm
from ..views import SettingsView
@pytest.fixture(autouse=True)
def messages_mock(mocker):
return mocker.patch("misago.conf.adm... | 3,241 | Python | .py | 69 | 42.652174 | 88 | 0.737145 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,503 | test_change_oauth2_settings.py | rafalp_Misago/misago/conf/admin/tests/test_change_oauth2_settings.py | from django.urls import reverse
from ...models import Setting
from ....test import assert_contains, assert_has_error_message
def test_oauth2_can_be_enabled(admin_client):
response = admin_client.post(
reverse("misago:admin:settings:oauth2:index"),
{
"enable_oauth2_client": "1",
... | 22,013 | Python | .py | 470 | 36.829787 | 109 | 0.582876 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,504 | models.py | rafalp_Misago/misago/oauth2/models.py | from django.db import models
from django.utils import timezone
from ..conf import settings
class Subject(models.Model):
sub = models.CharField(max_length=36, primary_key=True) # UUID4 str length
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
created_on = models.DateTimeFiel... | 406 | Python | .py | 8 | 47.375 | 80 | 0.78481 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,505 | client.py | rafalp_Misago/misago/oauth2/client.py | from base64 import urlsafe_b64encode
from hashlib import sha256
from secrets import token_urlsafe
from typing import Any
from urllib.parse import urlencode
import requests
from django.urls import reverse
from django.utils.crypto import get_random_string
from requests.exceptions import RequestException
from . import e... | 6,530 | Python | .py | 166 | 32.319277 | 86 | 0.679822 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,506 | user.py | rafalp_Misago/misago/oauth2/user.py | from django.contrib.auth import get_user_model
from django.db import IntegrityError, transaction
from django.utils import timezone
from django.utils.translation import pgettext_lazy
from ..users.setupnewuser import setup_new_user
from .exceptions import OAuth2UserDataValidationError, OAuth2UserIdNotProvidedError
from ... | 3,316 | Python | .py | 85 | 30.870588 | 106 | 0.64794 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,507 | urls.py | rafalp_Misago/misago/oauth2/urls.py | from django.urls import path
from .views import oauth2_login, oauth2_complete
urlpatterns = [
path("oauth2/login/", oauth2_login, name="oauth2-login"),
path("oauth2/complete/", oauth2_complete, name="oauth2-complete"),
]
| 231 | Python | .py | 6 | 35.833333 | 70 | 0.744395 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,508 | apps.py | rafalp_Misago/misago/oauth2/apps.py | from django.apps import AppConfig
class MisagoOAuthConfig(AppConfig):
name = "misago.oauth2"
label = "misago_oauth2"
verbose_name = "Misago OAuth2"
| 162 | Python | .py | 5 | 28.6 | 35 | 0.748387 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,509 | validation.py | rafalp_Misago/misago/oauth2/validation.py | from dataclasses import dataclass
from django.contrib.auth import get_user_model
from django.forms import ValidationError
from django.utils.crypto import get_random_string
from unidecode import unidecode
from ..users.validators import (
dj_validate_email,
validate_username_content,
validate_username_lengt... | 2,598 | Python | .py | 66 | 33 | 83 | 0.674502 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,510 | exceptions.py | rafalp_Misago/misago/oauth2/exceptions.py | from django.utils.translation import pgettext_lazy
class OAuth2Error(Exception):
pass
class OAuth2ProviderError(OAuth2Error):
pass
class OAuth2AccessDeniedError(OAuth2ProviderError):
message = pgettext_lazy(
"oauth2 error", "The OAuth2 process was canceled by the provider."
)
class OAuth... | 3,739 | Python | .py | 96 | 33.229167 | 119 | 0.734019 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,511 | views.py | rafalp_Misago/misago/oauth2/views.py | from functools import wraps
from logging import getLogger
from django.contrib.auth import get_user_model, login
from django.http import Http404
from django.shortcuts import redirect, render
from django.urls import reverse
from django.views.decorators.cache import never_cache
from ..core.exceptions import Banned
from ... | 2,660 | Python | .py | 80 | 26.075 | 77 | 0.661983 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,512 | 0002_copy_sso_subjects.py | rafalp_Misago/misago/oauth2/migrations/0002_copy_sso_subjects.py | # Generated by Django 3.2.15 on 2023-01-04 12:36
from django.db import migrations
from django.utils import timezone
CHUNK_SIZE = 50
def create_settings(apps, _):
Subject = apps.get_model("misago_oauth2", "Subject")
User = apps.get_model("misago_users", "User")
tz_now = timezone.now()
sso_users = Us... | 1,021 | Python | .py | 30 | 25.966667 | 58 | 0.606742 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,513 | 0001_initial.py | rafalp_Misago/misago/oauth2/migrations/0001_initial.py | # Generated by Django 3.2.15 on 2023-01-04 12:15
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUT... | 1,114 | Python | .py | 33 | 21.090909 | 88 | 0.516729 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,514 | conftest.py | rafalp_Misago/misago/oauth2/tests/conftest.py | from unittest.mock import patch
import pytest
def noop_filter_user_data(request, user, user_data):
return user_data
@pytest.fixture
def disable_user_data_filters():
with patch("misago.oauth2.validation.filter_user_data", noop_filter_user_data):
yield
| 272 | Python | .py | 8 | 30.375 | 83 | 0.76834 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,515 | test_default_user_name_filter.py | rafalp_Misago/misago/oauth2/tests/test_default_user_name_filter.py | from ..validation import filter_name
def test_filter_replaces_spaces_with_underscores(db):
assert filter_name(None, "John Doe") == "John_Doe"
def test_filter_strips_special_characters(db):
assert filter_name(None, "John Doe!") == "John_Doe"
def test_filter_strips_unicode_strings(db):
assert filter_nam... | 1,163 | Python | .py | 25 | 41.6 | 73 | 0.724729 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,516 | test_getting_json_values.py | rafalp_Misago/misago/oauth2/tests/test_getting_json_values.py | from ..client import get_value_from_json
def test_json_str_value_is_returned():
assert get_value_from_json("val", {"val": "ok", "val2": "nope"}) == "ok"
def test_json_str_value_has_stripped_whitespace():
assert get_value_from_json("val", {"val": " ok ", "val2": "nope"}) == "ok"
def test_json_int_value_i... | 2,578 | Python | .py | 88 | 17.022727 | 80 | 0.394737 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,517 | test_get_code_grant.py | rafalp_Misago/misago/oauth2/tests/test_get_code_grant.py | from unittest.mock import Mock
import pytest
from .. import exceptions
from ..client import SESSION_STATE, get_code_grant
def test_code_grant_is_returned_from_request():
state = "l0r3m1p5um"
code_grant = "valid-code"
request = Mock(
GET={
"state": state,
"code": code_gra... | 3,333 | Python | .py | 104 | 25.048077 | 74 | 0.644089 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,518 | test_get_access_token.py | rafalp_Misago/misago/oauth2/tests/test_get_access_token.py | from unittest.mock import Mock, patch
import pytest
from requests.exceptions import Timeout
from ...conf.test import override_dynamic_settings
from .. import exceptions
from ..client import (
REQUESTS_TIMEOUT,
SESSION_CODE_VERIFIER,
get_access_token,
)
ACCESS_TOKEN = "acc3ss-t0k3n"
CODE_GRANT = "valid-co... | 7,851 | Python | .py | 228 | 25.447368 | 88 | 0.597468 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,519 | test_get_code_challenge.py | rafalp_Misago/misago/oauth2/tests/test_get_code_challenge.py | import pytest
from .. import exceptions
from ..client import get_code_challenge
def test_exception_is_raised_if_code_verifier_is_not_provided():
with pytest.raises(exceptions.OAuth2CodeVerifierNotProvidedError):
get_code_challenge(None, "S256")
with pytest.raises(exceptions.OAuth2CodeVerifierNotProv... | 960 | Python | .py | 18 | 48.666667 | 73 | 0.767167 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,520 | test_get_user_data.py | rafalp_Misago/misago/oauth2/tests/test_get_user_data.py | from unittest.mock import Mock, patch
import pytest
from requests.exceptions import Timeout
from ...conf.test import override_dynamic_settings
from .. import exceptions
from ..client import REQUESTS_TIMEOUT, get_user_data
ACCESS_TOKEN = "acc3ss-t0k3n"
@pytest.fixture
def mock_request(dynamic_settings):
return ... | 16,106 | Python | .py | 485 | 25.381443 | 86 | 0.601596 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,521 | test_user_update_with_data.py | rafalp_Misago/misago/oauth2/tests/test_user_update_with_data.py | from unittest.mock import Mock
import pytest
from django.contrib.auth import get_user_model
from ..exceptions import OAuth2UserDataValidationError
from ..models import Subject
from ..user import get_user_from_data
User = get_user_model()
def test_user_is_updated_with_valid_data(user, dynamic_settings):
Subject... | 3,579 | Python | .py | 95 | 29.947368 | 79 | 0.629587 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,522 | test_user_data_filter.py | rafalp_Misago/misago/oauth2/tests/test_user_data_filter.py | from ..validation import filter_user_data
def test_new_user_data_is_filtered_using_default_filters(db, request):
filtered_data = filter_user_data(
request,
None,
{
"id": "242132",
"name": "New User",
"email": "oauth2@example.com",
"avatar": N... | 2,600 | Python | .py | 96 | 18.677083 | 77 | 0.507847 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,523 | test_oauth2_complete_view.py | rafalp_Misago/misago/oauth2/tests/test_oauth2_complete_view.py | import responses
from django.contrib.auth import get_user_model
from django.urls import reverse
from responses.matchers import header_matcher, urlencoded_params_matcher
from ...conf.test import override_dynamic_settings
from ...test import assert_contains
from ...users.bans import ban_ip, ban_user
from ..client import... | 29,501 | Python | .py | 923 | 23.151679 | 91 | 0.570312 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,524 | test_login_url_creation.py | rafalp_Misago/misago/oauth2/tests/test_login_url_creation.py | from unittest.mock import Mock, patch
from urllib.parse import parse_qsl, urlparse
from ...conf.test import override_dynamic_settings
from ..client import (
SESSION_CODE_VERIFIER,
SESSION_STATE,
create_login_url,
)
@override_dynamic_settings(
enable_oauth2_client=True,
oauth2_client_id="clientid1... | 2,602 | Python | .py | 69 | 32.014493 | 79 | 0.671559 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,525 | test_user_creation_from_data.py | rafalp_Misago/misago/oauth2/tests/test_user_creation_from_data.py | from unittest.mock import Mock
import pytest
from django.contrib.auth import get_user_model
from ...conf.test import override_dynamic_settings
from ..exceptions import OAuth2UserDataValidationError
from ..models import Subject
from ..user import get_user_from_data
User = get_user_model()
def test_activated_user_is... | 3,731 | Python | .py | 109 | 26.146789 | 87 | 0.599778 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,526 | test_user_data_validation.py | rafalp_Misago/misago/oauth2/tests/test_user_data_validation.py | from unittest.mock import Mock
import pytest
from ..exceptions import OAuth2UserDataValidationError
from ..validation import validate_user_data
def test_new_user_valid_data_is_validated(db, dynamic_settings):
valid_data = validate_user_data(
Mock(settings=dynamic_settings),
None,
{
... | 3,933 | Python | .py | 126 | 21.142857 | 81 | 0.527484 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,527 | test_oauth2_login_view.py | rafalp_Misago/misago/oauth2/tests/test_oauth2_login_view.py | from unittest.mock import patch
from urllib.parse import urlparse
from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains
from ...users.bans import ban_ip
def test_oauth2_login_view_returns_404_if_oauth_is_disabled(client, dynamic_settings):
assert ... | 2,999 | Python | .py | 73 | 36.739726 | 88 | 0.741569 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,528 | test_headers_dict_creation.py | rafalp_Misago/misago/oauth2/tests/test_headers_dict_creation.py | from ..client import get_headers_dict
def test_empty_headers_dict_is_returned_for_none():
headers = get_headers_dict(None)
assert headers == {}
def test_empty_headers_dict_is_returned_for_empty_str():
headers = get_headers_dict("")
assert headers == {}
def test_empty_headers_dict_is_returned_for_e... | 865 | Python | .py | 19 | 41.368421 | 66 | 0.681055 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,529 | filter_user_data.py | rafalp_Misago/misago/oauth2/hooks/filter_user_data.py | from typing import Optional, Protocol
from django.http import HttpRequest
from ...plugins.hooks import FilterHook
from ...users.models import User
class FilterUserDataHookAction(Protocol):
"""
A standard Misago function used for filtering the user data, or the next
filter function from another plugin.
... | 5,134 | Python | .py | 134 | 31.791045 | 84 | 0.664176 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,530 | __init__.py | rafalp_Misago/misago/oauth2/hooks/__init__.py | from .filter_user_data import filter_user_data_hook
from .validate_user_data import validate_user_data_hook
__all__ = ["filter_user_data_hook", "validate_user_data_hook"]
| 173 | Python | .py | 3 | 56 | 62 | 0.767857 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,531 | validate_user_data.py | rafalp_Misago/misago/oauth2/hooks/validate_user_data.py | from typing import Optional, Protocol
from django.http import HttpRequest
from ...plugins.hooks import FilterHook
from ...users.models import User
class ValidateUserDataHookAction(Protocol):
"""
A standard Misago function used for validating the user data, or the next
filter function from another plugin... | 5,080 | Python | .py | 138 | 30.086957 | 136 | 0.659984 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,532 | models.py | rafalp_Misago/misago/permissions/models.py | from dataclasses import dataclass
from typing import TYPE_CHECKING
from django.conf import settings
from django.contrib.postgres.fields import ArrayField
from django.db import models
from ..users.enums import DefaultGroupId
from .moderator import ModeratorPermissions
if TYPE_CHECKING:
from ..users.models import U... | 2,120 | Python | .py | 47 | 38.340426 | 88 | 0.717201 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,533 | moderator.py | rafalp_Misago/misago/permissions/moderator.py | from dataclasses import dataclass
@dataclass(frozen=True)
class ModeratorPermissions:
is_global: bool
categories_ids: set[int]
private_threads: bool
| 163 | Python | .py | 6 | 23.833333 | 33 | 0.793548 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,534 | enums.py | rafalp_Misago/misago/permissions/enums.py | from enum import StrEnum
class CategoryPermission(StrEnum):
SEE = "see"
BROWSE = "browse"
START = "start"
REPLY = "reply"
ATTACHMENTS = "attachments"
class CategoryQueryContext(StrEnum):
CURRENT = "current"
CHILD = "child"
OTHER = "other"
class CategoryThreadsQuery(StrEnum):
AL... | 1,309 | Python | .py | 34 | 33.705882 | 71 | 0.703791 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,535 | proxy.py | rafalp_Misago/misago/permissions/proxy.py | from functools import cached_property
from typing import TYPE_CHECKING, Any, Union
from django.contrib.auth.models import AnonymousUser
from ..users.enums import DefaultGroupId
from .enums import CategoryPermission
from .models import Moderator
from .moderator import ModeratorPermissions
from .user import get_user_pe... | 2,600 | Python | .py | 66 | 31.151515 | 81 | 0.671576 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,536 | user.py | rafalp_Misago/misago/permissions/user.py | from typing import TYPE_CHECKING, Union
from django.contrib.auth.models import AnonymousUser
from django.core.cache import cache
from ..cache.enums import CacheName
from ..categories.enums import CategoryTree
from ..categories.models import Category
from ..users.enums import DefaultGroupId
from ..users.models import ... | 6,440 | Python | .py | 174 | 29.413793 | 88 | 0.667845 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,537 | privatethreads.py | rafalp_Misago/misago/permissions/privatethreads.py | from django.core.exceptions import PermissionDenied
from django.db.models import QuerySet
from django.http import Http404
from django.utils.translation import pgettext
from ..threads.models import Thread, ThreadParticipant
from .hooks import (
check_private_threads_permission_hook,
check_see_private_thread_per... | 3,222 | Python | .py | 84 | 31.928571 | 86 | 0.728003 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,538 | apps.py | rafalp_Misago/misago/permissions/apps.py | from django.apps import AppConfig
class MisagoPermissionsConfig(AppConfig):
name = "misago.permissions"
label = "misago_permissions"
verbose_name = "Misago Permissions"
| 183 | Python | .py | 5 | 32.8 | 41 | 0.778409 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,539 | accounts.py | rafalp_Misago/misago/permissions/accounts.py | from django.core.exceptions import PermissionDenied
from django.utils.translation import pgettext
def check_delete_own_account_permission(user):
if user.is_misago_admin:
raise PermissionDenied(
pgettext(
"account permission error",
"You can't delete your account... | 605 | Python | .py | 17 | 25.470588 | 82 | 0.610256 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,540 | copy.py | rafalp_Misago/misago/permissions/copy.py | from django.http import HttpRequest
from ..categories.models import Category
from ..postgres.delete import delete_all
from ..users.models import Group
from .hooks import copy_category_permissions_hook, copy_group_permissions_hook
from .models import CategoryGroupPermission
__all__ = ["copy_category_permissions", "cop... | 2,633 | Python | .py | 74 | 29.364865 | 88 | 0.693733 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,541 | permissionsid.py | rafalp_Misago/misago/permissions/permissionsid.py | from hashlib import md5
def get_permissions_id(groups_ids: list[int]):
return md5((".".join(map(str, groups_ids))).encode()).hexdigest()[:12]
| 148 | Python | .py | 3 | 46.333333 | 74 | 0.699301 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,542 | admin.py | rafalp_Misago/misago/permissions/admin.py | from django.utils.translation import pgettext
from ..admin.views.generic import PermissionsFormView
from .enums import CategoryPermission
from .hooks import get_admin_category_permissions_hook
def get_admin_category_permissions(form: PermissionsFormView) -> list[dict]:
perms = [
form.create_permission(
... | 1,514 | Python | .py | 40 | 27.825 | 76 | 0.613342 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,543 | panels.py | rafalp_Misago/misago/permissions/panels.py | from debug_toolbar.panels import Panel
from django.utils.translation import pgettext_lazy
class MisagoUserPermissionsPanel(Panel):
"""Panel that displays current user's permission"""
title = pgettext_lazy("debug toolbar", "Misago User Permissions")
nav_title = pgettext_lazy("debug toolbar", "Misago Permi... | 1,112 | Python | .py | 28 | 30.714286 | 69 | 0.648699 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,544 | operations.py | rafalp_Misago/misago/permissions/operations.py | from typing import Any
def if_true(permissions: dict[str, Any], permission: str, value: bool):
if value is True:
permissions[permission] = True
def if_false(permissions: dict[str, Any], permission: str, value: bool):
if value is False:
permissions[permission] = False
def if_zero_or_greater... | 785 | Python | .py | 16 | 43.6875 | 81 | 0.710145 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,545 | categories.py | rafalp_Misago/misago/permissions/categories.py | from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.utils.translation import pgettext
from ..categories.models import Category
from .enums import CategoryPermission
from .hooks import (
check_browse_category_permission_hook,
check_see_category_permission_hook,
)
from... | 1,609 | Python | .py | 49 | 27.387755 | 85 | 0.731613 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,546 | 0002_default_category_permissions.py | rafalp_Misago/misago/permissions/migrations/0002_default_category_permissions.py | # Generated by Django 4.2.7 on 2023-12-21 22:37
from django.db import migrations
from ...users.enums import DefaultGroupId
from ..enums import CategoryPermission
CATEGORY_PERMISSIONS = (
CategoryPermission.SEE,
CategoryPermission.BROWSE,
CategoryPermission.START,
CategoryPermission.REPLY,
Catego... | 1,611 | Python | .py | 45 | 28.555556 | 80 | 0.690277 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,547 | 0001_initial.py | rafalp_Misago/misago/permissions/migrations/0001_initial.py | # Generated by Django 4.2.7 on 2023-12-21 21:41
from django.conf import settings
from django.db import migrations, models
import django.contrib.postgres.fields
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
("misago_users", "0029_users_permiss... | 2,881 | Python | .py | 83 | 17.457831 | 72 | 0.408879 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,548 | 0003_default_moderators.py | rafalp_Misago/misago/permissions/migrations/0003_default_moderators.py | # Generated by Django 4.2.8 on 2024-01-02 12:10
from django.db import migrations
from ...users.enums import DefaultGroupId
DEFAULT_MODERATOR_GROUPS = (DefaultGroupId.ADMINS, DefaultGroupId.MODERATORS)
def create_default_moderators(apps, schema_editor):
Moderator = apps.get_model("misago_permissions", "Moderat... | 757 | Python | .py | 21 | 29.238095 | 77 | 0.688705 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,549 | conftest.py | rafalp_Misago/misago/permissions/tests/conftest.py | import pytest
from ...categories.models import Category
from ...categories.proxy import CategoriesProxy
from ...threads.test import post_thread
from ...users.test import create_test_user
from ..enums import CategoryPermission
from ..models import CategoryGroupPermission, Moderator
from ..proxy import UserPermissionsPr... | 10,152 | Python | .py | 259 | 33.849421 | 87 | 0.765276 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,550 | test_thread_posts_queryset_filter.py | rafalp_Misago/misago/permissions/tests/test_thread_posts_queryset_filter.py | from ..models import Moderator
from ..proxy import UserPermissionsProxy
from ..threads import filter_thread_posts_queryset
def test_filter_thread_posts_queryset_shows_reply_to_anonymous_user(
cache_versions, anonymous_user, thread, post, reply
):
permissions = UserPermissionsProxy(anonymous_user, cache_versio... | 8,830 | Python | .py | 209 | 37.215311 | 94 | 0.749591 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,551 | test_copy_group_permissions.py | rafalp_Misago/misago/permissions/tests/test_copy_group_permissions.py | import pytest
from ..copy import copy_group_permissions
from ..models import CategoryGroupPermission
def test_copy_group_permissions_copies_group_permissions(members_group, custom_group):
assert not custom_group.can_see_user_profiles
copy_group_permissions(members_group, custom_group)
assert custom_gro... | 1,414 | Python | .py | 38 | 30.894737 | 86 | 0.734949 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,552 | test_permissions_id.py | rafalp_Misago/misago/permissions/tests/test_permissions_id.py | from ..permissionsid import get_permissions_id
def test_permissions_id_is_created_from_groups_ids():
assert get_permissions_id([1])
assert get_permissions_id([1, 6, 9])
def test_permissions_id_is_stable():
assert get_permissions_id([1]) == get_permissions_id([1])
assert get_permissions_id([1, 6, 9])... | 422 | Python | .py | 8 | 48.75 | 73 | 0.690244 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,553 | test_threads_queryset_filter.py | rafalp_Misago/misago/permissions/tests/test_threads_queryset_filter.py | from itertools import product
from ...categories.proxy import CategoriesProxy
from ...threads.enums import ThreadWeight
from ...threads.models import Thread
from ...threads.test import post_thread
from ..proxy import UserPermissionsProxy
from ..threads import filter_category_threads_queryset
def test_threads_querys... | 16,191 | Python | .py | 442 | 30.138009 | 93 | 0.703595 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,554 | test_categories_permissions.py | rafalp_Misago/misago/permissions/tests/test_categories_permissions.py | import pytest
from django.core.exceptions import PermissionDenied
from django.http import Http404
from ...categories.models import Category
from ...testutils import grant_category_group_permissions
from ..categories import (
PermissionDenied,
check_browse_category_permission,
check_see_category_permission,... | 9,394 | Python | .py | 179 | 47.391061 | 95 | 0.765948 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,555 | test_threads_permissions.py | rafalp_Misago/misago/permissions/tests/test_threads_permissions.py | import pytest
from django.core.exceptions import PermissionDenied
from django.http import Http404
from ..enums import CategoryPermission
from ..models import CategoryGroupPermission, Moderator
from ..proxy import UserPermissionsProxy
from ..threads import (
check_post_in_closed_category_permission,
check_see_t... | 17,912 | Python | .py | 397 | 40.052897 | 114 | 0.768796 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,556 | test_category_threads_queryset_filter.py | rafalp_Misago/misago/permissions/tests/test_category_threads_queryset_filter.py | from itertools import product
from ...threads.models import Thread
from ...threads.enums import ThreadWeight
from ...threads.test import post_thread
def test_category_threads_queryset_includes_category_with_see_and_browse_permission(
category_threads_filter_factory,
category,
category_thread,
categor... | 13,676 | Python | .py | 354 | 31.70339 | 97 | 0.698604 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,557 | test_moderator_manager.py | rafalp_Misago/misago/permissions/tests/test_moderator_manager.py | from ..models import Moderator
def test_moderator_manager_get_moderator_permissions_returns_empty_data_for_user_if_none_exist(
user,
):
data = Moderator.objects.get_moderator_permissions(user)
assert not data.is_global
assert not data.categories_ids
def test_moderator_manager_get_moderator_permissio... | 3,977 | Python | .py | 97 | 35.690722 | 95 | 0.742078 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,558 | test_accounts_permissions.py | rafalp_Misago/misago/permissions/tests/test_accounts_permissions.py | import pytest
from django.core.exceptions import PermissionDenied
from ..accounts import check_delete_own_account_permission
def test_regular_user_can_delete_their_own_account(user):
check_delete_own_account_permission(user)
def test_django_staff_cant_delete_their_own_account(staffuser):
with pytest.raises... | 714 | Python | .py | 14 | 46.5 | 63 | 0.797395 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,559 | test_build_user_permissions.py | rafalp_Misago/misago/permissions/tests/test_build_user_permissions.py | from ..enums import CategoryPermission
from ..user import build_user_permissions
def test_build_user_permissions_builds_user_permissions(user):
permissions = build_user_permissions(user)
assert permissions["can_see_user_profiles"]
def test_build_user_permissions_builds_user_permissions_from_multiple_groups(... | 1,860 | Python | .py | 41 | 40.04878 | 86 | 0.751384 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,560 | test_build_user_category_permissions.py | rafalp_Misago/misago/permissions/tests/test_build_user_category_permissions.py | from ..enums import CategoryPermission
from ..models import CategoryGroupPermission
from ..user import build_user_category_permissions
def test_build_user_category_permissions_returns_no_permissions_for_user_without_perms(
custom_group, category
):
permissions = build_user_category_permissions([custom_group],... | 6,812 | Python | .py | 192 | 29.005208 | 91 | 0.700925 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,561 | test_operations.py | rafalp_Misago/misago/permissions/tests/test_operations.py | from ..operations import (
if_false,
if_greater,
if_lesser,
if_true,
if_zero_or_greater,
)
def test_if_true_keeps_permission_false_if_value_is_false():
permissions = {"permission": False}
if_true(permissions, "permission", False)
assert permissions == {"permission": False}
def test_i... | 2,272 | Python | .py | 51 | 40.137255 | 71 | 0.707594 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,562 | test_get_user_permissions.py | rafalp_Misago/misago/permissions/tests/test_get_user_permissions.py | from unittest.mock import patch
from ..user import get_user_permissions
@patch("misago.permissions.user.build_user_permissions")
@patch("misago.permissions.user.cache")
def test_get_user_permissions_builds_user_permissions_on_cache_miss(
cache_mock, build_user_permissions, cache_versions, user
):
build_user_... | 2,349 | Python | .py | 48 | 45.083333 | 78 | 0.771016 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,563 | test_private_threads_permissions.py | rafalp_Misago/misago/permissions/tests/test_private_threads_permissions.py | import pytest
from django.core.exceptions import PermissionDenied
from django.http import Http404
from ...threads.models import ThreadParticipant
from ...threads.test import post_thread
from ..privatethreads import (
check_private_threads_permission,
check_see_private_thread_permission,
check_start_private... | 4,508 | Python | .py | 103 | 39.281553 | 93 | 0.78218 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,564 | test_user_permissions_proxy.py | rafalp_Misago/misago/permissions/tests/test_user_permissions_proxy.py | from ..enums import CategoryPermission
from ..models import CategoryGroupPermission, Moderator
from ..proxy import UserPermissionsProxy
def test_user_permissions_proxy_makes_no_queries_unused(
django_assert_num_queries, user, cache_versions
):
with django_assert_num_queries(0):
proxy = UserPermissions... | 6,479 | Python | .py | 138 | 41.572464 | 103 | 0.764032 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,565 | test_copy_category_permissions.py | rafalp_Misago/misago/permissions/tests/test_copy_category_permissions.py | import pytest
from ..copy import copy_category_permissions
from ..models import CategoryGroupPermission
def test_copy_category_permissions_copies_category_permission(
members_group, sibling_category, other_category
):
CategoryGroupPermission.objects.create(
group=members_group,
category=sibli... | 1,127 | Python | .py | 32 | 28.6875 | 72 | 0.729282 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,566 | checks.py | rafalp_Misago/misago/permissions/threads/checks.py | from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.utils.translation import pgettext
from ...categories.models import Category
from ...threads.models import Thread
from ..categories import check_see_category_permission
from ..enums import CategoryPermission
from ..hooks imp... | 3,382 | Python | .py | 94 | 27.925532 | 76 | 0.671459 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,567 | __init__.py | rafalp_Misago/misago/permissions/threads/__init__.py | from .checks import (
check_post_in_closed_category_permission,
check_see_thread_permission,
check_start_thread_in_category_permission,
)
from .querysets import (
CategoryThreadsQuerysetFilter,
ThreadsQuerysetFilter,
filter_category_threads_queryset,
filter_thread_posts_queryset,
)
__all__ ... | 600 | Python | .py | 20 | 26.15 | 48 | 0.753022 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,568 | querysets.py | rafalp_Misago/misago/permissions/threads/querysets.py | from typing import Iterable
from django.db.models import Q, QuerySet
from ...threads.enums import ThreadWeight
from ...threads.models import Thread
from ..enums import (
CategoryPermission,
CategoryQueryContext,
CategoryThreadsQuery,
)
from ..hooks import (
filter_thread_posts_queryset_hook,
get_c... | 18,636 | Python | .py | 475 | 30.305263 | 87 | 0.648506 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,569 | get_threads_category_query.py | rafalp_Misago/misago/permissions/hooks/get_threads_category_query.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class GetThreadsCategoryQueryHookAction(Protocol):
"""
A standard Misago function used to get the name of the predefined database
`WHERE` clause (represented ... | 3,822 | Python | .py | 92 | 35.565217 | 84 | 0.71208 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,570 | check_browse_category_permission.py | rafalp_Misago/misago/permissions/hooks/check_browse_category_permission.py | from typing import TYPE_CHECKING, Protocol
from ...categories.models import Category
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckBrowseCategoryPermissionHookAction(Protocol):
"""
A standard Misago function used to check if the user has pe... | 4,398 | Python | .py | 102 | 36.509804 | 85 | 0.704695 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,571 | check_start_private_threads_permission.py | rafalp_Misago/misago/permissions/hooks/check_start_private_threads_permission.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckStartPrivateThreadsPermissionHookAction(Protocol):
"""
A standard Misago function used to check if the user has a permission to
start new private t... | 3,133 | Python | .py | 76 | 34.486842 | 86 | 0.716408 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,572 | check_see_private_thread_permission.py | rafalp_Misago/misago/permissions/hooks/check_see_private_thread_permission.py | from typing import TYPE_CHECKING, Protocol
from ...categories.models import Category
from ...plugins.hooks import FilterHook
from ...threads.models import Thread
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckSeePrivateThreadPermissionHookAction(Protocol):
"""
A standard Misago fu... | 3,301 | Python | .py | 84 | 32.583333 | 85 | 0.701413 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,573 | get_category_threads_category_query.py | rafalp_Misago/misago/permissions/hooks/get_category_threads_category_query.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
from ..enums import CategoryQueryContext
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class GetCategoryThreadsCategoryQueryHookAction(Protocol):
"""
A standard Misago function used to get the name of the pre... | 5,077 | Python | .py | 114 | 38.464912 | 83 | 0.723002 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,574 | get_admin_category_permissions.py | rafalp_Misago/misago/permissions/hooks/get_admin_category_permissions.py | # get_stats.py
from typing import Protocol
from ...admin.views.generic import PermissionsFormView
from ...plugins.hooks import ActionHook
class GetAdminCategoryPermissionsHookAction(Protocol):
"""
A function implemented by a plugin that can be registered in this hook.
# Arguments
## `form: Permissi... | 2,426 | Python | .py | 59 | 33.508475 | 93 | 0.666098 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,575 | check_see_thread_permission.py | rafalp_Misago/misago/permissions/hooks/check_see_thread_permission.py | from typing import TYPE_CHECKING, Protocol
from ...categories.models import Category
from ...plugins.hooks import FilterHook
from ...threads.models import Thread
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckSeeThreadPermissionHookAction(Protocol):
"""
A standard Misago function ... | 3,741 | Python | .py | 96 | 32.260417 | 85 | 0.695484 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,576 | build_user_permissions.py | rafalp_Misago/misago/permissions/hooks/build_user_permissions.py | from typing import Protocol
from ...plugins.hooks import FilterHook
from ...users.models import Group
class BuildUserPermissionsHookAction(Protocol):
"""
A standard Misago function used to build user permissions from their groups.
# Arguments
## `groups: list[Group]`
A list of groups user belo... | 2,296 | Python | .py | 59 | 33.016949 | 88 | 0.706897 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,577 | get_category_threads_pinned_category_query.py | rafalp_Misago/misago/permissions/hooks/get_category_threads_pinned_category_query.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
from ..enums import CategoryQueryContext
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class GetCategoryThreadsPinnedCategoryQueryHookAction(Protocol):
"""
A standard Misago function used to get the name of t... | 5,210 | Python | .py | 118 | 38.152542 | 88 | 0.725922 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,578 | check_private_threads_permission.py | rafalp_Misago/misago/permissions/hooks/check_private_threads_permission.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckPrivateThreadsPermissionHookAction(Protocol):
"""
A standard Misago function used to check if the user has a permission to access
private threads f... | 3,057 | Python | .py | 76 | 33.486842 | 83 | 0.71148 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,579 | get_threads_query_orm_filter.py | rafalp_Misago/misago/permissions/hooks/get_threads_query_orm_filter.py | from typing import Protocol
from django.db.models import Q
from ...plugins.hooks import FilterHook
from ..enums import CategoryThreadsQuery
class GetThreadsQueryORMFilterHookAction(Protocol):
"""
A standard Misago function used to get Django's `Q` object instance to
retrieve threads using a specified qu... | 3,392 | Python | .py | 89 | 31.494382 | 86 | 0.666258 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,580 | check_see_category_permission.py | rafalp_Misago/misago/permissions/hooks/check_see_category_permission.py | from typing import TYPE_CHECKING, Protocol
from ...categories.models import Category
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckSeeCategoryPermissionHookAction(Protocol):
"""
A standard Misago function used to check if the user has a per... | 3,255 | Python | .py | 83 | 32.433735 | 86 | 0.7 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,581 | get_category_threads_query.py | rafalp_Misago/misago/permissions/hooks/get_category_threads_query.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
from ..enums import CategoryQueryContext
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class GetCategoryThreadsQueryHookAction(Protocol):
"""
A standard Misago function used to get the name of the predefined ... | 3,815 | Python | .py | 94 | 34.542553 | 83 | 0.708118 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,582 | filter_thread_posts_queryset.py | rafalp_Misago/misago/permissions/hooks/filter_thread_posts_queryset.py | from typing import TYPE_CHECKING, Protocol
from django.db.models import QuerySet
from ...plugins.hooks import FilterHook
from ...threads.models import Thread
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class FilterThreadPostsQuerysetHookAction(Protocol):
"""
A standard Misago function us... | 3,272 | Python | .py | 88 | 30.977273 | 81 | 0.707511 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,583 | __init__.py | rafalp_Misago/misago/permissions/hooks/__init__.py | from .build_user_category_permissions import build_user_category_permissions_hook
from .build_user_permissions import build_user_permissions_hook
from .check_browse_category_permission import check_browse_category_permission_hook
from .check_post_in_closed_category_permission import (
check_post_in_closed_category_... | 2,964 | Python | .py | 62 | 44.854839 | 85 | 0.797311 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,584 | check_post_in_closed_category_permission.py | rafalp_Misago/misago/permissions/hooks/check_post_in_closed_category_permission.py | from typing import TYPE_CHECKING, Protocol
from ...categories.models import Category
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckPostInClosedCategoryPermissionHookAction(Protocol):
"""
A standard Misago function used to check if the user ... | 3,548 | Python | .py | 89 | 33.292135 | 86 | 0.707908 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,585 | check_start_thread_in_category_permission.py | rafalp_Misago/misago/permissions/hooks/check_start_thread_in_category_permission.py | from typing import TYPE_CHECKING, Protocol
from ...categories.models import Category
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class CheckStartThreadInCategoryPermissionHookAction(Protocol):
"""
A standard Misago function used to check if the user... | 3,608 | Python | .py | 90 | 33.611111 | 87 | 0.713056 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,586 | filter_private_threads_queryset.py | rafalp_Misago/misago/permissions/hooks/filter_private_threads_queryset.py | from typing import TYPE_CHECKING, Protocol
from django.db.models import QuerySet
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class FilterPrivateThreadsQuerysetHookAction(Protocol):
"""
A standard Misago function used to set filters on a private thr... | 3,231 | Python | .py | 83 | 32.710843 | 89 | 0.717916 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,587 | build_user_category_permissions.py | rafalp_Misago/misago/permissions/hooks/build_user_category_permissions.py | from typing import Protocol
from ...categories.models import Category
from ...plugins.hooks import FilterHook
from ...users.models import Group
class BuildUserCategoryPermissionsHookAction(Protocol):
"""
A standard Misago function used to get user category permissions.
# Arguments
## `groups: list[... | 4,396 | Python | .py | 115 | 31.417391 | 87 | 0.676352 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,588 | get_category_access_level.py | rafalp_Misago/misago/permissions/hooks/get_category_access_level.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class GetCategoryAccessLevelHookAction(Protocol):
"""
A standard Misago function used to get a user's access level for a category.
Access levels are used to b... | 3,612 | Python | .py | 88 | 35.068182 | 91 | 0.71367 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,589 | filter_private_thread_posts_queryset.py | rafalp_Misago/misago/permissions/hooks/filter_private_thread_posts_queryset.py | from typing import TYPE_CHECKING, Protocol
from django.db.models import QuerySet
from ...plugins.hooks import FilterHook
from ...threads.models import Thread
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class FilterPrivateThreadPostsQuerysetHookAction(Protocol):
"""
A standard Misago func... | 3,399 | Python | .py | 88 | 32.420455 | 82 | 0.716427 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,590 | copy_group_permissions.py | rafalp_Misago/misago/permissions/hooks/copy_group_permissions.py | from typing import Protocol
from django.http import HttpRequest
from ...plugins.hooks import FilterHook
from ...users.models import Group
class CopyGroupPermissionsHookAction(Protocol):
"""
A standard Misago function used to copy permissions from one user group to another
or the next filter function fro... | 2,734 | Python | .py | 75 | 30.426667 | 87 | 0.683066 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,591 | copy_category_permissions.py | rafalp_Misago/misago/permissions/hooks/copy_category_permissions.py | from typing import Protocol
from django.http import HttpRequest
from ...categories.models import Category
from ...plugins.hooks import FilterHook
class CopyCategoryPermissionsHookAction(Protocol):
"""
A standard Misago function used to copy permissions from one category to another
or the next filter fun... | 3,205 | Python | .py | 84 | 31.452381 | 89 | 0.692408 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,592 | get_user_permissions.py | rafalp_Misago/misago/permissions/hooks/get_user_permissions.py | from typing import Protocol
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser
from ...plugins.hooks import FilterHook
User = get_user_model()
class GetUserPermissionsHookAction(Protocol):
"""
A standard Misago function used to get user permissions.
Ret... | 3,019 | Python | .py | 76 | 33.855263 | 88 | 0.707342 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,593 | get_threads_pinned_category_query.py | rafalp_Misago/misago/permissions/hooks/get_threads_pinned_category_query.py | from typing import TYPE_CHECKING, Protocol
from ...plugins.hooks import FilterHook
if TYPE_CHECKING:
from ..proxy import UserPermissionsProxy
class GetThreadsCategoryPinnedQueryHookAction(Protocol):
"""
A standard Misago function used to get the name of the predefined database
`WHERE` clause (repres... | 3,932 | Python | .py | 92 | 36.76087 | 81 | 0.718306 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,594 | urls.py | rafalp_Misago/misago/posting/urls.py | from django.urls import path
from .views.selectcategory import SelectCategoryView
from .views.start import StartPrivateThreadView, StartThreadView
urlpatterns = [
path(
"start-thread/",
SelectCategoryView.as_view(),
name="start-thread",
),
path(
"c/<slug:slug>/<int:id>/sta... | 535 | Python | .py | 20 | 20.8 | 64 | 0.644531 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,595 | apps.py | rafalp_Misago/misago/posting/apps.py | from django.apps import AppConfig
class MisagoPostingConfig(AppConfig):
name = "misago.posting"
label = "misago_posting"
verbose_name = "Misago Posting"
| 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,596 | selectcategory.py | rafalp_Misago/misago/posting/views/selectcategory.py | from django.core.exceptions import PermissionDenied
from django.http import Http404, HttpRequest, HttpResponse
from django.views import View
from django.shortcuts import render
from django.urls import reverse
from django.utils.translation import pgettext
from ...categories.models import Category
from ...permissions.th... | 3,150 | Python | .py | 73 | 30.452055 | 83 | 0.570356 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,597 | start.py | rafalp_Misago/misago/posting/views/start.py | from django.http import Http404, HttpRequest, HttpResponse
from django.views import View
from django.shortcuts import redirect, render
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.translation import pgettext
from ...auth.decorators import login_required
from ..... | 5,409 | Python | .py | 126 | 34.873016 | 87 | 0.677198 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,598 | start.py | rafalp_Misago/misago/posting/state/start.py | from datetime import datetime
from typing import TYPE_CHECKING
from django.db import models, transaction
from django.http import HttpRequest
from ...categories.models import Category
from ...core.utils import slugify
from ...parser.context import ParserContext
from ...threads.checksums import update_post_checksum
fro... | 3,566 | Python | .py | 97 | 28.773196 | 81 | 0.646118 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
18,599 | base.py | rafalp_Misago/misago/posting/state/base.py | from copy import deepcopy
from datetime import datetime
from typing import Any, TYPE_CHECKING
from django.db import models
from django.http import HttpRequest
from django.utils import timezone
from ...categories.models import Category
from ...core.utils import slugify
from ...parser.context import ParserContext, crea... | 3,372 | Python | .py | 80 | 34.7 | 84 | 0.676561 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |