zhuangyp 4 éve
commit
6756d11a1f
40 módosított fájl, 480 hozzáadás és 0 törlés
  1. 8 0
      .idea/.gitignore
  2. 28 0
      .idea/PyCharmItems1.iml
  3. 5 0
      .idea/codeStyles/codeStyleConfig.xml
  4. 6 0
      .idea/inspectionProfiles/profiles_settings.xml
  5. 7 0
      .idea/misc.xml
  6. 8 0
      .idea/modules.xml
  7. 7 0
      .idea/vcs.xml
  8. 15 0
      Pipfile
  9. 84 0
      Pipfile.lock
  10. 0 0
      PyCharmItems1/__init__.py
  11. BIN
      PyCharmItems1/__pycache__/__init__.cpython-37.pyc
  12. BIN
      PyCharmItems1/__pycache__/settings.cpython-37.pyc
  13. BIN
      PyCharmItems1/__pycache__/urls.cpython-37.pyc
  14. BIN
      PyCharmItems1/__pycache__/wsgi.cpython-37.pyc
  15. 16 0
      PyCharmItems1/asgi.py
  16. 121 0
      PyCharmItems1/settings.py
  17. 24 0
      PyCharmItems1/urls.py
  18. 16 0
      PyCharmItems1/wsgi.py
  19. 0 0
      README.md
  20. BIN
      __pycache__/manage.cpython-37.pyc
  21. 0 0
      db.sqlite3
  22. 21 0
      manage.py
  23. 0 0
      workreport/__init__.py
  24. BIN
      workreport/__pycache__/__init__.cpython-37.pyc
  25. BIN
      workreport/__pycache__/admin.cpython-37.pyc
  26. BIN
      workreport/__pycache__/models.cpython-37.pyc
  27. BIN
      workreport/__pycache__/serializers.cpython-37.pyc
  28. BIN
      workreport/__pycache__/urls.cpython-37.pyc
  29. BIN
      workreport/__pycache__/views.cpython-37.pyc
  30. 3 0
      workreport/admin.py
  31. 5 0
      workreport/apps.py
  32. 32 0
      workreport/migrations/0001_initial.py
  33. 0 0
      workreport/migrations/__init__.py
  34. BIN
      workreport/migrations/__pycache__/0001_initial.cpython-37.pyc
  35. BIN
      workreport/migrations/__pycache__/__init__.cpython-37.pyc
  36. 17 0
      workreport/models.py
  37. 9 0
      workreport/serializers.py
  38. 3 0
      workreport/tests.py
  39. 15 0
      workreport/urls.py
  40. 30 0
      workreport/views.py

+ 8 - 0
.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/

+ 28 - 0
.idea/PyCharmItems1.iml

@@ -0,0 +1,28 @@
+<?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="PyCharmItems1/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="jdk" jdkName="Python 3.7 (PyCharmItems1-Dekkwl70)" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="TemplatesService">
+    <option name="TEMPLATE_CONFIGURATION" value="Django" />
+    <option name="TEMPLATE_FOLDERS">
+      <list>
+        <option value="$MODULE_DIR$/../PyCharmItems1\templates" />
+      </list>
+    </option>
+  </component>
+</module>

+ 5 - 0
.idea/codeStyles/codeStyleConfig.xml

@@ -0,0 +1,5 @@
+<component name="ProjectCodeStyleConfiguration">
+  <state>
+    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
+  </state>
+</component>

+ 6 - 0
.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>

+ 7 - 0
.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JavaScriptSettings">
+    <option name="languageLevel" value="ES6" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (PyCharmItems1-Dekkwl70)" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
.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/PyCharmItems1.iml" filepath="$PROJECT_DIR$/.idea/PyCharmItems1.iml" />
+    </modules>
+  </component>
+</project>

+ 7 - 0
.idea/vcs.xml

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

+ 15 - 0
Pipfile

@@ -0,0 +1,15 @@
+[[source]]
+name = "pypi"
+url = "https://mirrors.aliyun.com/pypi/simple/"
+verify_ssl = true
+
+[dev-packages]
+
+[packages]
+django = "*"
+django-restframework = "*"
+djangorestframework-bulk = "*"
+mysqlclient = "*"
+
+[requires]
+python_version = "3.7"

+ 84 - 0
Pipfile.lock

@@ -0,0 +1,84 @@
+{
+    "_meta": {
+        "hash": {
+            "sha256": "49edf963b451d99cf67dc10752e8c513f962ea5642c41019d05bd4df301cfbd1"
+        },
+        "pipfile-spec": 6,
+        "requires": {
+            "python_version": "3.7"
+        },
+        "sources": [
+            {
+                "name": "pypi",
+                "url": "https://mirrors.aliyun.com/pypi/simple/",
+                "verify_ssl": true
+            }
+        ]
+    },
+    "default": {
+        "asgiref": {
+            "hashes": [
+                "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a",
+                "sha256:9fc6fb5d39b8af147ba40765234fa822b39818b12cc80b35ad9b0cef3a476aed"
+            ],
+            "markers": "python_version >= '3.5'",
+            "version": "==3.2.10"
+        },
+        "django": {
+            "hashes": [
+                "sha256:31a5fbbea5fc71c99e288ec0b2f00302a0a92c44b13ede80b73a6a4d6d205582",
+                "sha256:5457fc953ec560c5521b41fad9e6734a4668b7ba205832191bbdff40ec61073c"
+            ],
+            "index": "pypi",
+            "version": "==3.0.8"
+        },
+        "django-restframework": {
+            "hashes": [
+                "sha256:2bec9265463693ada558ad9a58c31f6f3de005a932fbfeaadf983c5c9f3b7058"
+            ],
+            "index": "pypi",
+            "version": "==0.0.1"
+        },
+        "djangorestframework": {
+            "hashes": [
+                "sha256:05809fc66e1c997fd9a32ea5730d9f4ba28b109b9da71fccfa5ff241201fd0a4",
+                "sha256:e782087823c47a26826ee5b6fa0c542968219263fb3976ec3c31edab23a4001f"
+            ],
+            "markers": "python_version >= '3.5'",
+            "version": "==3.11.0"
+        },
+        "djangorestframework-bulk": {
+            "hashes": [
+                "sha256:39230d8379acebd86d313df6c9150cafecb636eae1d097c30a26389ab9fee5b1"
+            ],
+            "index": "pypi",
+            "version": "==0.2.1"
+        },
+        "mysqlclient": {
+            "hashes": [
+                "sha256:3f39855a4ad22805361e782cc4d1010ac74796225fa2d1c03cc16673ccdc983a",
+                "sha256:a6b5648f648b16335e3b1aaec93dc3fcc81a9a661180e306936437cc522c810b",
+                "sha256:edd42ccaa444b00702d5374b2f5f7585c9d0ce201917f15339f1c3cf91c1b1ed",
+                "sha256:fb2f75aea14722390d2d8ddf384ad99da708c707a96656210a7be8af20a2c5e5"
+            ],
+            "index": "pypi",
+            "version": "==2.0.1"
+        },
+        "pytz": {
+            "hashes": [
+                "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed",
+                "sha256:c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048"
+            ],
+            "version": "==2020.1"
+        },
+        "sqlparse": {
+            "hashes": [
+                "sha256:022fb9c87b524d1f7862b3037e541f68597a730a8843245c349fc93e1643dc4e",
+                "sha256:e162203737712307dfe78860cc56c8da8a852ab2ee33750e33aeadf38d12c548"
+            ],
+            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
+            "version": "==0.3.1"
+        }
+    },
+    "develop": {}
+}

+ 0 - 0
PyCharmItems1/__init__.py


BIN
PyCharmItems1/__pycache__/__init__.cpython-37.pyc


BIN
PyCharmItems1/__pycache__/settings.cpython-37.pyc


BIN
PyCharmItems1/__pycache__/urls.cpython-37.pyc


BIN
PyCharmItems1/__pycache__/wsgi.cpython-37.pyc


+ 16 - 0
PyCharmItems1/asgi.py

@@ -0,0 +1,16 @@
+"""
+ASGI config for PyCharmItems1 project.
+
+It exposes the ASGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PyCharmItems1.settings')
+
+application = get_asgi_application()

+ 121 - 0
PyCharmItems1/settings.py

@@ -0,0 +1,121 @@
+"""
+Django settings for PyCharmItems1 project.
+
+Generated by 'django-admin startproject' using Django 3.0.8.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/3.0/ref/settings/
+"""
+
+import os
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '$=o$843^0xa2djpn9r6mqzn$%dzp=u#m@&&w=z_!q^%$gtw0$r'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = []
+
+# Application definition
+
+INSTALLED_APPS = [
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    'rest_framework',
+    'workreport',
+]
+
+MIDDLEWARE = [
+    'django.middleware.security.SecurityMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ROOT_URLCONF = 'PyCharmItems1.urls'
+
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': [os.path.join(BASE_DIR, 'templates')]
+        ,
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                'django.template.context_processors.debug',
+                'django.template.context_processors.request',
+                'django.contrib.auth.context_processors.auth',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    },
+]
+
+WSGI_APPLICATION = 'PyCharmItems1.wsgi.application'
+
+# Database
+# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.mysql',
+        'NAME': 'zhuangyp_django_demo',
+        'USER': 'root',
+        'PASSWORD': 'abc.123',
+        'HOST': 'srv.test.linkerplus.com',
+        'PORT': '3310'
+    }
+}
+
+# Password validation
+# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+    {
+        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
+    },
+]
+
+# Internationalization
+# https://docs.djangoproject.com/en/3.0/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/3.0/howto/static-files/
+
+STATIC_URL = '/static/'

+ 24 - 0
PyCharmItems1/urls.py

@@ -0,0 +1,24 @@
+"""PyCharmItems1 URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+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 import url
+from django.contrib import admin
+from django.urls import path, include
+
+urlpatterns = [
+    path('admin/', admin.site.urls),
+    url(r'^api-auth/', include('rest_framework.urls')),
+    url(r'^report/', include('workreport.urls'))
+]

+ 16 - 0
PyCharmItems1/wsgi.py

@@ -0,0 +1,16 @@
+"""
+WSGI config for PyCharmItems1 project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PyCharmItems1.settings')
+
+application = get_wsgi_application()

+ 0 - 0
README.md


BIN
__pycache__/manage.cpython-37.pyc


+ 0 - 0
db.sqlite3


+ 21 - 0
manage.py

@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PyCharmItems1.settings')
+    try:
+        from django.core.management import execute_from_command_line
+    except ImportError as exc:
+        raise ImportError(
+            "Couldn't import Django. Are you sure it's installed and "
+            "available on your PYTHONPATH environment variable? Did you "
+            "forget to activate a virtual environment?"
+        ) from exc
+    execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+    main()

+ 0 - 0
workreport/__init__.py


BIN
workreport/__pycache__/__init__.cpython-37.pyc


BIN
workreport/__pycache__/admin.cpython-37.pyc


BIN
workreport/__pycache__/models.cpython-37.pyc


BIN
workreport/__pycache__/serializers.cpython-37.pyc


BIN
workreport/__pycache__/urls.cpython-37.pyc


BIN
workreport/__pycache__/views.cpython-37.pyc


+ 3 - 0
workreport/admin.py

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

+ 5 - 0
workreport/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class WorkreportConfig(AppConfig):
+    name = 'workreport'

+ 32 - 0
workreport/migrations/0001_initial.py

@@ -0,0 +1,32 @@
+# Generated by Django 3.0.8 on 2020-07-16 07:00
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='DailyReport',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('title', models.CharField(max_length=50)),
+                ('content', models.TextField()),
+                ('create_at', models.DateTimeField(auto_now=True)),
+                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE,
+                                                to=settings.AUTH_USER_MODEL)),
+            ],
+            options={
+                'verbose_name': '工作汇报',
+                'verbose_name_plural': '工作汇报表',
+                'db_table': 'workreport_daily',
+            },
+        ),
+    ]

+ 0 - 0
workreport/migrations/__init__.py


BIN
workreport/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN
workreport/migrations/__pycache__/__init__.cpython-37.pyc


+ 17 - 0
workreport/models.py

@@ -0,0 +1,17 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+
+# Create your models here.
+
+class DailyReport(models.Model):
+    title = models.CharField(max_length=50)
+    content = models.TextField()
+    create_at = models.DateTimeField(auto_now=True)
+    create_by = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
+
+    class Meta:
+        app_label = 'workreport'
+        db_table = 'workreport_daily'
+        verbose_name = '工作汇报'
+        verbose_name_plural = '工作汇报表'

+ 9 - 0
workreport/serializers.py

@@ -0,0 +1,9 @@
+from rest_framework import serializers
+
+from workreport.models import DailyReport
+
+
+class DailyReportSerialiser(serializers.ModelSerializer):
+    class Meta:
+        model = DailyReport
+        fields = ('__all__')

+ 3 - 0
workreport/tests.py

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

+ 15 - 0
workreport/urls.py

@@ -0,0 +1,15 @@
+from django.conf.urls import url
+
+from rest_framework_bulk.routes import BulkRouter
+
+from workreport.views import ReportView, DailyReportView
+
+router = BulkRouter()
+router.register(r'dailyreport', DailyReportView)
+
+urlpatterns = router.urls
+
+urlpatterns += [
+    url(r'^report/', ReportView.as_view())
+
+]

+ 30 - 0
workreport/views.py

@@ -0,0 +1,30 @@
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework import status
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from rest_framework.viewsets import ModelViewSet
+
+from workreport.models import DailyReport
+from workreport.serializers import DailyReportSerialiser
+
+
+class ReportView(APIView):
+    def get(self, request):
+        data = DailyReport.objects.values('title', 'content', 'content', 'create_at', 'id')
+        return Response(data=data, status=status.HTTP_200_OK)
+
+    def post(self, request):
+        data = request.data
+        report = DailyReport(title=data['title'], content=data['content'], create_by_id=data['create_by_id'])
+        report.save()
+        return Response(status=status.HTTP_201_CREATED)
+
+    def delete(self, instance):
+        pass
+
+class DailyReportView(ModelViewSet):
+    queryset = DailyReport.objects.all()
+    serializer_class = DailyReportSerialiser
+