diff --git a/clientsideapp/templates/clientsideapp/ext.html b/clientsideapp/templates/clientsideapp/ext.html
index bdd7c4d..08404a1 100644
--- a/clientsideapp/templates/clientsideapp/ext.html
+++ b/clientsideapp/templates/clientsideapp/ext.html
@@ -71,7 +71,7 @@
- Ваш балланс {{ subscriber.ballance|floatformat:2 }} руб.
+ Ваш балланс {{ request.user.ballance|floatformat:2 }} руб.
diff --git a/djing/auth_backends.py b/djing/auth_backends.py
index 04f731f..4517b04 100644
--- a/djing/auth_backends.py
+++ b/djing/auth_backends.py
@@ -7,25 +7,16 @@ class CustomAuthBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
if username is None:
username = kwargs.get(BaseAccount.USERNAME_FIELD)
- print('username', username)
try:
user = BaseAccount._default_manager.get_by_natural_key(username)
- print('user', user)
if user.check_password(password):
- if user.is_admin:
- print('is adm')
+ if user.is_staff:
auser = UserProfile.objects.get_by_natural_key(username)
else:
- print('no adm')
auser = Abon.objects.get_by_natural_key(username)
if self.user_can_authenticate(auser):
- print('can auth')
return auser
- print('no can auth')
- else:
- print('wrong password')
except BaseAccount.DoesNotExist:
- print('does not exist')
# Run the default password hasher once to reduce the timing
# difference between an existing and a non-existing user (#20760).
BaseAccount().set_password(password)
@@ -33,11 +24,10 @@ class CustomAuthBackend(ModelBackend):
def get_user(self, user_id):
try:
user = BaseAccount._default_manager.get(pk=user_id)
- if user.is_admin:
+ if user.is_staff:
user = UserProfile._default_manager.get(pk=user_id)
else:
user = Abon._default_manager.get(pk=user_id)
except BaseAccount.DoesNotExist:
return None
return user if self.user_can_authenticate(user) else None
-
diff --git a/djing/settings.py b/djing/settings.py
index 93380e0..2148af7 100644
--- a/djing/settings.py
+++ b/djing/settings.py
@@ -79,12 +79,11 @@ TEMPLATES = [
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
- 'django.template.context_processors.debug',
+ #'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'taskapp.context_proc.get_active_tasks_count',
- 'global_context_processors.context_processor_additional_profile',
'msg_app.context_processors.get_new_messages_count'
],
},
@@ -118,7 +117,7 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
-SESSION_ENGINE = 'django.contrib.sessions.backends.file'
+SESSION_ENGINE = 'django.contrib.sessions.backends.db'
SESSION_COOKIE_HTTPONLY = True
diff --git a/global_context_processors.py b/global_context_processors.py
deleted file mode 100644
index 995a717..0000000
--- a/global_context_processors.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# -*- coding: utf-8 -*-
-from django.shortcuts import get_object_or_404
-from abonapp.models import Abon
-from django.conf import settings
-
-
-# От сюда можно получать на клиентской стороне профиль абонента
-def context_processor_additional_profile(request):
- if request.user.is_staff or request.user.is_anonymous():
- return {'subscriber': request.user, 'FILE_UPLOAD_MAX_MEMORY_SIZE': settings.FILE_UPLOAD_MAX_MEMORY_SIZE}
- else:
- return {'subscriber': get_object_or_404(Abon, id=request.user.pk), 'FILE_UPLOAD_MAX_MEMORY_SIZE': settings.FILE_UPLOAD_MAX_MEMORY_SIZE}