28 lines
873 B
Python
28 lines
873 B
Python
|
from django.db import models
|
||
|
from simple_history.models import HistoricalRecords
|
||
|
from django.contrib.auth.models import User
|
||
|
|
||
|
class Issue(models.Model):
|
||
|
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
||
|
title = models.CharField(max_length=128)
|
||
|
description = models.CharField(max_length=2048)
|
||
|
last_modified = models.DateTimeField(auto_now=True)
|
||
|
history = HistoricalRecords()
|
||
|
|
||
|
def get_absolute_url(self):
|
||
|
return f"/issues/{self.id}"
|
||
|
|
||
|
def __str__(self):
|
||
|
return f"{self.title}"
|
||
|
|
||
|
class Meta:
|
||
|
ordering = ["last_modified"]
|
||
|
|
||
|
class Comment(models.Model):
|
||
|
issue = models.ForeignKey(Issue, on_delete=models.CASCADE)
|
||
|
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
||
|
body = models.CharField(max_length=2048)
|
||
|
last_modified = models.DateTimeField(auto_now=True)
|
||
|
history = HistoricalRecords()
|
||
|
|