Browse Source

Refactored model field names and added timestamp column

pull/170/head
Michael Olund 5 years ago
parent
commit
216f82a7ac
5 changed files with 67 additions and 7 deletions
  1. +39
    -0
      edivorce/apps/poc/migrations/0008_auto_20200922_1027.py
  2. +18
    -0
      edivorce/apps/poc/migrations/0009_auto_20200922_1033.py
  3. +8
    -5
      edivorce/apps/poc/models.py
  4. +1
    -1
      edivorce/apps/poc/views.py
  5. +1
    -1
      vue/src/components/Uploader/Main.vue

+ 39
- 0
edivorce/apps/poc/migrations/0008_auto_20200922_1027.py View File

@ -0,0 +1,39 @@
# Generated by Django 2.2.15 on 2020-09-22 17:27
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0020_auto_20200903_2328'),
('poc', '0007_auto_20200921_1523'),
]
operations = [
migrations.RenameField(
model_name='document',
old_name='party_id',
new_name='party_code',
),
migrations.RenameField(
model_name='document',
old_name='length',
new_name='size',
),
migrations.RenameField(
model_name='document',
old_name='order',
new_name='sort_order',
),
migrations.AddField(
model_name='document',
name='date_uploaded',
field=models.DateTimeField(default=datetime.datetime.now),
),
migrations.AlterUniqueTogether(
name='document',
unique_together={('bceid_user', 'doc_type', 'party_code', 'filename', 'size')},
),
]

+ 18
- 0
edivorce/apps/poc/migrations/0009_auto_20200922_1033.py View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.15 on 2020-09-22 17:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('poc', '0008_auto_20200922_1027'),
]
operations = [
migrations.AlterField(
model_name='document',
name='date_uploaded',
field=models.DateTimeField(auto_now_add=True),
),
]

+ 8
- 5
edivorce/apps/poc/models.py View File

@ -12,7 +12,7 @@ class Document(models.Model):
filename = models.CharField(max_length=128, null=True) # saving the original filename separately filename = models.CharField(max_length=128, null=True) # saving the original filename separately
""" File name and extension """ """ File name and extension """
length = models.IntegerField(default=0)
size = models.IntegerField(default=0)
""" Size of the file (size and name uniquely identify each file on the input) """ """ Size of the file (size and name uniquely identify each file on the input) """
file = models.FileField(upload_to=redis.generate_unique_filename, storage=redis.RedisStorage()) file = models.FileField(upload_to=redis.generate_unique_filename, storage=redis.RedisStorage())
@ -21,10 +21,10 @@ class Document(models.Model):
doc_type = models.CharField(max_length=4, null=True, blank=True) doc_type = models.CharField(max_length=4, null=True, blank=True)
""" CEIS Document Type Code (2-4 letters) """ """ CEIS Document Type Code (2-4 letters) """
party_id = models.IntegerField(default=0)
party_code = models.IntegerField(default=0)
""" 1 = You, 2 = Your Spouse, 0 = Shared """ """ 1 = You, 2 = Your Spouse, 0 = Shared """
order = models.IntegerField(default=1)
sort_order = models.IntegerField(default=1)
""" file order (page number in the PDF) """ """ file order (page number in the PDF) """
rotation = models.IntegerField(default=0) rotation = models.IntegerField(default=0)
@ -33,12 +33,15 @@ class Document(models.Model):
bceid_user = models.ForeignKey(BceidUser, related_name='uploads', on_delete=models.CASCADE) bceid_user = models.ForeignKey(BceidUser, related_name='uploads', on_delete=models.CASCADE)
""" User who uploaded the attachment """ """ User who uploaded the attachment """
date_uploaded = models.DateTimeField(auto_now_add=True)
""" Date the record was last updated """
class Meta: class Meta:
unique_together = ("bceid_user", "doc_type", "party_id", "filename", "length")
unique_together = ("bceid_user", "doc_type", "party_code", "filename", "size")
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
self.filename = self.file.name self.filename = self.file.name
self.length = self.file.size
self.size = self.file.size
super(Document, self).save(*args, **kwargs) super(Document, self).save(*args, **kwargs)


+ 1
- 1
edivorce/apps/poc/views.py View File

@ -39,7 +39,7 @@ class UploadScan(FormView):
class UploadStorage(CreateView): class UploadStorage(CreateView):
model = Document model = Document
fields = ['file', 'doc_type', 'party_id']
fields = ['file', 'doc_type', 'party_code']
template_name = "storage.html" template_name = "storage.html"
success_url = settings.FORCE_SCRIPT_NAME + 'poc/storage' success_url = settings.FORCE_SCRIPT_NAME + 'poc/storage'


+ 1
- 1
vue/src/components/Uploader/Main.vue View File

@ -102,7 +102,7 @@ export default {
data() { data() {
return { return {
doc_type: this.docType, doc_type: this.docType,
party_id: this.party
party_code: this.party
}; };
} }
}, },


Loading…
Cancel
Save