From f098420bacd89682f3c8b206598b01ec8eec835a Mon Sep 17 00:00:00 2001 From: yann Date: Thu, 22 May 2025 21:46:16 +0200 Subject: [PATCH] 1st model`s draft, before 1st migration --- softdesk/authentication/models.py | 6 +++++- softdesk/support/admin.py | 8 +++++++- softdesk/support/models.py | 32 ++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/softdesk/authentication/models.py b/softdesk/authentication/models.py index 61cd0b3..d503d86 100644 --- a/softdesk/authentication/models.py +++ b/softdesk/authentication/models.py @@ -3,7 +3,11 @@ from django.contrib.auth.models import AbstractUser, Group class User(AbstractUser): - pass + can_be_contacted = models.BooleanField(default=False) + can_data_be_shared = models.BooleanField(default=False) + age = models.IntegerField() + + diff --git a/softdesk/support/admin.py b/softdesk/support/admin.py index 8c38f3f..d4b7299 100644 --- a/softdesk/support/admin.py +++ b/softdesk/support/admin.py @@ -1,3 +1,9 @@ from django.contrib import admin +from support.models import Project, Issue, Comment, ProjectContributor + + +admin.site.register(Project, ProjectAdmin) +admin.site.register(Issue, IssueAdmin) +admin.comment.register(Comment, CommentAdmin) +admin.ProjectContributor.register(ProjectContributor, ProjectContributorAdmin) -# Register your models here. diff --git a/softdesk/support/models.py b/softdesk/support/models.py index ec7e2fe..9a32eec 100644 --- a/softdesk/support/models.py +++ b/softdesk/support/models.py @@ -2,8 +2,22 @@ from django.db import models class Project(models.Model): - author = - contributor = + + class Type(models.TextChoices): + BACKEND = 'BackEnd' + FRONTEND = 'FrontEnd' + IOS = 'iOS' + ANDROID = 'Android' + + + title = models.CharField(length=255) + date_created = models.DateTimeField(auto_now_add=True) + type = models.CharField(choices=Type.choices, max_length=10) + description = models.CharField(length=4000) + author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) + + contributors = models.ManyToManyField( + settings.AUTH_USER_MODEL, through='ProjectContributor', related_name='contributor') class Issue(models.Model): @@ -33,19 +47,19 @@ class Issue(models.Model): priority = models.CharField(Priority.choices, max_lenght=15) tag = models.CharField(Tag.choices, max_length=15) + author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) + contributors = models.ManyToManyField( settings.AUTH_USER_MODEL, through='IssueContributors', related_name='contributors') - assigned_to = class Comment(models.Model): - - author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=SET + author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=DO_NOTHING) issue = models.ForeignKey(Issue, on_delete=models.CASCADE) +class ProjectContributors(models.Model): + contributor = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) + project = models.ForeignKey(Project, on_delete=models.CASCADE) + data = models.CharField(max_length=255, blank=True) - -class IssueContributors(models.Model): - contributor = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL) - issue = "ToDo"