added views and details to homepage

parent f5fe5dde
body{
font-family: Arial;
background-color: orange;
color: green;
}
\ No newline at end of file
#profilepic{
width: 20%;
height: 20%;
border-radius: 40px;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
{%load static%}
<head>
<title>Widget</title>
<link rel="stylesheet" type="text/css" href="{%static 'homepage/css/base.css'%}">
</head>
<body>
{%block body%}
{%endblock%}
</body>
</html>
\ No newline at end of file
{%extends "homepage/base.html" %}
{%load static%}
{%block body%}
<link rel="stylesheet" type="text/css" href="{%static 'homepage/css/details.css'%}">
<div class="container main">
<img id="profilepic" src="{%static imgurl%}"> <br><br>
<h1>{{widget_user.last_name}}, {{widget_user.first_name}} {{widget_user.middle_name}}</h1>
<h2>{{widget_user.id_num}}</h2>
<h3>{{widget_user.email}}</h3>
<h4>{{widget_user.department.dept_name}}</h4>
<h4>{{widget_user.department.home_unit}}</h4>
</div>
{%endblock%}
\ No newline at end of file
{%extends "homepage/base.html" %}
{%load static%}
{%block body%}
<link rel="stylesheet" type="text/css" href="{%static 'homepage/css/home.css'%}">
<div class="container main">
<h1>Welcome to Widget!</h1><br>
<h2>Widget Users:</h2>
<ol class="widgetusers">
{%for w in widget_users%}
<li><a href="{%url 'details' w.id_num%}">{{w.last_name}}, {{w.first_name}} {{w.middle_name}}</a></li>
{%endfor%}
</ol>
</div>
{%endblock%}
\ No newline at end of file
......@@ -2,5 +2,6 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
path('', views.homepage_view, name='homepage'),
path('users/<user_id>/details', views.details, name='details')
]
\ No newline at end of file
......@@ -3,6 +3,7 @@ from django.http import HttpResponse
from .models import Department, WidgetUser
# Create your views here.
"""
def index(request):
message = 'WIDGET USERS:<br/>'
......@@ -13,4 +14,22 @@ def index(request):
for w in widget_users:
message += f"{w.last_name}, {w.first_name} {w.middle_name}: {w.id_num}, {w.email}, {d.dept_name}, {d.home_unit}<br/>"
return HttpResponse(message)
\ No newline at end of file
return HttpResponse(message)
"""
def homepage_view(request):
widget_users = WidgetUser.objects.all().order_by('last_name')
homepage_dict = {
"widget_users" : widget_users
}
return render(request, "homepage/home.html", homepage_dict)
def details(request, user_id):
widget_user = WidgetUser.objects.get(id_num=user_id)
imgurl = f"homepage/images/{user_id}.png"
details_dict = {
"widget_user" : widget_user,
"imgurl" : imgurl
}
return render(request, "homepage/details.html", details_dict)
\ No newline at end of file
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