latest changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import uuid
|
||||
from django.conf import settings
|
||||
from django.core.validators import RegexValidator
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
|
||||
@@ -122,6 +123,32 @@ class CardComment(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
|
||||
class CardAttachment(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
card = models.ForeignKey(Card, on_delete=models.CASCADE, related_name='attachments')
|
||||
comment = models.ForeignKey(CardComment, null=True, blank=True, on_delete=models.CASCADE, related_name='attachments')
|
||||
file = models.FileField(upload_to='card-attachments/%Y/%m/')
|
||||
original_filename = models.CharField(max_length=255)
|
||||
title = models.CharField(max_length=255)
|
||||
mime_type = models.CharField(max_length=100)
|
||||
byte_size = models.PositiveIntegerField()
|
||||
sha256 = models.CharField(max_length=64)
|
||||
description = models.TextField(blank=True)
|
||||
uploaded_by = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL)
|
||||
source = models.CharField(max_length=16, default='web')
|
||||
source_path = models.CharField(max_length=500, blank=True)
|
||||
source_commit = models.CharField(max_length=64, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ['created_at', 'id']
|
||||
indexes = [models.Index(fields=['card', 'comment', 'created_at'])]
|
||||
|
||||
def clean(self):
|
||||
if self.comment_id and not CardComment.objects.filter(pk=self.comment_id, card_id=self.card_id).exists():
|
||||
raise ValidationError({'comment': 'Progress note must belong to this card.'})
|
||||
|
||||
|
||||
class CreationKey(models.Model):
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
key = models.CharField(max_length=128)
|
||||
@@ -133,6 +160,17 @@ class CreationKey(models.Model):
|
||||
constraints = [models.UniqueConstraint(fields=['user', 'key'], name='unique_card_creation_key')]
|
||||
|
||||
|
||||
class BulkUpdateKey(models.Model):
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
key = models.CharField(max_length=128)
|
||||
payload_hash = models.CharField(max_length=64)
|
||||
result = models.JSONField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
constraints = [models.UniqueConstraint(fields=['user', 'key'], name='unique_bulk_update_key')]
|
||||
|
||||
|
||||
class Activity(models.Model):
|
||||
project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='activity')
|
||||
card = models.ForeignKey(Card, null=True, blank=True, on_delete=models.CASCADE, related_name='activity')
|
||||
|
||||
Reference in New Issue
Block a user