From b1fa50f0072a545c789e29968dfbcda0869ee821 Mon Sep 17 00:00:00 2001 From: sahama Date: Tue, 6 Aug 2024 15:47:33 +0330 Subject: [PATCH] show display name --- apps/users/models.py | 44 ++---------------- static/fonts/Pelak/fonts.css | 81 ++++++++++++++++++++++++++++++++++ templates/base.html | 1 + templates/include/top_bar.html | 2 +- 4 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 static/fonts/Pelak/fonts.css diff --git a/apps/users/models.py b/apps/users/models.py index 0385155..9c1666c 100644 --- a/apps/users/models.py +++ b/apps/users/models.py @@ -130,6 +130,9 @@ class User(AbstractUser): objects = UserManager() + def get_display_name(self): + return str(self.name or self.get_full_name() or self.username or self.email or self.phone_number or self.pk) + @property def city_name(self): return state.get_city_by_id(self.city) @@ -222,44 +225,3 @@ class User(AbstractUser): def __str__(self): return self.name or self.get_full_name() or self.username or self.phone_number or self.email or _('no name') - - -def create_user_in_introspection(token, content): - # content = { - # "active": True, - # "scope": "read write email", - # "client_id": "J8NFmU4tJVgDxKaJFmXTWvaHO", - # "username": "aaronpk", - # "exp": 1437275311 - # } - - user_client = service_clients.Client(access_token=token, - scopes=content.get('scope', '').split(), - expires_in=100) - - user_account = user_client.accounts.account() - if user_account.get('uuid'): - content.update(user_account) - - # content = {'active': True, 'scope': 'ipg.payment:submit accounts.account:retrieve', 'exp': 1602619137, - # 'client_id': 'bd2hEGXytrqMjbFnplRyHJTeoW1vwKzCZJtH6ro0', 'username': '', - # 'uuid': '94255117-117c-4a9f-af50-35a6c47503ac', 'email': '', 'phone_number': '+989106853582', - # 'first_name': '', 'last_name': '', 'name': '', 'balance': 0, - # 'avatar': 'http://accounts.gooyal.com/media/avatars/1691899.jpg', 'iban': '', 'iban_verified': None} - - user = User.objects.filter(uuid=content['uuid']).first() - if user: - pass - - else: - user = User.objects.create_user( - **{User.USERNAME_FIELD: content["username"]}, - uuid=content['uuid'], - email=content['email'], - phone_number=content['phone_number'], - first_name=content['first_name'], - last_name=content['last_name'], - name=content['name'], - avatar=content['avatar'] - ) - return user, content diff --git a/static/fonts/Pelak/fonts.css b/static/fonts/Pelak/fonts.css new file mode 100644 index 0000000..b98bb7d --- /dev/null +++ b/static/fonts/Pelak/fonts.css @@ -0,0 +1,81 @@ +/*@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");*/ +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 100; + src: url('eot/PelakFA-Thin.eot'); + src: url('eot/PelakFA-Thin.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-Thin.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-Thin.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 200; + src: url('eot/PelakFA-light.eot'); + src: url('eot/PelakFA-light.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-light.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-light.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} + +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 400; + src: url('eot/PelakFA-Regular.eot'); + src: url('eot/PelakFA-Regular.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-Regular.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-Regular.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} + +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 500; + src: url('eot/PelakFA-Medium.eot'); + src: url('eot/PelakFA-Medium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-Medium.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-Medium.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} + + +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 600; + src: url('eot/PelakFA-SemiBold.eot'); + src: url('eot/PelakFA-SemiBold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-SemiBold.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-SemiBold.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} + +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 700; + src: url('eot/PelakFA-Bold.eot'); + src: url('eot/PelakFA-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-Bold.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-Bold.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} + + +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 800; + src: url('eot/PelakFA-ExtraBold.eot'); + src: url('eot/PelakFA-ExtraBold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-ExtraBold.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-ExtraBold.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} + +@font-face { + font-family: 'pelak'; + font-style: normal; + font-weight: 900; + src: url('eot/PelakFA-Black.eot'); + src: url('eot/PelakFA-Black.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('woff2/PelakFA-Black.woff2') format('woff2'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('woff/PelakFA-Black.woff') format('woff'); /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ +} diff --git a/templates/base.html b/templates/base.html index b105386..972b2d9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,6 +14,7 @@ + diff --git a/templates/include/top_bar.html b/templates/include/top_bar.html index 11a5992..f2b2320 100644 --- a/templates/include/top_bar.html +++ b/templates/include/top_bar.html @@ -31,7 +31,7 @@ - {{ request.user.pk }} + {{ request.user.get_display_name }}