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): ...@@ -12,9 +12,9 @@ class WidgetUser(models.Model):
return self.last_name return self.last_name
class Department(models.Model): class Department(models.Model):
widgetuser = models.ForeignKey(WidgetUser, on_delete=models.CASCADE) widgetuser = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, default='none')
dept_name = models.CharField(max_length=50) dept_name = models.CharField(max_length=50, default='none')
home_unit = models.CharField(max_length=50) home_unit = models.CharField(max_length=50, default='none')
def __str__(self): def __str__(self):
return self.dept_name 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> <p>
<h1>Welcome to Widget!</h1>
<h2>WIDGET USERS:</h2> <h2>WIDGET USERS:</h2>
{% if WidgetUser %} {% if WidgetUser %}
<ol> <ol>
{% for widgetUser in WidgetUser %} {% for widgetUser in WidgetUser %}
<li> <li>
<a href="/homepage/{{department.id_num}}/"> <a href="{% url 'homepage:details' widgetUser.id_num %}">
{{widgetUser.last_name}}, {{ widgetUser.last_name }},
{{widgetUser.first_name}} {{ widgetUser.first_name }}
{{widgetUser.middle_name}} {{ widgetUser.middle_name }}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
...@@ -15,4 +19,5 @@ ...@@ -15,4 +19,5 @@
{% else %} {% else %}
<p>No widget users registered.</p> <p>No widget users registered.</p>
{% endif %} {% endif %}
</p> </p>
\ No newline at end of file {% endblock %}
...@@ -2,7 +2,9 @@ from django.urls import path ...@@ -2,7 +2,9 @@ from django.urls import path
from . import views from . import views
app_name = "homepage"
urlpatterns = [ 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 Department
from .models import WidgetUser from .models import WidgetUser
from django.http import HttpResponse from django.http import Http404
from django.shortcuts import render from django.shortcuts import render
def index(request): widgetUser = WidgetUser.objects.order_by("last_name")
global WidgetUser #department = Department.objects.order_by("widgetuser.last_name")
widgetUser = WidgetUser.objects.order_by("last_name") def index(request):
context = { context = {
"WidgetUser": widgetUser "WidgetUser": widgetUser
} }
return render(request, "homepage/widgetusers_orderedlist.html", context) return render(request, "homepage/widgetusers_orderedlist.html", context)
# def detail(request, user_id): def detail(request, widgetuser_id):
# try: try:
# Departments = Department.objects.get(pk=department_widgetuser_id_num) department = Department.objects.get(pk=widgetuser_id)
# except Department.DoesNotExist: except Department.DoesNotExist:
# raise Http404("User does not exist!") raise Http404("User does not exist!")
# return render(request, "homepage/details.html", {"Departments": Department})
# return HttpResponse("This is Widget User # %s." % user_id) 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