Style: added CSS styling to homepage templates

parent 114833a7
# Generated by Django 3.2.12 on 2022-05-14 11:56
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0003_rename_id_name_widgetuser_id_num'),
]
operations = [
migrations.RemoveField(
model_name='department',
name='widgetuser',
),
migrations.AddField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(default='default', on_delete=django.db.models.deletion.CASCADE, to='homepage.department'),
),
]
# Generated by Django 3.2.12 on 2022-05-14 12:30
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0004_auto_20220514_1456'),
]
operations = [
migrations.RemoveField(
model_name='widgetuser',
name='department',
),
migrations.AddField(
model_name='department',
name='widgetuser',
field=models.ForeignKey(default='none', on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.AlterField(
model_name='department',
name='dept_name',
field=models.CharField(default='none', max_length=50),
),
migrations.AlterField(
model_name='department',
name='home_unit',
field=models.CharField(default='none', max_length=50),
),
]
......@@ -12,9 +12,9 @@ class WidgetUser(models.Model):
return self.last_name
class Department(models.Model):
widgetuser = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=50)
widgetuser = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, default='none')
dept_name = models.CharField(max_length=50, default='none')
home_unit = models.CharField(max_length=50, default='none')
def __str__(self):
return self.dept_name
\ No newline at end of file
h1 {
color: palevioletred;
font-weight: bold;
}
h2 {
color: palevioletred;
font-weight: bold;
}
ol {
color: wheat;
font-weight: bold;
}
ul {
color: wheat;
font-weight: bold;
}
body {
background-color: black;
}
a {
color: yellow;
}
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width-device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{% static 'homepage/style.css' %}">
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "homepage/base.html" %}
{% block content %}
<h2>
{{ Department.widgetuser.last_name }},
{{ Department.widgetuser.first_name }}
{{ Department.widgetuser.middle_name }}
</h2>
<ul>
<li>{{ Department.widgetuser.id_num }}</li>
<li>{{ Department.widgetuser.email }}</li>
<li>{{ Department.dept_name }}</li>
<li>{{ Department.home_unit }}</li>
</ul>
{% endblock %}
\ No newline at end of file
<p>
<h2>WIDGET USERS:</h2>
{% for Department in Departments %}
<p>
<b>{{Department.widgetuser.last_name}}, {{Department.widgetuser.first_name}} {{Department.widgetuser.middle_name}}</b>:
{{Department.widgetuser.id_num}}, {{Department.widgetuser.email}}, {{Department.dept_name}}, {{Department.home_unit}}
</p>
{% endfor %}
</p>
\ No newline at end of file
{% extends "homepage/base.html" %}
{% block content %}
<p>
<h1>Welcome to Widget!</h1>
<h2>WIDGET USERS:</h2>
{% if WidgetUser %}
<ol>
{% for widgetUser in WidgetUser %}
<li>
<a href="/homepage/{{department.id_num}}/">
{{widgetUser.last_name}},
{{widgetUser.first_name}}
{{widgetUser.middle_name}}
<a href="{% url 'homepage:details' widgetUser.id_num %}">
{{ widgetUser.last_name }},
{{ widgetUser.first_name }}
{{ widgetUser.middle_name }}
</a>
</li>
{% endfor %}
......@@ -15,4 +19,5 @@
{% else %}
<p>No widget users registered.</p>
{% endif %}
</p>
\ No newline at end of file
</p>
{% endblock %}
......@@ -2,7 +2,9 @@ from django.urls import path
from . import views
app_name = "homepage"
urlpatterns = [
path('', views.index, name='index')
]
path('', views.index, name='index'),
path("users/<int:widgetuser_id>/details/", views.detail, name='details')
]
\ No newline at end of file
from .models import Department
from .models import WidgetUser
from django.http import HttpResponse
from django.http import Http404
from django.shortcuts import render
def index(request):
global WidgetUser
widgetUser = WidgetUser.objects.order_by("last_name")
#department = Department.objects.order_by("widgetuser.last_name")
widgetUser = WidgetUser.objects.order_by("last_name")
def index(request):
context = {
"WidgetUser": widgetUser
}
return render(request, "homepage/widgetusers_orderedlist.html", context)
# def detail(request, user_id):
# try:
# Departments = Department.objects.get(pk=department_widgetuser_id_num)
# except Department.DoesNotExist:
# raise Http404("User does not exist!")
# return render(request, "homepage/details.html", {"Departments": Department})
# return HttpResponse("This is Widget User # %s." % user_id)
def detail(request, widgetuser_id):
try:
department = Department.objects.get(pk=widgetuser_id)
except Department.DoesNotExist:
raise Http404("User does not exist!")
return render(request, "homepage/details.html", {"Department": department})
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