wendaojidian před 3 roky
rodič
revize
87c9e6c234
100 změnil soubory, kde provedl 614 přidání a 85 odebrání
  1. binární
      .DS_Store
  2. 0 7
      Config/database_mysql.cnf
  3. 0 19
      Pipfile
  4. 0 20
      Pipfile.lock.old
  5. 0 9
      README.md
  6. binární
      TestLaboratory/.DS_Store
  7. 8 0
      TestLaboratory/.idea/.gitignore
  8. 34 0
      TestLaboratory/.idea/TestLaboratory.iml
  9. 34 0
      TestLaboratory/.idea/inspectionProfiles/Project_Default.xml
  10. 6 0
      TestLaboratory/.idea/inspectionProfiles/profiles_settings.xml
  11. 4 0
      TestLaboratory/.idea/misc.xml
  12. 8 0
      TestLaboratory/.idea/modules.xml
  13. 0 0
      TestLaboratory/Config/__init__.py
  14. 7 0
      TestLaboratory/Config/database_mysql.cnf
  15. 13 0
      TestLaboratory/Dockerfile
  16. 35 0
      TestLaboratory/README.md
  17. 0 0
      TestLaboratory/TestLaboratory/__init__.py
  18. binární
      TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-38.pyc
  19. binární
      TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-39.pyc
  20. binární
      TestLaboratory/TestLaboratory/__pycache__/settings.cpython-38.pyc
  21. binární
      TestLaboratory/TestLaboratory/__pycache__/settings.cpython-39.pyc
  22. binární
      TestLaboratory/TestLaboratory/__pycache__/urls.cpython-38.pyc
  23. binární
      TestLaboratory/TestLaboratory/__pycache__/urls.cpython-39.pyc
  24. binární
      TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-38.pyc
  25. binární
      TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-39.pyc
  26. 2 2
      TestLaboratory/TestLaboratory/asgi.py
  27. 71 16
      TestLaboratory/TestLaboratory/settings.py
  28. 11 7
      TestLaboratory/TestLaboratory/urls.py
  29. 2 2
      TestLaboratory/TestLaboratory/wsgi.py
  30. binární
      TestLaboratory/__pycache__/util_doc.cpython-38.pyc
  31. binární
      TestLaboratory/__pycache__/util_doc.cpython-39.pyc
  32. binární
      TestLaboratory/__pycache__/util_xlsx.cpython-38.pyc
  33. binární
      TestLaboratory/__pycache__/util_xlsx.cpython-39.pyc
  34. 0 0
      TestLaboratory/apps/__init__.py
  35. binární
      TestLaboratory/apps/__pycache__/__init__.cpython-38.pyc
  36. binární
      TestLaboratory/apps/__pycache__/__init__.cpython-39.pyc
  37. 0 0
      TestLaboratory/apps/file/__init__.py
  38. binární
      TestLaboratory/apps/file/__pycache__/__init__.cpython-38.pyc
  39. binární
      TestLaboratory/apps/file/__pycache__/__init__.cpython-39.pyc
  40. binární
      TestLaboratory/apps/file/__pycache__/admin.cpython-38.pyc
  41. binární
      TestLaboratory/apps/file/__pycache__/admin.cpython-39.pyc
  42. binární
      TestLaboratory/apps/file/__pycache__/apps.cpython-38.pyc
  43. binární
      TestLaboratory/apps/file/__pycache__/apps.cpython-39.pyc
  44. binární
      TestLaboratory/apps/file/__pycache__/models.cpython-38.pyc
  45. binární
      TestLaboratory/apps/file/__pycache__/models.cpython-39.pyc
  46. binární
      TestLaboratory/apps/file/__pycache__/urls.cpython-38.pyc
  47. binární
      TestLaboratory/apps/file/__pycache__/urls.cpython-39.pyc
  48. 0 0
      TestLaboratory/apps/file/admin.py
  49. 2 2
      TestLaboratory/apps/file/apps.py
  50. 30 0
      TestLaboratory/apps/file/migrations/0001_initial.py
  51. 0 0
      TestLaboratory/apps/file/migrations/__init__.py
  52. binární
      TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-38.pyc
  53. binární
      TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-39.pyc
  54. binární
      TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-38.pyc
  55. binární
      TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-39.pyc
  56. 24 0
      TestLaboratory/apps/file/models.py
  57. 0 0
      TestLaboratory/apps/file/tests.py
  58. 7 0
      TestLaboratory/apps/file/urls.py
  59. 0 0
      TestLaboratory/apps/file/views/__init__.py
  60. binární
      TestLaboratory/apps/file/views/__pycache__/__init__.cpython-38.pyc
  61. binární
      TestLaboratory/apps/file/views/__pycache__/__init__.cpython-39.pyc
  62. binární
      TestLaboratory/apps/file/views/__pycache__/fileview.cpython-38.pyc
  63. binární
      TestLaboratory/apps/file/views/__pycache__/fileview.cpython-39.pyc
  64. 117 0
      TestLaboratory/apps/file/views/fileview.py
  65. 0 0
      TestLaboratory/apps/log/__init__.py
  66. binární
      TestLaboratory/apps/log/__pycache__/__init__.cpython-38.pyc
  67. binární
      TestLaboratory/apps/log/__pycache__/__init__.cpython-39.pyc
  68. binární
      TestLaboratory/apps/log/__pycache__/admin.cpython-38.pyc
  69. binární
      TestLaboratory/apps/log/__pycache__/admin.cpython-39.pyc
  70. binární
      TestLaboratory/apps/log/__pycache__/apps.cpython-38.pyc
  71. binární
      TestLaboratory/apps/log/__pycache__/apps.cpython-39.pyc
  72. binární
      TestLaboratory/apps/log/__pycache__/models.cpython-38.pyc
  73. binární
      TestLaboratory/apps/log/__pycache__/models.cpython-39.pyc
  74. binární
      TestLaboratory/apps/log/__pycache__/urls.cpython-38.pyc
  75. binární
      TestLaboratory/apps/log/__pycache__/urls.cpython-39.pyc
  76. 0 0
      TestLaboratory/apps/log/admin.py
  77. 1 1
      TestLaboratory/apps/log/apps.py
  78. 0 0
      TestLaboratory/apps/log/middleware/__init__.py
  79. 33 0
      TestLaboratory/apps/log/middleware/loginfo.py
  80. 35 0
      TestLaboratory/apps/log/migrations/0001_initial.py
  81. 0 0
      TestLaboratory/apps/log/migrations/__init__.py
  82. binární
      TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-38.pyc
  83. binární
      TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-39.pyc
  84. binární
      TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-38.pyc
  85. binární
      TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-39.pyc
  86. 77 0
      TestLaboratory/apps/log/models.py
  87. 0 0
      TestLaboratory/apps/log/tests.py
  88. 6 0
      TestLaboratory/apps/log/urls.py
  89. 0 0
      TestLaboratory/apps/log/views/__init__.py
  90. binární
      TestLaboratory/apps/log/views/__pycache__/__init__.cpython-38.pyc
  91. binární
      TestLaboratory/apps/log/views/__pycache__/__init__.cpython-39.pyc
  92. binární
      TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-38.pyc
  93. binární
      TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-39.pyc
  94. 47 0
      TestLaboratory/apps/log/views/loglistview.py
  95. 0 0
      TestLaboratory/apps/plan/__init__.py
  96. binární
      TestLaboratory/apps/plan/__pycache__/__init__.cpython-38.pyc
  97. binární
      TestLaboratory/apps/plan/__pycache__/__init__.cpython-39.pyc
  98. binární
      TestLaboratory/apps/plan/__pycache__/admin.cpython-38.pyc
  99. binární
      TestLaboratory/apps/plan/__pycache__/admin.cpython-39.pyc
  100. binární
      TestLaboratory/apps/plan/__pycache__/apps.cpython-38.pyc

binární
.DS_Store


+ 0 - 7
Config/database_mysql.cnf

@@ -1,7 +0,0 @@
-[client]
-host = 127.0.0.1
-port = 3306
-database = Test_laboratory
-user = root
-password = liufan3344
-default-character-set = utf8

+ 0 - 19
Pipfile

@@ -1,19 +0,0 @@
-[[source]]
-url = "https://pypi.org/simple"
-verify_ssl = true
-name = "pypi"
-
-[packages]
-django = "*"
-pymysql = "*"
-django-simpleui = "*"
-djangorestframework-jwt = "*"
-requests = "*"
-pyjwt = "*"
-jwt = "*"
-djangorestframework = "*"
-
-[dev-packages]
-
-[requires]
-python_version = "3.9"

+ 0 - 20
Pipfile.lock.old

@@ -1,20 +0,0 @@
-{
-    "_meta": {
-        "hash": {
-            "sha256": "a36a5392bb1e8bbc06bfaa0761e52593cf2d83b486696bf54667ba8da616c839"
-        },
-        "pipfile-spec": 6,
-        "requires": {
-            "python_version": "3.9"
-        },
-        "sources": [
-            {
-                "name": "pypi",
-                "url": "https://pypi.org/simple",
-                "verify_ssl": true
-            }
-        ]
-    },
-    "default": {},
-    "develop": {}
-}

+ 0 - 9
README.md

@@ -1,9 +0,0 @@
-# Readme
-## 1. 安装第三方依赖
-```pipenv install -r requirements.txt```
-## 2.在Config/database_mysql.cnf文件中修改数据库配置
-## 3.数据库迁移
-```python manage.py makemigrations```
-```python manage.py migrate```
-## 4.运行服务端
-```python manage.py runserver```

binární
api_test/.DS_Store → TestLaboratory/.DS_Store


+ 8 - 0
TestLaboratory/.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 34 - 0
TestLaboratory/.idea/TestLaboratory.iml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="django" name="Django">
+      <configuration>
+        <option name="rootFolder" value="$MODULE_DIR$" />
+        <option name="settingsModule" value="TestLaboratory/settings.py" />
+        <option name="manageScript" value="$MODULE_DIR$/manage.py" />
+        <option name="environment" value="&lt;map/&gt;" />
+        <option name="doNotUseTestRunner" value="false" />
+        <option name="trackFilePattern" value="migrations" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
+    </content>
+    <orderEntry type="jdk" jdkName="Python 3.8 (TestLaboratory-PPS75GMw)" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="PackageRequirementsSettings">
+    <option name="versionSpecifier" value="Strong equality (==x.y.z)" />
+    <option name="removeUnused" value="true" />
+    <option name="modifyBaseFiles" value="true" />
+  </component>
+  <component name="PyDocumentationSettings">
+    <option name="format" value="PLAIN" />
+    <option name="myDocStringFormat" value="Plain" />
+  </component>
+  <component name="TemplatesService">
+    <option name="TEMPLATE_CONFIGURATION" value="Django" />
+  </component>
+</module>

+ 34 - 0
TestLaboratory/.idea/inspectionProfiles/Project_Default.xml

@@ -0,0 +1,34 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
+    <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="ignoredPackages">
+        <value>
+          <list size="3">
+            <item index="0" class="java.lang.String" itemvalue="pymysql" />
+            <item index="1" class="java.lang.String" itemvalue="pyjwt" />
+            <item index="2" class="java.lang.String" itemvalue="django-cors-headers" />
+          </list>
+        </value>
+      </option>
+    </inspection_tool>
+    <inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
+      <option name="ignoredErrors">
+        <list>
+          <option value="E722" />
+        </list>
+      </option>
+    </inspection_tool>
+    <inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
+      <option name="ignoredErrors">
+        <list>
+          <option value="N802" />
+          <option value="N806" />
+          <option value="N801" />
+        </list>
+      </option>
+    </inspection_tool>
+    <inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
+  </profile>
+</component>

+ 6 - 0
TestLaboratory/.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 4 - 0
TestLaboratory/.idea/misc.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (TestLaboratory-PPS75GMw)" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
TestLaboratory/.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/TestLaboratory.iml" filepath="$PROJECT_DIR$/.idea/TestLaboratory.iml" />
+    </modules>
+  </component>
+</project>

+ 0 - 0
utils/__init__.py → TestLaboratory/Config/__init__.py


+ 7 - 0
TestLaboratory/Config/database_mysql.cnf

@@ -0,0 +1,7 @@
+[client]
+host = db
+port = 3306
+database = TestLaboratory
+user = root
+password = liufan3344
+default-character-set = utf8

+ 13 - 0
TestLaboratory/Dockerfile

@@ -0,0 +1,13 @@
+From python:3.9
+
+MAINTAINER Liufan<1649750212@qq.com>
+ENV PYTHONUNBUFFERED 1
+
+COPY . /code
+WORKDIR /code
+
+RUN pip install -r requirements.txt -i https://pypi.douban.com/simple
+
+EXPOSE 8003
+
+ENTRYPOINT ["/bin/sh","startup.sh"]

+ 35 - 0
TestLaboratory/README.md

@@ -0,0 +1,35 @@
+# lims测试实验室管理平台
+
+## 系统地址
+
+http://127.0.0.1:8002 **(本地)**
+
+http://172.26.0.13:8002 **(局域网)**
+
+## 用户操作手册
+
+- 详见 **附件1**
+
+## 源代码地址
+
+- /home/dell/lims/TestLaboratory
+
+## 系统部署安装
+
+### step1:安装mysql镜像
+
+```shell
+docker load < lims-mysql.tar 
+```
+
+### step2: 部署前后端镜像
+
+```shell
+docker-compose up -d
+```
+
+## 系统运行环境
+
+- linux系统
+- 浏览器建议使用最新的chrome(老版本浏览器可能出现文件无法下载的问题)
+

+ 0 - 0
Test_laboratory/__init__.py → TestLaboratory/TestLaboratory/__init__.py


binární
TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-39.pyc


binární
TestLaboratory/TestLaboratory/__pycache__/settings.cpython-38.pyc


binární
TestLaboratory/TestLaboratory/__pycache__/settings.cpython-39.pyc


binární
TestLaboratory/TestLaboratory/__pycache__/urls.cpython-38.pyc


binární
TestLaboratory/TestLaboratory/__pycache__/urls.cpython-39.pyc


binární
TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-38.pyc


binární
TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-39.pyc


+ 2 - 2
Test_laboratory/asgi.py → TestLaboratory/TestLaboratory/asgi.py

@@ -1,5 +1,5 @@
 """
-ASGI config for Test_laboratory project.
+ASGI config for TestLaboratory project.
 
 It exposes the ASGI callable as a module-level variable named ``application``.
 
@@ -11,6 +11,6 @@ import os
 
 from django.core.asgi import get_asgi_application
 
-os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Test_laboratory.settings')
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestLaboratory.settings')
 
 application = get_asgi_application()

+ 71 - 16
Test_laboratory/settings.py → TestLaboratory/TestLaboratory/settings.py

@@ -1,5 +1,5 @@
 """
-Django settings for Test_laboratory project.
+Django settings for TestLaboratory project.
 
 Generated by 'django-admin startproject' using Django 3.2.
 
@@ -9,20 +9,28 @@ https://docs.djangoproject.com/en/3.2/topics/settings/
 For the full list of settings and their values, see
 https://docs.djangoproject.com/en/3.2/ref/settings/
 """
-
+import datetime
 from pathlib import Path
 import sys
 import os
 
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
-import apps.user.middleware.authentication
+# import apps.user.middleware.authentication
 
 BASE_DIR = Path(__file__).resolve().parent.parent
 sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
 
-MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
+MEDIA_ROOT = os.path.join(BASE_DIR, 'static')
 MEDIA_URL = '/media/'
 
+SOFTWARE_ROOT = "static/software/"
+PLAN_ROOT = "static/plan-statement/"
+TASK_ROOT = 'static/task-statement/'
+CASE_TEMPLATE_ROOT = 'static/case-template/测试用例模版.xlsx'
+CASE_FILE_ROOT = 'static/case-file/'
+CASE_FILE_EXPORT = 'static/case-file-export/'
+HTTP_HEAD = 'http://127.0.0.1:8003/'
+
 
 # Quick-start development settings - unsuitable for production
 # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
@@ -33,9 +41,11 @@ SECRET_KEY = 'django-insecure-zo64fvv02msf-se7!dek5*w$17#3nh6zta#!i=79bt9d#f88@i
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = True
 
-ALLOWED_HOSTS = []
-
-
+ALLOWED_HOSTS = ['*']
+# AUTH_USER_MODEL = "user.User"
+# AUTHENTICATION_BACKENDS = (
+#     'user.middleware.authentication.CustomBackend',
+# )
 # Application definition
 
 INSTALLED_APPS = [
@@ -47,10 +57,13 @@ INSTALLED_APPS = [
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'rest_framework',
+    'corsheaders',
     'user',
     'software',
-    'test_plan',
-    'apps.test_task'
+    'plan',
+    'apps.task',
+    'file',
+    'log'
 ]
 
 MIDDLEWARE = [
@@ -61,9 +74,11 @@ MIDDLEWARE = [
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    'corsheaders.middleware.CorsMiddleware',
+    'django.middleware.common.CommonMiddleware',
 ]
 
-ROOT_URLCONF = 'Test_laboratory.urls'
+ROOT_URLCONF = 'TestLaboratory.urls'
 
 TEMPLATES = [
     {
@@ -81,8 +96,7 @@ TEMPLATES = [
     },
 ]
 
-WSGI_APPLICATION = 'Test_laboratory.wsgi.application'
-
+WSGI_APPLICATION = 'TestLaboratory.wsgi.application'
 
 # Database
 # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
@@ -96,7 +110,6 @@ DATABASES = {
     }
 }
 
-
 # Password validation
 # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
 
@@ -115,25 +128,42 @@ AUTH_PASSWORD_VALIDATORS = [
     },
 ]
 
+REST_FRAMEWORK = {
+    'DEFAULT_PERMISSION_CLASSES': (
+        'rest_framework.permissions.IsAuthenticated'
+    ),
+    'DEFAULT_AUTHENTICATION_CLASSES': (
+        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
+        'rest_framework.authentication.BasicAuthentication',
+        'rest_framework.authentication.SessionAuthentication'
+    )
+}
+
+JWT_AUTH = {
+    # 设置token有效时间
+    'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=60 * 60 * 2)
+}
 
 # Internationalization
 # https://docs.djangoproject.com/en/3.2/topics/i18n/
 
 LANGUAGE_CODE = 'en-us'
 
-TIME_ZONE = 'UTC'
+TIME_ZONE = 'Asia/Shanghai'
 
 USE_I18N = True
 
 USE_L10N = True
 
-USE_TZ = True
-
+USE_TZ = False
 
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/3.2/howto/static-files/
 
 STATIC_URL = '/static/'
+STATICFILES_DIRS = [
+    os.path.join(BASE_DIR, "static"),
+]
 
 # Default primary key field type
 # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
@@ -143,3 +173,28 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
 REST_FRAMEWORK = {
     "DEFAULT_AUTHENTICATION_CLASSES": ["apps.user.middleware.authentication.JwtAutentication"]
 }
+
+CORS_ALLOW_CREDENTIALS = True
+CORS_ORIGIN_ALLOW_ALL = True
+
+CORS_ALLOW_METHODS = (
+    'GET',
+    'POST',
+    'PUT',
+    'PATCH',
+    'DELETE',
+    'OPTIONS'
+)
+
+CORS_ALLOW_HEADERS = (
+    'x-requested-with',
+    'content-type',
+    'accept',
+    'origin',
+    'authorization',
+    'x-csrftoken'
+)
+
+"""
+python manage.py runserver 172.16.100.180:8000   
+"""

+ 11 - 7
Test_laboratory/urls.py → TestLaboratory/TestLaboratory/urls.py

@@ -1,4 +1,4 @@
-"""Test_laboratory URL Configuration
+"""TestLaboratory URL Configuration
 
 The `urlpatterns` list routes URLs to views. For more information please see:
     https://docs.djangoproject.com/en/3.2/topics/http/urls/
@@ -13,12 +13,16 @@ Including another URLconf
     1. Import the include() function: from django.urls import include, path
     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
 """
+from django.conf.urls.static import static
 from django.urls import path, include
 
+from TestLaboratory import settings
+
 urlpatterns = [
-    path('v1/users/', include('user.urls')),
-    path('v1/software/', include('software.urls')),
-    path('v1/test-plans/', include('test_plan.urls')),
-    path('v1/test-tasks/', include('test_task.urls')),
-    path('v1/log-info/', include('log_info.urls')),
-]
+    path('api/v1/users/', include('user.urls')),
+    path('api/v1/software/', include('software.urls')),
+    path('api/v1/test-plans/', include('plan.urls')),
+    path('api/v1/test-tasks/', include('task.urls')),
+    path('api/v1/log-info/', include('log.urls')),
+    path('api/v1/files/', include('file.urls'))
+] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS)

+ 2 - 2
Test_laboratory/wsgi.py → TestLaboratory/TestLaboratory/wsgi.py

@@ -1,5 +1,5 @@
 """
-WSGI config for Test_laboratory project.
+WSGI config for TestLaboratory project.
 
 It exposes the WSGI callable as a module-level variable named ``application``.
 
@@ -11,6 +11,6 @@ import os
 
 from django.core.wsgi import get_wsgi_application
 
-os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Test_laboratory.settings')
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestLaboratory.settings')
 
 application = get_wsgi_application()

binární
TestLaboratory/__pycache__/util_doc.cpython-38.pyc


binární
TestLaboratory/__pycache__/util_doc.cpython-39.pyc


binární
TestLaboratory/__pycache__/util_xlsx.cpython-38.pyc


binární
TestLaboratory/__pycache__/util_xlsx.cpython-39.pyc


+ 0 - 0
apps/user/views/__init__.py → TestLaboratory/apps/__init__.py


binární
TestLaboratory/apps/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/__pycache__/__init__.cpython-39.pyc


+ 0 - 0
apps/user/migrations/__init__.py → TestLaboratory/apps/file/__init__.py


binární
TestLaboratory/apps/file/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/file/__pycache__/__init__.cpython-39.pyc


binární
TestLaboratory/apps/file/__pycache__/admin.cpython-38.pyc


binární
TestLaboratory/apps/file/__pycache__/admin.cpython-39.pyc


binární
TestLaboratory/apps/file/__pycache__/apps.cpython-38.pyc


binární
TestLaboratory/apps/file/__pycache__/apps.cpython-39.pyc


binární
TestLaboratory/apps/file/__pycache__/models.cpython-38.pyc


binární
TestLaboratory/apps/file/__pycache__/models.cpython-39.pyc


binární
TestLaboratory/apps/file/__pycache__/urls.cpython-38.pyc


binární
TestLaboratory/apps/file/__pycache__/urls.cpython-39.pyc


+ 0 - 0
apps/user/admin.py → TestLaboratory/apps/file/admin.py


+ 2 - 2
apps/service/apps.py → TestLaboratory/apps/file/apps.py

@@ -1,6 +1,6 @@
 from django.apps import AppConfig
 
 
-class ServiceConfig(AppConfig):
+class FileConfig(AppConfig):
     default_auto_field = 'django.db.models.BigAutoField'
-    name = 'apps.service'
+    name = 'apps.file'

+ 30 - 0
TestLaboratory/apps/file/migrations/0001_initial.py

@@ -0,0 +1,30 @@
+# Generated by Django 3.2 on 2021-07-17 20:05
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='FileManager',
+            fields=[
+                ('id', models.CharField(default='TestLaboratory_V1_File_1', max_length=30, primary_key=True, serialize=False, unique=True, verbose_name='文件id')),
+                ('path', models.FilePathField(max_length=200, verbose_name='文件路径')),
+                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
+                ('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
+                ('delete', models.BooleanField(default=False)),
+                ('category', models.CharField(max_length=20, verbose_name='文件类型')),
+            ],
+            options={
+                'verbose_name': '文件管理',
+                'verbose_name_plural': '文件管理',
+                'db_table': 'file_manager',
+            },
+        ),
+    ]

+ 0 - 0
apps/user/middleware/__init__.py → TestLaboratory/apps/file/migrations/__init__.py


binární
TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-38.pyc


binární
TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-39.pyc


binární
TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-39.pyc


+ 24 - 0
TestLaboratory/apps/file/models.py

@@ -0,0 +1,24 @@
+from django.db import models
+
+
+# Create your models here.
+class FileManager(models.Model):
+    id = models.CharField(max_length=30, unique=True, verbose_name='文件id', primary_key=True,
+                          default='TestLaboratory_V1_File_1')
+    path = models.FilePathField(max_length=200, verbose_name='文件路径')
+    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
+    update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
+    delete = models.BooleanField(default=False)
+    # category: software, report, plan_statement, task_statement, case_file
+    category = models.CharField(max_length=20, verbose_name='文件类型')
+
+    def __str__(self):
+        return self.path
+
+    class Meta:
+        verbose_name = '文件管理'
+        verbose_name_plural = verbose_name
+        db_table = 'file_manager'
+
+
+

+ 0 - 0
apps/user/tests.py → TestLaboratory/apps/file/tests.py


+ 7 - 0
TestLaboratory/apps/file/urls.py

@@ -0,0 +1,7 @@
+from django.urls import path
+
+from .views.fileview import FileView
+
+urlpatterns = [
+    path('', FileView.as_view()),
+]

+ 0 - 0
apps/user/__init__.py → TestLaboratory/apps/file/views/__init__.py


binární
TestLaboratory/apps/file/views/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/file/views/__pycache__/__init__.cpython-39.pyc


binární
TestLaboratory/apps/file/views/__pycache__/fileview.cpython-38.pyc


binární
TestLaboratory/apps/file/views/__pycache__/fileview.cpython-39.pyc


+ 117 - 0
TestLaboratory/apps/file/views/fileview.py

@@ -0,0 +1,117 @@
+import datetime
+import os
+
+from django.http import HttpResponse
+from rest_framework.views import APIView
+
+from TestLaboratory.settings import PLAN_ROOT, TASK_ROOT
+from apps.file.models import FileManager
+from apps.log.models import get_log, gen_log
+from apps.plan.models import TestPlan
+from apps.task.models import TestTask
+from apps.user.middleware.rolecontrol import RoleControl
+from utils.util_add_id import gen_next_id
+
+
+class FileView(APIView):
+    # create file
+    @staticmethod
+    @RoleControl
+    def post(request, *args, **kwargs):
+        file_type = request.POST.get('type')
+        plan_id = request.POST.get('plan_id')
+        task_id = request.POST.get('task_id')
+        files = request.FILES.getlist('files')
+
+        model_object = None
+        path_head = None
+        if file_type == 'plan_statement':
+            model_object = TestPlan.objects.filter(id=plan_id, delete=False)
+            if not model_object:
+                return HttpResponse(status=404, content='测试计划已删除或不存在')
+            model_object = model_object[0]
+            path_head = PLAN_ROOT
+
+        elif file_type == 'task_statement':
+            model_object = TestTask.objects.filter(id=task_id, delete=False)
+            if not model_object:
+                return HttpResponse(status=404, content='测试任务已删除或不存在')
+            model_object = model_object[0]
+            path_head = TASK_ROOT
+
+        # step7:创建文件的数据库字段
+        fids = ''
+        file_paths = []
+        for file in files:
+            try:
+                create_time = update_time = datetime.datetime.now()
+                file_dir = path_head + "/" + model_object.id + "/" + str(create_time)
+                if not os.path.exists(file_dir):
+                    os.makedirs(file_dir)
+                file_path = file_dir + "/" + file.name
+                with open(file_path, 'wb') as f:
+                    f.write(file.read())
+                f.close()
+            except:
+                return HttpResponse(status=500, content="文件上传失败")
+
+            if not FileManager.objects.last():
+                id_file = "TestLaboratory_V1_File_1"
+            else:
+                id_file = gen_next_id(FileManager.objects.order_by('create_time').last().id)
+
+            try:
+                file_new = FileManager.objects.create(id=id_file, category=file_type,
+                                                      path=model_object.id+ "/" + str(create_time) + "/" + file.name,
+                                                      create_time=create_time,
+                                                      update_time=update_time)
+            except:
+                return HttpResponse(status=500, content="文件路径写入数据库失败")
+            file_paths.append(PLAN_ROOT + file_new.path)
+            fids += id_file + "&&"
+        fids = fids[:-2]
+        model_object.statement_file += ("&&" + fids)
+        model_object.save()
+        executor, action, method = get_log(request)
+        gen_log(action, "说明文档", model_object.title, method, executor)
+        return HttpResponse(status=200, content='新建文件成功')
+
+    # create file
+    @staticmethod
+    @RoleControl
+    def delete(request, *args, **kwargs):
+        file_id = request.GET.get('file_id')
+        file_type = request.GET.get('type')
+        plan_id = request.GET.get('plan_id')
+        task_id = request.GET.get('task_id')
+
+        model_object = None
+        if file_type == 'plan_statement':
+            model_object = TestPlan.objects.filter(id=plan_id, delete=False)
+            if not model_object:
+                return HttpResponse(status=404, content='测试计划已删除或不存在')
+            model_object = model_object[0]
+
+        elif file_type == 'task_statement':
+            model_object = TestTask.objects.filter(id=task_id, delete=False)
+            if not model_object:
+                return HttpResponse(status=404, content='测试任务已删除或不存在')
+            model_object = model_object[0]
+
+        file = FileManager.objects.filter(id=file_id, delete=False)
+        if not file:
+            return HttpResponse(status=404, content='文件已删除不存在')
+        file = file[0]
+        file_list = model_object.statement_file.split('&&')
+        if file.id not in file_list:
+            return HttpResponse(status=404, content='该文件不存在于测试计划或测试任务中,数据库错误')
+        file_list.remove(file.id)
+        file_str = ''
+        for file_name in file_list:
+            file_str += file_name + "&&"
+        file_str = file_str[:-2]
+        model_object.statement_file = file_str
+        model_object.save()
+        executor, action, method = get_log(request)
+        gen_log(action, "说明文档", file.path.split('/')[-1], method, executor)
+        return HttpResponse(status=200, content='删除成功')

+ 0 - 0
apps/test_task/views/__init__.py → TestLaboratory/apps/log/__init__.py


binární
TestLaboratory/apps/log/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/log/__pycache__/__init__.cpython-39.pyc


binární
TestLaboratory/apps/log/__pycache__/admin.cpython-38.pyc


binární
TestLaboratory/apps/log/__pycache__/admin.cpython-39.pyc


binární
TestLaboratory/apps/log/__pycache__/apps.cpython-38.pyc


binární
TestLaboratory/apps/log/__pycache__/apps.cpython-39.pyc


binární
TestLaboratory/apps/log/__pycache__/models.cpython-38.pyc


binární
TestLaboratory/apps/log/__pycache__/models.cpython-39.pyc


binární
TestLaboratory/apps/log/__pycache__/urls.cpython-38.pyc


binární
TestLaboratory/apps/log/__pycache__/urls.cpython-39.pyc


+ 0 - 0
apps/test_task/admin.py → TestLaboratory/apps/log/admin.py


+ 1 - 1
apps/log_info/apps.py → TestLaboratory/apps/log/apps.py

@@ -3,4 +3,4 @@ from django.apps import AppConfig
 
 class LogInfoConfig(AppConfig):
     default_auto_field = 'django.db.models.BigAutoField'
-    name = 'apps.log_info'
+    name = 'apps.log'

+ 0 - 0
apps/test_task/migrations/__init__.py → TestLaboratory/apps/log/middleware/__init__.py


+ 33 - 0
TestLaboratory/apps/log/middleware/loginfo.py

@@ -0,0 +1,33 @@
+import re
+
+import jwt
+from django.http import HttpResponse
+
+from TestLaboratory.settings import SECRET_KEY
+from apps.user.models import User, Role
+
+
+class LogInfo(object):
+    """使用类装饰器来权限校验"""
+    def __init__(self, func):
+        self.func = func
+
+    def __call__(self, request, *args, **kwargs):
+        token = request.META.get('HTTP_ACCESSTOKEN')
+        SALT = SECRET_KEY
+
+        payload = jwt.decode(token, SALT, True)
+
+        user = User.objects.get(username=payload['username'])
+
+        role = Role.objects.get(id="TestLaboratory_V1_Role_"+str(user.identify+1))
+        permission = role.permissions.filter(method=request.method)
+
+        log = None
+        for per in permission:
+            if re.search(per.url, request.path[:-1]):
+                log = per
+                break
+
+        return self.func(request, *args, **kwargs)
+

+ 35 - 0
TestLaboratory/apps/log/migrations/0001_initial.py

@@ -0,0 +1,35 @@
+# Generated by Django 3.2 on 2021-07-17 20:05
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Log',
+            fields=[
+                ('id', models.CharField(default='TestLaboratory_V1_Log_1', max_length=50, primary_key=True, serialize=False, verbose_name='日志id')),
+                ('action', models.CharField(max_length=100, verbose_name='操作名称')),
+                ('entity_class', models.CharField(max_length=50, verbose_name='实体类型')),
+                ('entity_name', models.CharField(max_length=50, null=True, verbose_name='实体名称')),
+                ('method', models.CharField(max_length=30, verbose_name='操作方法')),
+                ('executor_id', models.CharField(max_length=50, verbose_name='操作者id')),
+                ('executor_username', models.CharField(max_length=50, verbose_name='操作者名称')),
+                ('executor_identify', models.IntegerField(verbose_name='操作者身份')),
+                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
+                ('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
+                ('delete', models.BooleanField(default=False)),
+            ],
+            options={
+                'verbose_name': '日志',
+                'verbose_name_plural': '日志',
+                'db_table': 'log',
+            },
+        ),
+    ]

+ 0 - 0
apps/test_task/__init__.py → TestLaboratory/apps/log/migrations/__init__.py


binární
TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-38.pyc


binární
TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-39.pyc


binární
TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-39.pyc


+ 77 - 0
TestLaboratory/apps/log/models.py

@@ -0,0 +1,77 @@
+import datetime
+import re
+
+import jwt
+from django.db import models
+
+# Create your models here.
+from TestLaboratory.settings import SECRET_KEY
+from apps.user.models import User, Role
+from utils.util_add_id import get_id, gen_next_id
+
+
+class Log(models.Model):
+    id = models.CharField(max_length=50, primary_key=True, verbose_name='日志id', default='TestLaboratory_V1_Log_1')
+    action = models.CharField(max_length=100, verbose_name='操作名称')
+    entity_class = models.CharField(max_length=50, verbose_name='实体类型')
+    entity_name = models.CharField(max_length=50, null=True, verbose_name='实体名称')
+    method = models.CharField(max_length=30, verbose_name='操作方法')
+    executor_id = models.CharField(max_length=50, verbose_name='操作者id')
+    executor_username = models.CharField(max_length=50, verbose_name='操作者名称')
+    executor_identify = models.IntegerField(verbose_name='操作者身份')
+    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
+    update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
+    delete = models.BooleanField(default=False)
+
+    def __str__(self):
+        return self.executor_username + self.action
+
+    class Meta:
+        verbose_name = '日志'
+        verbose_name_plural = verbose_name
+        db_table = 'log'
+
+
+def gen_log(action, entity_class, entity_name, method, executor):
+    log_id = get_id(Log, "TestLaboratory_V1_Log_1")
+    create_time = update_time = datetime.datetime.now()
+    try:
+        log_new = Log.objects.create(id=log_id, action=action, entity_class=entity_class, entity_name=entity_name,
+                                     method=method, executor_id=executor.id, executor_username=executor.username,
+                                     executor_identify=executor.identify, create_time=create_time,
+                                     update_time=update_time)
+    except:
+        log_id = gen_next_id(log_id)
+        log_new = Log.objects.create(id=log_id, action=action, entity_class=entity_class, entity_name=entity_name,
+                                     method=method, executor_id=executor.id, executor_username=executor.username,
+                                     executor_identify=executor.identify, create_time=create_time,
+                                     update_time=update_time)
+
+
+def get_log(request):
+    token = request.META.get('HTTP_ACCESSTOKEN')
+    SALT = SECRET_KEY
+
+    payload = jwt.decode(token, SALT, True)
+
+    user = User.objects.get(id=payload['userid'])
+
+    role = Role.objects.get(id="TestLaboratory_V1_Role_" + str(user.identify + 1))
+    permission = role.permissions.filter(method=request.method)
+    # print(user.username)
+
+    perm = None
+    for per in permission:
+        path = request.path
+        if request.path[-1] == '/':
+            path = request.path[:-1]
+        # print(per.url, per.name, path, re.search(per.url, path))
+
+        if re.search(per.url, path):
+            # print("匹配", per.url, request.path)
+            if not perm:
+                perm = per
+            elif len(per.url) > len(perm.url):
+                perm = per
+    # print(perm.url, perm.name, perm.method)
+    return user, perm.name, perm.method

+ 0 - 0
apps/test_task/tests.py → TestLaboratory/apps/log/tests.py


+ 6 - 0
TestLaboratory/apps/log/urls.py

@@ -0,0 +1,6 @@
+from django.urls import path
+from .views.loglistview import LogListView
+
+urlpatterns = [
+    path('', LogListView.as_view())
+]

+ 0 - 0
apps/test_plan/views/__init__.py → TestLaboratory/apps/log/views/__init__.py


binární
TestLaboratory/apps/log/views/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/log/views/__pycache__/__init__.cpython-39.pyc


binární
TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-38.pyc


binární
TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-39.pyc


+ 47 - 0
TestLaboratory/apps/log/views/loglistview.py

@@ -0,0 +1,47 @@
+from django.db.models import Q
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from django.http import HttpResponse
+
+from apps.log.models import Log
+
+
+class LogListView(APIView):
+    # view log_list
+    @staticmethod
+    def get(request, *args, **kwargs):
+        entity_class = request.GET.get('entity_class')
+        action = request.GET.get('action')
+        executor_username = request.GET.get('executor_username')
+        executor_identify = request.GET.get('executor_identify')
+        sort = request.GET.get('sort')
+        dont_get = request.GET.get('dontGet')
+
+        log_all = Log.objects.order_by('-create_time')
+        if entity_class:
+            log_all = log_all.filter(entity_class=entity_class)
+        if action:
+            log_all = log_all.filter(method=action)
+        if executor_username:
+            log_all = log_all.filter(executor_username=executor_username)
+        if executor_identify:
+            log_all = log_all.filter(executor_identify=executor_identify)
+        if dont_get == '1':
+            log_all = log_all.filter(~Q(method='GET'))
+        if sort:
+            log_all = log_all.order_by(sort)
+
+        log_infos = []
+        for log in log_all:
+            log_infos.append({
+                'entity_class': log.entity_class,
+                'entity_name': log.entity_name,
+                'action': log.action,
+                'method': log.method,
+                'executor_id': log.executor_id,
+                'executor_username': log.executor_username,
+                'executor_identify': log.executor_identify,
+                'execute_time': log.create_time
+            })
+
+        return Response(log_infos)

+ 0 - 0
apps/test_plan/migrations/__init__.py → TestLaboratory/apps/plan/__init__.py


binární
TestLaboratory/apps/plan/__pycache__/__init__.cpython-38.pyc


binární
TestLaboratory/apps/plan/__pycache__/__init__.cpython-39.pyc


binární
TestLaboratory/apps/plan/__pycache__/admin.cpython-38.pyc


binární
TestLaboratory/apps/plan/__pycache__/admin.cpython-39.pyc


binární
TestLaboratory/apps/plan/__pycache__/apps.cpython-38.pyc


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů