From dfdd54a24064a6076416e6d7811e02d5e0dcdf7a Mon Sep 17 00:00:00 2001 From: kingmo888 <17401091+kingmo888@users.noreply.github.com> Date: Mon, 11 Dec 2023 23:35:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/util.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 api/util.py diff --git a/api/util.py b/api/util.py new file mode 100644 index 0000000..1593586 --- /dev/null +++ b/api/util.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Nov 19 15:51:21 2020 + +@author: lenovo +""" + +import logging +from .models_user import UserProfile +logger = logging.getLogger(__name__) + +from django.conf import settings as _settings +def settings(request): + """ + TEMPLATE_CONTEXT_PROCESSORS + """ + context = { 'settings': _settings } + + + try: + username = request.user + u = UserProfile.objects.get(username=username) + context['test'] = '这是一个测试变量' + context['u'] = u + #context['user'] = u + context['username'] = username + context['is_admin'] = u.is_admin + context['is_active'] = u.is_active + + logger.info("set system status variable") + except Exception as e: + logger.error("settings:{}".format( e)) + return context \ No newline at end of file