diff --git a/lainatehtailijat/lainatehdas/static/media/Ruohonleikkuri.jpg b/lainatehtailijat/Ruohonleikkuri.jpg similarity index 100% rename from lainatehtailijat/lainatehdas/static/media/Ruohonleikkuri.jpg rename to lainatehtailijat/Ruohonleikkuri.jpg diff --git a/lainatehtailijat/lainatehdas/migrations/0021_alter_reservation_date_reserved.py b/lainatehtailijat/lainatehdas/migrations/0021_alter_reservation_date_reserved.py new file mode 100644 index 0000000..c1fc13f --- /dev/null +++ b/lainatehtailijat/lainatehdas/migrations/0021_alter_reservation_date_reserved.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.3 on 2024-04-22 12:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lainatehdas', '0020_item_item_avail'), + ] + + operations = [ + migrations.AlterField( + model_name='reservation', + name='date_reserved', + field=models.DateField(), + ), + ] diff --git a/lainatehtailijat/lainatehdas/migrations/0022_alter_item_item_img.py b/lainatehtailijat/lainatehdas/migrations/0022_alter_item_item_img.py new file mode 100644 index 0000000..325856c --- /dev/null +++ b/lainatehtailijat/lainatehdas/migrations/0022_alter_item_item_img.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.3 on 2024-04-23 14:46 + +import lainatehdas.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lainatehdas', '0021_alter_reservation_date_reserved'), + ] + + operations = [ + migrations.AlterField( + model_name='item', + name='item_img', + field=models.ImageField(default='media/placeholder.jpg', upload_to='media/', validators=[lainatehdas.models.validate_image_dimensions]), + ), + ] diff --git a/lainatehtailijat/lainatehdas/migrations/0023_alter_item_item_img.py b/lainatehtailijat/lainatehdas/migrations/0023_alter_item_item_img.py new file mode 100644 index 0000000..733c7a8 --- /dev/null +++ b/lainatehtailijat/lainatehdas/migrations/0023_alter_item_item_img.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.3 on 2024-04-23 14:51 + +import lainatehdas.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lainatehdas', '0022_alter_item_item_img'), + ] + + operations = [ + migrations.AlterField( + model_name='item', + name='item_img', + field=models.ImageField(default='images/placeholder.jpg', upload_to='images/', validators=[lainatehdas.models.validate_image_dimensions]), + ), + ] diff --git a/lainatehtailijat/lainatehdas/migrations/0024_alter_item_item_img.py b/lainatehtailijat/lainatehdas/migrations/0024_alter_item_item_img.py new file mode 100644 index 0000000..2af253d --- /dev/null +++ b/lainatehtailijat/lainatehdas/migrations/0024_alter_item_item_img.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.3 on 2024-04-23 15:12 + +import lainatehdas.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lainatehdas', '0023_alter_item_item_img'), + ] + + operations = [ + migrations.AlterField( + model_name='item', + name='item_img', + field=models.ImageField(default='images/placeholder.jpg', upload_to='MEDIA_URL', validators=[lainatehdas.models.validate_image_dimensions]), + ), + ] diff --git a/lainatehtailijat/lainatehdas/migrations/0025_alter_item_item_img.py b/lainatehtailijat/lainatehdas/migrations/0025_alter_item_item_img.py new file mode 100644 index 0000000..90cac9c --- /dev/null +++ b/lainatehtailijat/lainatehdas/migrations/0025_alter_item_item_img.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.3 on 2024-04-23 15:34 + +import lainatehdas.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lainatehdas', '0024_alter_item_item_img'), + ] + + operations = [ + migrations.AlterField( + model_name='item', + name='item_img', + field=models.ImageField(upload_to='', validators=[lainatehdas.models.validate_image_dimensions]), + ), + ] diff --git a/lainatehtailijat/lainatehdas/migrations/0026_alter_item_item_img.py b/lainatehtailijat/lainatehdas/migrations/0026_alter_item_item_img.py new file mode 100644 index 0000000..3eb9ced --- /dev/null +++ b/lainatehtailijat/lainatehdas/migrations/0026_alter_item_item_img.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.3 on 2024-04-23 15:42 + +import lainatehdas.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lainatehdas', '0025_alter_item_item_img'), + ] + + operations = [ + migrations.AlterField( + model_name='item', + name='item_img', + field=models.ImageField(upload_to='images/', validators=[lainatehdas.models.validate_image_dimensions]), + ), + ] diff --git a/lainatehtailijat/lainatehdas/models.py b/lainatehtailijat/lainatehdas/models.py index b23162c..773b412 100644 --- a/lainatehtailijat/lainatehdas/models.py +++ b/lainatehtailijat/lainatehdas/models.py @@ -1,9 +1,14 @@ from django.db import models from django.contrib.auth.models import User from datetime import timedelta, date +from django.core.exceptions import ValidationError # Create your models here. +def validate_image_dimensions(image): + if image.width < 326 or image.height < 326: + raise ValidationError("Image dimensions must be at least 326x326 pixels.") + class Item(models.Model): item_choices = { "Leik" : "Ruohonleikkuri", @@ -24,7 +29,7 @@ class Item(models.Model): item_desc = models.CharField(max_length= 500, verbose_name="Description") item_type = models.CharField(max_length=4, choices=item_choices, verbose_name="Type") item_avail = models.CharField(max_length=2, choices=item_avail_choices, default="Va") - item_img = models.ImageField(upload_to='media/', default='media/placeholder.jpg') + item_img = models.ImageField(upload_to= 'images/', validators=[validate_image_dimensions]) def __str__(self) -> str: return self.item_name @@ -34,6 +39,7 @@ def __str__(self): user = models.ForeignKey(User, on_delete=models.CASCADE) item = models.ForeignKey(Item, on_delete=models.CASCADE) - date_reserved = models.DateField(auto_now_add=True) + #date_reserved = models.DateField(auto_now_add=True) + date_reserved = models.DateField() date_returned = models.DateField(null=True, blank=True) diff --git a/lainatehtailijat/lainatehdas/static/media/SL-070720-32260-10.jpg b/lainatehtailijat/lainatehdas/static/media/SL-070720-32260-10.jpg deleted file mode 100644 index e69de29..0000000 diff --git a/lainatehtailijat/lainatehdas/static/media/harava.jpg b/lainatehtailijat/lainatehdas/static/media/harava.jpg deleted file mode 100644 index 7428735..0000000 Binary files a/lainatehtailijat/lainatehdas/static/media/harava.jpg and /dev/null differ diff --git "a/lainatehtailijat/lainatehdas/static/media/kottik\303\244rryt.jpg" "b/lainatehtailijat/lainatehdas/static/media/kottik\303\244rryt.jpg" deleted file mode 100644 index b937825..0000000 Binary files "a/lainatehtailijat/lainatehdas/static/media/kottik\303\244rryt.jpg" and /dev/null differ diff --git a/lainatehtailijat/lainatehdas/static/media/oksasakset.jpeg b/lainatehtailijat/lainatehdas/static/media/oksasakset.jpeg deleted file mode 100644 index 356ebaf..0000000 Binary files a/lainatehtailijat/lainatehdas/static/media/oksasakset.jpeg and /dev/null differ diff --git a/lainatehtailijat/lainatehdas/static/media/placeholder.jpg b/lainatehtailijat/lainatehdas/static/media/placeholder.jpg deleted file mode 100644 index ff08332..0000000 Binary files a/lainatehtailijat/lainatehdas/static/media/placeholder.jpg and /dev/null differ diff --git a/lainatehtailijat/lainatehdas/templates/lainatehdas/base.html b/lainatehtailijat/lainatehdas/templates/lainatehdas/base.html index a521b58..5223c90 100644 --- a/lainatehtailijat/lainatehdas/templates/lainatehdas/base.html +++ b/lainatehtailijat/lainatehdas/templates/lainatehdas/base.html @@ -17,14 +17,14 @@