├── README.md ├── 选题.docx ├── E-R图.docx ├── 关系模式.docx ├── books.xlsx ├── sql端代码.txt └── online_bookstore ├── login ├── models.py ├── tests.py ├── admin.py ├── apps.py ├── __pycache__ │ ├── urls.cpython-37.pyc │ ├── admin.cpython-37.pyc │ ├── forms.cpython-37.pyc │ ├── models.cpython-37.pyc │ ├── views.cpython-37.pyc │ └── __init__.cpython-37.pyc ├── migrations │ └── __pycache__ │ │ └── __init__.cpython-37.pyc ├── urls.py ├── forms.py └── views.py ├── manager ├── models.py ├── tests.py ├── admin.py ├── apps.py ├── __pycache__ │ ├── admin.cpython-37.pyc │ ├── forms.cpython-37.pyc │ ├── urls.cpython-37.pyc │ ├── views.cpython-37.pyc │ ├── models.cpython-37.pyc │ └── __init__.cpython-37.pyc ├── migrations │ └── __pycache__ │ │ └── __init__.cpython-37.pyc ├── urls.py ├── forms.py └── views.py ├── member ├── models.py ├── tests.py ├── admin.py ├── apps.py ├── __pycache__ │ ├── admin.cpython-37.pyc │ ├── models.cpython-37.pyc │ ├── urls.cpython-37.pyc │ ├── views.cpython-37.pyc │ └── __init__.cpython-37.pyc ├── migrations │ └── __pycache__ │ │ └── __init__.cpython-37.pyc ├── urls.py └── views.py ├── shopping ├── models.py ├── admin.py ├── tests.py ├── apps.py ├── __pycache__ │ ├── urls.cpython-37.pyc │ ├── admin.cpython-37.pyc │ ├── models.cpython-37.pyc │ ├── views.cpython-37.pyc │ └── __init__.cpython-37.pyc ├── urls.py ├── migrations │ └── __pycache__ │ │ └── __init__.cpython-37.pyc └── views.py ├── db.sqlite3 ├── online_bookstore ├── __pycache__ │ ├── urls.cpython-37.pyc │ ├── views.cpython-37.pyc │ ├── wsgi.cpython-37.pyc │ ├── __init__.cpython-37.pyc │ └── settings.cpython-37.pyc ├── views.py ├── urls.py ├── wsgi.py └── settings.py ├── context_processors ├── __pycache__ │ ├── __init__.cpython-37.pyc │ └── base_processors.cpython-37.pyc └── base_processors.py ├── manage.py └── templates ├── home.html ├── login_for_manager.html ├── shopping_cart.html ├── shopping.html ├── login.html ├── base.html ├── base_for manage.html ├── register.html └── manager.html /README.md: -------------------------------------------------------------------------------- 1 | # online_book_stroe 2 | 网上书店系统 base on django and sql_server 3 | -------------------------------------------------------------------------------- /选题.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/选题.docx -------------------------------------------------------------------------------- /E-R图.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/E-R图.docx -------------------------------------------------------------------------------- /关系模式.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/关系模式.docx -------------------------------------------------------------------------------- /books.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/books.xlsx -------------------------------------------------------------------------------- /sql端代码.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/sql端代码.txt -------------------------------------------------------------------------------- /online_bookstore/login/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/login/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /online_bookstore/manager/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/manager/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /online_bookstore/member/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/member/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /online_bookstore/shopping/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/login/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/manager/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/member/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/shopping/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /online_bookstore/shopping/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /online_bookstore/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/db.sqlite3 -------------------------------------------------------------------------------- /online_bookstore/login/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class LoginConfig(AppConfig): 5 | name = 'login' 6 | -------------------------------------------------------------------------------- /online_bookstore/member/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MemberConfig(AppConfig): 5 | name = 'member' 6 | -------------------------------------------------------------------------------- /online_bookstore/manager/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ManagerConfig(AppConfig): 5 | name = 'manager' 6 | -------------------------------------------------------------------------------- /online_bookstore/shopping/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ShoppingConfig(AppConfig): 5 | name = 'shopping' 6 | -------------------------------------------------------------------------------- /online_bookstore/login/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/login/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/login/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/login/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/login/__pycache__/forms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/login/__pycache__/forms.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/login/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/login/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/login/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/login/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/manager/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/manager/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/manager/__pycache__/forms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/manager/__pycache__/forms.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/manager/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/manager/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/manager/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/manager/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/member/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/member/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/member/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/member/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/member/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/member/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/member/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/member/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/shopping/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/shopping/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/login/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/login/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/manager/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/manager/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/member/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/member/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/shopping/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/shopping/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/shopping/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/shopping/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/shopping/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/shopping/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/manager/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/manager/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/shopping/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/shopping/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/shopping/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | 5 | urlpatterns = [ 6 | path('', views.index, name='shopping'), 7 | 8 | ] 9 | -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/online_bookstore/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/online_bookstore/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/__pycache__/wsgi.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/online_bookstore/__pycache__/wsgi.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/login/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/login/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/online_bookstore/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/__pycache__/settings.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/online_bookstore/__pycache__/settings.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/context_processors/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/context_processors/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/manager/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/manager/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/member/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/member/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/shopping/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/shopping/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/context_processors/__pycache__/base_processors.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder23263/online_book_stroe/HEAD/online_bookstore/context_processors/__pycache__/base_processors.cpython-37.pyc -------------------------------------------------------------------------------- /online_bookstore/member/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | 5 | urlpatterns = [ 6 | path('', views.member), 7 | path('shopping_cart/', views.shop_cart, name='shopping_cart'), 8 | ] -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import reverse, redirect, render 2 | from django.http import HttpResponse 3 | 4 | 5 | 6 | 7 | def home(request): 8 | return render(request, 'home.html') 9 | 10 | -------------------------------------------------------------------------------- /online_bookstore/manager/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path, include 2 | from . import views 3 | 4 | 5 | urlpatterns = [ 6 | path('', views.ManageView.as_view(), name='manager_login'), 7 | path('root_admin//', views.root_admin, name='manage'), 8 | 9 | ] -------------------------------------------------------------------------------- /online_bookstore/login/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | 5 | urlpatterns = [ 6 | path('', views.IndexView.as_view(), name='signin'), 7 | path('register/', views.RegisterView.as_view(), name='signup'), 8 | path('logout/', views.logout, name='logout'), 9 | ] 10 | -------------------------------------------------------------------------------- /online_bookstore/manager/forms.py: -------------------------------------------------------------------------------- 1 | #encoding: utf-8 2 | from django import forms 3 | from django.core import validators 4 | from django.db import connection 5 | 6 | #获取sql_server的游标 7 | cursor = connection.cursor() 8 | 9 | class managerForm(forms.Form):#登录类 10 | account = forms.CharField(max_length=10) 11 | password = forms.CharField(max_length=20) -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path, include 2 | from . import views 3 | 4 | 5 | 6 | urlpatterns = [ 7 | path('', views.home, name='home'), 8 | path('shopping/', include('shopping.urls')), 9 | path('member/', include('member.urls')), 10 | path('login/', include('login.urls')), 11 | path('manager/', include('manager.urls')), 12 | ] 13 | -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for online_bookstore project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'online_bookstore.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /online_bookstore/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == '__main__': 6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'online_bookstore.settings') 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /online_bookstore/context_processors/base_processors.py: -------------------------------------------------------------------------------- 1 | from django.db import connection 2 | 3 | 4 | def front_user(request): 5 | cookies = request.COOKIES 6 | account = cookies.get('account') 7 | context = {} 8 | if account: 9 | cursor = connection.cursor() 10 | cursor.execute("select * from MEMBER where mno={}".format(account)) # 获取昵称 11 | name = cursor.fetchone()[2] 12 | # print("=" * 15) 13 | # print(account, name) 14 | # print("=" * 15) 15 | try: 16 | context['front_user'] = account 17 | context['name'] = name 18 | except: 19 | pass 20 | return context -------------------------------------------------------------------------------- /online_bookstore/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | home 6 | 25 | 26 | 27 |
28 | 请选择你的身份 29 |
  • 管理员
  • 30 |
  • 游客
  • 31 |
  • 会员
  • 32 |
    33 | 34 | -------------------------------------------------------------------------------- /online_bookstore/templates/login_for_manager.html: -------------------------------------------------------------------------------- 1 | {% extends 'base_for manage.html' %} 2 | 3 | {% block head %} 4 | 5 | 6 | 12 | {% endblock %} 13 | 14 | {% block body %} 15 |
    16 |
    17 | {# #} 18 | {% csrf_token %} 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
    管理员账户
    密码
    33 |
    34 |
    35 | 36 | {% endblock %} -------------------------------------------------------------------------------- /online_bookstore/templates/shopping_cart.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% block head %} 3 | 9 | {% endblock %} 10 | {% block body %} 11 | 12 | 28 |
    29 | 30 | {# #} 39 | 40 | {% endblock %} -------------------------------------------------------------------------------- /online_bookstore/shopping/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from django.db import connection 4 | import re 5 | 6 | #为购物车定义一个字典,字段为: 书的ID:数量 7 | shopping_cart = dict() 8 | 9 | 10 | def get_cursor(): 11 | return connection.cursor() 12 | 13 | 14 | def index(request): 15 | cursor = get_cursor() 16 | cursor.execute("SELECT * FROM BOOKS") 17 | rows = cursor.fetchall() #get到所有元组组成的集合 18 | #print(rows) 19 | 20 | if request.method == 'GET': 21 | if request.GET.get('category'): 22 | new_rows = [] 23 | for row in rows: 24 | if request.GET.get('category') in row[0]: 25 | new_rows.append(row) 26 | context = { 27 | 'books': new_rows, 28 | } 29 | return render(request, 'shopping.html', context=context) 30 | 31 | context = { 32 | 'books': rows, 33 | } 34 | #如果表单提交为post请求,添加书到购物车(因为刚刷新页面的时候有一次空值,要忽略这次空值) 35 | if request.method == 'POST' and request.POST.get("book") is not None: 36 | add_shopping_cart(request.POST.get("book"))#执行加入购物车函数,传参为商品ID 37 | return render(request, 'shopping.html', context=context) 38 | 39 | 40 | def add_shopping_cart(bno):#传入的参数是bno即书的ID 41 | global shopping_cart 42 | if shopping_cart.get(bno):#若存在数量加一,不存在就置1 43 | shopping_cart[bno] += 1 44 | else: 45 | shopping_cart[bno] = 1 46 | -------------------------------------------------------------------------------- /online_bookstore/templates/shopping.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block body %} 4 |
    5 | 8 | 15 |
    16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | {% for book in books %} 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% if front_user %} 44 | 45 | {% endif %} 46 | 47 | 48 | {% endfor %} 49 | 50 | 51 | 52 |
    书标号书名类别出版社作者概述价格折扣库存量
    {{ book.0 }}{{ book.1 }}{{ book.2 }}{{ book.3 }}{{ book.4 }}{{ book.5 }}{{ book.6 }}{{ book.7 }}{{ book.8 }}
    53 | {% endblock %} -------------------------------------------------------------------------------- /online_bookstore/login/forms.py: -------------------------------------------------------------------------------- 1 | #encoding: utf-8 2 | from django import forms 3 | from django.core import validators 4 | from django.db import connection 5 | 6 | #获取sql_server的游标 7 | cursor = connection.cursor() 8 | class BaseForm(forms.Form): 9 | def get_errors(self): 10 | errors = self.errors.get_json_data() 11 | new_errors = {} 12 | for key, message_dicts in errors.items(): 13 | messages = [] 14 | for message_dict in message_dicts: 15 | message = message_dict['message'] 16 | messages.append(message) 17 | new_errors[key] = messages 18 | return new_errors 19 | 20 | class MyForm(BaseForm):#登录类 21 | account = forms.CharField(max_length=10) 22 | password = forms.CharField(max_length=20) 23 | 24 | 25 | class RegisterForm(BaseForm):#注册类 26 | account = forms.CharField(max_length=10) 27 | name = forms.CharField(max_length=30) 28 | telephone = forms.CharField(validators=[validators.RegexValidator(r'1[345678]\d{9}')]) 29 | email = forms.CharField(max_length=30) 30 | address = forms.CharField(max_length=50) 31 | pwd1 = forms.CharField(max_length=20) 32 | pwd2 = forms.CharField(max_length=20) 33 | 34 | #调用views.py中的is_valid()函数时自动调用clean_telephone(以clean开头,中间横线加上要验证的表单字段) 35 | def clean_account(self):#验证账户是否被注册过 36 | account = self.cleaned_data.get('account')#获取表单中的account 37 | cursor.execute("select * from MEMBER where mno={}".format(account))#获取db中的account 38 | try: 39 | db_account = cursor.fetchone()[0] 40 | except: 41 | db_account = '' 42 | if account == db_account.strip(): 43 | raise forms.ValidationError(message='%s已经被注册!'%db_account)#在db中存在 44 | # 如果验证没有问题,一定要记得把telephone返回回去 45 | return account #表单的account验证没有问题,返回 46 | 47 | def clean(self):#验证两次密码是否一致 48 | # 如果来到了clean方法,说明之前每一个字段都验证成功了 49 | cleaned_data = super().clean() 50 | pwd1 = cleaned_data.get('pwd1') 51 | pwd2 = cleaned_data.get('pwd2') 52 | if pwd1 != pwd2: 53 | raise forms.ValidationError(message='两次密码输入不一致!') 54 | print("密码不一致") 55 | return cleaned_data 56 | -------------------------------------------------------------------------------- /online_bookstore/templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block head %} 4 | 5 | 6 | 13 | {% endblock %} 14 | 15 | {% block body %} 16 |
    17 |
    18 | 38 |
    39 |
    40 | 41 | 42 | 43 | 44 | 45 | {#
    #} 46 | {#
    #} 47 | {# #} 48 | {# {% csrf_token %}#} 49 | {# #} 50 | {# #} 51 | {# #} 52 | {# #} 53 | {# #} 54 | {# #} 55 | {# #} 56 | {# #} 57 | {# #} 58 | {# #} 59 | {# #} 60 | {# #} 61 | {# #} 62 | {#
    账户
    密码
    #} 63 | {#
    #} 64 | {#
    #} 65 | 66 | {% endblock %} 67 | -------------------------------------------------------------------------------- /online_bookstore/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 网上书店系统 6 | 7 | 8 | {% block head %}{% endblock %} 9 | 10 | 11 | 46 | 47 | {% block body %}{% endblock %} 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /online_bookstore/templates/base_for manage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 网上书店系统 6 | 7 | 8 | {% block head %}{% endblock %} 9 | 10 | 11 | 46 | {% block body %}{% endblock %} 47 | 48 | -------------------------------------------------------------------------------- /online_bookstore/login/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.generic import View 3 | from .forms import MyForm, RegisterForm 4 | from django.http import HttpResponse 5 | from django.db import connection 6 | from django.shortcuts import reverse, redirect 7 | from shopping.views import shopping_cart 8 | 9 | cursor = connection.cursor() 10 | class IndexView(View): 11 | def get(self,request): 12 | return render(request,'login.html') 13 | 14 | def verify_ID(self, account, password): # 验证身份函数,传入前端得到的账号密码(str类型),传出TURE or FALSE 15 | cursor.execute("select * from MEMBER where mno={}".format(account)) # 调用游标指针的execute方法执行sql语句 16 | db_password = cursor.fetchone()[1] 17 | if password == db_password.strip(): 18 | return True 19 | 20 | def post(self,request): 21 | form = MyForm(request.POST) 22 | if form.is_valid(): 23 | account = form.cleaned_data.get('account') 24 | password = form.cleaned_data.get('password') 25 | is_success_or_fail = self.verify_ID(account, password) 26 | if is_success_or_fail: 27 | #print("登录成功") 28 | #登录成功之后设置cookies 29 | response = redirect(reverse('shopping'))#得到response对象,预备设置cookies值 30 | response.set_cookie('account', account)#为response对象设置cookies值 31 | return response#若登录成功,页面重定向到购物页面 32 | else: 33 | print("登录失败 %s"%password) 34 | return HttpResponse('请输入正确的密码') 35 | else: 36 | print(form.errors.get_json_data()) 37 | return redirect(reverse('signin')) 38 | 39 | 40 | class RegisterView(View): 41 | def get(self,request): 42 | return render(request,'register.html') 43 | 44 | def post(self,request): 45 | form = RegisterForm(request.POST) 46 | if form.is_valid():#如果注册信息验证成功,插入sql_server 47 | account = form.cleaned_data.get('account') 48 | password = form.cleaned_data.get('pwd1') 49 | name = form.cleaned_data.get('name') 50 | telephone = form.cleaned_data.get('telephone') 51 | email = form.cleaned_data.get('email') 52 | address = form.cleaned_data.get('address') 53 | #插入数据 54 | cursor.execute("INSERT INTO MEMBER(mno, mpassword, mname, mphone, mpost, madress) VALUES ('{}','{}','{}','{}','{}','{}')".format(account, password, name, telephone, email, address)) 55 | return HttpResponse('注册成功!') 56 | else: 57 | print(form.get_errors()) 58 | return HttpResponse('注册失败!') 59 | 60 | def logout(request):#删除cookies并反转到shopping页面 61 | global shopping_cart 62 | response = redirect(reverse('shopping')) 63 | response.delete_cookie('account') 64 | shopping_cart = dict() 65 | return response 66 | -------------------------------------------------------------------------------- /online_bookstore/member/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from shopping.views import shopping_cart 4 | from datetime import datetime 5 | from django.db import connection 6 | import time 7 | 8 | 9 | def get_cursor(): 10 | return connection.cursor() 11 | 12 | def member(request): 13 | return HttpResponse("会员") 14 | 15 | def shop_cart(request):#购物车视图函数 16 | cookies = request.COOKIES 17 | 18 | if cookies.get('account'): 19 | account = request.GET.get("account") 20 | global shopping_cart 21 | if request.method == 'POST': 22 | if request.POST.get("book_plus"): 23 | shopping_cart[request.POST.get("book_plus")] += 1 24 | 25 | elif request.POST.get("book_reduce"): 26 | shopping_cart[request.POST.get("book_reduce")] -= 1 27 | if shopping_cart[request.POST.get("book_reduce")] == 0: # 如果数量为零就移除购物车中该商品 28 | shopping_cart.pop(request.POST.get("book_reduce")) 29 | 30 | elif request.POST.get("create_order"):#提交订单函数 31 | cursor = get_cursor() 32 | for key, value in shopping_cart.items(): 33 | if cursor.execute("select stock from books where bno='{}'".format(key)).fetchone()[0] < value: 34 | #shopping_cart.clear() # 清空购物车 35 | return HttpResponse("{}库存不足,请查看库存从新选择并提交订单".format(key)) 36 | 37 | ono = str(request.GET.get("account")) + "_" + str(int(time.time()))#获取账户名加空格加时间戳W为订单唯一ID 38 | 39 | total_price = 0#用来存放订单总价 40 | for key, value in shopping_cart.items(): 41 | price_and_discount = cursor.execute("select price, discount from books where bno='{}'".format(key)).fetchone() 42 | price = price_and_discount[0] 43 | discount = price_and_discount[1] 44 | total_price += price * discount * value * 0.1#计算订单总价 45 | 46 | #### 插入操作,将订单信息插入order_form, ##### 47 | cursor.execute("insert into order_form(ono, submit_date, send_date, total_price, mno) values('{}','{}','{}','{:.2f}','{}')".format(ono, datetime.today(), '', total_price, account)) 48 | #将订购信息插入order_information ,订单号,书号,书的数量,因为有主键约束,所有先进行插入order_form,后进行插入order_information 49 | for key, value in shopping_cart.items(): 50 | cursor.execute("insert into order_information(bno, ono, order_number) values('{}','{}','{}')".format(key, ono,value)) 51 | #将订单图书在库存中减少 52 | for key, value in shopping_cart.items(): 53 | orig_stock = cursor.execute("select stock from books where bno='{}'".format(key)).fetchone()[0] 54 | cursor.execute("update books set stock='{}' where bno='{}'".format(orig_stock - value, key)) 55 | #订单提交到数据库,清空购物车字典 56 | shopping_cart.clear()#清空购物车 57 | return HttpResponse("订单提交成功") 58 | else: 59 | print("另类的post请求") 60 | context = { 61 | 'account': account,#暂时没有用到 62 | 'books': shopping_cart, 63 | 64 | } 65 | #print(context) 66 | return render(request, 'shopping_cart.html', context=context) 67 | else: 68 | return HttpResponse("请登录后查看购物车") 69 | -------------------------------------------------------------------------------- /online_bookstore/templates/register.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block head %} 4 | 14 | {% endblock %} 15 | 16 | {% block body %} 17 | {#
    #} 18 | {# #} 19 | {# #} 20 | {# #} 21 | {# #} 22 | {# #} 23 | {# #} 24 | {# #} 25 | {# #} 26 | {# #} 27 | {# #} 28 | {# #} 29 | {# #} 30 | {# #} 31 | {# #} 32 | {# #} 33 | {# #} 34 | {# #} 35 | {# #} 36 | {# #} 37 | {# #} 38 | {# #} 39 | {# #} 40 | {# #} 41 | {# #} 42 | {# #} 43 | {# #} 44 | {# #} 45 | {# #} 46 | {# #} 47 | {# #} 48 | {# #} 49 | {# #} 50 | {# #} 51 | {#
    账户:
    昵称:
    联系电话:
    邮箱:
    地址:
    密码:
    重复密码:
    #} 52 | {#
    #} 53 | {##} 54 | {##} 55 | {##} 56 | 57 | 58 | 59 | 60 |
    61 |
    62 |

    欢迎注册,加入我们

    63 |
    64 |
    65 |
    66 | 67 | 68 |
    69 |
    70 | 71 | 72 |
    73 |
    74 | 75 | 76 |
    77 |
    78 | 79 | 80 |
    81 |
    82 | 83 | 84 |
    85 |
    86 | 87 | 88 |
    89 |
    90 | 91 | 92 |
    93 | 94 | 95 | 96 |
    97 |
    98 |
    99 |
    100 | 101 | 102 | {% endblock %} -------------------------------------------------------------------------------- /online_bookstore/online_bookstore/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for online_bookstore project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.1.10. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.1/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'ld@z2)6tzv^t6gde^y8%!1kg7-26n$e9ue5mf^0pgq7g^)7)88' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = ['127.0.0.1', '10.128.59.140'] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'shopping', 41 | 'member', 42 | 'login', 43 | 'manager', 44 | ] 45 | 46 | MIDDLEWARE = [ 47 | 'django.middleware.security.SecurityMiddleware', 48 | 'django.contrib.sessions.middleware.SessionMiddleware', 49 | 'django.middleware.common.CommonMiddleware', 50 | #'django.middleware.csrf.CsrfViewMiddleware', 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 52 | 'django.contrib.messages.middleware.MessageMiddleware', 53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 54 | ] 55 | 56 | ROOT_URLCONF = 'online_bookstore.urls' 57 | 58 | TEMPLATES = [ 59 | { 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 61 | 'DIRS': [os.path.join(BASE_DIR, 'templates')] 62 | , 63 | 'APP_DIRS': True, 64 | 'OPTIONS': { 65 | 'context_processors': [ 66 | 'django.template.context_processors.debug', 67 | 'django.template.context_processors.request', 68 | 'django.contrib.auth.context_processors.auth', 69 | 'django.contrib.messages.context_processors.messages', 70 | 'context_processors.base_processors.front_user', 71 | ], 72 | }, 73 | }, 74 | ] 75 | 76 | WSGI_APPLICATION = 'online_bookstore.wsgi.application' 77 | 78 | 79 | # Database 80 | # https://docs.djangoproject.com/en/2.1/ref/settings/#databases 81 | 82 | DATABASES = { 83 | 'default': { 84 | 'NAME': 'online_shopping', 85 | 'ENGINE': 'sql_server.pyodbc', 86 | 'HOST': 'DESKTOP-R3I66AJ', 87 | 'USER': 'sa', 88 | 'PASSWORD': '23263', 89 | } 90 | } 91 | 92 | 93 | 94 | # Password validation 95 | # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators 96 | 97 | AUTH_PASSWORD_VALIDATORS = [ 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 106 | }, 107 | { 108 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 109 | }, 110 | ] 111 | 112 | 113 | # Internationalization 114 | # https://docs.djangoproject.com/en/2.1/topics/i18n/ 115 | 116 | LANGUAGE_CODE = 'en-us' 117 | 118 | TIME_ZONE = 'UTC' 119 | 120 | USE_I18N = True 121 | 122 | USE_L10N = True 123 | 124 | USE_TZ = True 125 | 126 | 127 | # Static files (CSS, JavaScript, Images) 128 | # https://docs.djangoproject.com/en/2.1/howto/static-files/ 129 | 130 | STATIC_URL = '/static/' 131 | -------------------------------------------------------------------------------- /online_bookstore/manager/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.generic import View 3 | from .forms import managerForm 4 | from django.http import HttpResponse 5 | from django.db import connection 6 | from django.shortcuts import reverse, redirect 7 | from datetime import datetime 8 | import pandas as pd 9 | cursor = connection.cursor() 10 | 11 | class ManageView(View): 12 | def get(self, request): 13 | return render(request, 'login_for_manager.html') 14 | 15 | def verify_ID(self, account, password): # 验证身份账号密码(str类型),传出TURE or FALSE,默认管理员账户为 root,密码为23263 16 | if account == 'root' and password == '23263': 17 | return True 18 | else: 19 | return False 20 | 21 | def post(self,request): 22 | form = managerForm(request.POST) 23 | if form.is_valid(): 24 | account = form.cleaned_data.get('account') 25 | password = form.cleaned_data.get('password') 26 | is_success_or_fail = self.verify_ID(account, password) 27 | if is_success_or_fail: 28 | #登录成功之后设置cookies 29 | response = redirect(reverse('manage', kwargs={"deal": 'index'}))#得到response对象,预备设置cookies值 30 | response.set_cookie('manager_account', 'ROOT_ROOT')#为response对象设置cookies值为root , path='/manager/root_admin/' 31 | return response#若登录成功,页面重定向到购物页面 32 | else: 33 | return HttpResponse('请输入正确的账号密码') 34 | else: 35 | print(form.errors.get_json_data()) 36 | return redirect(reverse('manager_login')) 37 | 38 | 39 | def root_admin(request, deal): 40 | cookies = request.COOKIES 41 | if cookies.get('manager_account') == 'ROOT_ROOT': 42 | context = dict()#创建一个空字典来储存传递到html页面的内容 43 | 44 | if request.method == 'GET':#get方法不同参数渲染不同的页面 45 | if deal == 'index': 46 | context['deal'] = 'index' 47 | if deal == 'change_member': 48 | context['deal'] = 'change_member' 49 | if deal == 'send_goods': 50 | context['deal'] = 'send_goods' 51 | cursor.execute("select * from order_form where send_date = '1900-01-01'") 52 | send_goods_data = cursor.fetchall() 53 | context['send_goods_data'] = send_goods_data 54 | if deal == 'update_order': 55 | context['deal'] = 'update_order' 56 | cursor.execute("select order_form.ono,order_form.submit_date,send_date,total_price,mno,order_information.bno, order_number,bname from order_form,order_information,books where order_form.ono=order_information.ono and order_information.bno=books.bno group by order_form.ono,order_form.submit_date,send_date,total_price,mno,order_number,order_information.bno,bname") 57 | order_informations = cursor.fetchall()#所有数据组成的元组 58 | # order_onos = [order_information[0] for order_information in order_informations]#订单号作为键值k 59 | # order_fronts = [order_information[:6] for order_information in order_informations]#前面的重复字段 60 | context['order_informations'] = dict()#创建一个空的字典来存储订单信息 61 | for i in order_informations: 62 | if context['order_informations'].get(i[0]):#如果订单号的k存在,进行继续添加具体信息即书的数量和种类 63 | context['order_informations'][i[0]]['number'] += 1 64 | context['order_informations'][i[0]]['books'].append(i[5:8]) 65 | 66 | else:#如果订单号不存在,添加该订单号的第一条数据进入字典 67 | context['order_informations'][i[0]] = { 68 | 'number': 2,#为什么把初始值改成2就渲染成功了 69 | 'order_front': i[:5], 70 | 'books': [i[5:8]], 71 | } 72 | if deal == 'update_goods': 73 | if request.GET.get('bno'):#如果得到查询字符串bno 74 | bno = request.GET.get('bno') 75 | cursor.execute("select * from books where bno='{}'".format(bno)) 76 | book_data = cursor.fetchall()[0] 77 | context['book_data'] = book_data 78 | if request.GET.get('books_data_position'): 79 | books_data_position = request.GET.get('books_data_position') 80 | try: 81 | mydf = pd.read_excel(books_data_position, encoding='utf-8') 82 | mydf_tuples = [tuple(xi) for xi in mydf.values]#df转元组 83 | for mydf_tuple in mydf_tuples: 84 | cursor.execute("insert into test_books(bno, bname, category, press, author, survey, price, discount, stock) values {}".format(mydf_tuple)) 85 | return HttpResponse("批量导入成功") 86 | except: 87 | return HttpResponse('输入的路径有误或者存在重复导入') 88 | if request.GET.get('delete_book_ID'): 89 | delete_book_ID = request.GET.get('delete_book_ID') 90 | cursor.execute("delete from books where bno={}".format(delete_book_ID)) 91 | return HttpResponse("删除成功") 92 | context['deal'] = 'update_goods' 93 | 94 | if request.method == 'POST':#post方法 95 | if deal == 'change_member': 96 | change_member(request) 97 | return HttpResponse('修改会员信息成功!') 98 | if deal == 'send_goods': 99 | send_goods(request) 100 | return HttpResponse('发货成功') 101 | if deal == 'update_order': 102 | update_order(request) 103 | return HttpResponse('删除订单信息成功') 104 | if deal == 'update_goods': 105 | update_goods(request) 106 | if request.POST.get('stock') < 0: 107 | return HttpResponse('书的数量不能小于0') 108 | return HttpResponse('更新图书信息成功') 109 | 110 | 111 | 112 | context['manager_user'] = 'root'#添加验证身份字段,以便渲染页面 113 | return render(request, 'manager.html', context=context) 114 | else: 115 | return HttpResponse("请输入管理员账号密码登录") 116 | 117 | def change_member(request): 118 | account = request.POST.get('account') 119 | password = request.POST.get('pwd1') 120 | name = request.POST.get('name') 121 | telephone = request.POST.get('telephone') 122 | email = request.POST.get('email') 123 | address = request.POST.get('address') 124 | try: 125 | cursor.execute("update member set mno='{}',mpassword='{}',mname='{}',mphone='{}',mpost='{}',madress='{}' where mno='{}'".format(account, password, name, telephone, email, address, account)) 126 | except: 127 | pass 128 | 129 | def send_goods(request):#管理员发货函数 130 | ono = request.POST.get('order_ID') 131 | cursor.execute("update order_form set send_date='{}' where ono='{}'".format(datetime.today(), ono)) 132 | 133 | def update_order(request): 134 | ono = request.POST.get('delete_order') 135 | cursor.execute("delete from order_form where ono='{}'".format(ono)) 136 | 137 | def update_goods(request): 138 | web_bno = request.POST.get('bno') 139 | web_bname = request.POST.get('bname') 140 | web_category = request.POST.get('category') 141 | web_press = request.POST.get('press') 142 | web_author = request.POST.get('author') 143 | web_survey = request.POST.get('survey') 144 | web_price = request.POST.get('price') 145 | web_discount = request.POST.get('discount') 146 | web_stock = request.POST.get('stock') 147 | bookdata = cursor.execute("select * from books where bno='{}'".format(web_bno)).fetchone() 148 | 149 | if web_bname == '':#如果获取不到就填补原来的值 150 | web_bname = bookdata[1] 151 | if web_category == '': 152 | web_category = bookdata[2] 153 | if web_press == '': 154 | web_press = bookdata[3] 155 | if web_author == '': 156 | web_author = bookdata[4] 157 | if web_survey == '': 158 | web_survey = bookdata[5] 159 | if web_price == '': 160 | web_price = bookdata[6] 161 | if web_discount == '': 162 | web_discount = bookdata[7] 163 | if web_stock == '': 164 | web_stock = bookdata[8] 165 | cursor.execute("update books set bname='{}',category='{}', press='{}', author='{}', survey='{}', price='{}', discount='{}', stock='{}' where bno='{}'".format(web_bname, web_category, web_press, web_author, web_survey, web_price, web_discount, web_stock, web_bno)) 166 | 167 | 168 | 169 | 170 | def logout_manager(request):#退出登录视图 171 | response = redirect(reverse('home')) 172 | response.delete_cookie('manager_account') 173 | return response -------------------------------------------------------------------------------- /online_bookstore/templates/manager.html: -------------------------------------------------------------------------------- 1 | {% extends 'base_for manage.html' %} 2 | 3 | {% block head %} 4 | 43 | {% endblock %} 44 | 45 | {% block body %} 46 | {% if deal == 'index' %} 47 |

    首页

    48 |

    点击上方按钮选择你要进行的操作

    49 |
    50 | 51 |
    52 | {% endif %} 53 | {% if deal == 'change_member' %} 54 |
    55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 |
    账户:
    昵称:
    联系电话:
    邮箱:
    地址:
    密码:
    85 |
    86 | {% endif %} 87 | 88 | 89 | {% if deal == 'send_goods' %} 90 |

    未发货商品如下:

    91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | {% for data in send_goods_data %} 104 | 105 | 106 | 107 | 108 | 109 | 110 | {% endfor %} 111 | 112 | 113 |
    订单ID下单时间订单总价(元)所属会员账号
    {{ data.0 }}{{ data.1 }}{{ data.3 }}{{ data.4 }}
    114 | {% endif %} 115 | 116 | 117 | {% if deal == 'update_order' %} 118 |

    选择你要修改的订单

    119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | {% for key, value in order_informations.items %} 135 | 136 | {% for i in value.order_front %} 137 | 138 | {% endfor %} 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | {% for book in value.books %} 148 | 149 | {% for book_data in book %} 150 | 151 | {% endfor %} 152 | 153 | 154 | {% endfor %} 155 | {% endfor %} 156 | 157 |
    订单ID下单时间发货时间总价买家ID图书ID所购图书数量订单包涵图书
    {{ i }}
    {{ book_data }}
    158 | 159 | {% endif %} 160 | 161 | {% if deal == 'update_goods' %} 162 |
    163 |
    164 |

    查找你要修改的图书名称

    165 |
    166 | 167 | 168 |
    169 |

    图书信息如下:

    170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | {% for data in book_data %} 187 | 188 | {% endfor %} 189 | 190 | 191 |
    书号书名类别出版社作者简介售价折扣库存
    {{ data }}
    192 |
    193 |
    194 | 195 |
    196 |
    197 |

    增删图书

    198 |

    批量导入图书信息,请输入图书信息文件路径

    199 |
    200 | 201 | 202 |
    203 |

    输入图书的ID删除图书

    204 |
    205 | 206 | 207 |
    208 |
    209 |
    210 | 211 | 212 |
    213 |
    214 |

    填写你要修改的字段并提交

    215 |
    216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 |
    图书ID:
    书名:
    分类:
    出版社:
    作者:
    简介:
    价格:
    打折:
    库存:
    258 |
    259 |
    260 |
    261 | {% endif %} 262 | 263 | 264 | 265 | 266 | 273 | {% endblock %} --------------------------------------------------------------------------------