Change set_context function, using **kwargs
This commit is contained in:
parent
b9cb22e2e5
commit
bb74072c32
@ -35,8 +35,7 @@ from main.serializers import ProfileSerializer, ZendeskUserSerializer
|
||||
from .models import UserProfile
|
||||
|
||||
|
||||
def setup_context(profile_lit: bool = False, control_lit: bool = False, work_lit: bool = False,
|
||||
registration_lit: bool = False, login_lit: bool = False, stats_lit: bool = False) -> Dict[str, Any]:
|
||||
def setup_context(**kwargs) -> Dict[str, Any]:
|
||||
"""
|
||||
Функция добавления в контекст статуса пользователя.
|
||||
|
||||
@ -48,15 +47,12 @@ def setup_context(profile_lit: bool = False, control_lit: bool = False, work_lit
|
||||
:param stats_lit: True, при получении пользователем прав администратора (просмотр статистики), иначе False
|
||||
:return: Контекст (context)
|
||||
"""
|
||||
|
||||
context = {
|
||||
'profile_lit': profile_lit,
|
||||
'control_lit': control_lit,
|
||||
'work_lit': work_lit,
|
||||
'registration_lit': registration_lit,
|
||||
'login_lit': login_lit,
|
||||
'stats_lit': stats_lit,
|
||||
}
|
||||
context = {}
|
||||
for key in ('profile_lit', 'control_lit', 'work_lit', 'registration_lit', 'login_lit', 'stats_lit'):
|
||||
if key in kwargs:
|
||||
context.update({key: True})
|
||||
else:
|
||||
context.update({key: False})
|
||||
return context
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user