Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

226 changed files with 1967 additions and 1461 deletions

8
.idea/.gitignore vendored
View File

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

View File

@ -1,32 +0,0 @@
<?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="py08test/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$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/templates" />
</list>
</option>
</component>
</module>

View File

@ -1,64 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="51">
<item index="0" class="java.lang.String" itemvalue="bs4" />
<item index="1" class="java.lang.String" itemvalue="greenlet" />
<item index="2" class="java.lang.String" itemvalue="logzero" />
<item index="3" class="java.lang.String" itemvalue="typed-ast" />
<item index="4" class="java.lang.String" itemvalue="atomicwrites" />
<item index="5" class="java.lang.String" itemvalue="python-dateutil" />
<item index="6" class="java.lang.String" itemvalue="py" />
<item index="7" class="java.lang.String" itemvalue="astroid" />
<item index="8" class="java.lang.String" itemvalue="Faker" />
<item index="9" class="java.lang.String" itemvalue="certifi" />
<item index="10" class="java.lang.String" itemvalue="lxml" />
<item index="11" class="java.lang.String" itemvalue="gevent" />
<item index="12" class="java.lang.String" itemvalue="pyparsing" />
<item index="13" class="java.lang.String" itemvalue="beautifulsoup4" />
<item index="14" class="java.lang.String" itemvalue="pywin32" />
<item index="15" class="java.lang.String" itemvalue="idna-ssl" />
<item index="16" class="java.lang.String" itemvalue="pytest-metadata" />
<item index="17" class="java.lang.String" itemvalue="wrapt" />
<item index="18" class="java.lang.String" itemvalue="zope.interface" />
<item index="19" class="java.lang.String" itemvalue="attrdict" />
<item index="20" class="java.lang.String" itemvalue="BeautifulReport" />
<item index="21" class="java.lang.String" itemvalue="attrs" />
<item index="22" class="java.lang.String" itemvalue="weditor" />
<item index="23" class="java.lang.String" itemvalue="PyMySQL" />
<item index="24" class="java.lang.String" itemvalue="idna" />
<item index="25" class="java.lang.String" itemvalue="decorator" />
<item index="26" class="java.lang.String" itemvalue="more-itertools" />
<item index="27" class="java.lang.String" itemvalue="cffi" />
<item index="28" class="java.lang.String" itemvalue="wcwidth" />
<item index="29" class="java.lang.String" itemvalue="importlib-metadata" />
<item index="30" class="java.lang.String" itemvalue="cookies" />
<item index="31" class="java.lang.String" itemvalue="jdcal" />
<item index="32" class="java.lang.String" itemvalue="uiautomator2" />
<item index="33" class="java.lang.String" itemvalue="Deprecated" />
<item index="34" class="java.lang.String" itemvalue="zipp" />
<item index="35" class="java.lang.String" itemvalue="cached-property" />
<item index="36" class="java.lang.String" itemvalue="urllib3" />
<item index="37" class="java.lang.String" itemvalue="zope.event" />
<item index="38" class="java.lang.String" itemvalue="six" />
<item index="39" class="java.lang.String" itemvalue="tornado" />
<item index="40" class="java.lang.String" itemvalue="pytest" />
<item index="41" class="java.lang.String" itemvalue="packaging" />
<item index="42" class="java.lang.String" itemvalue="et-xmlfile" />
<item index="43" class="java.lang.String" itemvalue="facebook-wda" />
<item index="44" class="java.lang.String" itemvalue="lazy-object-proxy" />
<item index="45" class="java.lang.String" itemvalue="pytest-testreport" />
<item index="46" class="java.lang.String" itemvalue="ddt" />
<item index="47" class="java.lang.String" itemvalue="progress" />
<item index="48" class="java.lang.String" itemvalue="openpyxl" />
<item index="49" class="java.lang.String" itemvalue="Pillow" />
<item index="50" class="java.lang.String" itemvalue="unittestreport" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

View File

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

View File

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

View File

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

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

16
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "3ea235286f3cb02870378097b40744aa50d1ae64a1116afeb73088d0af9c1d23"
"sha256": "c36ae28fea7b9a4cc02145632e2f41469af2e7b38b801903abb8333d3306f36b"
},
"pipfile-spec": 6,
"requires": {
@ -10,7 +10,7 @@
"sources": [
{
"name": "pypi",
"url": "https://pypi.douban.com/simple",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
@ -26,11 +26,11 @@
},
"django": {
"hashes": [
"sha256:95b318319d6997bac3595517101ad9cc83fe5672ac498ba48d1a410f47afecd2",
"sha256:e93c93565005b37ddebf2396b4dc4b6913c1838baa82efdfb79acedd5816c240"
"sha256:7f92413529aa0e291f3be78ab19be31aefb1e1c9a52cd59e130f505f27a51f13",
"sha256:f27f8544c9d4c383bbe007c57e3235918e258364577373d4920e9162837be022"
],
"index": "pypi",
"version": "==3.2.7"
"version": "==3.2.6"
},
"pytz": {
"hashes": [
@ -41,11 +41,11 @@
},
"sqlparse": {
"hashes": [
"sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae",
"sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d"
"sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0",
"sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8"
],
"markers": "python_version >= '3.5'",
"version": "==0.4.2"
"version": "==0.4.1"
}
},
"develop": {}

127
README.md
View File

@ -1,127 +1,2 @@
# kiftd——青阳网络文件传输系统 #
## 一款面向个人、团队、小型组织的网盘应用系统,免费、开源、完善。 ##
### 欢迎访问kiftd官方资源站官方网站https://kohgylw.gitee.io/
# home
-------
![主界面展示](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/kiftd-mainpage.png?raw=true)
-------
## 快速导航
* 访问kiftd官方主页来快速了解kiftd -- [kiftd官方主页](https://kohgylw.gitee.io/)
* 国内托管地址——阿里云上的项目主页https://code.aliyun.com/kohgylw/kiftd/tree/master -- [点击下载](https://code.aliyun.com/kohgylw/kiftd/repository/archive.zip?ref=master)
* 国内托管地址——码云上的项目主页: https://gitee.com/kohgylw/kiftd -- [点击下载](https://gitee.com/kohgylw/kiftd/repository/archive/master.zip)
* 国际托管地址——github上的项目主页 https://github.com/KOHGYLW/kiftd -- [点击下载](https://github.com/KOHGYLW/kiftd/archive/master.zip)
## 什么是kiftd?
* ### 您还在使用U盘分享软件么
> 很不幸U盘易丢同时又无法兼容各种平台的文件系统在需要大规模分享时--通过U盘拷贝简直就像是接力赛一样原始又低效。
* ### 您还在使用免费的公用网盘么?
> 时不时传来的网盘关停热潮令人担忧,而其由外人管理的特性则让您不敢轻易把隐私文件存放在上面。
* ### 您需要利用自己的资源搭建起一个网盘系统而苦于没有好的选择?
> 使用破解软件同样无法确保安全性,闭源的特性令人担忧。同时,很多已有的网盘服务器软件性能笨重、功能简单、语言的障碍更是使用中不可忽视的问题。
### 现在您可以选择kiftd了
本软件的作者 kohgylw 相信除了他本人之外一定还有其他人也面临着同样的问题。毕竟作为教师的他需要时常分发资料给学生——在他成功弄丢了几次U盘后便萌生了利用自己闲暇的时间去开发出一套“基于常见web浏览器的网络文件存储、分发、管理、预览系统”的计划。该系统要比ftp更便捷要比操作系统自带的文件分享功能适应性更强要比已有的网盘软件更强大、更高效。不久之后作为该计划的成果这款名为kiftd的软件就此诞生了。
_注kift为该功能的开发名称其实际成果命名为kiftd。_
-------
## kiftd有哪些优势
![mark](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/mark_icon.png?raw=true) 无上传限制——不足1MB的文档和超过5GB的高清电影资源均能够随意上传和下载。
![mark](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/mark_icon.png?raw=true) 主流商业网盘特有的高级功能甚至需要收费的功能——文件夹访问级别控制、视频在线影院、Word/PPT/TXT/PDF文档在线预览、音乐在线欣赏、图片库在线预览...kiftd均一一具备每一份kiftd均是“完全版”。
![mark](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/mark_icon.png?raw=true) 操作系统全兼容——无论是Windows、Linux还是Unix(包括Mac OS X),均可运行使用。
![mark](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/mark_icon.png?raw=true) 支持移动端操作,即使没有数据线,手机、平板、电脑之间也能文件互传。
![mark](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/mark_icon.png?raw=true) 同时满足日常需求or专业需求——kiftd同时具备了图形界面模式和纯命令模式的双操作模式无论您是喜欢点击鼠标的电脑小白还是需要使用命令在远程Linux上部署的运维人员均能完美操作。
![mark](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/mark_icon.png?raw=true) 无任何使用成本——kiftd完全开源免费因此唯一的使用成本就是需要安装它。至于之后您想将其用于什么领域哪怕是商业领域——均无任何限制。
![mark](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/mark_icon.png?raw=true) 无内置代码的隐患——kiftd完全开源您可以随意下载其源代码并用它自己编译一份kiftd同时它删除即走绝不和你撒娇卖萌。保护用户硬件环境从开源做起。
## 总之,无论您是想:
+ 安装在自己的笔记本电脑上用于替代老旧的U盘……
+ 利用家用台式机,来搭建一个家庭存储云……
+ 利用办公室中的服务器,为同事们提供一个团队资料分享网盘……
+ 利用公网托管的云服务器,搭建一个能够随时随地访问的快捷云……
+ ……
## 使用kiftd都能让您得心应手。
想要眼见为实您可以通过下方的《功能速览》一节来查看kiftd特色功能的演示。
------
## Quick Strat
### 现在您只需抽出3分钟时间就可以立即体验这款专业快捷的网盘服务器了。
* 马上下载本网盘服务器请点击右上方绿色按钮“Clone or Download”之后选择“Download ZIP”进行下载Github,也可以前往国内托管的下载地址: https://gitee.com/kohgylw/kiftd (码云)或 https://code.aliyun.com/kohgylw/kiftd/tree/master (阿里云)
* 想要开始使用您应该从阅读《kiftd说明文档》开始这是一份十分全面的官方介绍文档简单易懂且图文并茂相信您能很快学会它。想在线阅读请直接点击上方文件列表中的《kiftd说明文档》来在线预览该操作仅GitHub有效
* 立刻获取源代码请访问本应用代码托管地址https://github.com/KOHGYLW/kiftd-source Github
* 使用中遇到问题?请将您的发现提交到 https://github.com/KOHGYLW/kiftd/issues (Github)
* 需要联系作者?请立即发件至 kohgylw@163.com ,描述您所遇到的任何问题
-------------------
## News
最新讯息:
> 提示:当您更新版本后,请手动清除浏览器的缓存,之后刷新网盘主页以确保数据文件保持最新!否则可能导致新版页面功能无法使用。
### 常规更新v1.0.35
_本次更新为维护性的更新修复一些已经发现的问题并优化使用体验推荐所有用户升级。_
+ 修复了当用户执行批量上传操作时,中途切换所在的文件夹可能会导致上传路径发生改变的问题。
+ 升级了内置的MySQL数据库驱动的版本。
> 需要查看更多版本历史信息?请访问: https://kohgylw.gitee.io/News.html
--------------------
## Functional Examples
### 功能速览
>注图中涉及资源均来源于网络仅用于展示kiftd功能版权归其作者所有。
+ 主页与基本功能展示……
![MainPage](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/kiftd-mainpage.png?raw=true)
![UploadFile](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/kiftd-upload2.png?raw=true)
![CreateFolder](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/kiftd-newfolder.png?raw=true)
+ 各种高级功能展示……
![Vadio](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/vadio.png?raw=true)
![Audio](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/audio.png?raw=true)
![Picture](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/kiftd-picture.png?raw=true)
![PDF](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/pdf.png?raw=true)
+ 人性化的服务器控制面板
![UI](https://github.com/KOHGYLW/kiftd-showPicture/blob/master/kiftd-ui2.png?raw=true)
### 想要了解更多功能详见随程序附带的《kiftd说明文档》...
> 在开始使用前您应该先阅读每一份kiftd程序中均会附带的《kiftd说明文档》来了解整个kiftd的全貌——这是kiftd的说明书和使用教程它并不枯燥相信您能很轻松地读懂它。
-------------------
## Contact Author?
### 有意见建议或问题需要联系作者欢迎随时至信kohgylw@163.com作者会恭候您的来信
_作者会每隔1-3周浏览一次邮箱如未能及时回复请耐心等待。回复或许会迟到但它不会缺席。_
2018-2020 kohgylw@青阳龙野 作者保留版权

6
apps/__init__.py Normal file
View File

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# @Time : 2021/8/28 22:19
# @Author : Flora.Chen
# @File : __init__.py.py
# @Software: PyCharm
# @Desc:

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/configures/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
apps/configures/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ConfiguresConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'configures'

View File

@ -0,0 +1,34 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('interfaces', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Configures',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='配置名称', max_length=50, unique=True, verbose_name='配置名称')),
('author', models.CharField(help_text='编写人员', max_length=50, verbose_name='编写人员')),
('request', models.TextField(help_text='请求信息', verbose_name='请求信息')),
('interface', models.ForeignKey(help_text='所属接口', on_delete=django.db.models.deletion.CASCADE, related_name='configures', to='interfaces.interfaces', verbose_name='所属接口')),
],
options={
'verbose_name': '配置表',
'verbose_name_plural': '配置表',
'db_table': 'tb_configures',
'ordering': ['id'],
},
),
]

View File

21
apps/configures/models.py Normal file
View File

@ -0,0 +1,21 @@
from django.db import models
from utils.base_models import BaseModel
class Configures(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(unique=True, max_length=50, help_text="配置名称", verbose_name="配置名称")
interface = models.ForeignKey("interfaces.Interfaces", on_delete=models.CASCADE,
help_text="所属接口", verbose_name="所属接口", related_name="configures")
author = models.CharField(max_length=50, help_text="编写人员", verbose_name="编写人员")
request = models.TextField(help_text="请求信息", verbose_name="请求信息")
class Meta:
"""内部类"""
db_table = "tb_configures"
verbose_name = "配置表"
ordering = ["id"]
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:48
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import Configures
class ConfiguresModelSerializers(serializers.ModelSerializer):
"""配置管理的序列化器类"""
class Meta:
model = Configures
exclude = ("create_time", "update_time")
extra_kwargs = {
}

3
apps/configures/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

16
apps/configures/urls.py Normal file
View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:46
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from rest_framework.routers import SimpleRouter
from django.urls import path, re_path
from . import views
router = SimpleRouter()
router.register(r"configures", views.ConfiguresView)
urlpatterns = []
urlpatterns += router.urls

8
apps/configures/views.py Normal file
View File

@ -0,0 +1,8 @@
from rest_framework.viewsets import ModelViewSet
from .models import Configures
from . import serializers
class ConfiguresView(ModelViewSet):
queryset = Configures.objects.all()
serializer_class = serializers.ConfiguresModelSerializers

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/debugtalks/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
apps/debugtalks/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class DebugtalksConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'debugtalks'

View File

@ -0,0 +1,33 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('projects', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='DebugTalks',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='debugtalk文件名称', max_length=200, unique=True, verbose_name='debugtalk文件名称')),
('debugtalk', models.TextField(default='#debugtalk.py', help_text='debugtalk.py文件', null=True)),
('project', models.OneToOneField(help_text='所属项目', on_delete=django.db.models.deletion.CASCADE, related_name='debugtalks', to='projects.projects')),
],
options={
'verbose_name': 'debugtalk文件',
'verbose_name_plural': 'debugtalk文件',
'db_table': 'tb_debugtalks',
'ordering': ['id'],
},
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2021-09-13 16:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('debugtalks', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='debugtalks',
name='name',
field=models.CharField(help_text='debugtalk文件名称', max_length=200, verbose_name='debugtalk文件名称'),
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.6 on 2021-09-13 16:11
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('debugtalks', '0002_alter_debugtalks_name'),
]
operations = [
migrations.AlterModelOptions(
name='debugtalks',
options={'verbose_name': 'debugtalk文件', 'verbose_name_plural': 'debugtalk文件'},
),
]

View File

20
apps/debugtalks/models.py Normal file
View File

@ -0,0 +1,20 @@
from django.db import models
from utils.base_models import BaseModel
class DebugTalks(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(max_length=200, help_text="debugtalk文件名称", default='debugtalk.py',
verbose_name="debugtalk文件名称")
debugtalk = models.TextField(null=True, default="#debugtalk.py", help_text="debugtalk.py文件")
project = models.OneToOneField("projects.Projects", on_delete=models.CASCADE, related_name="debugtalks",
help_text="所属项目")
class Meta:
"""内部类"""
db_table = "tb_debugtalks"
verbose_name = "debugtalk文件"
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

View File

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:50
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import DebugTalks
class DebugtalksModelSerailizers(serializers.ModelSerializer):
"""内置函数的序列化器类"""
project = serializers.SlugRelatedField(slug_field="name", read_only=True, label="所属项目", help_text="所属项目")
class Meta:
model = DebugTalks
exclude = ("create_time", "update_time")
extra_kwargs = {
"debugtalk": {
"write_only": "True",
"error_messages": {
"null": "debugtalk文件不能为空"
}
},
"name": {
"max_length": 50,
"error_messages": {
"max_length": "name最大长度为50"
}
}
}
class DebugtalkSerializer(serializers.ModelSerializer):
class Meta:
model = DebugTalks
fields = ('id', 'debugtalk')

3
apps/debugtalks/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

14
apps/debugtalks/urls.py Normal file
View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:50
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from rest_framework.routers import SimpleRouter
from .views import DebugtalksView
router = SimpleRouter()
router.register(r"debugtalks", DebugtalksView)
urlpatterns = []
urlpatterns += router.urls

14
apps/debugtalks/views.py Normal file
View File

@ -0,0 +1,14 @@
from rest_framework.viewsets import GenericViewSet
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, UpdateModelMixin
from . import serializers
from .models import DebugTalks
from rest_framework import permissions
class DebugtalksView(GenericViewSet, ListModelMixin, RetrieveModelMixin, UpdateModelMixin):
queryset = DebugTalks.objects.all()
serializer_class = serializers.DebugtalksModelSerailizers
permission_classes = [permissions.IsAuthenticated]
def get_serializer_class(self):
return serializers.DebugtalkSerializer if self.action == "retrieve" else super().get_serializer_class()

0
apps/envs/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/envs/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
apps/envs/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class EnvsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'envs'

View File

@ -0,0 +1,31 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Envs',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='环境名称', max_length=200, unique=True, verbose_name='环境名称')),
('base_url', models.URLField(help_text='请求base_url', verbose_name='请求base_url')),
('desc', models.CharField(help_text='简要描述', max_length=200, verbose_name='简要描述')),
],
options={
'verbose_name': '环境信息',
'verbose_name_plural': '环境信息',
'db_table': 'tb_envs',
'ordering': ['id'],
},
),
]

View File

19
apps/envs/models.py Normal file
View File

@ -0,0 +1,19 @@
from django.db import models
from utils.base_models import BaseModel
class Envs(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(unique=True, max_length=200, help_text="环境名称", verbose_name="环境名称")
base_url = models.URLField(verbose_name="请求base_url", max_length=200, help_text="请求base_url")
desc = models.CharField(verbose_name="简要描述", help_text="简要描述", max_length=200)
class Meta:
"""内部类"""
db_table = "tb_envs"
verbose_name = "环境信息"
ordering = ["id"]
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

50
apps/envs/serializers.py Normal file
View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:20
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import Envs
class EnvsModelSerializer(serializers.ModelSerializer):
"""环境管理的序列化器类"""
class Meta:
model = Envs
exclude = ("update_time",)
extra_kwargs = {
"name": {
"min_length": 1,
"max_length": 50,
"error_messages": {
"unique": "环境名称不能重复",
"max_length": "环境名称不能超过50个字符",
"min_length": "环境名称至少输入1个字符"
}
},
"base_url": {
"max_length": 50,
"error_messages": {
"max_length": "base_url不能超过50个字符",
}
},
"desc": {
"error_messages": {
"max_length": "描述不能超过200个字符",
}
},
"create_time": {
"format": "%Y-%m-%d %H:%M:%S"
}
}
class EnvsNameSerializer(serializers.ModelSerializer):
"""返回环境的名称"""
class Meta:
model = Envs
fields = ("id", "name")

3
apps/envs/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

16
apps/envs/urls.py Normal file
View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:14
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from django.urls import path, re_path
from rest_framework.routers import SimpleRouter
from .views import EnvView
router = SimpleRouter()
router.register(r"envs", EnvView)
urlpatterns = []
urlpatterns += router.urls

30
apps/envs/views.py Normal file
View File

@ -0,0 +1,30 @@
from rest_framework.decorators import action
from .models import Envs
from . import serializers
from rest_framework.viewsets import ModelViewSet
from rest_framework import filters
from rest_framework import permissions
from utils.mixins import GetDataMinxin
class EnvView(ModelViewSet, GetDataMinxin):
queryset = Envs.objects.all()
serializer_class = serializers.EnvsModelSerializer
# filter_backends = [filters.SearchFilter, filters.OrderingFilter]
# search_fields = ['id', 'name', 'tester']
# ordering_fields = ['name', 'tester']
# permission_classes = [permissions.IsAuthenticated]
@action(detail=False)
def names(self, request, *args, **kwargs):
"""获取所有的环境名称"""
response = super().list(request, *args, **kwargs)
return response
def get_serializer_class(self):
if self.action == "names":
return serializers.EnvsNameSerializer
else:
return super(EnvView, self).get_serializer_class()

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/interfaces/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
apps/interfaces/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class InterfacesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'interfaces'

View File

@ -0,0 +1,34 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('projects', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Interfaces',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='接口名称', max_length=200, unique=True, verbose_name='接口名称')),
('tester', models.CharField(help_text='测试人员', max_length=50, verbose_name='测试人员')),
('desc', models.TextField(blank=True, default='', help_text='描述', max_length=200, null=True, verbose_name='描述')),
('project', models.ForeignKey(help_text='所属项目', on_delete=django.db.models.deletion.CASCADE, related_name='interfaces', to='projects.projects', verbose_name='所属项目')),
],
options={
'verbose_name': '接口表',
'verbose_name_plural': '接口表',
'db_table': 'tb_interfaces',
'ordering': ['id'],
},
),
]

View File

21
apps/interfaces/models.py Normal file
View File

@ -0,0 +1,21 @@
from django.db import models
from utils.base_models import BaseModel
class Interfaces(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(unique=True, max_length=200, help_text="接口名称", verbose_name="接口名称")
tester = models.CharField(max_length=50, help_text="测试人员", verbose_name="测试人员")
desc = models.TextField(help_text="描述", verbose_name="描述", null=True, blank=True, default="", max_length=200)
project = models.ForeignKey("projects.Projects", on_delete=models.CASCADE, related_name="interfaces",
help_text="所属项目", verbose_name="所属项目")
class Meta:
"""内部类"""
db_table = "tb_interfaces"
verbose_name = "接口表"
ordering = ["id"]
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

View File

@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/14 23:24
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import Interfaces
from projects.models import Projects
from configures.models import Configures
from testcases.models import TestCases
from projects.models import Projects
class InterfacesModelSerializer(serializers.ModelSerializer):
"""接口序列化器类"""
project_id = serializers.PrimaryKeyRelatedField(queryset=Projects.objects.all(), label="所属项目id", help_text="所属项目id")
project = serializers.SlugRelatedField(slug_field="name", read_only=True, label="所属项目名称", help_text="所属项目名称")
class Meta:
model = Interfaces
exclude = ("update_time",)
extra_kwargs = {
"name": {
"error_messages": {"required": "请输入接口名称", "null": "接口名称不能为null", "blank": "接口名称不能为空字符串",
"max_length": "接口名称长度不能超过200"}
},
"tester": {
"error_messages": {"required": "请输入测试人员", "null": "测试人员不能为null", "blank": "测试人员不能为空字符串",
"max_length": "测试人员长度不能超过50"}
},
"desc": {
"error_messages": {"max_length": "简要描述长度不能超过200"}
},
"project": {
"error_messages": {"required": "请选择所属项目", }
},
"create_time": {
"format": "%Y-%m-%d %H:%M:%S"
}
}
def to_internal_value(self, data):
result = super(InterfacesModelSerializer, self).to_internal_value(data)
result["project"] = result.pop("project_id")
return result
class TestcasesNameSerializer(serializers.ModelSerializer):
"""获取用例名称"""
class Meta:
model = TestCases
fields = ('id', 'name')
class TestCasesInterfaceSerializer(serializers.ModelSerializer):
testcases = TestcasesNameSerializer(many=True)
class Meta:
model = Interfaces
fields = ("testcases", )
class ConfiguresNameSerializer(serializers.ModelSerializer):
"""获取配置名称"""
class Meta:
model = Configures
fields = ('id', 'name')
class ConfiguresInterfaceSerializer(serializers.ModelSerializer):
configures = ConfiguresNameSerializer(many=True)
class Meta:
model = Interfaces
fields = ("configures", )

3
apps/interfaces/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

14
apps/interfaces/urls.py Normal file
View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# @Time : 2021/8/31 23:20
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from . import views
from rest_framework import routers
router = routers.SimpleRouter()
router.register(r"interfaces", views.InterfacesViewSet)
urlpatterns = []
urlpatterns += router.urls

79
apps/interfaces/views.py Normal file
View File

@ -0,0 +1,79 @@
import logging
from rest_framework.decorators import action
from rest_framework.viewsets import ModelViewSet
from .models import Interfaces
from . import serializers
from interfaces.models import Interfaces
from testcases.models import TestCases
from configures.models import Configures
from rest_framework import filters
from rest_framework import permissions
from utils.mixins import GetDataMinxin
logger = logging.getLogger("mytest")
class InterfacesViewSet(ModelViewSet, GetDataMinxin):
"""接口"""
queryset = Interfaces.objects.all()
serializer_class = serializers.InterfacesModelSerializer
filter_backends = [filters.SearchFilter, filters.OrderingFilter]
search_fields = ['id', 'name', 'tester']
ordering_fields = ['name', 'tester']
permission_classes = [permissions.IsAuthenticated]
def list(self, request, *args, **kwargs):
response = super().list(request, *args, **kwargs)
for item in response.data["results"]:
item["testcases"] = TestCases.objects.filter(interface_id=item.get("id")).count()
item["configures"] = Configures.objects.filter(interface_id=item.get("id")).count()
return response
@action(detail=False)
def names(self, request, *args, **kwargs):
"""获取所有接口的名称"""
response = super().list(request, *args, **kwargs)
logger.error(response.data)
return response
# def get_data_by_ation(self, request, *args, **kwargs):
# response = self.retrieve(request, *args, **kwargs)
# response.data = response.data.get(self.action)
# logger.error(response.data)
# return response
#
# @action(detail=True, url_name="configs", url_path="configs")
# def configures(self, request, *args, **kwargs):
# """获取接口下的配置信息"""
# return self.get_data_by_ation(request, *args, **kwargs)
#
# @action(detail=True)
# def testcases(self, request, *args, **kwargs):
# """获取接口下的配置信息"""
# return self.get_data_by_ation(request, *args, **kwargs)
# ----------------- 使用继承的GetDataMinxin ------------------------ #
@action(detail=True, url_name="configs", url_path="configs")
def configures(self, request, *args, **kwargs):
"""获取接口下的配置信息"""
return self.get_data_by_ation(request, *args, **kwargs)
@action(detail=True)
def testcases(self, request, *args, **kwargs):
"""获取接口下的配置信息"""
return self.get_data_by_ation(request, *args, **kwargs)
# ----------------- 使用继承的GetDataMinxin ------------------------ #
def get_serializer_class(self):
if self.action == "names":
return serializers.TestcasesNameSerializer
elif self.action == "configs":
return serializers.ConfiguresInterfaceSerializer
elif self.action == "testcases":
return serializers.TestCasesInterfaceSerializer
else:
return super().get_serializer_class()

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/projects/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

Some files were not shown because too many files have changed in this diff Show More