show display name

This commit is contained in:
sahama 2024-08-06 15:47:33 +03:30
parent acaec7fd14
commit b1fa50f007
4 changed files with 86 additions and 42 deletions

View file

@ -130,6 +130,9 @@ class User(AbstractUser):
objects = UserManager() 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 @property
def city_name(self): def city_name(self):
return state.get_city_by_id(self.city) return state.get_city_by_id(self.city)
@ -222,44 +225,3 @@ class User(AbstractUser):
def __str__(self): def __str__(self):
return self.name or self.get_full_name() or self.username or self.phone_number or self.email or _('no name') 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

View file

@ -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+*/
}

View file

@ -14,6 +14,7 @@
<link href="{% static 'bootstrap-5.3.0-dist/css/bootstrap.rtl.min.css' %}" rel="stylesheet"> <link href="{% static 'bootstrap-5.3.0-dist/css/bootstrap.rtl.min.css' %}" rel="stylesheet">
<link href="{% static 'bootstrap-icons-1.11.3/font/bootstrap-icons.css' %}" rel="stylesheet"> <link href="{% static 'bootstrap-icons-1.11.3/font/bootstrap-icons.css' %}" rel="stylesheet">
<link href="{% static 'fonts/vazirmatn-v33.003/misc/UI-Farsi-Digits/Vazirmatn-UI-FD-font-face.css' %}" rel="stylesheet"> <link href="{% static 'fonts/vazirmatn-v33.003/misc/UI-Farsi-Digits/Vazirmatn-UI-FD-font-face.css' %}" rel="stylesheet">
<link href="{% static 'fonts/Pelak/fonts.css' %}" rel="stylesheet">
<link href="{% static 'main.css' %}" rel="stylesheet"> <link href="{% static 'main.css' %}" rel="stylesheet">
<script src="{% static 'jquery-3.6.0.min.js' %}"></script> <script src="{% static 'jquery-3.6.0.min.js' %}"></script>

View file

@ -31,7 +31,7 @@
<img src="{% static 'image/no-user.png' %}" width="30" height="30" <img src="{% static 'image/no-user.png' %}" width="30" height="30"
class="rounded-circle"> class="rounded-circle">
<span class="d-sm-inline mx-1">{{ request.user.pk }}</span> <span class="d-sm-inline mx-1">{{ request.user.get_display_name }}</span>
</a> </a>
<ul class="dropdown-menu bg-light text-small shadow" <ul class="dropdown-menu bg-light text-small shadow"
aria-labelledby="dropdownUser1"> aria-labelledby="dropdownUser1">