Skip to content

Commit

Permalink
Merge pull request #46 from SADiLaR/feature/downloading-logo
Browse files Browse the repository at this point in the history
added pillow and updated image inputs models
  • Loading branch information
daniel-gray-tangent authored May 10, 2024
2 parents 986946c + 08bd894 commit ab60c89
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 31 deletions.
50 changes: 25 additions & 25 deletions app/fixtures/institution.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"abbreviation": "UNISA",
"url": "https://www.unisa.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -18,7 +18,7 @@
"abbreviation": "NWU",
"url": "https://www.nwu.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -29,7 +29,7 @@
"abbreviation": "UP",
"url": "https://www.up.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -40,7 +40,7 @@
"abbreviation": "UJ",
"url": "https://www.uj.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -51,7 +51,7 @@
"abbreviation": "UKZN",
"url": "https://www.ukzn.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -62,7 +62,7 @@
"abbreviation": "UFS",
"url": "https://www.ufs.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -73,7 +73,7 @@
"abbreviation": "CPUT",
"url": "https://www.cput.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -84,7 +84,7 @@
"abbreviation": "WITS",
"url": "https://www.wits.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -95,7 +95,7 @@
"abbreviation": "US",
"url": "http://www.sun.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -106,7 +106,7 @@
"abbreviation": "UCT",
"url": "https://uct.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -117,7 +117,7 @@
"abbreviation": "NMU",
"url": "https://www.mandela.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -128,7 +128,7 @@
"abbreviation": "WSU",
"url": "https://www.wsu.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -139,7 +139,7 @@
"abbreviation": "DUT",
"url": "https://www.dut.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -150,7 +150,7 @@
"abbreviation": "UL",
"url": "https://www.ul.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -161,7 +161,7 @@
"abbreviation": "VUT",
"url": "https://www.vut.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -172,7 +172,7 @@
"abbreviation": "UniZulu",
"url": "https://www.unizulu.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -183,7 +183,7 @@
"abbreviation": "UWC",
"url": "https://www.uwc.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -194,7 +194,7 @@
"abbreviation": "CUT",
"url": "https://www.cut.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -205,7 +205,7 @@
"abbreviation": "UFH",
"url": "https://www.ufh.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -216,7 +216,7 @@
"abbreviation": "RU",
"url": "https://www.ru.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -227,7 +227,7 @@
"abbreviation": "Venda",
"url": "https://www.univen.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -238,7 +238,7 @@
"abbreviation": "MUT",
"url": "https://www.mut.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -249,7 +249,7 @@
"abbreviation": "FMHSU",
"url": "https://www.smu.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -260,7 +260,7 @@
"abbreviation": "UMP",
"url": "https://www.ump.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
},
{
Expand All @@ -271,7 +271,7 @@
"abbreviation": "SPU",
"url": "https://www.spu.ac.za/",
"email": "[email protected]",
"logo": "logo"
"logo": ""
}
}
]
4 changes: 2 additions & 2 deletions app/fixtures/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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/'),
),
]
4 changes: 2 additions & 2 deletions app/general/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion app/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ html {
}

.uni-logo {
width: 50px;
width: auto;
height: 50px;
margin: 10px 0 0 0;
}
Expand Down
5 changes: 4 additions & 1 deletion app/templates/app/institutions.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ <h5 class="card-title">{{ institution.name }}</h5>
</div>
<br>
<div class="card-logo">
<img src=" {% static 'img/UP_logo.png' %}" class="uni-logo" alt="university logo">
{% if institution.logo %}
<img src="{{ institution.logo.url }}" alt="{{ institution.name }} logo"
class="uni-logo">
{% endif %}
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ django-simple-history
gunicorn
psycopg2-binary
whitenoise
pillow

0 comments on commit ab60c89

Please sign in to comment.