Browse Source

DIV-1120 - Store width and height in the core_document table

pull/170/head
Michael Olund 5 years ago
parent
commit
30f30ec035
4 changed files with 42 additions and 3 deletions
  1. +27
    -0
      edivorce/apps/core/migrations/0022_auto_20200928_1157.py
  2. +7
    -1
      edivorce/apps/core/models.py
  3. +4
    -0
      edivorce/apps/core/views/api.py
  4. +4
    -2
      vue/src/components/Uploader/Uploader.vue

+ 27
- 0
edivorce/apps/core/migrations/0022_auto_20200928_1157.py View File

@ -0,0 +1,27 @@
# Generated by Django 2.2.15 on 2020-09-28 18:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0021_document'),
]
operations = [
migrations.AlterModelOptions(
name='document',
options={'ordering': ('sort_order',)},
),
migrations.AddField(
model_name='document',
name='height',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='document',
name='width',
field=models.IntegerField(default=0),
),
]

+ 7
- 1
edivorce/apps/core/models.py View File

@ -130,11 +130,17 @@ class Document(models.Model):
""" 1 = You, 2 = Your Spouse, 0 = Shared """
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)
""" 0, 90, 180 or 270 """
height = models.IntegerField(default=0)
""" Initial image height (before rotation) """
width = models.IntegerField(default=0)
""" Initial image width (before rotation) """
bceid_user = models.ForeignKey(BceidUser, related_name='uploads', on_delete=models.CASCADE)
""" User who uploaded the attachment """


+ 4
- 0
edivorce/apps/core/views/api.py View File

@ -123,6 +123,8 @@ class Query(graphene.ObjectType):
class DocumentInput(graphene.InputObjectType):
filename = graphene.String(required=True)
size = graphene.Int(required=True)
width = graphene.Int()
height = graphene.Int()
rotation = graphene.Int()
@ -152,6 +154,8 @@ class UpdateMetadata(graphene.Mutation):
try:
doc = documents.get(filename=file['filename'], size=file['size'])
doc.sort_order = i + 1
doc.width = file.get('width', file.width)
doc.height = file.get('height', file.height)
doc.rotation = file.get('rotation', file.rotation)
if doc.rotation not in [0, 90, 180, 270]:
raise GraphQLError(f"Invalid rotation {doc.rotation}, must be 0, 90, 180, 270")


+ 4
- 2
vue/src/components/Uploader/Uploader.vue View File

@ -302,7 +302,9 @@ export default {
this.files.forEach((file) => {
allFiles.push({
filename: file.name,
size: file.size,
size: file.size,
width: file.width,
height: file.height,
rotation: rotateFix(file.rotation)
});
});
@ -318,7 +320,7 @@ export default {
query: `
mutation updateMetadata {
updateMetadata(input:${graphQLData}){
documents{filename size rotation}
documents{filename size width height rotation}
}
}
`})


Loading…
Cancel
Save