-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
381 additions
and
135 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by Django 3.0.5 on 2020-05-11 13:55 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('common', '0001_initial'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='project', | ||
name='user', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='entity', | ||
name='project', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='common.Project'), | ||
), | ||
] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# from django.http import JsonResponse | ||
# import json | ||
# from django.core.files.storage import default_storage | ||
# from django.core.files.base import ContentFile | ||
# | ||
# from common.models import Text | ||
# | ||
# | ||
# def dispatcher(request): | ||
# # 将请求参数统一放入request 的 params 属性中,方便后续处理 | ||
# if request.user.is_authenticated(): | ||
# return JsonResponse({ | ||
# 'ret': 302, | ||
# 'msg': '未登录'}, | ||
# status=302) | ||
# | ||
# # GET请求 参数在url中,同过request 对象的 GET属性获取 | ||
# if request.method == 'GET': | ||
# request.params = request.GET | ||
# | ||
# # POST/PUT/DELETE 请求 参数 从 request 对象的 body 属性中获取 | ||
# elif request.method in ['POST', 'DELETE']: | ||
# # 根据接口,POST/PUT/DELETE 请求的消息体都是 json格式 | ||
# request.params = json.loads(request.body) | ||
# | ||
# # 根据不同的action分派给不同的函数进行处理 | ||
# action = request.params['action'] | ||
# if action == 'list_text': | ||
# return listtexts(request) | ||
# elif action == 'add_text': | ||
# return addtext(request) | ||
# elif action == 'del_text': | ||
# return deltext(request) | ||
# | ||
# else: | ||
# return JsonResponse({'ret': 1, 'msg': '不支持该类型http请求'}) | ||
# | ||
# | ||
# def listtexts(request): | ||
# # 返回一个 QuerySet 对象 ,包含所有的表记录 | ||
# pid = request.params['project_id'] | ||
# qs = Text.objects.filter(project_id=pid).values('id', 'name', 'text') | ||
# | ||
# # 将 QuerySet 对象 转化为 list 类型 | ||
# retlist = list(qs) | ||
# | ||
# return JsonResponse({'ret': 0, 'retlist': retlist}) | ||
# | ||
# | ||
# def addtext(request): | ||
# info = request.params['data'] | ||
# | ||
# text = request.Files.get('text') | ||
# | ||
# # path = default_storage.save('') | ||
# | ||
# record = Text.objects.create(name=text.name, | ||
# text=text, | ||
# project_id=info['project_id']) | ||
# | ||
# return JsonResponse({'ret': 0, 'id': record.id}) | ||
# | ||
# | ||
# def deltext(request): | ||
# textid = request.params['id'] | ||
# | ||
# try: | ||
# # 根据 id 从数据库中找到相应的客户记录 | ||
# text = Text.objects.get(id=textid) | ||
# except text.DoesNotExist: | ||
# return { | ||
# 'ret': 1, | ||
# 'msg': f'id 为`{textid}`的文本不存在' | ||
# } | ||
# | ||
# # delete 方法就将该记录从数据库中删除了 | ||
# text.delete() | ||
# | ||
# return JsonResponse({'ret': 0}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.