fix model & relation issues before migration
This commit is contained in:
parent
10384e6761
commit
54d8cb9846
@ -1,9 +1,9 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from support.models import Project, Issue, Comment, ProjectContributor
|
from support.models import Project, Issue, Comment, Contributor
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Project, ProjectAdmin)
|
admin.site.register(Project)
|
||||||
admin.site.register(Issue, IssueAdmin)
|
admin.site.register(Issue)
|
||||||
admin.comment.register(Comment, CommentAdmin)
|
admin.site.register(Comment)
|
||||||
admin.ProjectContributor.register(ProjectContributor, ProjectContributorAdmin)
|
admin.site.register(Contributor)
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class Project(models.Model):
|
class Project(models.Model):
|
||||||
@ -10,14 +11,20 @@ class Project(models.Model):
|
|||||||
ANDROID = 'Android'
|
ANDROID = 'Android'
|
||||||
|
|
||||||
|
|
||||||
title = models.CharField(length=255)
|
title = models.CharField(max_length=255)
|
||||||
date_created = models.DateTimeField(auto_now_add=True)
|
date_created = models.DateTimeField(auto_now_add=True)
|
||||||
type = models.CharField(choices=Type.choices, max_length=10)
|
type = models.CharField(choices=Type.choices, max_length=10)
|
||||||
description = models.CharField(length=4000)
|
description = models.CharField(max_length=4000)
|
||||||
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING)
|
author = models.ForeignKey('Contributor', on_delete=models.DO_NOTHING, related_name='author')
|
||||||
|
|
||||||
contributors = models.ManyToManyField(
|
contributors = models.ManyToManyField(
|
||||||
settings.AUTH_USER_MODEL, through='ProjectContributor', related_name='contributor')
|
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')
|
||||||
|
data = models.CharField(max_length=255, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Issue(models.Model):
|
class Issue(models.Model):
|
||||||
@ -40,26 +47,21 @@ class Issue(models.Model):
|
|||||||
TASK = 'Task'
|
TASK = 'Task'
|
||||||
|
|
||||||
|
|
||||||
title = models.CharField(max_lenght=255, verbose_name='title')
|
title = models.CharField(max_length=255, verbose_name='title')
|
||||||
|
date_created = models.DateTimeField(auto_now_add=True)
|
||||||
description = models.TextField()
|
description = models.TextField()
|
||||||
project = models.ForeignKey(Project, null=True, on_delete=models.SET_NULL, blank=True)
|
project = models.ForeignKey(Project, null=True, on_delete=models.SET_NULL, blank=True)
|
||||||
status = models.CharField(Status.choices, max_length=15)
|
status = models.CharField(Status.choices, max_length=15)
|
||||||
priority = models.CharField(Priority.choices, max_lenght=15)
|
priority = models.CharField(Priority.choices, max_length=15)
|
||||||
tag = models.CharField(Tag.choices, max_length=15)
|
tag = models.CharField(Tag.choices, max_length=15)
|
||||||
|
|
||||||
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING)
|
author = models.ForeignKey('Contributor', on_delete=models.DO_NOTHING)
|
||||||
|
|
||||||
contributors = models.ManyToManyField(
|
|
||||||
settings.AUTH_USER_MODEL, through='IssueContributors', related_name='contributors')
|
|
||||||
|
|
||||||
|
|
||||||
class Comment(models.Model):
|
class Comment(models.Model):
|
||||||
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=DO_NOTHING)
|
title = models.CharField(max_length=255)
|
||||||
|
date_created = models.DateTimeField(auto_now_add=True)
|
||||||
|
description = models.CharField(max_length=4000)
|
||||||
|
author = models.ForeignKey('Contributor', on_delete=models.DO_NOTHING)
|
||||||
issue = models.ForeignKey(Issue, on_delete=models.CASCADE)
|
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)
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user