DT
какой лучше знаешь
Size: a a a
DT
f
(Pdb) user.user_permissions.all()[0].__dict__
{'_state': <django.db.models.base.ModelState object at 0x112b5d250>, 'id': 65, 'name': 'Recieve email updates for Post', 'content_type_id': 16, 'codename': 'recieve_post_email_updates'}
(Pdb) user.has_perm('main.recieve_post_email_updates')
False
DT
(Pdb) user.user_permissions.all()[0].__dict__
{'_state': <django.db.models.base.ModelState object at 0x112b5d250>, 'id': 65, 'name': 'Recieve email updates for Post', 'content_type_id': 16, 'codename': 'recieve_post_email_updates'}
(Pdb) user.has_perm('main.recieve_post_email_updates')
False
f
main.models.Post.Meta
.U
from django.contrib.auth.models import User
U
from django.contrib.auth.models import User
f
@pytest.mark.django_db
def test_can_recieve_notification_permission(post_email_permission, comment, users):
user = users[-1]
assert _can_recieve_notification(user, comment) == False
user.user_permissions.add(post_email_permission)
assert _can_recieve_notification(user, comment) == True
def _can_recieve_notification(user: User, comment: Comment) -> bool:
if not user.has_perm(RECIEVE_NOTIFICATIONS_PERMISSION):
return False
_can_recieve_notification
вызывает hast_perm, реальной записи в БД нет, хотя права на уровне ORM в менеджере якобы существуют.ДМ
response = HttpResponse(f.content, content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response['Content-Disposition'] = "attachment; filename={!s}.xlsx".format(f.name)
A
response = HttpResponse(f.content, content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response['Content-Disposition'] = "attachment; filename={!s}.xlsx".format(f.name)
ДМ
ДМ
A
A
ДМ
A
ДМ
A
A
ДМ
A