id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
17,800 | test_paginate_queryset.py | rafalp_Misago/misago/pagination/tests/test_paginate_queryset.py | from unittest.mock import Mock
from ...notifications.models import Notification
from ..cursor import paginate_queryset
def test_pagination_returns_all_items(notifications):
request = Mock(GET={})
page = paginate_queryset(request, Notification.objects, 20, "id")
assert len(page.items) == 15
assert no... | 3,276 | Python | .py | 71 | 41.408451 | 86 | 0.718829 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,801 | test_paginate_queryset_with_cursor.py | rafalp_Misago/misago/pagination/tests/test_paginate_queryset_with_cursor.py | from unittest.mock import Mock
import pytest
from ...notifications.models import Notification
from ..cursor import EmptyPageError, paginate_queryset
def test_pagination_with_cursor_returns_items_up_to_limit(notifications):
request = Mock(GET={"cursor": notifications[4]})
page = paginate_queryset(request, No... | 3,195 | Python | .py | 67 | 42.955224 | 100 | 0.718528 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,802 | test_query_values_validation.py | rafalp_Misago/misago/pagination/tests/test_query_values_validation.py | from unittest.mock import Mock
import pytest
from ...notifications.models import Notification
from ..cursor import PaginationError, paginate_queryset
def test_pagination_raises_error_if_cursor_is_not_a_number(db):
request = Mock(GET={"cursor": "str"})
with pytest.raises(PaginationError) as excinfo:
... | 991 | Python | .py | 19 | 47.263158 | 67 | 0.745303 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,803 | apps.py | rafalp_Misago/misago/metatags/apps.py | from django.apps import AppConfig
class MisagoMetatagsConfig(AppConfig):
name = "misago.metatags"
label = "misago_metatags"
verbose_name = "Misago Metatags"
| 171 | Python | .py | 5 | 30.4 | 38 | 0.762195 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,804 | metatags.py | rafalp_Misago/misago/metatags/metatags.py | from django.conf import settings as dj_settings
from django.http import HttpRequest
from django.templatetags.static import static
from .hooks import get_default_metatags_hook, get_forum_index_metatags_hook
from .metatag import MetaTag
__all__ = ["MetaTag", "get_default_metatags", "get_forum_index_metatags"]
def get... | 3,139 | Python | .py | 77 | 29.454545 | 86 | 0.582457 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,805 | metatag.py | rafalp_Misago/misago/metatags/metatag.py | import html
from dataclasses import dataclass
@dataclass(frozen=True)
class MetaTag:
content: str | int
name: str | None = None
property: str | None = None
itemprop: str | None = None
def get_attrs(self) -> dict[str, str]:
attrs: dict[str, str] = {}
if self.name:
attrs... | 777 | Python | .py | 22 | 28.090909 | 88 | 0.593333 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,806 | test_default_metatags.py | rafalp_Misago/misago/metatags/tests/test_default_metatags.py | from django.conf import settings
from ...conf.dynamicsettings import DynamicSettings
from ...conf.models import Setting
from ..metatags import get_default_metatags
def test_get_default_metatags_returns_default_metatags_with_default_og_image(
rf, dynamic_settings
):
request = rf.get("/")
request.settings ... | 2,492 | Python | .py | 77 | 23.545455 | 86 | 0.543867 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,807 | test_forum_index_metatags.py | rafalp_Misago/misago/metatags/tests/test_forum_index_metatags.py | from django.conf import settings
from ...conf.test import override_dynamic_settings
from ..metatags import get_forum_index_metatags
@override_dynamic_settings(index_title="Index Title")
def test_get_forum_index_metatags_includes_index_title_if_set(rf, dynamic_settings):
request = rf.get("/")
request.settings... | 5,304 | Python | .py | 159 | 23.899371 | 86 | 0.530811 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,808 | get_forum_index_metatags.py | rafalp_Misago/misago/metatags/hooks/get_forum_index_metatags.py | from typing import Protocol
from django.http import HttpRequest
from ...plugins.hooks import FilterHook
from ..metatag import MetaTag
class GetForumIndexMetatagsHookAction(Protocol):
"""
A standard Misago function used to get metatags for the forum index page.
# Arguments
## `request: HttpRequest`... | 2,361 | Python | .py | 64 | 30.765625 | 83 | 0.696689 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,809 | get_default_metatags.py | rafalp_Misago/misago/metatags/hooks/get_default_metatags.py | from typing import Protocol
from django.http import HttpRequest
from ...plugins.hooks import FilterHook
from ..metatag import MetaTag
class GetDefaultMetatagsHookAction(Protocol):
"""
A standard Misago function used to get default metatags for all pages.
# Arguments
## `request: HttpRequest`
... | 2,302 | Python | .py | 64 | 29.84375 | 83 | 0.692203 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,810 | users.py | rafalp_Misago/misago/faker/users.py | import hashlib
import random
from django.contrib.auth import get_user_model
from django.utils.crypto import get_random_string
from ..users.bans import ban_user
from ..users.test import create_test_user
from .utils import retry_on_db_error
User = get_user_model()
AVATAR_SIZES = (400, 200, 100)
GRAVATAR_URL = "https:... | 1,807 | Python | .py | 51 | 30.509804 | 84 | 0.695276 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,811 | colors.py | rafalp_Misago/misago/faker/colors.py | # Tailwind colors palette, 500 - 900 shades
# https://tailwindcss.com/docs/customizing-colors
COLORS = [
# Slate
"#64748b",
"#475569",
"#334155",
"#1e293b",
"#0f172a",
# Gray
"#6b7280",
"#4b5563",
"#374151",
"#1f2937",
"#111827",
# Zinc
"#71717a",
"#52525b",
... | 2,019 | Python | .py | 136 | 9.963235 | 49 | 0.450345 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,812 | englishcorpus.py | rafalp_Misago/misago/faker/englishcorpus.py | import os
import random
PHRASES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "phrases.txt")
class EnglishCorpus:
def __init__(self, phrases_file=PHRASES_FILE, min_length=None, max_length=None):
self._countdown = 0
self._previous = None
self.phrases = []
with op... | 1,451 | Python | .py | 38 | 28.605263 | 86 | 0.589707 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,813 | apps.py | rafalp_Misago/misago/faker/apps.py | from django.apps import AppConfig
class MisagoFakerConfig(AppConfig):
name = "misago.faker"
label = "misago_faker"
verbose_name = "Misago Test Data Generator"
| 173 | Python | .py | 5 | 30.8 | 47 | 0.753012 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,814 | bans.py | rafalp_Misago/misago/faker/bans.py | import random
from datetime import timedelta
from django.utils import timezone
from ..users.models import Ban
def get_fake_username_ban(fake):
ban = _create_base_ban(fake, Ban.USERNAME)
banned_value = fake.first_name()
if random.randint(0, 100) < 31:
banned_value = "%s*" % banned_value
elif... | 2,961 | Python | .py | 73 | 32.369863 | 74 | 0.58842 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,815 | utils.py | rafalp_Misago/misago/faker/utils.py | from django.db import IntegrityError
from django.db.transaction import TransactionManagementError
def retry_on_db_error(f):
def wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
except (IntegrityError, TransactionManagementError):
return wrapper(*args, **kwargs)
... | 336 | Python | .py | 9 | 30.666667 | 60 | 0.700617 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,816 | posts.py | rafalp_Misago/misago/faker/posts.py | import random
from django.utils import timezone
from ..threads.checksums import update_post_checksum
from ..threads.models import Post
from .englishcorpus import EnglishCorpus
from .users import get_fake_username
PLACEKITTEN_URL = "https://dummyimage.com/g/%s/%s"
corpus = EnglishCorpus()
def get_fake_post(fake, t... | 2,542 | Python | .py | 65 | 31.923077 | 88 | 0.634216 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,817 | threads.py | rafalp_Misago/misago/faker/threads.py | from django.utils import timezone
from ..threads.models import Thread
from .englishcorpus import EnglishCorpus
from .posts import get_fake_hidden_post, get_fake_post, get_fake_unapproved_post
corpus_short = EnglishCorpus(max_length=150)
def get_fake_thread(fake, category, starter=None):
thread = _create_base_th... | 1,780 | Python | .py | 44 | 35.204545 | 80 | 0.70889 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,818 | categories.py | rafalp_Misago/misago/faker/categories.py | import random
from ..categories.models import Category, RoleCategoryACL
from ..permissions.copy import copy_category_permissions
from .colors import COLORS
def fake_category(fake, parent, copy_permissions=None):
category = Category()
category.set_name(fake_category_name(fake))
if random.randint(1, 100) ... | 1,629 | Python | .py | 41 | 33.02439 | 64 | 0.692357 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,819 | conftest.py | rafalp_Misago/misago/faker/tests/conftest.py | import pytest
from faker import Factory
@pytest.fixture
def fake():
return Factory.create()
| 98 | Python | .py | 5 | 17.4 | 27 | 0.802198 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,820 | test_create_fake_users_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_users_command.py | from io import StringIO
from django.contrib.auth import get_user_model
from django.core.management import call_command
from ..management.commands import createfakeusers
User = get_user_model()
def test_management_command_creates_fake_users(db):
call_command(createfakeusers.Command(), stdout=StringIO())
ass... | 346 | Python | .py | 8 | 40.625 | 62 | 0.813814 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,821 | test_create_fake_bans_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_bans_command.py | from io import StringIO
from django.core.management import call_command
from ...cache.test import assert_invalidates_cache
from ...users import BANS_CACHE
from ...users.models import Ban
from ..management.commands import createfakebans
def test_management_command_creates_fake_bans(db):
call_command(createfakeba... | 556 | Python | .py | 12 | 43.166667 | 65 | 0.795539 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,822 | test_create_fake_threads_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_threads_command.py | from io import StringIO
from django.core.management import call_command
from ...threads.models import Thread
from ..management.commands import createfakethreads
def test_management_command_creates_fake_threads(db):
call_command(createfakethreads.Command(), stdout=StringIO())
assert Thread.objects.exists()
| 319 | Python | .py | 7 | 42.857143 | 64 | 0.821429 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,823 | test_fake_posts.py | rafalp_Misago/misago/faker/tests/test_fake_posts.py | import pytest
from ..posts import (
get_fake_hidden_post,
get_fake_post,
get_fake_post_content,
get_fake_unapproved_post,
)
from ..threads import get_fake_thread
@pytest.fixture
def thread(fake, default_category):
return get_fake_thread(fake, default_category)
def test_fake_post_can_be_created(... | 2,051 | Python | .py | 49 | 37.734694 | 78 | 0.737987 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,824 | test_fake_users.py | rafalp_Misago/misago/faker/tests/test_fake_users.py | from ...users.bans import get_user_ban
from ...users.models import Rank
from ..users import (
PASSWORD,
get_fake_admin_activated_user,
get_fake_banned_user,
get_fake_deleted_user,
get_fake_inactive_user,
get_fake_user,
get_fake_username,
)
def test_fake_user_can_be_created(db, fake):
a... | 1,790 | Python | .py | 44 | 36.545455 | 72 | 0.732599 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,825 | test_create_fake_watched_threads_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_watched_threads_command.py | from io import StringIO
from django.core.management import call_command
from ...notifications.models import WatchedThread
from ..management.commands import createfakewatchedthreads
def test_management_command_creates_watched_threads(
user, other_user, thread, other_thread
):
call_command(createfakewatchedth... | 425 | Python | .py | 9 | 44.444444 | 71 | 0.808252 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,826 | test_create_fake_categories_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_categories_command.py | from io import StringIO
from django.core.management import call_command
from ...acl import ACL_CACHE
from ...cache.test import assert_invalidates_cache
from ..management.commands import createfakecategories
def test_management_command_creates_fake_categories(root_category):
call_command(createfakecategories.Com... | 1,705 | Python | .py | 36 | 41.944444 | 85 | 0.747884 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,827 | test_fake_categories.py | rafalp_Misago/misago/faker/tests/test_fake_categories.py | from ..categories import (
fake_category,
fake_category_description,
fake_category_name,
fake_closed_category,
)
from ...permissions.models import CategoryGroupPermission
def test_fake_category_can_be_created(fake, root_category):
assert fake_category(fake, root_category)
def test_fake_category_... | 1,657 | Python | .py | 32 | 47.625 | 86 | 0.77301 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,828 | test_englishcorpus.py | rafalp_Misago/misago/faker/tests/test_englishcorpus.py | from ..englishcorpus import EnglishCorpus
def test_corpus_has_length():
corpus = EnglishCorpus()
assert corpus
def test_corpus_can_be_shuffled():
corpus = EnglishCorpus()
corpus.shuffle()
def test_corpus_can_be_limited_to_phrases_shorter_than_specified():
corpus = EnglishCorpus(max_length=100)... | 780 | Python | .py | 20 | 34.8 | 67 | 0.740642 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,829 | test_fake_bans.py | rafalp_Misago/misago/faker/tests/test_fake_bans.py | from ...users.models import Ban
from ..bans import get_fake_email_ban, get_fake_ip_ban, get_fake_username_ban
def test_fake_username_ban_can_be_created(db, fake):
assert get_fake_username_ban(fake)
Ban.objects.get(check_type=Ban.USERNAME)
def test_fake_email_ban_can_be_created(db, fake):
assert get_fake... | 500 | Python | .py | 11 | 41.727273 | 77 | 0.743271 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,830 | test_create_fake_history_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_history_command.py | from datetime import timedelta
from io import StringIO
import pytest
from django.contrib.auth import get_user_model
from django.core.management import call_command
from django.utils import timezone
from ...categories.models import Category
from ...threads.models import Post, Thread
from ...users.models import Rank
fr... | 4,823 | Python | .py | 106 | 41.556604 | 88 | 0.754551 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,831 | test_fake_threads.py | rafalp_Misago/misago/faker/tests/test_fake_threads.py | from ..threads import (
get_fake_closed_thread,
get_fake_hidden_thread,
get_fake_thread,
get_fake_unapproved_thread,
)
def test_fake_thread_can_be_created(fake, default_category):
assert get_fake_thread(fake, default_category)
def test_fake_thread_is_created_with_opening_post(fake, default_categ... | 1,876 | Python | .py | 37 | 46.405405 | 85 | 0.766063 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,832 | test_create_fake_posts_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_posts_command.py | from io import StringIO
from django.core.management import call_command
from ...threads.models import Post
from ..management.commands import createfakeposts
from ..threads import get_fake_thread
def test_management_command_creates_fake_threads(fake, default_category):
thread = get_fake_thread(fake, default_cate... | 455 | Python | .py | 9 | 47.777778 | 73 | 0.80543 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,833 | test_create_fake_followers_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_followers_command.py | from io import StringIO
from django.core.management import call_command
from ..management.commands import createfakefollowers
from ..users import get_fake_user
def test_management_command_creates_fake_followers_for_two_users(user, other_user):
call_command(createfakefollowers.Command(), stdout=StringIO())
def... | 915 | Python | .py | 19 | 44.315789 | 83 | 0.778781 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,834 | test_create_fake_notifications_command.py | rafalp_Misago/misago/faker/tests/test_create_fake_notifications_command.py | from io import StringIO
from django.core.management import call_command
from ...notifications.models import Notification
from ..management.commands import createfakenotifications
def test_management_command_creates_notifications(
user, other_user, thread, reply, other_thread
):
call_command(createfakenotifi... | 424 | Python | .py | 9 | 44.333333 | 70 | 0.805353 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,835 | createfakefollowers.py | rafalp_Misago/misago/faker/management/commands/createfakefollowers.py | import random
import time
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from ....core.management.progressbar import show_progress
User = get_user_model()
class Command(BaseCommand):
help = "Adds random followers for testing purposes"
def handle(self, *a... | 2,120 | Python | .py | 45 | 35.888889 | 82 | 0.605429 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,836 | createfakeusers.py | rafalp_Misago/misago/faker/management/commands/createfakeusers.py | import random
import time
from django.core.management.base import BaseCommand
from faker import Factory
from ....core.management.progressbar import show_progress
from ....users.models import Rank
from ...users import (
get_fake_inactive_user,
get_fake_admin_activated_user,
get_fake_banned_user,
get_fa... | 1,791 | Python | .py | 43 | 33.209302 | 85 | 0.630184 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,837 | createfakebans.py | rafalp_Misago/misago/faker/management/commands/createfakebans.py | import random
import sys
from django.core.management.base import BaseCommand
from faker import Factory
from ....core.management.progressbar import show_progress
from ....users.models import Ban
from ...bans import get_fake_username_ban, get_fake_email_ban, get_fake_ip_ban
class Command(BaseCommand):
help = "Cre... | 1,336 | Python | .py | 31 | 35.032258 | 81 | 0.657651 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,838 | createfakeposts.py | rafalp_Misago/misago/faker/management/commands/createfakeposts.py | import random
import time
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from faker import Factory
from ....categories.models import Category
from ....core.management.progressbar import show_progress
from ....threads.models import Thread
from ...posts import get_fak... | 2,519 | Python | .py | 56 | 34.785714 | 85 | 0.609247 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,839 | createfakenotifications.py | rafalp_Misago/misago/faker/management/commands/createfakenotifications.py | import random
import time
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from ....core.management.progressbar import show_progress
from ....notifications.models import Notification
from ....notifications.verbs import NotificationVerb
from ....threads.models import P... | 2,235 | Python | .py | 52 | 31.711538 | 82 | 0.591517 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,840 | createfakecategories.py | rafalp_Misago/misago/faker/management/commands/createfakecategories.py | import random
import time
from django.core.management.base import BaseCommand
from faker import Factory
from ....acl.cache import clear_acl_cache
from ....categories.models import Category
from ....core.management.progressbar import show_progress
from ...categories import fake_category, fake_closed_category
class C... | 2,242 | Python | .py | 54 | 32.12963 | 79 | 0.623676 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,841 | createfakethreads.py | rafalp_Misago/misago/faker/management/commands/createfakethreads.py | import random
import time
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from faker import Factory
from ....categories.models import Category
from ....core.management.progressbar import show_progress
from ....threads.models import Thread
from ...threads import (
... | 3,320 | Python | .py | 79 | 31.670886 | 83 | 0.596333 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,842 | createfakewatchedthreads.py | rafalp_Misago/misago/faker/management/commands/createfakewatchedthreads.py | import random
import time
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from ....core.management.progressbar import show_progress
from ....notifications.models import WatchedThread
from ....threads.models import Thread
User = get_user_model()
class Command(BaseC... | 1,727 | Python | .py | 37 | 36.675676 | 77 | 0.642218 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,843 | createfakehistory.py | rafalp_Misago/misago/faker/management/commands/createfakehistory.py | import random
import time
from datetime import timedelta
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from django.db.models import F
from django.utils import timezone
from faker import Factory
from ....categories.models import Category
from ....notifications.model... | 11,770 | Python | .py | 276 | 31.771739 | 88 | 0.590372 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,844 | urls.py | rafalp_Misago/misago/account/urls.py | from django.urls import path
from .views import settings, validate
urlpatterns = [
path("", settings.index, name="account-settings"),
path(
"preferences/",
settings.AccountPreferencesView.as_view(),
name="account-preferences",
),
path(
"details/",
settings.Acco... | 1,741 | Python | .py | 70 | 17.828571 | 54 | 0.585132 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,845 | apps.py | rafalp_Misago/misago/account/apps.py | from django.apps import AppConfig
class MisagoAccountConfig(AppConfig):
name = "misago.account"
label = "misago_account"
verbose_name = "Misago Account"
| 167 | Python | .py | 5 | 29.6 | 37 | 0.75625 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,846 | namechanges.py | rafalp_Misago/misago/account/namechanges.py | from dataclasses import dataclass
from datetime import datetime, timedelta
from django.utils import timezone
@dataclass
class AvailableUsernameChanges:
unlimited: bool
changes_left: int | None
next_change: datetime | None
@property
def can_change_username(self) -> bool:
if self.unlimited... | 3,238 | Python | .py | 78 | 34.910256 | 86 | 0.708666 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,847 | menus.py | rafalp_Misago/misago/account/menus.py | from django.conf import settings
from django.http import HttpRequest
from django.utils.translation import pgettext_lazy
from ..menus.menu import Menu
account_settings_menu = Menu()
account_settings_menu.add_item(
key="preferences",
url_name="misago:account-preferences",
label=pgettext_lazy("account sett... | 2,189 | Python | .py | 63 | 30.746032 | 68 | 0.73822 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,848 | forms.py | rafalp_Misago/misago/account/forms.py | from dataclasses import dataclass
from functools import cached_property
from typing import Any
from django import forms
from django.core.exceptions import PermissionDenied
from django.contrib.auth import get_user_model, update_session_auth_hash
from django.contrib.auth.password_validation import validate_password
from... | 12,014 | Python | .py | 322 | 27.23913 | 86 | 0.59647 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,849 | emailchange.py | rafalp_Misago/misago/account/emailchange.py | import datetime
import hashlib
import hmac
from base64 import urlsafe_b64decode, urlsafe_b64encode
from datetime import timedelta
from enum import StrEnum
from typing import TYPE_CHECKING
from django.conf import settings
from django.utils import timezone
from django.utils.translation import pgettext
if TYPE_CHECKING:... | 3,593 | Python | .py | 79 | 37.835443 | 87 | 0.693608 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,850 | settings.py | rafalp_Misago/misago/account/views/settings.py | from typing import Any
from django.conf import settings
from django.contrib import messages
from django.contrib.auth import get_user_model, logout
from django.forms import Form, ValidationError
from django.http import Http404, HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
f... | 17,452 | Python | .py | 411 | 33.547445 | 95 | 0.653178 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,851 | validate.py | rafalp_Misago/misago/account/views/validate.py | from functools import wraps
from django.contrib.auth import get_user_model
from django.contrib.auth.password_validation import validate_password
from django.core.exceptions import BadRequest, ValidationError
from django.http import HttpRequest, JsonResponse
from django.utils.translation import pgettext
from django.vie... | 2,419 | Python | .py | 65 | 30.8 | 85 | 0.680805 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,852 | test_account_username.py | rafalp_Misago/misago/account/tests/test_account_username.py | from unittest.mock import patch
from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...pagination.cursor import EmptyPageError
from ...test import assert_contains, assert_has_success_message, assert_not_contains
@override_dynamic_settings(enable_oauth2_client=True)
def test_accou... | 5,645 | Python | .py | 120 | 42.35 | 88 | 0.741499 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,853 | test_account_email_confirm_change.py | rafalp_Misago/misago/account/tests/test_account_email_confirm_change.py | from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains
from ..emailchange import create_email_change_token
@override_dynamic_settings(enable_oauth2_client=True)
def test_account_email_confirm_change_returns_error_if_oauth_client_is_enabled(
user, us... | 2,549 | Python | .py | 68 | 30.970588 | 88 | 0.662612 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,854 | test_account_details.py | rafalp_Misago/misago/account/tests/test_account_details.py | from django.urls import reverse
from ...test import assert_contains, assert_has_success_message
def test_account_details_displays_login_page_for_guests(db, client):
response = client.get(reverse("misago:account-details"))
assert_contains(response, "Sign in to change your settings")
def test_account_details... | 3,937 | Python | .py | 113 | 26.734513 | 82 | 0.582478 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,855 | test_account_download_data.py | rafalp_Misago/misago/account/tests/test_account_download_data.py | from unittest.mock import patch
from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...pagination.cursor import EmptyPageError
from ...test import (
assert_contains,
assert_has_success_message,
assert_has_warning_message,
assert_not_contains,
)
from ...users.datadow... | 5,307 | Python | .py | 110 | 43.818182 | 88 | 0.756395 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,856 | test_email_change_token.py | rafalp_Misago/misago/account/tests/test_email_change_token.py | import pytest
from django.test import override_settings
from ..emailchange import (
EmailChangeTokenError,
EmailChangeTokenErrorCode,
create_email_change_token,
read_email_change_token,
)
def test_email_change_token_can_be_created_and_unpacked(user):
new_email = "email@example.com"
token = cr... | 3,743 | Python | .py | 65 | 52.261538 | 88 | 0.75775 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,857 | test_account_email.py | rafalp_Misago/misago/account/tests/test_account_email.py | from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains
@override_dynamic_settings(enable_oauth2_client=True)
def test_account_email_returns_error_if_oauth_client_is_enabled(db, client):
response = client.get(reverse("misago:account-email"))
asse... | 3,976 | Python | .py | 101 | 32.277228 | 85 | 0.659398 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,858 | test_account_delete.py | rafalp_Misago/misago/account/tests/test_account_delete.py | from unittest.mock import patch
from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains
@override_dynamic_settings(enable_oauth2_client=True, allow_delete_own_account=True)
def test_account_delete_returns_error_if_oauth_client_is_enabled(db, client):
... | 3,437 | Python | .py | 64 | 49.75 | 86 | 0.764337 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,859 | test_available_username_changes.py | rafalp_Misago/misago/account/tests/test_available_username_changes.py | from dataclasses import dataclass
from datetime import timedelta
from django.utils import timezone
from ..namechanges import get_available_username_changes
@dataclass
class Permissions:
can_change_username: bool = False
username_changes_limit: int = 0
username_changes_expire: int = 0
username_change... | 7,082 | Python | .py | 202 | 28.653465 | 99 | 0.696952 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,860 | test_account_password.py | rafalp_Misago/misago/account/tests/test_account_password.py | from django.urls import reverse
from ...conf.test import override_dynamic_settings
from ...test import assert_contains, assert_has_success_message
@override_dynamic_settings(enable_oauth2_client=True)
def test_account_password_returns_error_if_oauth_client_is_enabled(db, client):
response = client.get(reverse("m... | 4,463 | Python | .py | 116 | 31.681034 | 88 | 0.673536 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,861 | test_account_preferences.py | rafalp_Misago/misago/account/tests/test_account_preferences.py | from django.urls import reverse
from ...test import assert_contains, assert_has_success_message
def test_account_preferences_displays_login_page_for_guests(db, client):
response = client.get(reverse("misago:account-preferences"))
assert_contains(response, "Sign in to change your settings")
def test_account... | 3,476 | Python | .py | 76 | 37.092105 | 82 | 0.642034 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,862 | test_validate.py | rafalp_Misago/misago/account/tests/test_validate.py | import json
from django.urls import reverse
def test_validate_views_return_400_if_method_is_not_post(db, client):
response = client.get(reverse("misago:account-validate-username"))
assert response.status_code == 400
def test_validate_views_return_400_if_value_is_missing(db, client):
response = client.p... | 4,766 | Python | .py | 109 | 38.073394 | 95 | 0.675962 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,863 | apps.py | rafalp_Misago/misago/forms/apps.py | from django.apps import AppConfig
class MisagoFormsConfig(AppConfig):
name = "misago.forms"
label = "misago_forms"
verbose_name = "Misago Forms"
| 159 | Python | .py | 5 | 28 | 35 | 0.743421 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,864 | formset.py | rafalp_Misago/misago/forms/formset.py | from functools import cached_property
from django.forms import Form
class Formset:
"""Formset that combines forms of any type.
Used by views and templates that display multiple forms that should be validated
together.
"""
def __init__(self):
self.forms: dict[str, Form] = {}
def __g... | 1,414 | Python | .py | 37 | 29.621622 | 86 | 0.603372 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,865 | misago_forms.py | rafalp_Misago/misago/forms/templatetags/misago_forms.py | from django import template
from django.forms.boundfield import BoundField, BoundWidget
register = template.Library()
@register.filter
def checkedhtml(bound_widget: BoundWidget) -> str:
return " checked" if bound_widget.data.get("selected") else ""
@register.filter
def selectedhtml(bound_widget: BoundWidget) ... | 748 | Python | .py | 18 | 37.388889 | 86 | 0.739251 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,866 | test_formset.py | rafalp_Misago/misago/forms/tests/test_formset.py | import pytest
from django import forms
from ..formset import Formset
class UserForm(forms.Form):
name = forms.CharField(max_length=10)
def clean(self):
data = super().clean()
if data.get("name") == "Bob":
raise forms.ValidationError("Name can't be Bob!")
return data
cla... | 3,776 | Python | .py | 81 | 41.246914 | 91 | 0.684441 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,867 | models.py | rafalp_Misago/misago/socialauth/models.py | from django.db import models
from .providers import providers
class SocialAuthProvider(models.Model):
provider = models.CharField(primary_key=True, max_length=30)
button_text = models.CharField(max_length=255, null=True, blank=True)
button_color = models.CharField(max_length=7, null=True, blank=True)
... | 576 | Python | .py | 13 | 39.230769 | 73 | 0.734767 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,868 | pipeline.py | rafalp_Misago/misago/socialauth/pipeline.py | # pylint: disable=keyword-arg-before-vararg
import json
from django.contrib.auth import get_user_model
from django.db import IntegrityError
from django.http import JsonResponse
from django.shortcuts import render
from django.urls import reverse
from django.utils.translation import pgettext
from social_core.pipeline.pa... | 8,773 | Python | .py | 216 | 33.018519 | 126 | 0.659722 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,869 | urls.py | rafalp_Misago/misago/socialauth/urls.py | from django.urls import path
from . import views
urlpatterns = [
path("login/<str:backend>/", views.auth, name="social-login"),
path("complete/<str:backend>/", views.complete, name="social-complete"),
]
| 214 | Python | .py | 6 | 32.833333 | 76 | 0.712195 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,870 | apps.py | rafalp_Misago/misago/socialauth/apps.py | from django.apps import AppConfig
from social_core.backends.discord import DiscordOAuth2
from social_core.backends.facebook import FacebookOAuth2
from social_core.backends.github import GithubOAuth2
from social_core.backends.google import GoogleOAuth2
from social_core.backends.twitter import TwitterOAuth
from .provide... | 2,023 | Python | .py | 58 | 24.896552 | 63 | 0.606633 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,871 | context_processors.py | rafalp_Misago/misago/socialauth/context_processors.py | from django.urls import reverse
def preload_socialauth_json(request):
request.frontend_context.update(
{"SOCIAL_AUTH": get_enabled_social_auth_providers(request.socialauth)}
)
return {}
def get_enabled_social_auth_providers(socialauth):
providers = []
for provider in socialauth.values()... | 730 | Python | .py | 21 | 24.571429 | 78 | 0.559659 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,872 | cache.py | rafalp_Misago/misago/socialauth/cache.py | from django.core.cache import cache
from . import SOCIALAUTH_CACHE
from ..cache.versions import invalidate_cache
def get_socialauth_cache(cache_versions):
key = get_cache_key(cache_versions)
return cache.get(key)
def set_socialauth_cache(cache_versions, socialauth):
key = get_cache_key(cache_versions)
... | 533 | Python | .py | 13 | 37.461538 | 73 | 0.771037 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,873 | enabledproviders.py | rafalp_Misago/misago/socialauth/enabledproviders.py | from .cache import get_socialauth_cache, set_socialauth_cache
from .models import SocialAuthProvider
from .providers import providers
def get_enabled_providers(cache_versions):
data = get_socialauth_cache(cache_versions)
if data is None:
data = get_providers_from_db()
set_socialauth_cache(cach... | 1,313 | Python | .py | 33 | 32.30303 | 70 | 0.663265 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,874 | middleware.py | rafalp_Misago/misago/socialauth/middleware.py | from django.utils.functional import SimpleLazyObject
from .enabledproviders import get_enabled_providers
def socialauth_providers_middleware(get_response):
"""Sets request.socialauth attribute with dict of setup social auth providers."""
def middleware(request):
def lazily_get_enabled_providers():
... | 521 | Python | .py | 10 | 45.7 | 85 | 0.772277 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,875 | strategy.py | rafalp_Misago/misago/socialauth/strategy.py | from django.core.exceptions import PermissionDenied
from social_django.strategy import DjangoStrategy
class MisagoStrategy(DjangoStrategy):
def setting(self, name, default=None, backend=None):
if backend:
backend_settings = self.request.socialauth[backend.name]["settings"]
if name ... | 730 | Python | .py | 17 | 34.117647 | 80 | 0.668079 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,876 | providers.py | rafalp_Misago/misago/socialauth/providers.py | class Providers:
def __init__(self):
self._dict = {}
self._list = []
def dict(self):
return self._dict
def list(self):
return self._list
def is_registered(self, provider):
return provider in self._dict
def add(
self, *, provider, name, auth_backend... | 1,487 | Python | .py | 40 | 28.15 | 88 | 0.585774 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,877 | views.py | rafalp_Misago/misago/socialauth/views.py | from django.contrib.auth import REDIRECT_FIELD_NAME, login
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.urls import reverse
from django.utils.translation import pgettext
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf... | 2,033 | Python | .py | 54 | 30.833333 | 90 | 0.692621 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,878 | 0003_rename_google_to_google_oauth.py | rafalp_Misago/misago/socialauth/migrations/0003_rename_google_to_google_oauth.py | # Generated by Django 2.2.3 on 2019-11-10 14:32
from django.db import migrations
def rename_google_provider(apps, _):
SocialAuthProvider = apps.get_model("misago_socialauth", "SocialAuthProvider")
SocialAuthProvider.objects.filter(provider="google").update(
provider="google-oauth2"
)
class Migr... | 479 | Python | .py | 10 | 43.5 | 82 | 0.75594 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,879 | 0001_initial.py | rafalp_Misago/misago/socialauth/migrations/0001_initial.py | # Generated by Django 2.2.1 on 2019-06-16 13:39
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="SocialAuthProvider",
fields=[
(
... | 1,003 | Python | .py | 28 | 22.357143 | 88 | 0.489691 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,880 | 0002_cache_version.py | rafalp_Misago/misago/socialauth/migrations/0002_cache_version.py | from django.db import migrations
from .. import SOCIALAUTH_CACHE
from ...cache.operations import StartCacheVersioning
class Migration(migrations.Migration):
dependencies = [
("misago_socialauth", "0001_initial"),
("misago_cache", "0001_initial"),
]
operations = [StartCacheVersioning(SOCI... | 335 | Python | .py | 9 | 32.666667 | 57 | 0.736025 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,881 | conftest.py | rafalp_Misago/misago/socialauth/tests/conftest.py | import pytest
from ..models import SocialAuthProvider
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(
provider="facebook",
is_active=True,
order=0,
settings={"key": "test-key", "secret": "test-secret"},
)
@pytest.fixture
def disabled_provider(db):... | 425 | Python | .py | 15 | 23.266667 | 62 | 0.693827 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,882 | test_social_pipeline.py | rafalp_Misago/misago/socialauth/tests/test_social_pipeline.py | import json
from unittest.mock import Mock
import pytest
from django.contrib.auth import get_user_model
from django.core import mail
from django.test import RequestFactory
from social_core.backends.github import GithubOAuth2
from social_django.utils import load_strategy
from ...acl.useracl import get_user_acl
from ..... | 29,340 | Python | .py | 649 | 35.978428 | 88 | 0.636991 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,883 | test_socialauth_middleware.py | rafalp_Misago/misago/socialauth/tests/test_socialauth_middleware.py | from unittest.mock import Mock
import pytest
from django.utils.functional import SimpleLazyObject
from ..middleware import socialauth_providers_middleware
@pytest.fixture
def get_response():
return Mock()
class PlainRequest:
pass
@pytest.fixture
def plain_request():
return PlainRequest()
def test_... | 1,521 | Python | .py | 37 | 37.135135 | 87 | 0.781719 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,884 | test_begin_auth.py | rafalp_Misago/misago/socialauth/tests/test_begin_auth.py | from django.urls import reverse
from ...conf.test import override_dynamic_settings
def test_view_begins_social_auth_for_provider(client, provider):
response = client.get(
reverse("misago:social-login", kwargs={"backend": provider.pk})
)
assert response.status_code == 302
@override_dynamic_setti... | 1,038 | Python | .py | 26 | 35.192308 | 80 | 0.717846 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,885 | test_providers.py | rafalp_Misago/misago/socialauth/tests/test_providers.py | import pytest
from ..providers import Providers
class Mock:
def __init__(self, name):
self.name = name
@pytest.fixture
def auth_backend():
return Mock(name="facebook")
@pytest.fixture
def providers(auth_backend):
obj = Providers()
obj.add(
provider="facebook",
name="Facebo... | 3,603 | Python | .py | 106 | 26.066038 | 88 | 0.60225 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,886 | test_context_processor.py | rafalp_Misago/misago/socialauth/tests/test_context_processor.py | from unittest.mock import Mock
from ..context_processors import preload_socialauth_json
def test_context_processor_sets_socialauth_entry_in_frontend_context():
request = Mock(frontend_context={}, socialauth={})
preload_socialauth_json(request)
assert "SOCIAL_AUTH" in request.frontend_context
| 308 | Python | .py | 6 | 47.833333 | 71 | 0.792642 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,887 | test_getting_enabled_providers.py | rafalp_Misago/misago/socialauth/tests/test_getting_enabled_providers.py | from unittest.mock import Mock
import pytest
from .. import SOCIALAUTH_CACHE
from ..enabledproviders import get_enabled_providers, get_provider_settings
from ..models import SocialAuthProvider
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(
provider="facebook", is_active=True... | 3,381 | Python | .py | 68 | 45.352941 | 88 | 0.747871 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,888 | ordering.py | rafalp_Misago/misago/socialauth/admin/ordering.py | from ..models import SocialAuthProvider
def get_next_free_order():
last = SocialAuthProvider.objects.filter(is_active=True).last()
if last:
return last.order + 1
return 0
| 193 | Python | .py | 6 | 27.5 | 67 | 0.718919 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,889 | __init__.py | rafalp_Misago/misago/socialauth/admin/__init__.py | from django.urls import path
from django.utils.translation import pgettext_lazy
from .views import (
DisableSocialAuthProvider,
EditSocialAuthProvider,
MoveDownSocialAuthProvider,
MoveUpSocialAuthProvider,
SocialAuthProvidersList,
)
class MisagoAdminExtension:
def register_urlpatterns(self, u... | 1,494 | Python | .py | 43 | 23.883721 | 81 | 0.565308 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,890 | views.py | rafalp_Misago/misago/socialauth/admin/views.py | from django.contrib import messages
from django.utils.translation import pgettext_lazy
from ...admin.views import generic
from ..cache import clear_socialauth_cache
from ..models import SocialAuthProvider
from ..providers import providers
class SocialAuthProviderAdmin(generic.AdminBaseMixin):
root_link = "misago... | 4,872 | Python | .py | 101 | 38.712871 | 88 | 0.66456 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,891 | twitter.py | rafalp_Misago/misago/socialauth/admin/forms/twitter.py | from django import forms
from django.utils.translation import pgettext_lazy
from .base import OAuthProviderForm
class TwitterForm(OAuthProviderForm):
key = forms.CharField(
label=pgettext_lazy("admin social auth twitter form", "Consumer API key"),
required=False,
)
secret = forms.CharFiel... | 465 | Python | .py | 14 | 27.142857 | 82 | 0.696429 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,892 | github.py | rafalp_Misago/misago/socialauth/admin/forms/github.py | from django import forms
from django.utils.translation import pgettext_lazy
from .base import OAuthProviderForm
class GitHubForm(OAuthProviderForm):
key = forms.CharField(
label=pgettext_lazy("admin social auth github form", "Client ID"),
required=False,
)
secret = forms.CharField(
... | 423 | Python | .py | 12 | 30 | 78 | 0.723039 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,893 | facebook.py | rafalp_Misago/misago/socialauth/admin/forms/facebook.py | from django import forms
from django.utils.translation import pgettext_lazy
from .base import OAuthProviderForm
class FacebookForm(OAuthProviderForm):
key = forms.CharField(
label=pgettext_lazy("admin social auth facebook form", "App ID"),
required=False,
)
secret = forms.CharField(
... | 423 | Python | .py | 12 | 30 | 77 | 0.723039 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,894 | __init__.py | rafalp_Misago/misago/socialauth/admin/forms/__init__.py | from .base import OAuthProviderForm, ProviderForm
from .discord import DiscordForm
from .facebook import FacebookForm
from .github import GitHubForm
from .google import GoogleForm
from .twitter import TwitterForm
| 213 | Python | .py | 6 | 34.5 | 49 | 0.874396 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,895 | google.py | rafalp_Misago/misago/socialauth/admin/forms/google.py | from django import forms
from django.utils.translation import pgettext_lazy
from .base import OAuthProviderForm
class GoogleForm(OAuthProviderForm):
key = forms.CharField(
label=pgettext_lazy("admin social auth google form", "Client ID"),
required=False,
)
secret = forms.CharField(
... | 423 | Python | .py | 12 | 30 | 78 | 0.723039 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,896 | base.py | rafalp_Misago/misago/socialauth/admin/forms/base.py | from django import forms
from django.utils.translation import gettext, pgettext_lazy
from ....admin.forms import ColorField, YesNoSwitch
from ...models import SocialAuthProvider
from ..ordering import get_next_free_order
class ProviderForm(forms.ModelForm):
button_text = forms.CharField(
label=pgettext_l... | 2,371 | Python | .py | 50 | 39.2 | 354 | 0.659879 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,897 | discord.py | rafalp_Misago/misago/socialauth/admin/forms/discord.py | from django import forms
from django.utils.translation import pgettext_lazy
from .base import OAuthProviderForm
class DiscordForm(OAuthProviderForm):
key = forms.CharField(
label=pgettext_lazy("admin social auth discord form", "App ID"),
required=False,
)
secret = forms.CharField(
... | 420 | Python | .py | 12 | 29.75 | 76 | 0.720988 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,898 | conftest.py | rafalp_Misago/misago/socialauth/admin/tests/conftest.py | import pytest
from ...models import SocialAuthProvider
@pytest.fixture
def provider(db):
return SocialAuthProvider.objects.create(
provider="facebook", is_active=True, order=0
)
@pytest.fixture
def other_provider(db):
return SocialAuthProvider.objects.create(provider="github", is_active=True, o... | 484 | Python | .py | 15 | 28.4 | 88 | 0.764069 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |
17,899 | test_providers_list.py | rafalp_Misago/misago/socialauth/admin/tests/test_providers_list.py | from django.urls import reverse
admin_link = reverse("misago:admin:settings:socialauth:index")
def test_providers_list_renders(admin_client):
response = admin_client.get(admin_link)
assert response.status_code == 200
def test_providers_list_renders_with_active_provider(admin_client, provider):
respons... | 566 | Python | .py | 11 | 47.545455 | 88 | 0.780622 | rafalp/Misago | 2,519 | 524 | 136 | GPL-2.0 | 9/5/2024, 5:12:22 PM (Europe/Amsterdam) |