chore: remove sample comments
TS Lint / ESLint (push) Successful in 7m49s
Python Lint CI / ruff (push) Successful in 8m2s
Python Lint CI / ty (push) Successful in 8m1s
Python Lint CI / ruff-format-check (push) Successful in 8m1s
TS Lint / Oxlint (push) Successful in 4m11s
TS Lint / TypeScript (push) Successful in 4m6s
TS Lint / ESLint (push) Successful in 7m49s
Python Lint CI / ruff (push) Successful in 8m2s
Python Lint CI / ty (push) Successful in 8m1s
Python Lint CI / ruff-format-check (push) Successful in 8m1s
TS Lint / Oxlint (push) Successful in 4m11s
TS Lint / TypeScript (push) Successful in 4m6s
This commit is contained in:
@@ -4,18 +4,23 @@ from uuid import uuid4
|
||||
from tortoise import fields
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
operations = [
|
||||
ops.CreateModel(
|
||||
name='Comment',
|
||||
name='Task',
|
||||
fields=[
|
||||
('id', fields.UUIDField(primary_key=True, default=uuid4, unique=True, db_index=True)),
|
||||
('created_at', fields.DatetimeField(auto_now=False, auto_now_add=True)),
|
||||
('updated_at', fields.DatetimeField(auto_now=True, auto_now_add=False)),
|
||||
('content', fields.TextField(unique=False)),
|
||||
('list_name', fields.CharField(db_index=True, max_length=32)),
|
||||
('name', fields.TextField(unique=False)),
|
||||
('reset_cron', fields.CharField(null=True, max_length=32)),
|
||||
('check_date', fields.DatetimeField(null=True, auto_now=False, auto_now_add=False)),
|
||||
('previous_check_date', fields.DatetimeField(null=True, auto_now=False, auto_now_add=False)),
|
||||
],
|
||||
options={'table': 'comment', 'app': 'models', 'pk_attr': 'id'},
|
||||
options={'table': 'task', 'app': 'models', 'pk_attr': 'id'},
|
||||
bases=['AbstractModel'],
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
from tortoise import migrations
|
||||
from tortoise.migrations import operations as ops
|
||||
from uuid import uuid4
|
||||
from tortoise import fields
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [('models', '0001_initial')]
|
||||
|
||||
initial = False
|
||||
|
||||
operations = [
|
||||
ops.CreateModel(
|
||||
name='Task',
|
||||
fields=[
|
||||
('id', fields.UUIDField(primary_key=True, default=uuid4, unique=True, db_index=True)),
|
||||
('created_at', fields.DatetimeField(auto_now=False, auto_now_add=True)),
|
||||
('updated_at', fields.DatetimeField(auto_now=True, auto_now_add=False)),
|
||||
('list_name', fields.CharField(db_index=True, max_length=32)),
|
||||
('name', fields.TextField(unique=False)),
|
||||
('reset_cron', fields.CharField(null=True, max_length=32)),
|
||||
('check_date', fields.DatetimeField(null=True, auto_now=False, auto_now_add=False)),
|
||||
('previous_check_date', fields.DatetimeField(null=True, auto_now=False, auto_now_add=False)),
|
||||
],
|
||||
options={'table': 'task', 'app': 'models', 'pk_attr': 'id'},
|
||||
bases=['AbstractModel'],
|
||||
),
|
||||
]
|
||||
@@ -1,2 +1 @@
|
||||
from .comment import Comment # noqa: F401
|
||||
from .task import Task # noqa: F401
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import tortoise
|
||||
|
||||
from app.models.base import AbstractModel
|
||||
|
||||
|
||||
class Comment(AbstractModel):
|
||||
content = tortoise.fields.TextField(null=False)
|
||||
+1
-11
@@ -8,7 +8,7 @@ import gunicorn.app.base
|
||||
import tortoise
|
||||
|
||||
from app import PKG_NAME
|
||||
from app.models import Comment, Task
|
||||
from app.models import Task
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from app.params import Parameters
|
||||
@@ -41,16 +41,6 @@ class Server(gunicorn.app.base.BaseApplication):
|
||||
def index() -> str:
|
||||
return flask.render_template("index.html")
|
||||
|
||||
@self.app.route("/api/comments", methods=["GET"])
|
||||
async def get_comments() -> list:
|
||||
return await Comment.all().order_by("created_at").values()
|
||||
|
||||
@self.app.route("/api/comments", methods=["POST"])
|
||||
async def post_comment() -> tuple[str, int]:
|
||||
data = flask.request.get_json()
|
||||
await Comment.create(content=data["content"])
|
||||
return ("", 204)
|
||||
|
||||
@self.app.route("/api/lists/<list_name>/tasks", methods=["GET"])
|
||||
async def get_tasks(list_name: str) -> list:
|
||||
return await Task.filter(list_name=list_name).values()
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import type { Comment } from "@/types";
|
||||
|
||||
export async function getComments(): Promise<Comment[]> {
|
||||
const response = await fetch("/api/comments");
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function postComment(content: string): Promise<void> {
|
||||
await fetch("/api/comments", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ content }),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user