Quellcode durchsuchen

Merge branch 'open-unstable' of blezz-tech/sharix-open-webapp-base into unstable

Merging from assist
david berlinskiy vor 1 Monat
Ursprung
Commit
4248de3dde

+ 1 - 0
sharix_admin/signals.py

@@ -6,6 +6,7 @@ from django.db.models.signals import post_migrate
 from django.contrib.auth import get_user_model
 from django.contrib.auth.hashers import make_password
 from django.conf import settings
+from django.db import models
 
 from tickets.models import TicketList
 

+ 1 - 1
sharix_admin/templates/sharix_admin/base_admin.html

@@ -206,7 +206,7 @@
     </div>
 
     <div class="d-flex gap-3 mx-2">
-        <a href="{% url 'contact' %}">{% trans 'Contacts' %}</a>
+        {% comment %} <a href="{% url 'contact' %}">{% trans 'Contacts' %}</a> {% endcomment %}
         <a href="https://wiki.sharix-app.org/doku.php/sharix/legal/soglashenie_s_servisom_na_ispolzovanie_platformy_sharix">{% trans 'Terms of use' %}</a>
         <a href="https://wiki.sharix-app.org/doku.php/sharix/legal/politika_konfidencialnosti_platformy_sharix">{% trans 'Privacy policy' %}</a>
         <a href="https://wiki.sharix-app.org/doku.php">Помощь</a>

+ 1 - 0
sharix_admin/urls.py

@@ -74,6 +74,7 @@ urlpatterns = [
 
     path('api/v1/auth/', include('djoser.urls.authtoken'), name="api-auth"),
     path('api/v1/platform/', include(router.urls), name="api-platform"),
+    path('by_phone/<phone_number>/', get_user_by_phone_number, name='get_user_by_phone_number'),
 
     path('senderphone/', PhoneSender.as_view()),
 

+ 2 - 1
sharix_admin/views/__init__.py

@@ -16,4 +16,5 @@ from .payment import *
 from .balance import *
 from .trans_id import *
 from .schema import *
-from .user_info import *
+from .user_info import *
+from .get_userid import *

+ 29 - 0
sharix_admin/views/get_userid.py

@@ -0,0 +1,29 @@
+from django.http import JsonResponse
+from django.contrib.auth import get_user_model
+from django.contrib.auth.decorators import login_required
+from django.views.decorators.csrf import csrf_exempt
+
+@csrf_exempt
+def get_user_by_phone_number(request, phone_number):
+    if request.method == 'GET':
+        if phone_number:
+            User = get_user_model()
+            try:
+                users_with_phone = User.objects.filter(phone_number=phone_number)
+                if users_with_phone.exists():
+                    user = users_with_phone.first()
+                    user_info = {
+                        'id': user.id,
+                        'username': user.username,
+                        'email': user.email,
+                    }
+                    return JsonResponse(user_info)
+                else:
+                    # Если пользователь не найден, возвращаем ошибку 404
+                    return JsonResponse({'error': 'User not found'}, status=404)
+            except User.DoesNotExist:
+                return JsonResponse({'error': 'User not found'}, status=404)
+        else:
+            return JsonResponse({'error': 'Phone number is missing'}, status=400)
+    else:
+        return JsonResponse({'error': 'Only GET requests are allowed'}, status=405)