From af58cf44afeaba356e95beb1d3ace0c107d04c82 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Tue, 13 Feb 2018 08:12:22 +0300 Subject: [PATCH] LIL-227. Add serialized user data to window --- apps/user/models.py | 7 +++++++ project/templates/lilcity/index.html | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/user/models.py b/apps/user/models.py index 5986e33c..98118880 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -3,6 +3,8 @@ from django.contrib.auth.models import AbstractUser, UserManager from django.contrib.postgres import fields as pgfields from django.utils.translation import gettext_lazy as _ +from json import dumps +from api.v1 import serializers class User(AbstractUser): USER_ROLE = 0 @@ -44,3 +46,8 @@ class User(AbstractUser): class Meta(AbstractUser.Meta): ordering = ('-date_joined',) + + def serialized(self): + user_data = serializers.user.UserSerializer(instance=self).data + user_data = dumps(user_data, ensure_ascii=False) + return user_data diff --git a/project/templates/lilcity/index.html b/project/templates/lilcity/index.html index 34efa451..0d086601 100644 --- a/project/templates/lilcity/index.html +++ b/project/templates/lilcity/index.html @@ -50,11 +50,18 @@