-
-
Notifications
You must be signed in to change notification settings - Fork 499
Treat get_user_model as a dynamic class factory #1730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e9529fa
6d493d8
990fb64
05c09f5
42c8eee
f5ed69d
10d3528
8f72a8b
fdea347
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,6 +41,28 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
from django.contrib.auth.decorators import user_passes_test | ||||||||||||||||||||||||||||||||||||||||||||||||
@user_passes_test # E: Argument 1 to "user_passes_test" has incompatible type "Callable[[HttpRequest], HttpResponse]"; expected "Callable[[Union[AbstractBaseUser, AnonymousUser]], bool]" | ||||||||||||||||||||||||||||||||||||||||||||||||
def view_func(request: HttpRequest) -> HttpResponse: ... | ||||||||||||||||||||||||||||||||||||||||||||||||
- case: user_passes_test_has_user_of_type_auth_user_model | ||||||||||||||||||||||||||||||||||||||||||||||||
disable_cache: true | ||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would we need to disable cache? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, this is just a copy-past mistake 😇 |
||||||||||||||||||||||||||||||||||||||||||||||||
main: | | ||||||||||||||||||||||||||||||||||||||||||||||||
from typing import Union | ||||||||||||||||||||||||||||||||||||||||||||||||
from django.http import HttpRequest, HttpResponse | ||||||||||||||||||||||||||||||||||||||||||||||||
from django.contrib.auth.models import AnonymousUser | ||||||||||||||||||||||||||||||||||||||||||||||||
from django.contrib.auth.decorators import user_passes_test | ||||||||||||||||||||||||||||||||||||||||||||||||
from myapp.models import MyUser | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
def check_user(user: Union[MyUser, AnonymousUser]) -> bool: return True | ||||||||||||||||||||||||||||||||||||||||||||||||
@user_passes_test(check_user) | ||||||||||||||||||||||||||||||||||||||||||||||||
def view_func(request: HttpRequest) -> HttpResponse: ... | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+47
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we check a couple of the often used and now plugin changed signatures from
Suggested change
We could perhaps change the name of the test to something like |
||||||||||||||||||||||||||||||||||||||||||||||||
custom_settings: | | ||||||||||||||||||||||||||||||||||||||||||||||||
INSTALLED_APPS = ('django.contrib.contenttypes', 'django.contrib.auth', 'myapp') | ||||||||||||||||||||||||||||||||||||||||||||||||
AUTH_USER_MODEL='myapp.MyUser' | ||||||||||||||||||||||||||||||||||||||||||||||||
files: | ||||||||||||||||||||||||||||||||||||||||||||||||
- path: myapp/__init__.py | ||||||||||||||||||||||||||||||||||||||||||||||||
- path: myapp/models.py | ||||||||||||||||||||||||||||||||||||||||||||||||
content: | | ||||||||||||||||||||||||||||||||||||||||||||||||
from django.db import models | ||||||||||||||||||||||||||||||||||||||||||||||||
class MyUser(models.Model): | ||||||||||||||||||||||||||||||||||||||||||||||||
pass | ||||||||||||||||||||||||||||||||||||||||||||||||
- case: permission_required | ||||||||||||||||||||||||||||||||||||||||||||||||
main: | | ||||||||||||||||||||||||||||||||||||||||||||||||
from django.contrib.auth.decorators import permission_required | ||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have my lazy reference resolver in #1719 we wouldn't need to use the runtime model here:
We might want to use the fallback only on last iteration then