Commit 01039807 authored by Justin Daniel Mendoza's avatar Justin Daniel Mendoza

Merge branch 'mendoza/homepage'

parents d650ba02 c24cecae
# Generated by Django 4.0.3 on 2022-05-15 08:45
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_widgetuser_email_widgetuser_id_num_department'),
('announcements', '0002_alter_announcement_announcement_body'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='author',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.AlterField(
model_name='announcement',
name='announcement_title',
field=models.CharField(max_length=100),
),
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reaction_name', models.CharField(choices=[('LIKE', 'Like'), ('LOVE', 'Love'), ('ANGRY', 'Angry')], default='LIKE', max_length=5)),
('tally', models.IntegerField(default=0)),
('announcement', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
No preview for this file type
# Generated by Django 4.0.3 on 2022-05-15 09:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_widgetuser_email_widgetuser_id_num_department'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='user_imageUrl',
field=models.CharField(default=0, max_length=999),
),
]
...@@ -8,6 +8,7 @@ class WidgetUser(models.Model): ...@@ -8,6 +8,7 @@ class WidgetUser(models.Model):
last_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20)
id_num = models.IntegerField() id_num = models.IntegerField()
email = models.EmailField(max_length=100) email = models.EmailField(max_length=100)
user_imageUrl = models.CharField(max_length=999, default = 1)
......
h1 {
font-family: 'Courier New', Courier, monospace;
}
h3 {
font-family: 'Courier New', Courier, monospace;
border: 2px solid black;
background-color: azure;
}
body {
background-color: bisque;
}
ul {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
list-style-type: square;
border: 5px solid black;
background-color: aliceblue;
}
img {
max-width: 500px;
}
\ 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' %}">
<title></title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "homepage/base.html" %}
{% block content %}
<img src = {{user.user_imageUrl}}><br>
{% for dept in dept_list%}
{% if dept.widgetuser.last_name == user.last_name %}
<h3>{{dept.widgetuser.id_num}}</h3><br>
<h3>{{dept.widgetuser.email}}</h3><br>
<h3>{{dept.dept_name}}</h3><br>
<h3>{{dept.home_unit}}</h3><br>
{% endif %}
{% endfor %}
{% endblock %}
\ No newline at end of file
{% extends "homepage/base.html" %}
{% block content %}
<h1> Welcome to Widget!</h1>
{% if user_list %}
<p>WIDGET USERS: </p>
<ol type = "1">
{% for user in user_list %}
<p><li><a href ="{% url 'user' user.id%}">{{user.last_name}}, {{user.first_name}} {{user.middle_name}}</a></li></p>
{% endfor %}
</ol>
{% else %}
<p> users do not exist. </p>
{% endif %}
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<body>
<h1>WIDGET USERS: </h1>
{% for Depts in Depts %}
<h4>{{Depts.widgetuser.last_name}}, {{Depts.widgetuser.first_name}} {{Depts.widgetuser.middle_name}}: {{Depts.widgetuser.id_num}}, {{Depts.widgetuser.email}}, {{ Depts.dept_name }}, {{ Depts.home_unit }}</h4>
{% endfor %}
</body>
</html>
\ No newline at end of file
...@@ -3,6 +3,8 @@ from django.urls import path ...@@ -3,6 +3,8 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index') path('', views.index, name='index'),
path("<int:user_id>/details/", views.user, name='user')
] ]
...@@ -7,11 +7,19 @@ from django.shortcuts import render ...@@ -7,11 +7,19 @@ from django.shortcuts import render
def index(request): def index(request):
widgets = WidgetUser.objects.all() widgets = WidgetUser.objects.all()
depts = Department.objects.all() depts = Department.objects.all()
user_list = WidgetUser.objects.order_by("last_name")
context ={ context ={
'Widgets':widgets, 'Widgets':widgets,
'Depts':depts 'Depts':depts,
'user_list':user_list
} }
return render(request, "view_homepage.html", context) return render(request, "homepage/view_homepage.html", context)
def user(request, user_id):
dept_list = Department.objects.order_by("widgetuser_id")
try:
user = WidgetUser.objects.get(pk=user_id)
except WidgetUser.DoesNotExist:
raise Http404("User doesnt exist")
return render(request,"homepage/user_details.html",{"user": user, 'dept_list':dept_list})
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