add telegram
This commit is contained in:
parent
319bed3dfc
commit
f1f7c0e89b
@ -25,6 +25,9 @@
|
|||||||
{{ account.surname }} {{ account.name }}
|
{{ account.surname }} {{ account.name }}
|
||||||
<span style="margin-left: 15px; margin-bottom: 20px;" class="badge bg-{% if account.userinfo.activity_status == online_status %}success{% else %}secondary{% endif %}">{{ account.userinfo.activity_status }}</span>
|
<span style="margin-left: 15px; margin-bottom: 20px;" class="badge bg-{% if account.userinfo.activity_status == online_status %}success{% else %}secondary{% endif %}">{{ account.userinfo.activity_status }}</span>
|
||||||
</h3>
|
</h3>
|
||||||
|
<form method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="action" value="save_data" />
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@ -68,7 +71,27 @@
|
|||||||
</td>
|
</td>
|
||||||
<td><div style="width: 20px;"></div></td>
|
<td><div style="width: 20px;"></div></td>
|
||||||
<td>
|
<td>
|
||||||
|
{% if owner %}
|
||||||
|
<input placeholder="email" type="text" name="email" value="{% if account.email %}{{ account.email }}{% endif %}" style="width: 400px;">
|
||||||
|
{% else %}
|
||||||
<p style="padding-top: 8px; font-size: 24px;">{{ account.email }}</p>
|
<p style="padding-top: 8px; font-size: 24px;">{{ account.email }}</p>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h2><i class="fa fa-telegram"></i></h2>
|
||||||
|
</td>
|
||||||
|
<td><div style="width: 20px;"></div></td>
|
||||||
|
<td>
|
||||||
|
{% if owner %}
|
||||||
|
<input placeholder="telegram username" type="text" name="telegram_username" value="{% if account.telegram_username %}{{ account.telegram_username }}{% endif %}" style="width: 400px; margin-bottom: 5px;"><br>
|
||||||
|
<input placeholder="telegram id" type="number" name="telegram_id" value="{% if account.telegram_id %}{{ account.telegram_id }}{% endif %}" style="width: 400px;"> <a style="color: blue;" href="https://t.me/getmyid_bot">Узнать можно в боте</a>
|
||||||
|
{% else %}
|
||||||
|
{% if account.telegram_username %}
|
||||||
|
<a style="padding-top: 8px; font-size: 24px;" href="https://t.me/{{ account.telegram_username }}">{{ account.telegram_username }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -86,11 +109,12 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td></td><td></td>
|
<td></td><td></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="/logout" class="btn btn-primary">Выход из аккаунта</a>
|
<a href="/logout" class="btn btn-primary" style="margin-right: 5px;">Выход из аккаунта</a><a class="btn btn-success">Сохранить данные</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 4.1.7 on 2023-10-11 15:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('web', '0006_remove_project_web_project_next_st_234c0f_idx_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='customuser',
|
||||||
|
name='telegram_id',
|
||||||
|
field=models.BigIntegerField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='customuser',
|
||||||
|
name='telegram_username',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -5,6 +5,8 @@ from django.db import models
|
|||||||
class CustomUser(AbstractUser):
|
class CustomUser(AbstractUser):
|
||||||
vk_id = models.IntegerField(null=True, blank=True)
|
vk_id = models.IntegerField(null=True, blank=True)
|
||||||
yandex_id = models.BigIntegerField(null=True, blank=True)
|
yandex_id = models.BigIntegerField(null=True, blank=True)
|
||||||
|
telegram_id = models.BigIntegerField(null=True, blank=True)
|
||||||
|
telegram_username = models.TextField(null=True, blank=True)
|
||||||
only_one_project = models.BooleanField(default=True)
|
only_one_project = models.BooleanField(default=True)
|
||||||
selected_project = models.ForeignKey('Project', on_delete=models.CASCADE, null=True)
|
selected_project = models.ForeignKey('Project', on_delete=models.CASCADE, null=True)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
from django.db.models import Q
|
|
||||||
from django.http import HttpResponse, JsonResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
|
|
||||||
from Platform import settings
|
from Platform import settings
|
||||||
@ -18,6 +17,9 @@ def is_staff(request):
|
|||||||
email = request.GET.get('email')
|
email = request.GET.get('email')
|
||||||
if email:
|
if email:
|
||||||
data['email'] = email
|
data['email'] = email
|
||||||
|
telegram_id = request.GET.get('telegram_id')
|
||||||
|
if telegram_id:
|
||||||
|
data['telegram_id'] = telegram_id
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
if len(CustomUser.objects.filter(**{key: value})) != 0:
|
if len(CustomUser.objects.filter(**{key: value})) != 0:
|
||||||
return JsonResponse({'is_staff': True})
|
return JsonResponse({'is_staff': True})
|
||||||
|
@ -18,6 +18,14 @@ class ProfileView(BaseView):
|
|||||||
minio_client.put_object(self.request.FILES["file"].read(), f"profile_photos/{self.request.user.id}")
|
minio_client.put_object(self.request.FILES["file"].read(), f"profile_photos/{self.request.user.id}")
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def post_save_data(self):
|
||||||
|
self.request.user.telegram_username = self.request.POST['telegram_username'] if self.request.POST['telegram_username'] else None
|
||||||
|
self.request.user.telegram_id = int(self.request.POST['telegram_id']) if self.request.POST['telegram_id'] and str(self.request.POST['telegram_id']).isnumeric() else None
|
||||||
|
self.request.user.email = self.request.POST['email'] if self.request.POST['email'] else None
|
||||||
|
self.request.user.save()
|
||||||
|
return '/profile'
|
||||||
|
|
||||||
|
|
||||||
def post_change_password(self):
|
def post_change_password(self):
|
||||||
if self.request.POST['password'] != self.request.POST['repeat']:
|
if self.request.POST['password'] != self.request.POST['repeat']:
|
||||||
return '/profile?err=true'
|
return '/profile?err=true'
|
||||||
|
Loading…
Reference in New Issue
Block a user