Commit c7241cd4 authored by Franco Velasco's avatar Franco Velasco

Fixed profile image in Homepage users

parent cd6d2b07
......@@ -3,6 +3,9 @@ from django.urls import reverse
from datetime import datetime
import os
def dp_location(request, filename):
return os.path.join("widget-users/images/", filename)
"""
A model for a school department in Widget.
Has fields for the names of the department and the unit it is associated with.
......@@ -28,7 +31,7 @@ class WidgetUser(models.Model):
department = models.ForeignKey(Department, on_delete=models.CASCADE)
profile_image = models.ImageField(upload_to=f"widget-users/images/{id_num}", null=True, blank=True)
profile_image = models.ImageField(upload_to=dp_location, null=True, blank=True)
def __str__(self):
return f"""{self.last_name}, {self.first_name} {self.middle_name}:
......
......@@ -34,8 +34,8 @@
{% block content %}
<h1> Widget User Profile </h1>
<div class="user-page-container">
{% if post.profile_image %}
<img src="{{ MEDIA_DIR }}/widget-users/images/{{ user.id_num }}" alt="Profile Image of {{ user.get_name }}" width="192" height="192">
{% if user.profile_image %}
<img src="{{ MEDIA_DIR }}/widget-users/images/{{ user.profile_image }}" alt="Profile Image of {{ user.get_name }}" width="192" height="192">
{% else %}
<img src="{% static 'Homepage/3.JPG' %}" alt="Profile Image of {{ user.get_name }}" width="192" height="192">
{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment