From 1c7c94312f16408883eb7f9d4f8b384dc0eb72e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20S=C3=BCckr?= Date: Sat, 30 Nov 2024 15:23:12 +0100 Subject: [PATCH 1/2] feat(tutorial): init Django app --- comrade/comrade_tutorial/__init__.py | 0 comrade/comrade_tutorial/admin.py | 3 +++ comrade/comrade_tutorial/apps.py | 6 ++++++ comrade/comrade_tutorial/migrations/__init__.py | 0 comrade/comrade_tutorial/models.py | 3 +++ comrade/comrade_tutorial/tests.py | 3 +++ comrade/comrade_tutorial/views.py | 3 +++ 7 files changed, 18 insertions(+) create mode 100644 comrade/comrade_tutorial/__init__.py create mode 100644 comrade/comrade_tutorial/admin.py create mode 100644 comrade/comrade_tutorial/apps.py create mode 100644 comrade/comrade_tutorial/migrations/__init__.py create mode 100644 comrade/comrade_tutorial/models.py create mode 100644 comrade/comrade_tutorial/tests.py create mode 100644 comrade/comrade_tutorial/views.py diff --git a/comrade/comrade_tutorial/__init__.py b/comrade/comrade_tutorial/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/comrade/comrade_tutorial/admin.py b/comrade/comrade_tutorial/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/comrade/comrade_tutorial/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/comrade/comrade_tutorial/apps.py b/comrade/comrade_tutorial/apps.py new file mode 100644 index 0000000..a9e283f --- /dev/null +++ b/comrade/comrade_tutorial/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ComradeTutorialConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'comrade_tutorial' diff --git a/comrade/comrade_tutorial/migrations/__init__.py b/comrade/comrade_tutorial/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/comrade/comrade_tutorial/models.py b/comrade/comrade_tutorial/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/comrade/comrade_tutorial/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/comrade/comrade_tutorial/tests.py b/comrade/comrade_tutorial/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/comrade/comrade_tutorial/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/comrade/comrade_tutorial/views.py b/comrade/comrade_tutorial/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/comrade/comrade_tutorial/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. From 2963667cb457deb2df9e47515c0b245887629a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20S=C3=BCckr?= Date: Sat, 30 Nov 2024 15:47:36 +0100 Subject: [PATCH 2/2] feat(tutorial): init models --- comrade/comrade_tutorial/apps.py | 4 ++-- comrade/comrade_tutorial/models.py | 35 +++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/comrade/comrade_tutorial/apps.py b/comrade/comrade_tutorial/apps.py index a9e283f..1900ece 100644 --- a/comrade/comrade_tutorial/apps.py +++ b/comrade/comrade_tutorial/apps.py @@ -2,5 +2,5 @@ class ComradeTutorialConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'comrade_tutorial' + default_auto_field = "django.db.models.BigAutoField" + name = "comrade_tutorial" diff --git a/comrade/comrade_tutorial/models.py b/comrade/comrade_tutorial/models.py index 71a8362..4692627 100644 --- a/comrade/comrade_tutorial/models.py +++ b/comrade/comrade_tutorial/models.py @@ -1,3 +1,36 @@ +from comrade_core.models import Skill as CoreSkill +from django.contrib.auth import get_user_model from django.db import models -# Create your models here. +User = get_user_model() + + +class TaskTemplate(models.Model): + description = models.TextField() + video_url = models.URLField() + name = models.CharField(max_length=64) + reward = models.ForeignKey("Reward", on_delete=models.SET_NULL) + + +class Reward(models.Model): + skill = models.ForeignKey(CoreSkill, on_delete=models.RESTRICT) + + +class Task(models.Model): + owner = models.ForeignKey(User, on_delete=models.SET_NULL) + assignee = models.ForeignKey(User, on_delete=models.CASCADE) + template = models.ForeignKey("TaskTemplate", on_delete=models.CASCADE) + + +class TaskSolutionPhoto(models.Model): + task_solution = models.ForeignKey("TaskSolution", on_delete=models.CASCADE) + file = models.FileField() + description = models.TextField() + + +class TaskSolutionText(models.Model): + task_solution = models.ForeignKey("TaskSolution", on_delete=models.CASCADE) + + +class TaskSolution(models.Model): + task = models.ForeignKey("Task", on_delete=models.RESTRICT)