finished the front for the task manager

This commit is contained in:
celeste
2026-03-01 14:04:21 +01:00
parent 8c368f3c8e
commit 358df6e0bd
66 changed files with 1319 additions and 179 deletions

0
back/testapp/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
back/testapp/admin.py Normal file
View File

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

5
back/testapp/apps.py Normal file
View File

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

View File

@@ -0,0 +1,23 @@
# Generated by Django 6.0.2 on 2026-02-21 15:43
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='task',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('task_text', models.CharField(max_length=1024)),
('pub_date', models.DateTimeField(verbose_name='date published')),
('done', models.BooleanField(default=False)),
],
),
]

View File

9
back/testapp/models.py Normal file
View File

@@ -0,0 +1,9 @@
from django.db import models
# Create your models here.
class Task (models.Model) :
task_text = models.CharField(max_length=1024)
pub_date = models.DateTimeField("date published")
done = models.BooleanField(default=False)

3
back/testapp/tests.py Normal file
View File

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

6
back/testapp/urls.py Normal file
View File

@@ -0,0 +1,6 @@
from django.urls import path
from .views import getAllTasks
urlpatterns = [
path("getAllTasks", getAllTasks, name="api_view")
]

36
back/testapp/views.py Normal file
View File

@@ -0,0 +1,36 @@
from django.shortcuts import render
from django.http import JsonResponse
import json
from datetime import datetime
from .models import Task
# Create your views here.
from django.forms.models import model_to_dict
from rest_framework.response import Response
from rest_framework.decorators import api_view
@api_view(['GET'])
def getAllTasks(request, *args, **kwargs) :
#data = json.loads(request.body)
#print(data)
#data = {"salutation":"wsh wsh "+data["name"]}
#return JsonResponse(data)
query = Task.objects.all().order_by("?")
print("query : ", query)
data = {"data" : []}
if query and len(query) > 0 :
for q in query :
sub_data = {}
sub_data["text"] = q.task_text
sub_data["pub date"] = q.pub_date.strftime('%m/%d/%Y at %H')
sub_data["done"] = q.done
data["data"].append(sub_data)
#equivalent à model_to_dict
return Response(data)