aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2021-05-15 15:15:21 +0300
committerFilipp Lepalaan <filipp@mac.com>2021-05-15 15:15:21 +0300
commitd2ca08edbef7e08afbeb18a1dd8e6cabe1f16a3f (patch)
tree1b79189369d7c079fd704c983f73cac9118e5ded
parent2d5770393e55d3ba055fb10db54afe37bd28b590 (diff)
downloadServo-d2ca08edbef7e08afbeb18a1dd8e6cabe1f16a3f.tar.gz
Servo-d2ca08edbef7e08afbeb18a1dd8e6cabe1f16a3f.tar.bz2
Servo-d2ca08edbef7e08afbeb18a1dd8e6cabe1f16a3f.zip
Fix saving notes
-rw-r--r--servo/migrations/0004_auto_20210515_1414.py46
-rw-r--r--servo/models/common.py6
2 files changed, 49 insertions, 3 deletions
diff --git a/servo/migrations/0004_auto_20210515_1414.py b/servo/migrations/0004_auto_20210515_1414.py
new file mode 100644
index 0000000..834614c
--- /dev/null
+++ b/servo/migrations/0004_auto_20210515_1414.py
@@ -0,0 +1,46 @@
+# Generated by Django 3.2.2 on 2021-05-15 12:14
+
+from django.db import migrations, models
+import django.db.models.deletion
+import mptt.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('contenttypes', '0002_remove_content_type_name'),
+ ('servo', '0003_auto_20210515_1333'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='attachment',
+ name='ref',
+ ),
+ migrations.RemoveField(
+ model_name='attachment',
+ name='ref_id',
+ ),
+ migrations.AddField(
+ model_name='attachment',
+ name='content_type',
+ field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='attachment',
+ name='object_id',
+ field=models.PositiveIntegerField(default=None),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='queue',
+ name='locations',
+ field=models.ManyToManyField(blank=True, help_text='Pick the locations you want this queue to appear in.', to='servo.Location', verbose_name='locations'),
+ ),
+ migrations.AlterField(
+ model_name='user',
+ name='customer',
+ field=mptt.fields.TreeForeignKey(blank=True, help_text='Tie the user to this customer (company).', limit_choices_to={'is_company': True}, null=True, on_delete=django.db.models.deletion.SET_NULL, to='servo.customer'),
+ ),
+ ]
diff --git a/servo/models/common.py b/servo/models/common.py
index 69feea2..520b769 100644
--- a/servo/models/common.py
+++ b/servo/models/common.py
@@ -762,9 +762,9 @@ class Template(models.Model):
class Attachment(models.Model):
"""A file attached to something."""
-
- ref = models.CharField(max_length=32)
- ref_id = models.IntegerField()
+ content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
+ object_id = models.PositiveIntegerField()
+ content_object = GenericForeignKey('content_type', 'object_id')
mime_type = models.CharField(max_length=64, editable=False)
content = models.FileField(