nkdsu package

Subpackages

Submodules

nkdsu.forms module

class nkdsu.forms.RegistrationForm(*args, **kwargs)[source]

Bases: TriviaForm, UserCreationForm

clean_username() str[source]
_meta = <django.forms.models.ModelFormOptions object>
base_fields = {'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'trivia': <django.forms.fields.CharField object>, 'trivia_question': <django.forms.fields.CharField object>, 'username': <django.contrib.auth.forms.UsernameField object>}
declared_fields = {'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'trivia': <django.forms.fields.CharField object>, 'trivia_question': <django.forms.fields.CharField object>}
property media
class nkdsu.forms.ResetPasswordForm(*args, **kwargs)[source]

Bases: TriviaForm, ResetPasswordForm

base_fields = {'email': <django.forms.fields.EmailField object>, 'trivia': <django.forms.fields.CharField object>, 'trivia_question': <django.forms.fields.CharField object>}
declared_fields = {'email': <django.forms.fields.EmailField object>, 'trivia': <django.forms.fields.CharField object>, 'trivia_question': <django.forms.fields.CharField object>}
property media

nkdsu.icons module

nkdsu.icons._get_icons() Iterable[tuple[str, str]][source]

nkdsu.middleware module

class nkdsu.middleware.SocialAuthHandlingMiddleware(get_response: Callable[[HttpRequest], HttpResponse])[source]

Bases: object

Middleware for doing nkd.su-specific workarounds for unwanted Python Social Auth behaviour.

prefix: str
get_response: Callable[[HttpRequest], HttpResponse]
process_view(request: HttpRequest, view_func: Callable, view_args: Sequence[Any], view_kwargs: dict[str, Any]) HttpResponse[source]

nkdsu.mixins module

class nkdsu.mixins.MarkdownView(**kwargs)[source]

Bases: TemplateView

template_name: str | None = 'markdown.html'
filename: str
title: str
get_context_data(**kwargs) dict[str, Any][source]

nkdsu.monkey module

Horrible hacks. Please ignore.

nkdsu.monkey.patch() None[source]
nkdsu.monkey._replace_password_validators_help_text_html() None[source]

Don’t use a <ul> to surface multiple password requirements against password fields. It’s invalid HTML when used within an as_p()-rendered form, and browsers interpret the DOM structure wrong as a result. As far as Firefox is concerned, if we let Django do what it does by default, these help texts aren’t within a .helptext element at all.

I hope this is made unnecessary if we adopt the <div>-based form renderer that becomes the default in Django 5.0.

nkdsu.settings module

nkdsu.settings.MAX_REQUEST_TRACKS = 6

The maximum number of tracks that can be associated with a single Vote object

nkdsu.settings_local module

nkdsu.settings_local_example module

nkdsu.settings_profile module

nkdsu.settings_testing module

nkdsu.tests module

class nkdsu.tests.EverythingTest(methodName='runTest')[source]

Bases: ExternalLinks, ValidHTML5, ValidJSON, InstantCoverageMixin, TestCase

fixtures = ['vote.json']
covered_urls: Sequence[str] = ['/vote-admin/tw-abuse/46162630/', '/vote-admin/local-abuse/45/', '/vote-admin/block/0007C3F2760E0541/', '/vote-admin/block/0007C3F2760E0541/reason?reason=announced', '/vote-admin/unblock/0007C3F2760E0541/', '/vote-admin/archive/0007C3F2760E0541/', '/vote-admin/unarchive/0007C3F2760E0541/', '/vote-admin/hide/0007C3F2760E0541/', '/vote-admin/unhide/0007C3F2760E0541/', '/vote-admin/lm/0007C3F2760E0541/', '/vote-admin/ulm/0007C3F2760E0541/', '/vote-admin/shortlist/0007C3F2760E0541/', '/vote-admin/discard/0007C3F2760E0541/', '/vote-admin/reset/0007C3F2760E0541/', '/vote-admin/make-note/0007C3F2760E0541/', '/vote-admin/post-about-play/0007C3F2760E0541/', '/vote-admin/migrate-away-from/0007C3F2760E0541/', '/vote-admin/remove-note/2/', '/vote-admin/archived/', '/vote-admin/hidden/', '/vote-admin/no-media-id/', '/vote-admin/inudesu/', '/vote-admin/artless/', '/vote-admin/add-manual-vote/0007C3F2760E0541/', '/vote-admin/upload/', '/vote-admin/upload-myriad/', '/vote-admin/requests/', '/vote-admin/check-metadata/', '/vote-admin/play/0007C3F2760E0541/', '/js/deselect/', '/js/select/', '/js/selection/', '/js/clear_selection/', '/api/', '/api/week/', '/api/week/2014-02-05/', '/api/track/0007C3F2760E0541/', '/api/search/?q=Canpeki', '/api/user/EuricaeriS/', '/', '/browse/', '/anime/', '/artists/', '/years/', '/composers/', '/roles/', '/info/', '/info/api/', '/info/privacy/', '/info/tos/', '/profile/', '/request/?t=0007C3F2760E0541', '/request-addition/', '/add-to-list/?t=0007C3F2760E0541', '/roulette/', '/roulette/hipster/', '/roulette/indiscriminate/', '/roulette/staple/', '/roulette/decade/', '/roulette/decade/1970/', '/roulette/short/1/', '/roulette/pro/', '/archive/', '/archive/2014/', '/stats/', '/0007C3F2760E0541/', '/canpeki-shinakya/0007C3F2760E0541/', '/0007C3F2760E0541/report/', '/artist/Hikasa Youko/', '/anime/Ro-Kyu-Bu!/', '/composer/folks/', '/year/2014/', '/show/2014-02-05/listen/', '/show/2014-02-05/', '/show/', '/added/2014-02-05/', '/added/', '/search/?q=Canpeki', '/user/EuricaeriS/', '/@what/', '/@what/list/coollist-for-pros/', '/profile/email/', '/profile/', '/confirm-email/', '/confirm-email/abc/', '/login/', '/account/login/', '/register/', '/account/register/', '/change-password/', '/change-password/done/', '/reset-password/', '/reset-password/done/', '/reset-password/key/abc-def/', '/reset-password/key/done/']

URLs to test

uncovered_urls: Sequence[str] = ['/vote-admin/upload/confirm/', '/vote-admin/shortlist-selection/', '/vote-admin/discard-selection/', '/vote-admin/hide-selection/', '/vote-admin/unhide-selection/', '/vote-admin/archive-selection/', '/vote-admin/unarchive-selection/', '/vote-admin/reset-shortlist-discard-selection/', '/@what/list-members/coollist-for-pros/', '/vote-admin/shortlist-order/', '/vote-admin/requests/fill/1/', '/vote-admin/requests/claim/1/', '/vote-admin/requests/shelf/1/', '/set-dark-mode/', '/logout/', '/account/logout/', '/anime-picture/Ro-Kyu-Bu!/', '/set-password/', '/update-request/1/', '/vote-admin/unmatched-anime/', '/vote-admin/throw-500/']

URLs we’re okay with not testing

uncovered_includes: Sequence[Tuple[str, ...]] = [('^admin/',), ('^s/',)]

tuples of includes we’re okay with not testing (see README for more details)

instant_tracebacks = True

whether to show full tracebacks in test_no_errors

setUp() None[source]
ensure_all_urls_resolve(urls)[source]
_classSetupFailed = False
_class_cleanups = []
class nkdsu.tests.LoggedInEverythingTest(methodName='runTest')[source]

Bases: EverythingTest

covered_urls: Sequence[str] = ['/update-request/123/', '/vote-admin/tw-abuse/46162630/', '/vote-admin/local-abuse/45/', '/vote-admin/block/0007C3F2760E0541/', '/vote-admin/block/0007C3F2760E0541/reason?reason=announced', '/vote-admin/unblock/0007C3F2760E0541/', '/vote-admin/archive/0007C3F2760E0541/', '/vote-admin/unarchive/0007C3F2760E0541/', '/vote-admin/hide/0007C3F2760E0541/', '/vote-admin/unhide/0007C3F2760E0541/', '/vote-admin/lm/0007C3F2760E0541/', '/vote-admin/ulm/0007C3F2760E0541/', '/vote-admin/shortlist/0007C3F2760E0541/', '/vote-admin/discard/0007C3F2760E0541/', '/vote-admin/reset/0007C3F2760E0541/', '/vote-admin/make-note/0007C3F2760E0541/', '/vote-admin/post-about-play/0007C3F2760E0541/', '/vote-admin/migrate-away-from/0007C3F2760E0541/', '/vote-admin/remove-note/2/', '/vote-admin/archived/', '/vote-admin/hidden/', '/vote-admin/no-media-id/', '/vote-admin/inudesu/', '/vote-admin/artless/', '/vote-admin/add-manual-vote/0007C3F2760E0541/', '/vote-admin/upload/', '/vote-admin/upload-myriad/', '/vote-admin/requests/', '/vote-admin/check-metadata/', '/vote-admin/play/0007C3F2760E0541/', '/js/deselect/', '/js/select/', '/js/selection/', '/js/clear_selection/', '/api/', '/api/week/', '/api/week/2014-02-05/', '/api/track/0007C3F2760E0541/', '/api/search/?q=Canpeki', '/api/user/EuricaeriS/', '/', '/browse/', '/anime/', '/artists/', '/years/', '/composers/', '/roles/', '/info/', '/info/api/', '/info/privacy/', '/info/tos/', '/profile/', '/request/?t=0007C3F2760E0541', '/request-addition/', '/add-to-list/?t=0007C3F2760E0541', '/roulette/', '/roulette/hipster/', '/roulette/indiscriminate/', '/roulette/staple/', '/roulette/decade/', '/roulette/decade/1970/', '/roulette/short/1/', '/roulette/pro/', '/archive/', '/archive/2014/', '/stats/', '/0007C3F2760E0541/', '/canpeki-shinakya/0007C3F2760E0541/', '/0007C3F2760E0541/report/', '/artist/Hikasa Youko/', '/anime/Ro-Kyu-Bu!/', '/composer/folks/', '/year/2014/', '/show/2014-02-05/listen/', '/show/2014-02-05/', '/show/', '/added/2014-02-05/', '/added/', '/search/?q=Canpeki', '/user/EuricaeriS/', '/@what/', '/@what/list/coollist-for-pros/', '/profile/email/', '/profile/', '/confirm-email/', '/confirm-email/abc/', '/login/', '/account/login/', '/register/', '/account/register/', '/change-password/', '/change-password/done/', '/reset-password/', '/reset-password/done/', '/reset-password/key/abc-def/', '/reset-password/key/done/']

URLs to test

setUp() None[source]
_classSetupFailed = False
_class_cleanups = []
class nkdsu.tests.ElfEverythingTest(methodName='runTest')[source]

Bases: EverythingTest

covered_urls: Sequence[str] = ['/vote-admin/unmatched-anime/', '/vote-admin/tw-abuse/46162630/', '/vote-admin/local-abuse/45/', '/vote-admin/block/0007C3F2760E0541/', '/vote-admin/block/0007C3F2760E0541/reason?reason=announced', '/vote-admin/unblock/0007C3F2760E0541/', '/vote-admin/archive/0007C3F2760E0541/', '/vote-admin/unarchive/0007C3F2760E0541/', '/vote-admin/hide/0007C3F2760E0541/', '/vote-admin/unhide/0007C3F2760E0541/', '/vote-admin/lm/0007C3F2760E0541/', '/vote-admin/ulm/0007C3F2760E0541/', '/vote-admin/shortlist/0007C3F2760E0541/', '/vote-admin/discard/0007C3F2760E0541/', '/vote-admin/reset/0007C3F2760E0541/', '/vote-admin/make-note/0007C3F2760E0541/', '/vote-admin/post-about-play/0007C3F2760E0541/', '/vote-admin/migrate-away-from/0007C3F2760E0541/', '/vote-admin/remove-note/2/', '/vote-admin/archived/', '/vote-admin/hidden/', '/vote-admin/no-media-id/', '/vote-admin/inudesu/', '/vote-admin/artless/', '/vote-admin/add-manual-vote/0007C3F2760E0541/', '/vote-admin/upload/', '/vote-admin/upload-myriad/', '/vote-admin/requests/', '/vote-admin/check-metadata/', '/vote-admin/play/0007C3F2760E0541/', '/js/deselect/', '/js/select/', '/js/selection/', '/js/clear_selection/', '/api/', '/api/week/', '/api/week/2014-02-05/', '/api/track/0007C3F2760E0541/', '/api/search/?q=Canpeki', '/api/user/EuricaeriS/', '/', '/browse/', '/anime/', '/artists/', '/years/', '/composers/', '/roles/', '/info/', '/info/api/', '/info/privacy/', '/info/tos/', '/profile/', '/request/?t=0007C3F2760E0541', '/request-addition/', '/add-to-list/?t=0007C3F2760E0541', '/roulette/', '/roulette/hipster/', '/roulette/indiscriminate/', '/roulette/staple/', '/roulette/decade/', '/roulette/decade/1970/', '/roulette/short/1/', '/roulette/pro/', '/archive/', '/archive/2014/', '/stats/', '/0007C3F2760E0541/', '/canpeki-shinakya/0007C3F2760E0541/', '/0007C3F2760E0541/report/', '/artist/Hikasa Youko/', '/anime/Ro-Kyu-Bu!/', '/composer/folks/', '/year/2014/', '/show/2014-02-05/listen/', '/show/2014-02-05/', '/show/', '/added/2014-02-05/', '/added/', '/search/?q=Canpeki', '/user/EuricaeriS/', '/@what/', '/@what/list/coollist-for-pros/', '/profile/email/', '/profile/', '/confirm-email/', '/confirm-email/abc/', '/login/', '/account/login/', '/register/', '/account/register/', '/change-password/', '/change-password/done/', '/reset-password/', '/reset-password/done/', '/reset-password/key/abc-def/', '/reset-password/key/done/']

URLs to test

setUp() None[source]
_classSetupFailed = False
_class_cleanups = []
class nkdsu.tests.StaffEverythingTest(methodName='runTest')[source]

Bases: EverythingTest

setUp() None[source]
_classSetupFailed = False
_class_cleanups = []

nkdsu.urls module

nkdsu.views module

class nkdsu.views.LoginView(**kwargs)[source]

Bases: MarkdownView, LoginView

template_name: str | None = 'registration/login.html'
title: str = 'login'
filename: str = 'TWITTER.md'
get_context_data(**kwargs) dict[str, Any][source]
class nkdsu.views.RegisterView(**kwargs)[source]

Bases: CreateView

template_name = 'auth/register.html'
model

alias of User

form_class

alias of RegistrationForm

success_url = '/profile/'
form_valid(form: RegistrationForm) HttpResponse[source]
class nkdsu.views.SetPasswordView(**kwargs)[source]

Bases: FormView

template_name = 'auth/set_password.html'
form_class

alias of SetPasswordForm

success_url = '/login/'
get_form_kwargs() dict[str, Any][source]
classmethod as_view(**kw)[source]
form_valid(form: SetPasswordForm) HttpResponse[source]
class nkdsu.views.EmailView(**kwargs)[source]

Bases: LoginRequiredMixin, BreadcrumbMixin, EmailView

breadcrumbs: list[tuple[str | None, str]] = [('/profile/', 'edit profile')]
class nkdsu.views.PasswordResetView(**kwargs)[source]

Bases: PasswordResetView

form_class

alias of ResetPasswordForm

nkdsu.wsgi module