added active to Project
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 5.2.1 on 2025-05-25 19:20
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('support', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='project',
|
||||
name='active',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='issue',
|
||||
name='project',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='support.project'),
|
||||
),
|
||||
]
|
||||
@@ -14,16 +14,23 @@ class Project(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
date_created = models.DateTimeField(auto_now_add=True)
|
||||
type = models.CharField(choices=Type.choices, max_length=10)
|
||||
active = models.BooleanField(default=True)
|
||||
description = models.CharField(max_length=4000)
|
||||
author = models.ForeignKey('Contributor', on_delete=models.DO_NOTHING, related_name='author')
|
||||
author = models.ForeignKey('Contributor',
|
||||
on_delete=models.DO_NOTHING,
|
||||
related_name='author')
|
||||
|
||||
contributors = models.ManyToManyField(
|
||||
settings.AUTH_USER_MODEL, through='Contributor', related_name='contribution')
|
||||
contributors = models.ManyToManyField(settings.AUTH_USER_MODEL,
|
||||
through='Contributor',
|
||||
related_name='contribution')
|
||||
|
||||
|
||||
class Contributor(models.Model):
|
||||
contributor = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING)
|
||||
project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='project')
|
||||
contributor = models.ForeignKey(settings.AUTH_USER_MODEL,
|
||||
on_delete=models.DO_NOTHING)
|
||||
project = models.ForeignKey('Project',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='project')
|
||||
data = models.CharField(max_length=255, blank=True)
|
||||
|
||||
|
||||
@@ -50,7 +57,10 @@ class Issue(models.Model):
|
||||
title = models.CharField(max_length=255, verbose_name='title')
|
||||
date_created = models.DateTimeField(auto_now_add=True)
|
||||
description = models.TextField()
|
||||
project = models.ForeignKey(Project, null=True, on_delete=models.CASCADE, blank=True)
|
||||
project = models.ForeignKey(Project,
|
||||
null=True,
|
||||
on_delete=models.CASCADE,
|
||||
blank=True)
|
||||
status = models.CharField(Status.choices, max_length=15)
|
||||
priority = models.CharField(Priority.choices, max_length=15)
|
||||
tag = models.CharField(Tag.choices, max_length=15)
|
||||
|
||||
11
softdesk/support/serializers.py
Normal file
11
softdesk/support/serializers.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from support.models import Project, Contributor, Issue, Comment
|
||||
|
||||
|
||||
class ProjectSerializer(ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Project
|
||||
fields = ['title', 'date_created', 'type', 'description', 'author',
|
||||
'contributors']
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
from support.models import Project, Contributor, Issue, Comment
|
||||
from support.serializers import ProjectSerializer
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class ProjectViewSet(ModelViewSet):
|
||||
serializer_class = ProjectSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
return Project.objects.all()
|
||||
Reference in New Issue
Block a user