From 08bd89415e3791195f116f66bc315792de33d0ca Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Wed, 8 May 2024 13:45:33 +0200 Subject: [PATCH] added pillow and updated image inputs models - updated institution fixtures - updated project fixtures - updated institution templetes --- app/fixtures/institution.json | 50 +++++++++---------- app/fixtures/projects.json | 4 +- ...ter_institution_logo_alter_project_logo.py | 23 +++++++++ app/general/models.py | 4 +- app/static/css/styles.css | 2 +- app/templates/app/institutions.html | 5 +- requirements.txt | 1 + 7 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 app/general/migrations/0005_alter_institution_logo_alter_project_logo.py diff --git a/app/fixtures/institution.json b/app/fixtures/institution.json index d6c38bcf..1337adb9 100644 --- a/app/fixtures/institution.json +++ b/app/fixtures/institution.json @@ -7,7 +7,7 @@ "abbreviation": "UNISA", "url": "https://www.unisa.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -18,7 +18,7 @@ "abbreviation": "NWU", "url": "https://www.nwu.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -29,7 +29,7 @@ "abbreviation": "UP", "url": "https://www.up.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -40,7 +40,7 @@ "abbreviation": "UJ", "url": "https://www.uj.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -51,7 +51,7 @@ "abbreviation": "UKZN", "url": "https://www.ukzn.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -62,7 +62,7 @@ "abbreviation": "UFS", "url": "https://www.ufs.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -73,7 +73,7 @@ "abbreviation": "CPUT", "url": "https://www.cput.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -84,7 +84,7 @@ "abbreviation": "WITS", "url": "https://www.wits.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -95,7 +95,7 @@ "abbreviation": "US", "url": "http://www.sun.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -106,7 +106,7 @@ "abbreviation": "UCT", "url": "https://uct.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -117,7 +117,7 @@ "abbreviation": "NMU", "url": "https://www.mandela.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -128,7 +128,7 @@ "abbreviation": "WSU", "url": "https://www.wsu.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -139,7 +139,7 @@ "abbreviation": "DUT", "url": "https://www.dut.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -150,7 +150,7 @@ "abbreviation": "UL", "url": "https://www.ul.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -161,7 +161,7 @@ "abbreviation": "VUT", "url": "https://www.vut.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -172,7 +172,7 @@ "abbreviation": "UniZulu", "url": "https://www.unizulu.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -183,7 +183,7 @@ "abbreviation": "UWC", "url": "https://www.uwc.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -194,7 +194,7 @@ "abbreviation": "CUT", "url": "https://www.cut.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -205,7 +205,7 @@ "abbreviation": "UFH", "url": "https://www.ufh.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -216,7 +216,7 @@ "abbreviation": "RU", "url": "https://www.ru.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -227,7 +227,7 @@ "abbreviation": "Venda", "url": "https://www.univen.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -238,7 +238,7 @@ "abbreviation": "MUT", "url": "https://www.mut.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -249,7 +249,7 @@ "abbreviation": "FMHSU", "url": "https://www.smu.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -260,7 +260,7 @@ "abbreviation": "UMP", "url": "https://www.ump.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } }, { @@ -271,7 +271,7 @@ "abbreviation": "SPU", "url": "https://www.spu.ac.za/", "email": "email@example.dev", - "logo": "logo" + "logo": "" } } ] diff --git a/app/fixtures/projects.json b/app/fixtures/projects.json index 6c85eb2b..7f1874e0 100644 --- a/app/fixtures/projects.json +++ b/app/fixtures/projects.json @@ -5,7 +5,7 @@ "fields": { "name": "Study Centre", "url": "https://example.dev", - "logo": "logo.png", + "logo": "", "start_date": "2020-01-01", "end_date": "2020-01-01", "institution": 1 @@ -17,7 +17,7 @@ "fields": { "name": "Research Centre", "url": "https://example.dev", - "logo": "logo.png", + "logo": "", "start_date": "2020-01-01", "end_date": "2020-01-01", "institution": 2 diff --git a/app/general/migrations/0005_alter_institution_logo_alter_project_logo.py b/app/general/migrations/0005_alter_institution_logo_alter_project_logo.py new file mode 100644 index 00000000..aa039c46 --- /dev/null +++ b/app/general/migrations/0005_alter_institution_logo_alter_project_logo.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.2 on 2024-05-10 08:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('general', '0004_historicaldocumentfile_historicalinstitution_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='institution', + name='logo', + field=models.ImageField(blank=True, upload_to='institutions/logos/'), + ), + migrations.AlterField( + model_name='project', + name='logo', + field=models.ImageField(blank=True, upload_to='projects/logos/'), + ), + ] diff --git a/app/general/models.py b/app/general/models.py index 8de06076..930a8773 100644 --- a/app/general/models.py +++ b/app/general/models.py @@ -6,7 +6,7 @@ class Project(models.Model): name = models.CharField(max_length=200) url = models.URLField(max_length=200, blank=True, verbose_name="URL") - logo = models.FileField(upload_to="logos/", blank=True) + logo = models.ImageField(upload_to="projects/logos/", blank=True) start_date = models.DateField(blank=True, null=True) end_date = models.DateField(blank=True, null=True) institution = models.ForeignKey( @@ -27,7 +27,7 @@ class Institution(models.Model): abbreviation = models.CharField(max_length=200) url = models.URLField(max_length=200, blank=True, verbose_name="URL") email = models.EmailField(max_length=200, blank=True) - logo = models.FileField(upload_to="logos/", blank=True) + logo = models.ImageField(upload_to="institutions/logos/", blank=True) # added simple historical records to the model history = HistoricalRecords() diff --git a/app/static/css/styles.css b/app/static/css/styles.css index fae6824b..70d81857 100755 --- a/app/static/css/styles.css +++ b/app/static/css/styles.css @@ -142,7 +142,7 @@ html { } .uni-logo { - width: 50px; + width: auto; height: 50px; margin: 10px 0 0 0; } diff --git a/app/templates/app/institutions.html b/app/templates/app/institutions.html index 3a30bda0..39d99cdc 100644 --- a/app/templates/app/institutions.html +++ b/app/templates/app/institutions.html @@ -33,7 +33,10 @@
{{ institution.name }}

diff --git a/requirements.txt b/requirements.txt index c2b69d85..ebacdb41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ django-simple-history gunicorn psycopg2-binary whitenoise +pillow