mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-08-27 22:04:16 +02:00
feat(transactions): add filter preset model
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("transactions", "0049_transactionattachment"),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="FilterPreset",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=100)),
|
||||||
|
("parameters", models.JSONField(default=dict)),
|
||||||
|
(
|
||||||
|
"owner",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="filter_presets",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={"ordering": ["name", "id"]},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -30,12 +30,27 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
transaction_created = Signal()
|
transaction_created = Signal()
|
||||||
transaction_updated = Signal()
|
transaction_updated = Signal()
|
||||||
transaction_deleted = Signal()
|
transaction_deleted = Signal()
|
||||||
|
|
||||||
|
|
||||||
|
class FilterPreset(models.Model):
|
||||||
|
owner = models.ForeignKey(
|
||||||
|
settings.AUTH_USER_MODEL,
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="filter_presets",
|
||||||
|
)
|
||||||
|
name = models.CharField(max_length=100)
|
||||||
|
parameters = models.JSONField(default=dict)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ["name", "id"]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
def transaction_attachment_path(instance, filename):
|
def transaction_attachment_path(instance, filename):
|
||||||
extension = Path(filename).suffix
|
extension = Path(filename).suffix
|
||||||
return f"transaction_attachments/{instance.transaction_id}/{instance.id}{extension}"
|
return f"transaction_attachments/{instance.transaction_id}/{instance.id}{extension}"
|
||||||
@@ -535,6 +550,7 @@ class Transaction(OwnedObject):
|
|||||||
|
|
||||||
return new_obj
|
return new_obj
|
||||||
|
|
||||||
|
|
||||||
class TransactionAttachment(models.Model):
|
class TransactionAttachment(models.Model):
|
||||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
transaction = models.ForeignKey(
|
transaction = models.ForeignKey(
|
||||||
@@ -590,6 +606,7 @@ def delete_transaction_attachment_file(sender, instance, **kwargs):
|
|||||||
if storage.exists(instance.file.name):
|
if storage.exists(instance.file.name):
|
||||||
storage.delete(instance.file.name)
|
storage.delete(instance.file.name)
|
||||||
|
|
||||||
|
|
||||||
class InstallmentPlan(models.Model):
|
class InstallmentPlan(models.Model):
|
||||||
class Recurrence(models.TextChoices):
|
class Recurrence(models.TextChoices):
|
||||||
YEARLY = "yearly", _("Yearly")
|
YEARLY = "yearly", _("Yearly")
|
||||||
|
|||||||
Reference in New Issue
Block a user