Browse Source

rebuild views

Evgeny Polivanov 1 năm trước cách đây
mục cha
commit
47cfa20a69

+ 2 - 1
SharixAdmin/urls.py

@@ -1,5 +1,6 @@
 from django.urls import path, include, re_path
-from .views import *
+from .views_old import *
+from SharixAdmin.views import *
 from .apiviews import *
 from rest_framework import routers
 from django_spaghetti.views import Plate

+ 2 - 0
SharixAdmin/views/__init__.py

@@ -0,0 +1,2 @@
+from .index import index
+from .transactions import transactions

+ 31 - 0
SharixAdmin/views/context.py

@@ -0,0 +1,31 @@
+from django.urls import resolve
+
+menu = [
+    {'title':'Главная/баланс',          'link':'home', 'sel':'house'},
+    {'title':'Платежная информация',    'link':'test-page', 'sel':'credit-card'},
+    {'title':'История платежей',        'link':'trans','sel':'clock-history'},
+    {'title':'Курсы',                   'link':'course', 'sel':'education'},
+    {'title':'Личная информация',       'link':'test-page', 'sel':'person'},
+    {'title':'Управление сервисами',    'link':'test-page', 'sel':'hdd-network'},
+    {'title':'Мои связи',               'link':'test-page', 'sel':'people'},
+    {'title':'Сотрудничество',          'link':'test-page', 'sel':'sotrud'},
+    {'title':'Техподдержка',            'link':'test-page', 'sel':'gear'},
+    {'title':'Мои заявки',              'link':'tickets', 'sel':'tikets'},
+    {'title':'Исполнители',             'link':'provider', 'sel':'people'},
+    {'title':'Тарифы услуг',            'link':'service_tariff', 'sel':'person'},
+    {'title':'Партнеры',                'link':'partners', 'sel':'people'},
+    {'title':'Ресурсы',                 'link':'resource', 'sel':'sotrud'},
+    {'title':'Услуги сервиса',          'link':'service_type', 'sel':'hdd-network'},
+    {'title':'Информация о сервисе',    'link':'partner_information/add/', 'sel':'hdd-network'},
+    {'title':'Информация о партнере',   'link':'partner_information/add/', 'sel':'person'},
+    {'title':'Тарифы',                  'link':'service', 'sel':'tikets'},
+]
+
+def get_context(request, page_context) -> dict:
+    base_context = {
+        "title":page_context['title'],
+        'url_path':resolve(request.path_info).url_name,
+        'menu':menu
+    }
+    context = dict(list(base_context.items()) + list(page_context.items()))
+    return context

+ 16 - 0
SharixAdmin/views/index.py

@@ -0,0 +1,16 @@
+from django.contrib.auth.decorators import login_required
+from SharixAdmin.views.context import get_context
+from django.shortcuts import render
+
+@login_required
+def index(request):
+
+    ph_num = str(request.user.phone_number)
+    convert_ph_num = f"+{ph_num[:1]} ({ph_num[1:4]}) {ph_num[4:7]}-{ph_num[7:9]}-{ph_num[9:11]}"
+    #print(convert_ph_num)
+    context = get_context(request, {
+        'title':'Главная/баланс',
+        'phone':convert_ph_num
+    })
+    
+    return render(request, 'SharixAdmin/main.html', context)

+ 12 - 0
SharixAdmin/views/transactions.py

@@ -0,0 +1,12 @@
+from django.contrib.auth.decorators import login_required
+from SharixAdmin.views.context import get_context
+from django.shortcuts import render
+
+@login_required
+def transactions(request):
+    
+    context = get_context(request, {
+        'title':'История платежей',
+        })
+        
+    return render(request, 'SharixAdmin/transactions.html', context)

+ 16 - 19
SharixAdmin/views.py → SharixAdmin/views_old.py

@@ -1,5 +1,3 @@
-
-import json
 from django.shortcuts import render
 from django.http import HttpResponseRedirect, HttpResponse, JsonResponse
 from django.contrib.auth.views import LoginView
@@ -26,27 +24,27 @@ from django.views.generic.edit import UpdateView, CreateView, DeleteView
 # Create your views here.
 
 
-@login_required
-def index(request):
+# @login_required
+# def index(request):
 
-    ph_num = str(request.user.phone_number)
-    convert_ph_num = f"+{ph_num[:1]} ({ph_num[1:4]}) {ph_num[4:7]}-{ph_num[7:9]}-{ph_num[9:11]}"
-    #print(convert_ph_num)
-    context = get_context(request, {
-        'title':'Главная/баланс',
-        'phone':convert_ph_num
-    })
+#     ph_num = str(request.user.phone_number)
+#     convert_ph_num = f"+{ph_num[:1]} ({ph_num[1:4]}) {ph_num[4:7]}-{ph_num[7:9]}-{ph_num[9:11]}"
+#     #print(convert_ph_num)
+#     context = get_context(request, {
+#         'title':'Главная/баланс',
+#         'phone':convert_ph_num
+#     })
     
-    return render(request, 'SharixAdmin/main.html', context)
+#     return render(request, 'SharixAdmin/main.html', context)
 
-@login_required
-def transactions(request):
+# @login_required
+# def transactions(request):
     
-    context = get_context(request, {
-        'title':'История платежей',
-        })
+#     context = get_context(request, {
+#         'title':'История платежей',
+#         })
         
-    return render(request, 'SharixAdmin/transactions.html', context)
+#     return render(request, 'SharixAdmin/transactions.html', context)
 
 @login_required
 def servicetype(request):
@@ -393,7 +391,6 @@ def change_service_status(request):
 #Shema views
 @login_required
 def schema_v3(request):
-    
     return render(request, "SharixAdmin/schema.html")