mirror of
https://github.com/Xevion/simple-viewer.git
synced 2025-12-06 01:16:24 -06:00
fix references to image resolution field not being properly added/saved
This commit is contained in:
23
viewer/migrations/0008_auto_20201103_1918.py
Normal file
23
viewer/migrations/0008_auto_20201103_1918.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.2 on 2020-11-04 01:18
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('viewer', '0007_auto_20201103_1909'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='imageresolution',
|
||||||
|
name='x',
|
||||||
|
field=models.PositiveIntegerField(null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='imageresolution',
|
||||||
|
name='y',
|
||||||
|
field=models.PositiveIntegerField(null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -74,8 +74,8 @@ class ImageResolution(models.Model):
|
|||||||
A simple model for storing the dimensions of a specific image. A tuple, in essence.
|
A simple model for storing the dimensions of a specific image. A tuple, in essence.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
x = models.PositiveIntegerField()
|
x = models.PositiveIntegerField(null=True)
|
||||||
y = models.PositiveIntegerField()
|
y = models.PositiveIntegerField(null=True)
|
||||||
|
|
||||||
def set(self, size: Tuple[int, int]) -> None:
|
def set(self, size: Tuple[int, int]) -> None:
|
||||||
"""Sets the X and Y attributes"""
|
"""Sets the X and Y attributes"""
|
||||||
@@ -117,8 +117,15 @@ class File(models.Model):
|
|||||||
path=full_path,
|
path=full_path,
|
||||||
filename=os.path.basename(full_path),
|
filename=os.path.basename(full_path),
|
||||||
mediatype=File.get_mediatype(full_path),
|
mediatype=File.get_mediatype(full_path),
|
||||||
directory=parent
|
directory=parent,
|
||||||
|
resolution=ImageResolution(),
|
||||||
|
thumbnailResolution=ImageResolution()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Save references to ImageResolution objects
|
||||||
|
file.resolution.save()
|
||||||
|
file.thumbnailResolution.save()
|
||||||
|
|
||||||
if refresh:
|
if refresh:
|
||||||
file.refresh()
|
file.refresh()
|
||||||
return file
|
return file
|
||||||
|
|||||||
Reference in New Issue
Block a user