作者 wanweibin

update

1 venv 1 venv
2 runtime/log/* 2 runtime/log/*
3 db.sqlite3 3 db.sqlite3
  4 +.idea
  5 +.env
1 -# Default ignored files  
2 -/workspace.xml  
3 -# Datasource local storage ignored files  
4 -/dataSources/  
5 -/dataSources.local.xml  
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project version="4">  
3 - <component name="DataSourceManagerImpl" format="xml" multifile-model="true">  
4 - <data-source source="LOCAL" name="SQLite - db.sqlite3" uuid="40358238-ad1d-4a4e-aa6e-a585a40363bc">  
5 - <driver-ref>sqlite.xerial</driver-ref>  
6 - <synchronize>true</synchronize>  
7 - <jdbc-driver>org.sqlite.JDBC</jdbc-driver>  
8 - <jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db.sqlite3</jdbc-url>  
9 - </data-source>  
10 - </component>  
11 -</project>  
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project version="4">  
3 - <component name="PublishConfigData">  
4 - <serverData>  
5 - <paths name="10.1.10.113">  
6 - <serverdata>  
7 - <mappings>  
8 - <mapping local="$PROJECT_DIR$" web="/" />  
9 - </mappings>  
10 - </serverdata>  
11 - </paths>  
12 - <paths name="192.168.26.59">  
13 - <serverdata>  
14 - <mappings>  
15 - <mapping local="$PROJECT_DIR$" web="/" />  
16 - </mappings>  
17 - </serverdata>  
18 - </paths>  
19 - </serverData>  
20 - </component>  
21 -</project>  
1 -<component name="ProjectDictionaryState">  
2 - <dictionary name="a2">  
3 - <words>  
4 - <w>abelzhu</w>  
5 - <w>agentid</w>  
6 - <w>authsucc</w>  
7 - <w>blocksize</w>  
8 - <w>btntxt</w>  
9 - <w>corpid</w>  
10 - <w>corpsecret</w>  
11 - <w>corsheaders</w>  
12 - <w>getuserdetail</w>  
13 - <w>getuserinfo</w>  
14 - <w>lconf</w>  
15 - <w>msgtype</w>  
16 - <w>simplejwt</w>  
17 - <w>textcard</w>  
18 - <w>touser</w>  
19 - <w>usercenter</w>  
20 - <w>userid</w>  
21 - <w>userlogin</w>  
22 - <w>vanwhebin</w>  
23 - <w>wxlogin</w>  
24 - <w>xlsx</w>  
25 - </words>  
26 - </dictionary>  
27 -</component>  
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<module type="PYTHON_MODULE" version="4">  
3 - <component name="FacetManager">  
4 - <facet type="django" name="Django">  
5 - <configuration>  
6 - <option name="rootFolder" value="$MODULE_DIR$/wxProject" />  
7 - <option name="settingsModule" value="wxProject/settings.py" />  
8 - <option name="manageScript" value="manage.py" />  
9 - <option name="environment" value="&lt;map/&gt;" />  
10 - <option name="doNotUseTestRunner" value="false" />  
11 - <option name="trackFilePattern" value="" />  
12 - </configuration>  
13 - </facet>  
14 - </component>  
15 - <component name="NewModuleRootManager">  
16 - <content url="file://$MODULE_DIR$" />  
17 - <orderEntry type="jdk" jdkName="Python 3.8 (end)" jdkType="Python SDK" />  
18 - <orderEntry type="sourceFolder" forTests="false" />  
19 - <orderEntry type="library" name="Django Lib" level="project" />  
20 - </component>  
21 - <component name="TemplatesService">  
22 - <option name="TEMPLATE_CONFIGURATION" value="Django" />  
23 - <option name="TEMPLATE_FOLDERS">  
24 - <list>  
25 - <option value="$MODULE_DIR$/venv/Lib/site-packages/django/forms/templates" />  
26 - </list>  
27 - </option>  
28 - </component>  
29 -</module>  
1 -<component name="InspectionProjectProfileManager">  
2 - <settings>  
3 - <option name="USE_PROJECT_PROFILE" value="false" />  
4 - <version value="1.0" />  
5 - </settings>  
6 -</component>  
1 -<component name="libraryTable">  
2 - <library name="Django Lib">  
3 - <CLASSES>  
4 - <root url="file://$PROJECT_DIR$/venv/Lib/site-packages" />  
5 - </CLASSES>  
6 - <SOURCES />  
7 - </library>  
8 -</component>  
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project version="4">  
3 - <component name="JavaScriptSettings">  
4 - <option name="languageLevel" value="ES6" />  
5 - </component>  
6 - <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (end)" project-jdk-type="Python SDK" />  
7 -</project>  
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project version="4">  
3 - <component name="ProjectModuleManager">  
4 - <modules>  
5 - <module fileurl="file://$PROJECT_DIR$/.idea/end.iml" filepath="$PROJECT_DIR$/.idea/end.iml" />  
6 - </modules>  
7 - </component>  
8 -</project>  
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project version="4">  
3 - <component name="VcsDirectoryMappings">  
4 - <mapping directory="$PROJECT_DIR$" vcs="Git" />  
5 - </component>  
6 -</project>  
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<module type="PYTHON_MODULE" version="4">  
3 - <component name="FacetManager">  
4 - <facet type="django" name="Django">  
5 - <configuration>  
6 - <option name="rootFolder" value="$MODULE_DIR$" />  
7 - <option name="settingsModule" value="wxProject/settings.py" />  
8 - <option name="manageScript" value="$MODULE_DIR$/manage.py" />  
9 - <option name="environment" value="&lt;map/&gt;" />  
10 - <option name="doNotUseTestRunner" value="false" />  
11 - <option name="trackFilePattern" value="migrations" />  
12 - </configuration>  
13 - </facet>  
14 - </component>  
15 - <component name="NewModuleRootManager">  
16 - <content url="file://$MODULE_DIR$" />  
17 - <orderEntry type="inheritedJdk" />  
18 - <orderEntry type="sourceFolder" forTests="false" />  
19 - <orderEntry type="library" name="Django Lib" level="project" />  
20 - </component>  
21 - <component name="PyDocumentationSettings">  
22 - <option name="format" value="PLAIN" />  
23 - <option name="myDocStringFormat" value="Plain" />  
24 - </component>  
25 - <component name="TemplatesService">  
26 - <option name="TEMPLATE_CONFIGURATION" value="Django" />  
27 - <option name="TEMPLATE_FOLDERS">  
28 - <list>  
29 - <option value="$MODULE_DIR$/venv/Lib/site-packages/django/forms/templates" />  
30 - </list>  
31 - </option>  
32 - </component>  
33 -</module>  
1 -# Generated by Django 3.1.1 on 2020-09-30 07:38 1 +# Generated by Django 3.1.1 on 2020-10-08 07:45
2 2
3 from django.db import migrations, models 3 from django.db import migrations, models
4 import django.db.models.deletion 4 import django.db.models.deletion
@@ -16,11 +16,14 @@ class Migration(migrations.Migration): @@ -16,11 +16,14 @@ class Migration(migrations.Migration):
16 name='Auditor', 16 name='Auditor',
17 fields=[ 17 fields=[
18 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 - ('leader', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='p', to='project.auditor', verbose_name='上级领导')), 19 + ('order', models.PositiveSmallIntegerField(blank=True, default=0, null=True, verbose_name='排序')),
20 ], 20 ],
  21 + options={
  22 + 'ordering': ('order',),
  23 + },
21 ), 24 ),
22 migrations.CreateModel( 25 migrations.CreateModel(
23 - name='Program', 26 + name='Project',
24 fields=[ 27 fields=[
25 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 28 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
26 ('category', models.CharField(default='', max_length=100, verbose_name='产品类目')), 29 ('category', models.CharField(default='', max_length=100, verbose_name='产品类目')),
@@ -28,8 +31,24 @@ class Migration(migrations.Migration): @@ -28,8 +31,24 @@ class Migration(migrations.Migration):
28 ('market_share_analysis', models.TextField(default='', verbose_name='产品市场占有率分析')), 31 ('market_share_analysis', models.TextField(default='', verbose_name='产品市场占有率分析')),
29 ('context_analysis', models.TextField(default='', verbose_name='产品场景分析')), 32 ('context_analysis', models.TextField(default='', verbose_name='产品场景分析')),
30 ('attachments', models.CharField(default='', max_length=800, verbose_name='附件地址')), 33 ('attachments', models.CharField(default='', max_length=800, verbose_name='附件地址')),
  34 + ('is_done', models.BooleanField(blank=True, default=False, verbose_name='是否完成')),
  35 + ('is_pass', models.BooleanField(blank=True, default=False, verbose_name='是否通过')),
  36 + ('create_time', models.DateTimeField(auto_now_add=True)),
  37 + ('auditor', models.ManyToManyField(blank=True, related_name='project_auditor', to='project.Auditor', verbose_name='审核人员')),
  38 + ],
  39 + options={
  40 + 'ordering': ('-is_done',),
  41 + },
  42 + ),
  43 + migrations.CreateModel(
  44 + name='Result',
  45 + fields=[
  46 + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  47 + ('is_accept', models.CharField(choices=[('accept', '通过'), ('reject', '否决')], max_length=10, null=True, verbose_name='审核项目')),
  48 + ('memo', models.CharField(blank=True, default='', max_length=300, verbose_name='审核结果陈述')),
31 ('create_time', models.DateTimeField(auto_now_add=True)), 49 ('create_time', models.DateTimeField(auto_now_add=True)),
32 - ('auditor', models.ManyToManyField(related_name='auditor', to='project.Auditor', verbose_name='审核人员')), 50 + ('auditor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='result_auditor', to='project.auditor', verbose_name='审核人员')),
  51 + ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='result_project', to='project.project', verbose_name='审核项目')),
33 ], 52 ],
34 options={ 53 options={
35 'ordering': ('-create_time',), 54 'ordering': ('-create_time',),
1 -# Generated by Django 3.1.1 on 2020-09-30 07:38 1 +# Generated by Django 3.1.1 on 2020-10-08 07:45
2 2
3 from django.conf import settings 3 from django.conf import settings
4 from django.db import migrations, models 4 from django.db import migrations, models
@@ -16,8 +16,18 @@ class Migration(migrations.Migration): @@ -16,8 +16,18 @@ class Migration(migrations.Migration):
16 16
17 operations = [ 17 operations = [
18 migrations.AddField( 18 migrations.AddField(
  19 + model_name='project',
  20 + name='creator',
  21 + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_creator', to=settings.AUTH_USER_MODEL, verbose_name='创建人员'),
  22 + ),
  23 + migrations.AddField(
  24 + model_name='auditor',
  25 + name='leader',
  26 + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='p', to='project.auditor', verbose_name='上级领导'),
  27 + ),
  28 + migrations.AddField(
19 model_name='auditor', 29 model_name='auditor',
20 name='user', 30 name='user',
21 - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='aud', to=settings.AUTH_USER_MODEL, verbose_name='审批人员'), 31 + field=models.ForeignKey(choices=[(1, 'admin'), (2, 'wanweibin'), (3, 'wanweibin1')], on_delete=django.db.models.deletion.CASCADE, related_name='aud', to=settings.AUTH_USER_MODEL, verbose_name='审批人员'),
22 ), 32 ),
23 ] 33 ]
1 -# Generated by Django 3.1.1 on 2020-09-30 08:07  
2 -  
3 -from django.db import migrations, models  
4 -  
5 -  
6 -class Migration(migrations.Migration):  
7 -  
8 - dependencies = [  
9 - ('project', '0002_auditor_user'),  
10 - ]  
11 -  
12 - operations = [  
13 - migrations.AlterField(  
14 - model_name='program',  
15 - name='auditor',  
16 - field=models.ManyToManyField(related_name='project_auditor', to='project.Auditor', verbose_name='审核人员'),  
17 - ),  
18 - ]  
1 -# Generated by Django 3.1.1 on 2020-09-30 08:43  
2 -  
3 -from django.db import migrations, models  
4 -  
5 -  
6 -class Migration(migrations.Migration):  
7 -  
8 - dependencies = [  
9 - ('project', '0003_auto_20200930_1607'),  
10 - ]  
11 -  
12 - operations = [  
13 - migrations.AlterField(  
14 - model_name='auditor',  
15 - name='user',  
16 - field=models.CharField(choices=[('admin', 'admin')], max_length=100, verbose_name='审批人员'),  
17 - ),  
18 - ]  
1 -# Generated by Django 3.1.1 on 2020-09-30 09:21  
2 -  
3 -from django.conf import settings  
4 -from django.db import migrations, models  
5 -import django.db.models.deletion  
6 -  
7 -  
8 -class Migration(migrations.Migration):  
9 -  
10 - dependencies = [  
11 - migrations.swappable_dependency(settings.AUTH_USER_MODEL),  
12 - ('project', '0004_auto_20200930_1643'),  
13 - ]  
14 -  
15 - operations = [  
16 - migrations.AlterField(  
17 - model_name='auditor',  
18 - name='user',  
19 - field=models.ForeignKey(choices=[{'id': 1, 'username': 'admin'}, {'id': 2, 'username': 'wanweibin'}, {'id': 3, 'username': 'wanweibin1'}], on_delete=django.db.models.deletion.CASCADE, related_name='aud', to=settings.AUTH_USER_MODEL, verbose_name='审批人员'),  
20 - ),  
21 - ]  
1 -# Generated by Django 3.1.1 on 2020-09-30 09:45  
2 -  
3 -from django.conf import settings  
4 -from django.db import migrations, models  
5 -import django.db.models.deletion  
6 -  
7 -  
8 -class Migration(migrations.Migration):  
9 -  
10 - dependencies = [  
11 - migrations.swappable_dependency(settings.AUTH_USER_MODEL),  
12 - ('project', '0005_auto_20200930_1721'),  
13 - ]  
14 -  
15 - operations = [  
16 - migrations.AlterField(  
17 - model_name='auditor',  
18 - name='user',  
19 - field=models.ForeignKey(choices=[(1, 'admin'), (2, 'wanweibin'), (3, 'wanweibin1')], on_delete=django.db.models.deletion.CASCADE, related_name='aud', to=settings.AUTH_USER_MODEL, verbose_name='审批人员'),  
20 - ),  
21 - migrations.RenameModel(  
22 - old_name='Program',  
23 - new_name='Project',  
24 - ),  
25 - migrations.CreateModel(  
26 - name='Result',  
27 - fields=[  
28 - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),  
29 - ('is_accept', models.CharField(choices=[('accept', '通过'), ('reject', '否决')], max_length=10, null=True, verbose_name='审核项目')),  
30 - ('memo', models.CharField(blank=True, default='', max_length=300, verbose_name='审核结果陈述')),  
31 - ('create_time', models.DateTimeField(auto_now_add=True)),  
32 - ('auditor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='result_auditor', to='project.auditor', verbose_name='审核人员')),  
33 - ('program', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='result_project', to='project.project', verbose_name='审核项目')),  
34 - ],  
35 - options={  
36 - 'ordering': ('-create_time',),  
37 - },  
38 - ),  
39 - ]  
1 -# Generated by Django 3.1.1 on 2020-10-07 04:21  
2 -  
3 -from django.db import migrations, models  
4 -  
5 -  
6 -class Migration(migrations.Migration):  
7 -  
8 - dependencies = [  
9 - ('project', '0006_auto_20200930_1745'),  
10 - ]  
11 -  
12 - operations = [  
13 - migrations.AlterField(  
14 - model_name='project',  
15 - name='auditor',  
16 - field=models.ManyToManyField(blank=True, related_name='project_auditor', to='project.Auditor', verbose_name='审核人员'),  
17 - ),  
18 - ]  
1 -# Generated by Django 3.1.1 on 2020-10-07 07:44  
2 -  
3 -from django.db import migrations, models  
4 -  
5 -  
6 -class Migration(migrations.Migration):  
7 -  
8 - dependencies = [  
9 - ('project', '0007_auto_20201007_1221'),  
10 - ]  
11 -  
12 - operations = [  
13 - migrations.AddField(  
14 - model_name='project',  
15 - name='is_done',  
16 - field=models.BooleanField(blank=True, default=False, verbose_name='是否完成'),  
17 - ),  
18 - migrations.AddField(  
19 - model_name='project',  
20 - name='is_pass',  
21 - field=models.BooleanField(blank=True, default=False, verbose_name='是否通过'),  
22 - ),  
23 - ]  
1 -# Generated by Django 3.1.1 on 2020-10-07 08:26  
2 -  
3 -from django.conf import settings  
4 -from django.db import migrations, models  
5 -import django.db.models.deletion  
6 -  
7 -  
8 -class Migration(migrations.Migration):  
9 -  
10 - dependencies = [  
11 - migrations.swappable_dependency(settings.AUTH_USER_MODEL),  
12 - ('project', '0008_auto_20201007_1544'),  
13 - ]  
14 -  
15 - operations = [  
16 - migrations.AlterModelOptions(  
17 - name='project',  
18 - options={'ordering': ('-is_done',)},  
19 - ),  
20 - migrations.RenameField(  
21 - model_name='result',  
22 - old_name='program',  
23 - new_name='project',  
24 - ),  
25 - migrations.AddField(  
26 - model_name='project',  
27 - name='creator',  
28 - field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='project_creator', to=settings.AUTH_USER_MODEL, verbose_name='创建人员'),  
29 - ),  
30 - ]  
1 -# Generated by Django 3.1.1 on 2020-10-07 08:26  
2 -  
3 -from django.conf import settings  
4 -from django.db import migrations, models  
5 -import django.db.models.deletion  
6 -  
7 -  
8 -class Migration(migrations.Migration):  
9 -  
10 - dependencies = [  
11 - migrations.swappable_dependency(settings.AUTH_USER_MODEL),  
12 - ('project', '0009_auto_20201007_1626'),  
13 - ]  
14 -  
15 - operations = [  
16 - migrations.AlterField(  
17 - model_name='project',  
18 - name='creator',  
19 - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_creator', to=settings.AUTH_USER_MODEL, verbose_name='创建人员'),  
20 - ),  
21 - ]  
1 -# Generated by Django 3.1.1 on 2020-10-07 09:16  
2 -  
3 -from django.db import migrations, models  
4 -  
5 -  
6 -class Migration(migrations.Migration):  
7 -  
8 - dependencies = [  
9 - ('project', '0010_auto_20201007_1626'),  
10 - ]  
11 -  
12 - operations = [  
13 - migrations.AlterModelOptions(  
14 - name='auditor',  
15 - options={'ordering': ('order',)},  
16 - ),  
17 - migrations.AddField(  
18 - model_name='auditor',  
19 - name='order',  
20 - field=models.PositiveSmallIntegerField(blank=True, default=0, null=True, verbose_name='排序'),  
21 - ),  
22 - ]  
@@ -17,7 +17,7 @@ class AuditorSerializer(serializers.ModelSerializer): @@ -17,7 +17,7 @@ class AuditorSerializer(serializers.ModelSerializer):
17 17
18 18
19 class ProjectSerializer(serializers.ModelSerializer): 19 class ProjectSerializer(serializers.ModelSerializer):
20 - creator = serializers.ReadOnlyField(source='project_creator.id') 20 + creator = serializers.ReadOnlyField(source='project_creator')
21 # teacher = serializers.ReadOnlyField(source='teacher.username') # 外键字段 只读 21 # teacher = serializers.ReadOnlyField(source='teacher.username') # 外键字段 只读
22 22
23 class Meta: 23 class Meta:
@@ -11,6 +11,7 @@ from .serializers import ProjectSerializer @@ -11,6 +11,7 @@ from .serializers import ProjectSerializer
11 from .models import Auditor, Project, Result 11 from .models import Auditor, Project, Result
12 from utils.helpers import WxPushHelper 12 from utils.helpers import WxPushHelper
13 from utils.pagination import MyPageNumberPagination 13 from utils.pagination import MyPageNumberPagination
  14 +from utils.util import response
14 15
15 16
16 class CreateProject(CreateAPIView): 17 class CreateProject(CreateAPIView):
@@ -29,7 +30,7 @@ class CreateProject(CreateAPIView): @@ -29,7 +30,7 @@ class CreateProject(CreateAPIView):
29 obj_dict = serializer.data 30 obj_dict = serializer.data
30 wx_client.push_card(request.user.wx_token, 31 wx_client.push_card(request.user.wx_token,
31 reverse("project:retrieve_project", kwargs={"pk": obj_dict['id']}), u"流程创建成功") 32 reverse("project:retrieve_project", kwargs={"pk": obj_dict['id']}), u"流程创建成功")
32 - return Response(obj_dict) 33 + return response(obj_dict)
33 34
34 35
35 class ProjectDetail(RetrieveAPIView): 36 class ProjectDetail(RetrieveAPIView):
@@ -37,6 +38,8 @@ class ProjectDetail(RetrieveAPIView): @@ -37,6 +38,8 @@ class ProjectDetail(RetrieveAPIView):
37 serializer_class = ProjectSerializer 38 serializer_class = ProjectSerializer
38 permission_classes = (IsAuthenticated,) 39 permission_classes = (IsAuthenticated,)
39 40
  41 + # def get_object(self):
  42 +
40 43
41 class AuditProject(UpdateAPIView): 44 class AuditProject(UpdateAPIView):
42 queryset = Project.objects.all() 45 queryset = Project.objects.all()
@@ -89,7 +92,7 @@ class AuditProject(UpdateAPIView): @@ -89,7 +92,7 @@ class AuditProject(UpdateAPIView):
89 obj.save() 92 obj.save()
90 wx_client.push_card(obj.creator.wx_token, reverse("project:retrieve_project", kwargs={"pk": obj.id}), desc) 93 wx_client.push_card(obj.creator.wx_token, reverse("project:retrieve_project", kwargs={"pk": obj.id}), desc)
91 94
92 - return Response(ProjectSerializer(obj).data) 95 + return response(ProjectSerializer(obj).data)
93 96
94 97
95 class AuditProjectsList(ListAPIView): 98 class AuditProjectsList(ListAPIView):
@@ -102,4 +105,4 @@ class AuditProjectsList(ListAPIView): @@ -102,4 +105,4 @@ class AuditProjectsList(ListAPIView):
102 105
103 def get(self, request, *args, **kwargs): 106 def get(self, request, *args, **kwargs):
104 qs = self.get_queryset(user=request.user) 107 qs = self.get_queryset(user=request.user)
105 - return Response(ProjectSerializer(qs, many=True).data) 108 + return response(ProjectSerializer(qs, many=True).data)
1 asgiref==3.2.10 1 asgiref==3.2.10
  2 +certifi==2020.6.20
  3 +chardet==3.0.4
2 Django==3.1.1 4 Django==3.1.1
3 django-cors-headers==3.5.0 5 django-cors-headers==3.5.0
  6 +django-environ==0.4.5
4 django-filter==2.4.0 7 django-filter==2.4.0
5 djangorestframework==3.12.1 8 djangorestframework==3.12.1
6 djangorestframework-simplejwt==4.4.0 9 djangorestframework-simplejwt==4.4.0
  10 +idna==2.10
7 mysqlclient==2.0.1 11 mysqlclient==2.0.1
8 Pillow==7.2.0 12 Pillow==7.2.0
9 PyJWT==1.7.1 13 PyJWT==1.7.1
10 pytz==2020.1 14 pytz==2020.1
  15 +requests==2.24.0
11 sqlparse==0.3.1 16 sqlparse==0.3.1
  17 +urllib3==1.25.10
1 -# Generated by Django 3.1.1 on 2020-09-30 07:38 1 +# Generated by Django 3.1.1 on 2020-10-08 07:45
2 2
3 from django.conf import settings 3 from django.conf import settings
4 from django.db import migrations, models 4 from django.db import migrations, models
1 -import os 1 +# _*_ coding: utf-8 _*_
  2 +# @Time : 2020/9/24 21:48
  3 +# @Author vanwhebin
2 4
3 from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager, Group, Permission 5 from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager, Group, Permission
4 from django.utils.translation import gettext_lazy as _ 6 from django.utils.translation import gettext_lazy as _
@@ -10,9 +10,9 @@ from rest_framework.generics import CreateAPIView @@ -10,9 +10,9 @@ from rest_framework.generics import CreateAPIView
10 from usercenter.serializers import MediaSerializer 10 from usercenter.serializers import MediaSerializer
11 from usercenter.models import Media 11 from usercenter.models import Media
12 from wxProject.settings import MEDIA_ROOT, UPLOAD_MEDIA_CHOICES 12 from wxProject.settings import MEDIA_ROOT, UPLOAD_MEDIA_CHOICES
13 -from utils.util import uuid, get_md5_hash, response as res 13 +from utils.util import uuid, get_md5_hash, response
14 from rest_framework.permissions import IsAuthenticated, AllowAny 14 from rest_framework.permissions import IsAuthenticated, AllowAny
15 -from rest_framework import response, status 15 +from rest_framework import status
16 16
17 17
18 class UploadMedia(CreateAPIView): 18 class UploadMedia(CreateAPIView):
@@ -25,11 +25,11 @@ class UploadMedia(CreateAPIView): @@ -25,11 +25,11 @@ class UploadMedia(CreateAPIView):
25 uploaded_file.name = uploaded_file.name.strip('"') 25 uploaded_file.name = uploaded_file.name.strip('"')
26 26
27 if not uploaded_file: 27 if not uploaded_file:
28 - return response.Response(u"文件上传失败", status=status.HTTP_400_BAD_REQUEST) 28 + return response(u"文件上传失败", status=status.HTTP_400_BAD_REQUEST)
29 ext_pos = uploaded_file.name.rfind('.') 29 ext_pos = uploaded_file.name.rfind('.')
30 uploaded_file_ext = uploaded_file.name[ext_pos:] 30 uploaded_file_ext = uploaded_file.name[ext_pos:]
31 if not self.allowed_extension(uploaded_file_ext): 31 if not self.allowed_extension(uploaded_file_ext):
32 - return response.Response(u"非法文件类型", status=status.HTTP_400_BAD_REQUEST) 32 + return response({"msg": "非法文件类型"}, status=status.HTTP_400_BAD_REQUEST)
33 hash_file_name = uuid() + uploaded_file_ext 33 hash_file_name = uuid() + uploaded_file_ext
34 time_tag = time.strftime('%Y-%m-%d') 34 time_tag = time.strftime('%Y-%m-%d')
35 file_path = time_tag + os.sep + hash_file_name 35 file_path = time_tag + os.sep + hash_file_name
@@ -53,7 +53,7 @@ class UploadMedia(CreateAPIView): @@ -53,7 +53,7 @@ class UploadMedia(CreateAPIView):
53 ) 53 )
54 os.remove(os.path.join(MEDIA_ROOT, file_path)) 54 os.remove(os.path.join(MEDIA_ROOT, file_path))
55 # return response.Response(MediaSerializer(file, context={'request': request}).data) 55 # return response.Response(MediaSerializer(file, context={'request': request}).data)
56 - return res(MediaSerializer(file, context={'request': request}).data) 56 + return response(MediaSerializer(file, context={'request': request}).data)
57 57
58 @staticmethod 58 @staticmethod
59 def allowed_extension(ext): 59 def allowed_extension(ext):
@@ -9,6 +9,7 @@ import pytz @@ -9,6 +9,7 @@ import pytz
9 import datetime 9 import datetime
10 from uuid import uuid4 10 from uuid import uuid4
11 from base64 import urlsafe_b64encode 11 from base64 import urlsafe_b64encode
  12 +from rest_framework import status
12 13
13 from django.http import JsonResponse 14 from django.http import JsonResponse
14 from wxProject.settings import TIME_ZONE, BASE_LOG_DIR 15 from wxProject.settings import TIME_ZONE, BASE_LOG_DIR
@@ -24,7 +25,7 @@ def get_yesterday(day=1): @@ -24,7 +25,7 @@ def get_yesterday(day=1):
24 return (datetime.datetime.now(pytz.timezone(TIME_ZONE)) - datetime.timedelta(days=day)).strftime("%Y-%m-%d") 25 return (datetime.datetime.now(pytz.timezone(TIME_ZONE)) - datetime.timedelta(days=day)).strftime("%Y-%m-%d")
25 26
26 27
27 -def response(data="", code=0, **kwargs): 28 +def response(data="", status_code=status.HTTP_200_OK, code=0, **kwargs):
28 """ 格式化返回信息 """ 29 """ 格式化返回信息 """
29 res = { 30 res = {
30 "code": code, 31 "code": code,
@@ -32,7 +33,7 @@ def response(data="", code=0, **kwargs): @@ -32,7 +33,7 @@ def response(data="", code=0, **kwargs):
32 "data": data, 33 "data": data,
33 } 34 }
34 res.update(kwargs) 35 res.update(kwargs)
35 - return JsonResponse(data=res) 36 + return JsonResponse(data=res, status=status_code)
36 37
37 38
38 def save_log(directory, content, log_type=None): 39 def save_log(directory, content, log_type=None):
  1 +__pycache__
1 -"""  
2 -Django settings for wxProject project.  
3 -  
4 -Generated by 'django-admin startproject' using Django 3.1.1.  
5 -  
6 -For more information on this file, see  
7 -https://docs.djangoproject.com/en/3.1/topics/settings/  
8 -  
9 -For the full list of settings and their values, see  
10 -https://docs.djangoproject.com/en/3.1/ref/settings/  
11 -""" 1 +# _*_ coding: utf-8 _*_
  2 +# @Time : 2020/9/24 21:43
  3 +# @Author vanwhebin
12 import os 4 import os
  5 +import environ
13 from pathlib import Path 6 from pathlib import Path
14 from datetime import timedelta 7 from datetime import timedelta
15 8
16 # Build paths inside the project like this: BASE_DIR / 'subdir'. 9 # Build paths inside the project like this: BASE_DIR / 'subdir'.
17 BASE_DIR = Path(__file__).resolve().parent.parent 10 BASE_DIR = Path(__file__).resolve().parent.parent
  11 +env = environ.Env()
18 12
  13 +READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=True) # 使用.env,此项设置为True
19 14
20 -# Quick-start development settings - unsuitable for production  
21 -# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ 15 +if READ_DOT_ENV_FILE:
  16 + env.read_env(os.path.join(BASE_DIR, '.env'))
22 17
23 -# SECURITY WARNING: keep the secret key used in production secret!  
24 -SECRET_KEY = '@llib83ily_q%g4)vere-+n#_6oj#b$=7r7_@btj9u5tm&1$-4' 18 +DEBUG = env.bool('DJANGO_DEBUG', False)
  19 +# DEBUG = True
25 20
26 -# SECURITY WARNING: don't run with debug turned on in production!  
27 -DEBUG = True  
28 21
29 -ALLOWED_HOSTS = ['*'] 22 +SECRET_KEY = '@llib83ily_q%g4)vere-+n#_6oj#b$=7r7_@btj9u5tm&1$-4'
30 23
  24 +ALLOWED_HOSTS = ['*']
31 25
32 -# Application definition  
33 26
34 INSTALLED_APPS = [ 27 INSTALLED_APPS = [
35 'django.contrib.admin', 28 'django.contrib.admin',
@@ -75,15 +68,30 @@ TEMPLATES = [ @@ -75,15 +68,30 @@ TEMPLATES = [
75 68
76 WSGI_APPLICATION = 'wxProject.wsgi.application' 69 WSGI_APPLICATION = 'wxProject.wsgi.application'
77 70
78 -  
79 # Database 71 # Database
80 # https://docs.djangoproject.com/en/3.1/ref/settings/#databases 72 # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
81 73
82 DATABASES = { 74 DATABASES = {
83 'default': { 75 'default': {
84 - 'ENGINE': 'django.db.backends.sqlite3',  
85 - 'NAME': BASE_DIR / 'db.sqlite3', 76 + 'ENGINE': 'django.db.backends.mysql',
  77 + 'NAME': env('MYSQL_DATABASE', default='wxproject'),
  78 + 'HOST': env('MYSQL_HOST', default='127.0.0.1'),
  79 + 'PORT': env('MYSQL_PORT', default='3306'),
  80 + 'USER': env('MYSQL_USER', default='autouser'),
  81 + 'PASSWORD': env('MYSQL_PASSWORD', default='m6Q&P0xTJ^$h3X8DAzpS!Y%Xs8'),
  82 + 'OPTIONS': {'charset': 'utf8mb4'}
86 } 83 }
  84 +
  85 + # 'default': {
  86 + # 'ENGINE': 'django.db.backends.mysql',
  87 + # 'NAME': 'wxProject',
  88 + # 'USER': 'root',
  89 + # 'PASSWORD': '123456',
  90 + # 'HOST': '127.0.0.1',
  91 + # 'PORT': '3306',
  92 + # # 'ENGINE': 'django.db.backends.sqlite3',
  93 + # # 'NAME': os.path.realpath(os.path.join(BASE_DIR, 'db.sqlite3'))
  94 + # }
87 } 95 }
88 96
89 # Password validation 97 # Password validation
@@ -134,7 +142,6 @@ CORS_ORIGIN_WHITELIST = ( @@ -134,7 +142,6 @@ CORS_ORIGIN_WHITELIST = (
134 'http://localhost:8080', # 凡是出现在白名单中的域名,都可以访问后端接口 142 'http://localhost:8080', # 凡是出现在白名单中的域名,都可以访问后端接口
135 ) 143 )
136 144
137 -  
138 REST_FRAMEWORK = { 145 REST_FRAMEWORK = {
139 # Use Django's standard `django.contrib.auth` permissions, 146 # Use Django's standard `django.contrib.auth` permissions,
140 # or allow read-only access for unauthenticated users. 147 # or allow read-only access for unauthenticated users.
@@ -167,5 +174,3 @@ SIMPLE_JWT = { @@ -167,5 +174,3 @@ SIMPLE_JWT = {
167 174
168 # 项目用户验证模型 175 # 项目用户验证模型
169 AUTH_USER_MODEL = "usercenter.User" 176 AUTH_USER_MODEL = "usercenter.User"
170 -  
171 -