from django.contrib import admin
from django.urls import path,include
# Two bags
from django.views.static import serve
from andun import settings
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('myapp.urls')),
path('upload/<path>',serve,{'document_root':settings.UPLOAD_FILE})
]
app Under the urls.py
from rest_framework.routers import DefaultRouter
from myapp import views
router = DefaultRouter()
router.register('',views.HelloWorldViewSet,basename='hello')
urlpatterns = router.urls
app Under the views.py
from email import header
from lib2to3.pgen2 import driver
from django.db.models import Q, query
from requests import head
from myapp import models
from rest_framework.viewsets import GenericViewSet
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework import pagination # Pagination
import datetime
import os
from andun import settings
import re
import requests
from selenium import webdriver
import time
# Create your views here.
# Initialize drive
driver=webdriver.Chrome()
driver.minimize_window()
class HelloWorldViewSet(GenericViewSet):
@action(detail=False,methods=['GET'])
def get_code(self,request):
return Response({'code':'200'})
@action(detail=False,methods=['POST'])
def login(self,request):
''' Operate the login page '''
code=request.data.get('code')
return Response({'code':'200'})
app Under the models.py
from django.db import models
from django.db.models.deletion import CASCADE
from django.db.models.fields import Field
# Create your models here.
class User(models.Model):
''' User table '''
name=models.CharField(verbose_name=' User name ',max_length=50,primary_key=True,db_index=True)
tag=models.CharField(verbose_name=' label ',max_length=50,db_index=True,default='')
create_time=models.CharField(verbose_name=' Create timestamps ',max_length=50,default=0)
class Meta:
managed=True
verbose_name_plural=' User table '
def __str__(self):
return self.name
class Group(models.Model):
''' Group chat table '''
send=models.ForeignKey(User,on_delete=CASCADE)
recive=models.CharField(verbose_name=' The receiving party ',max_length=50)
group_id=models.IntegerField(verbose_name=' Group chat number ')
msgtime=models.IntegerField(verbose_name=' Send time ')
msgtype=models.CharField(verbose_name=' Message type ',max_length=50)
msg=models.CharField(verbose_name=' The message content ',max_length=2550)
class Meta:
managed=True
verbose_name_plural=' Group chat table '
def __str__(self):
return self.send.name
class Alone(models.Model):
''' Talk alone '''
send=models.ForeignKey(User,on_delete=CASCADE)
recive=models.CharField(verbose_name=' The receiving party ',max_length=50)
msgtime=models.IntegerField(verbose_name=' Send time ')
msgtype=models.CharField(verbose_name=' Message type ',max_length=50)
msg=models.CharField(verbose_name=' The message content ',max_length=2550)
class Meta:
managed=True
verbose_name_plural=' Talk alone '
def __str__(self):
return self.send.name
class File(models.Model):
''' Document list '''
user=models.ForeignKey(User,on_delete=CASCADE)
file_path=models.CharField(verbose_name=' File path ',max_length=500)
file_classify=models.CharField(verbose_name=' file type ',max_length=50)
class Meta:
managed=True
verbose_name_plural=' Document list '
def __str__(self):
return self.user.name
class Identity(models.Model):
''' Identity table '''
identity=models.CharField(verbose_name=' identity ',max_length=30,primary_key=True,db_index=True)
class Meta:
managed=True
verbose_name_plural=' Identity table '
def __str__(self):
return self.identity
class Account(models.Model):
''' Account table '''
account=models.CharField(verbose_name=' account number ',max_length=20,primary_key=True,db_index=True)
password=models.CharField(verbose_name=' password ',max_length=20)
identity_id=models.ForeignKey(Identity,on_delete=CASCADE)
class Meta:
managed=True
verbose_name_plural=' Account table '
def __str__(self):
return self.account
class File_Privilege(models.Model):
''' Document authority table '''
file_path=models.CharField(verbose_name=' File path ',max_length=500,primary_key=True)
user=models.ForeignKey(User,on_delete=CASCADE)
file_classify=models.CharField(verbose_name=' file type ',max_length=50)
name=models.CharField(verbose_name=' file name ',max_length=500)
file_grade=models.IntegerField(verbose_name=' Document level ',default=1)
last_file=models.CharField(verbose_name=' Upper level file directory ',max_length=500,default='')
is_folder=models.BooleanField(verbose_name=' Is it a folder ',default=False)
class Meta:
managed=True
verbose_name_plural=' Document authority table '
def __str__(self):
return self.file_path
class Account_File_Privilege(models.Model):
''' Account file permission table '''
file_path=models.ForeignKey(File_Privilege,on_delete=CASCADE)
account=models.ForeignKey(Account,on_delete=CASCADE)
add=models.BooleanField(verbose_name=' Whether you can add files ',default=False)
rm=models.BooleanField(verbose_name=' Whether the file can be deleted ',default=False)
edit=models.BooleanField(verbose_name=' Whether the file can be edited ',default=False)
class Meta:
managed=True
verbose_name_plural=' Account file permission table '
def __str__(self):
return self.file_path.file_path+'——>'+self.account.account
class Account_Navigation_Privilege(models.Model):
''' Account navigation bar permission table '''
name=models.CharField(verbose_name=' Navigation name ',max_length=500)
account=models.ForeignKey(Account,on_delete=CASCADE)
class Meta:
managed=True
verbose_name_plural=' Account navigation bar permission table '
def __str__(self):
return self.name+'——>'+self.account.account
class Identity_File_Privilege(models.Model):
''' Identity file permission table '''
file_path=models.ForeignKey(File_Privilege,on_delete=CASCADE)
identity_id=models.ForeignKey(Identity,on_delete=CASCADE)
add=models.BooleanField(verbose_name=' Whether you can add files ',default=False)
rm=models.BooleanField(verbose_name=' Whether the file can be deleted ',default=False)
edit=models.BooleanField(verbose_name=' Whether the file can be edited ',default=False)
class Meta:
managed=True
verbose_name_plural=' Identity file permission table '
def __str__(self):
return self.file_path.file_path+'——>'+self.identity_id.identity
class Identity_Navigation_Privilege(models.Model):
''' Identity navigation bar permission table '''
name=models.CharField(verbose_name=' Navigation name ',max_length=500)
identity_id=models.ForeignKey(Identity,on_delete=CASCADE)
class Meta:
managed=True
verbose_name_plural=' Identity navigation bar permission table '
def __str__(self):
return self.name+'——>'+self.identity_id.identity
class Food_File(models.Model):
''' File upload food path table '''
file_path=models.CharField(verbose_name=' Server path ',max_length=500)
file_truth=models.CharField(verbose_name=' The local path ',max_length=500,default='')
handle_res=models.BooleanField(verbose_name=' Whether to pass ',default=False)
is_handle=models.BooleanField(verbose_name=' Whether to deal with ',default=False)
class Meta:
managed=True
verbose_name_plural=' File upload food path table '
def __str__(self):
return self.file_path
app Under the admin.py
from django.contrib import admin
from myapp import models
# Register your models here.
### User table
admin.site.register(models.Account)
### Group chat table
admin.site.register(models.Group)
### Talk alone
admin.site.register(models.Alone)
### Document list
admin.site.register(models.File)
### Account file permission table
admin.site.register(models.Account_File_Privilege)
### Account navigation bar permission table
admin.site.register(models.Account_Navigation_Privilege)
### Identity file permission table
admin.site.register(models.Identity_File_Privilege)
### Identity navigation bar permission table
admin.site.register(models.Identity_Navigation_Privilege)
### Account table
admin.site.register(models.User)
### Identity table
admin.site.register(models.Identity)
### Document authority table
admin.site.register(models.File_Privilege)
### Food paperwork
admin.site.register(models.Food_File)