mirror of
https://github.com/evgen-app/hackbot.git
synced 2024-12-04 13:53:43 +03:00
add api
This commit is contained in:
commit
5856b27dcd
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
hack
|
||||||
|
db.sqlite3
|
||||||
|
.idea
|
||||||
|
.code
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
15
.idea/hackbackend.iml
Normal file
15
.idea/hackbackend.iml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<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="TestRunnerService">
|
||||||
|
<option name="PROJECT_TEST_RUNNER" value="pytest" />
|
||||||
|
</component>
|
||||||
|
</module>
|
170
.idea/inspectionProfiles/Project_Default.xml
Normal file
170
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
<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="148">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="aniso8601" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="colorama" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="cffi" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="click" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="Jinja2" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="six" />
|
||||||
|
<item index="6" class="java.lang.String" itemvalue="opencv-python" />
|
||||||
|
<item index="7" class="java.lang.String" itemvalue="mccabe" />
|
||||||
|
<item index="8" class="java.lang.String" itemvalue="pytesseract" />
|
||||||
|
<item index="9" class="java.lang.String" itemvalue="MarkupSafe" />
|
||||||
|
<item index="10" class="java.lang.String" itemvalue="numpy" />
|
||||||
|
<item index="11" class="java.lang.String" itemvalue="pycparser" />
|
||||||
|
<item index="12" class="java.lang.String" itemvalue="toml" />
|
||||||
|
<item index="13" class="java.lang.String" itemvalue="singledispatch" />
|
||||||
|
<item index="14" class="java.lang.String" itemvalue="django-graphql-jwt" />
|
||||||
|
<item index="15" class="java.lang.String" itemvalue="greenlet" />
|
||||||
|
<item index="16" class="java.lang.String" itemvalue="testpath" />
|
||||||
|
<item index="17" class="java.lang.String" itemvalue="pickleshare" />
|
||||||
|
<item index="18" class="java.lang.String" itemvalue="defusedxml" />
|
||||||
|
<item index="19" class="java.lang.String" itemvalue="instalooter" />
|
||||||
|
<item index="20" class="java.lang.String" itemvalue="coreschema" />
|
||||||
|
<item index="21" class="java.lang.String" itemvalue="ipython-genutils" />
|
||||||
|
<item index="22" class="java.lang.String" itemvalue="Pygments" />
|
||||||
|
<item index="23" class="java.lang.String" itemvalue="bleach" />
|
||||||
|
<item index="24" class="java.lang.String" itemvalue="docutils" />
|
||||||
|
<item index="25" class="java.lang.String" itemvalue="soupsieve" />
|
||||||
|
<item index="26" class="java.lang.String" itemvalue="jsonschema" />
|
||||||
|
<item index="27" class="java.lang.String" itemvalue="pywin32" />
|
||||||
|
<item index="28" class="java.lang.String" itemvalue="terminado" />
|
||||||
|
<item index="29" class="java.lang.String" itemvalue="pydub" />
|
||||||
|
<item index="30" class="java.lang.String" itemvalue="jupyter-client" />
|
||||||
|
<item index="31" class="java.lang.String" itemvalue="jupyterlab-pygments" />
|
||||||
|
<item index="32" class="java.lang.String" itemvalue="ipykernel" />
|
||||||
|
<item index="33" class="java.lang.String" itemvalue="nbconvert" />
|
||||||
|
<item index="34" class="java.lang.String" itemvalue="attrs" />
|
||||||
|
<item index="35" class="java.lang.String" itemvalue="django-gcloud-storage" />
|
||||||
|
<item index="36" class="java.lang.String" itemvalue="jedi" />
|
||||||
|
<item index="37" class="java.lang.String" itemvalue="boto3" />
|
||||||
|
<item index="38" class="java.lang.String" itemvalue="platformdirs" />
|
||||||
|
<item index="39" class="java.lang.String" itemvalue="matplotlib" />
|
||||||
|
<item index="40" class="java.lang.String" itemvalue="drf-jwt" />
|
||||||
|
<item index="41" class="java.lang.String" itemvalue="decorator" />
|
||||||
|
<item index="42" class="java.lang.String" itemvalue="pandocfilters" />
|
||||||
|
<item index="43" class="java.lang.String" itemvalue="chempy" />
|
||||||
|
<item index="44" class="java.lang.String" itemvalue="PuLP" />
|
||||||
|
<item index="45" class="java.lang.String" itemvalue="pyrsistent" />
|
||||||
|
<item index="46" class="java.lang.String" itemvalue="XlsxWriter" />
|
||||||
|
<item index="47" class="java.lang.String" itemvalue="virtualenv-clone" />
|
||||||
|
<item index="48" class="java.lang.String" itemvalue="selenium" />
|
||||||
|
<item index="49" class="java.lang.String" itemvalue="pyOpenSSL" />
|
||||||
|
<item index="50" class="java.lang.String" itemvalue="nest-asyncio" />
|
||||||
|
<item index="51" class="java.lang.String" itemvalue="tenacity" />
|
||||||
|
<item index="52" class="java.lang.String" itemvalue="prompt-toolkit" />
|
||||||
|
<item index="53" class="java.lang.String" itemvalue="pyreadline" />
|
||||||
|
<item index="54" class="java.lang.String" itemvalue="uritemplate" />
|
||||||
|
<item index="55" class="java.lang.String" itemvalue="scipy" />
|
||||||
|
<item index="56" class="java.lang.String" itemvalue="tornado" />
|
||||||
|
<item index="57" class="java.lang.String" itemvalue="botocore" />
|
||||||
|
<item index="58" class="java.lang.String" itemvalue="Send2Trash" />
|
||||||
|
<item index="59" class="java.lang.String" itemvalue="incremental" />
|
||||||
|
<item index="60" class="java.lang.String" itemvalue="mistune" />
|
||||||
|
<item index="61" class="java.lang.String" itemvalue="autobahn" />
|
||||||
|
<item index="62" class="java.lang.String" itemvalue="mpmath" />
|
||||||
|
<item index="63" class="java.lang.String" itemvalue="debugpy" />
|
||||||
|
<item index="64" class="java.lang.String" itemvalue="itypes" />
|
||||||
|
<item index="65" class="java.lang.String" itemvalue="argon2-cffi" />
|
||||||
|
<item index="66" class="java.lang.String" itemvalue="google-api-python-client" />
|
||||||
|
<item index="67" class="java.lang.String" itemvalue="webencodings" />
|
||||||
|
<item index="68" class="java.lang.String" itemvalue="Twisted" />
|
||||||
|
<item index="69" class="java.lang.String" itemvalue="traitlets" />
|
||||||
|
<item index="70" class="java.lang.String" itemvalue="Automat" />
|
||||||
|
<item index="71" class="java.lang.String" itemvalue="pywinpty" />
|
||||||
|
<item index="72" class="java.lang.String" itemvalue="python-dateutil" />
|
||||||
|
<item index="73" class="java.lang.String" itemvalue="quantities" />
|
||||||
|
<item index="74" class="java.lang.String" itemvalue="nbclient" />
|
||||||
|
<item index="75" class="java.lang.String" itemvalue="cycler" />
|
||||||
|
<item index="76" class="java.lang.String" itemvalue="twisted-iocpsupport" />
|
||||||
|
<item index="77" class="java.lang.String" itemvalue="constantly" />
|
||||||
|
<item index="78" class="java.lang.String" itemvalue="uuid" />
|
||||||
|
<item index="79" class="java.lang.String" itemvalue="appdirs" />
|
||||||
|
<item index="80" class="java.lang.String" itemvalue="docopt" />
|
||||||
|
<item index="81" class="java.lang.String" itemvalue="filelock" />
|
||||||
|
<item index="82" class="java.lang.String" itemvalue="pyodesys" />
|
||||||
|
<item index="83" class="java.lang.String" itemvalue="pyzmq" />
|
||||||
|
<item index="84" class="java.lang.String" itemvalue="entrypoints" />
|
||||||
|
<item index="85" class="java.lang.String" itemvalue="daphne" />
|
||||||
|
<item index="86" class="java.lang.String" itemvalue="Markdown" />
|
||||||
|
<item index="87" class="java.lang.String" itemvalue="sympy" />
|
||||||
|
<item index="88" class="java.lang.String" itemvalue="notebook" />
|
||||||
|
<item index="89" class="java.lang.String" itemvalue="beautifulsoup4" />
|
||||||
|
<item index="90" class="java.lang.String" itemvalue="hyperlink" />
|
||||||
|
<item index="91" class="java.lang.String" itemvalue="service-identity" />
|
||||||
|
<item index="92" class="java.lang.String" itemvalue="kiwisolver" />
|
||||||
|
<item index="93" class="java.lang.String" itemvalue="zope.interface" />
|
||||||
|
<item index="94" class="java.lang.String" itemvalue="django-appconf" />
|
||||||
|
<item index="95" class="java.lang.String" itemvalue="dot2tex" />
|
||||||
|
<item index="96" class="java.lang.String" itemvalue="coloredlogs" />
|
||||||
|
<item index="97" class="java.lang.String" itemvalue="backcall" />
|
||||||
|
<item index="98" class="java.lang.String" itemvalue="channels" />
|
||||||
|
<item index="99" class="java.lang.String" itemvalue="json-rpc" />
|
||||||
|
<item index="100" class="java.lang.String" itemvalue="virtualenv" />
|
||||||
|
<item index="101" class="java.lang.String" itemvalue="distlib" />
|
||||||
|
<item index="102" class="java.lang.String" itemvalue="peewee-migrations" />
|
||||||
|
<item index="103" class="java.lang.String" itemvalue="async-generator" />
|
||||||
|
<item index="104" class="java.lang.String" itemvalue="oauth2client" />
|
||||||
|
<item index="105" class="java.lang.String" itemvalue="jupyter-core" />
|
||||||
|
<item index="106" class="java.lang.String" itemvalue="matplotlib-inline" />
|
||||||
|
<item index="107" class="java.lang.String" itemvalue="sym" />
|
||||||
|
<item index="108" class="java.lang.String" itemvalue="rope" />
|
||||||
|
<item index="109" class="java.lang.String" itemvalue="SQLAlchemy" />
|
||||||
|
<item index="110" class="java.lang.String" itemvalue="httplib2" />
|
||||||
|
<item index="111" class="java.lang.String" itemvalue="wcwidth" />
|
||||||
|
<item index="112" class="java.lang.String" itemvalue="fs" />
|
||||||
|
<item index="113" class="java.lang.String" itemvalue="djangorestframework-stubs" />
|
||||||
|
<item index="114" class="java.lang.String" itemvalue="verboselogs" />
|
||||||
|
<item index="115" class="java.lang.String" itemvalue="backports.entry-points-selectable" />
|
||||||
|
<item index="116" class="java.lang.String" itemvalue="google-auth-httplib2" />
|
||||||
|
<item index="117" class="java.lang.String" itemvalue="txaio" />
|
||||||
|
<item index="118" class="java.lang.String" itemvalue="amply" />
|
||||||
|
<item index="119" class="java.lang.String" itemvalue="urllib3" />
|
||||||
|
<item index="120" class="java.lang.String" itemvalue="django-googledrive-storage" />
|
||||||
|
<item index="121" class="java.lang.String" itemvalue="parso" />
|
||||||
|
<item index="122" class="java.lang.String" itemvalue="pyTelegramBotAPI" />
|
||||||
|
<item index="123" class="java.lang.String" itemvalue="nbformat" />
|
||||||
|
<item index="124" class="java.lang.String" itemvalue="ipython" />
|
||||||
|
<item index="125" class="java.lang.String" itemvalue="humanfriendly" />
|
||||||
|
<item index="126" class="java.lang.String" itemvalue="prometheus-client" />
|
||||||
|
<item index="127" class="java.lang.String" itemvalue="tqdm" />
|
||||||
|
<item index="128" class="java.lang.String" itemvalue="coreapi" />
|
||||||
|
<item index="129" class="java.lang.String" itemvalue="pyneqsys" />
|
||||||
|
<item index="130" class="java.lang.String" itemvalue="Django" />
|
||||||
|
<item index="131" class="java.lang.String" itemvalue="zipp" />
|
||||||
|
<item index="132" class="java.lang.String" itemvalue="tzdata" />
|
||||||
|
<item index="133" class="java.lang.String" itemvalue="asgiref" />
|
||||||
|
<item index="134" class="java.lang.String" itemvalue="pytz" />
|
||||||
|
<item index="135" class="java.lang.String" itemvalue="importlib-metadata" />
|
||||||
|
<item index="136" class="java.lang.String" itemvalue="sqlparse" />
|
||||||
|
<item index="137" class="java.lang.String" itemvalue="whitenois" />
|
||||||
|
<item index="138" class="java.lang.String" itemvalue="whitenoise" />
|
||||||
|
<item index="139" class="java.lang.String" itemvalue="django-flat-theme" />
|
||||||
|
<item index="140" class="java.lang.String" itemvalue="django-ckeditor" />
|
||||||
|
<item index="141" class="java.lang.String" itemvalue="django-flat-responsive" />
|
||||||
|
<item index="142" class="java.lang.String" itemvalue="django-colorfield" />
|
||||||
|
<item index="143" class="java.lang.String" itemvalue="django-js-asset" />
|
||||||
|
<item index="144" class="java.lang.String" itemvalue="django-cors-headers" />
|
||||||
|
<item index="145" class="java.lang.String" itemvalue="django-admin-interface" />
|
||||||
|
<item index="146" class="java.lang.String" itemvalue="djangorestframework" />
|
||||||
|
<item index="147" class="java.lang.String" itemvalue="psycopg2" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredIdentifiers">
|
||||||
|
<list>
|
||||||
|
<option value="telebot.types.InlineKeyboardMarkup" />
|
||||||
|
<option value="telebot.types.KeyboardButton" />
|
||||||
|
<option value="telebot.types.InlineKeyboardButton" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
7
.idea/misc.xml
Normal file
7
.idea/misc.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PyCharmProfessionalAdvertiser">
|
||||||
|
<option name="shown" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/hackbackend.iml" filepath="$PROJECT_DIR$/.idea/hackbackend.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
0
api/__init__.py
Normal file
0
api/__init__.py
Normal file
BIN
api/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
api/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/admin.cpython-39.pyc
Normal file
BIN
api/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/apps.cpython-39.pyc
Normal file
BIN
api/__pycache__/apps.cpython-39.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/models.cpython-39.pyc
Normal file
BIN
api/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/serializers.cpython-39.pyc
Normal file
BIN
api/__pycache__/serializers.cpython-39.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/urls.cpython-39.pyc
Normal file
BIN
api/__pycache__/urls.cpython-39.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/views.cpython-39.pyc
Normal file
BIN
api/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
3
api/admin.py
Normal file
3
api/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
api/apps.py
Normal file
6
api/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ApiConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'api'
|
0
api/migrations/__init__.py
Normal file
0
api/migrations/__init__.py
Normal file
BIN
api/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
api/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
3
api/models.py
Normal file
3
api/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
14
api/serializers.py
Normal file
14
api/serializers.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from rest_framework.serializers import ModelSerializer
|
||||||
|
from chat_models.models import Chat, Message
|
||||||
|
|
||||||
|
|
||||||
|
class ChatSerializer(ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Chat
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
|
||||||
|
class MessageSerializer(ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Message
|
||||||
|
fields = "__all__"
|
3
api/tests.py
Normal file
3
api/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
10
api/urls.py
Normal file
10
api/urls.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from django.urls import path
|
||||||
|
from .views import ListCreateMessage, ListCreateChat, RetrieveUpdateMessage, RetrieveUpdateDestroyChat
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("chat", ListCreateChat.as_view()),
|
||||||
|
path("message", ListCreateMessage.as_view()),
|
||||||
|
path("chat/<pk>", RetrieveUpdateDestroyChat.as_view()),
|
||||||
|
path("message/<pk>", RetrieveUpdateMessage.as_view())
|
||||||
|
]
|
23
api/views.py
Normal file
23
api/views.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
from .serializers import ChatSerializer, MessageSerializer
|
||||||
|
from chat_models.models import Chat, Message
|
||||||
|
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateAPIView, RetrieveUpdateDestroyAPIView
|
||||||
|
|
||||||
|
|
||||||
|
class ListCreateMessage(ListCreateAPIView):
|
||||||
|
serializer_class = MessageSerializer
|
||||||
|
queryset = Message.objects.all()
|
||||||
|
|
||||||
|
|
||||||
|
class ListCreateChat(ListCreateAPIView):
|
||||||
|
serializer_class = ChatSerializer
|
||||||
|
queryset = Chat.objects.all()
|
||||||
|
|
||||||
|
|
||||||
|
class RetrieveUpdateMessage(RetrieveUpdateAPIView):
|
||||||
|
queryset = Message.objects.all()
|
||||||
|
serializer_class = MessageSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class RetrieveUpdateDestroyChat(RetrieveUpdateAPIView):
|
||||||
|
queryset = Chat.objects.all()
|
||||||
|
serializer_class = ChatSerializer
|
0
chat_models/__init__.py
Normal file
0
chat_models/__init__.py
Normal file
BIN
chat_models/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
chat_models/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
chat_models/__pycache__/admin.cpython-39.pyc
Normal file
BIN
chat_models/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
chat_models/__pycache__/apps.cpython-39.pyc
Normal file
BIN
chat_models/__pycache__/apps.cpython-39.pyc
Normal file
Binary file not shown.
BIN
chat_models/__pycache__/models.cpython-39.pyc
Normal file
BIN
chat_models/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
3
chat_models/admin.py
Normal file
3
chat_models/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
chat_models/apps.py
Normal file
6
chat_models/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ChatModelsConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'chat_models'
|
33
chat_models/migrations/0001_initial.py
Normal file
33
chat_models/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# Generated by Django 4.0.3 on 2022-03-18 15:07
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Chat',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.TextField()),
|
||||||
|
('start_message', models.TextField(blank=True)),
|
||||||
|
('api_key', models.TextField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Message',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('text', models.TextField()),
|
||||||
|
('author', models.TextField()),
|
||||||
|
('chat', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='chat_models.chat')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
0
chat_models/migrations/__init__.py
Normal file
0
chat_models/migrations/__init__.py
Normal file
BIN
chat_models/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
BIN
chat_models/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
Binary file not shown.
BIN
chat_models/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
chat_models/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
13
chat_models/models.py
Normal file
13
chat_models/models.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Chat(models.Model):
|
||||||
|
name = models.TextField()
|
||||||
|
start_message = models.TextField(blank=True)
|
||||||
|
api_key = models.TextField()
|
||||||
|
|
||||||
|
|
||||||
|
class Message(models.Model):
|
||||||
|
text = models.TextField()
|
||||||
|
author = models.TextField()
|
||||||
|
chat = models.ForeignKey(Chat, on_delete=models.CASCADE)
|
3
chat_models/tests.py
Normal file
3
chat_models/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
chat_models/views.py
Normal file
3
chat_models/views.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
0
hackbackend/__init__.py
Normal file
0
hackbackend/__init__.py
Normal file
BIN
hackbackend/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
hackbackend/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
hackbackend/__pycache__/settings.cpython-39.pyc
Normal file
BIN
hackbackend/__pycache__/settings.cpython-39.pyc
Normal file
Binary file not shown.
BIN
hackbackend/__pycache__/urls.cpython-39.pyc
Normal file
BIN
hackbackend/__pycache__/urls.cpython-39.pyc
Normal file
Binary file not shown.
BIN
hackbackend/__pycache__/wsgi.cpython-39.pyc
Normal file
BIN
hackbackend/__pycache__/wsgi.cpython-39.pyc
Normal file
Binary file not shown.
16
hackbackend/asgi.py
Normal file
16
hackbackend/asgi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
ASGI config for hackbackend 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/4.0/howto/deployment/asgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hackbackend.settings')
|
||||||
|
|
||||||
|
application = get_asgi_application()
|
126
hackbackend/settings.py
Normal file
126
hackbackend/settings.py
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
"""
|
||||||
|
Django settings for hackbackend project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 4.0.3.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.0/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/4.0/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
|
SECRET_KEY = 'django-insecure-6(#2x^yq=plz6ou!=_8wke%trs_+*80$vuorx4ybh@dhx7xpzg'
|
||||||
|
|
||||||
|
# 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',
|
||||||
|
'chat_models',
|
||||||
|
'api'
|
||||||
|
]
|
||||||
|
|
||||||
|
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 = 'hackbackend.urls'
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': [],
|
||||||
|
'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 = 'hackbackend.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = 'static/'
|
||||||
|
|
||||||
|
# Default primary key field type
|
||||||
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
||||||
|
|
||||||
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
22
hackbackend/urls.py
Normal file
22
hackbackend/urls.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
"""hackbackend URL Configuration
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/4.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.contrib import admin
|
||||||
|
from django.urls import path, include
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
path('api/', include("api.urls"))
|
||||||
|
]
|
16
hackbackend/wsgi.py
Normal file
16
hackbackend/wsgi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
WSGI config for hackbackend 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/4.0/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hackbackend.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
22
manage.py
Normal file
22
manage.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""Django's command-line utility for administrative tasks."""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Run administrative tasks."""
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hackbackend.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()
|
6
requirements.txt
Normal file
6
requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
asgiref==3.5.0
|
||||||
|
Django==4.0.3
|
||||||
|
djangorestframework==3.13.1
|
||||||
|
pytz==2021.3
|
||||||
|
sqlparse==0.4.2
|
||||||
|
tzdata==2022.1
|
Loading…
Reference in New Issue
Block a user