Commit 2f2f0e03 authored by Miguel Luis D. Bandelaria's avatar Miguel Luis D. Bandelaria

update: modified templates to display partially according to specifications.

parents 6f0226c9 c4320554
<h1>{{ post.post_title }}</h1>
<h3>by {{ post.author.first_name }}, {{ post.pub_date|date:"SHORT_DATE_FORMAT" }}</h3>
<p>{{ post.post_body }}</p>
\ No newline at end of file
{% if posts_list %}
<ul>
{% for post in posts_list %}
<li><a href="{% url 'forum:detail' post.id %}">{{ post.post_title }}</a></li>
<li><a href="{% url 'forum:detail' post.id %}">{{ post.post_title }}</a> by {{ post.author_id.first_name }} {{ post.author_id.last_name}} dated {{ post.pub_date|date:"SHORT_DATE_FORMAT" }}</li>
{% endfor %}
</ul>
{% else %}
......
# Generated by Django 4.0.3 on 2022-05-06 09:01
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0007_alter_widgetuser_id_num'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='homeunit',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='homeunit', to='homepage.department'),
),
]
# Generated by Django 4.0.3 on 2022-05-06 09:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0008_widgetuser_homeunit'),
]
operations = [
migrations.RemoveField(
model_name='widgetuser',
name='homeunit',
),
]
# Generated by Django 4.0.3 on 2022-05-06 14:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0009_remove_widgetuser_homeunit'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='profile',
field=models.ImageField(null=True, upload_to='homepage/static/homepage/'),
),
]
# Generated by Django 4.0.3 on 2022-05-06 15:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0010_widgetuser_profile'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile',
field=models.TextField(),
),
]
# Generated by Django 4.0.3 on 2022-05-06 15:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0011_alter_widgetuser_profile'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile',
field=models.TextField(null=True),
),
]
# Generated by Django 4.0.3 on 2022-05-06 15:09
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0012_alter_widgetuser_profile'),
]
operations = [
migrations.RenameField(
model_name='widgetuser',
old_name='profile',
new_name='profile_url',
),
]
# Generated by Django 4.0.3 on 2022-05-07 00:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0013_rename_profile_widgetuser_profile_url'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.ImageField(null=True, upload_to='homepage/static/'),
),
]
# Generated by Django 4.0.3 on 2022-05-07 01:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0014_alter_widgetuser_profile_url'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.ImageField(null=True, upload_to='static/'),
),
]
# Generated by Django 4.0.3 on 2022-05-07 01:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0015_alter_widgetuser_profile_url'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.ImageField(null=True, upload_to='homepage/static/'),
),
]
# Generated by Django 4.0.3 on 2022-05-07 02:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0016_alter_widgetuser_profile_url'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.FileField(null=True, upload_to='homepage/static/'),
),
]
from django.db import models
from django.core.validators import MaxValueValidator
import os
class Department(models.Model):
dept_name = models.CharField(max_length=50, null=True)
......@@ -18,6 +19,11 @@ class WidgetUser(models.Model):
on_delete=models.CASCADE,
null=True,
related_name='department')
profile_url = models.FileField(upload_to='homepage/static/', null=True)
def __str__(self):
return self.first_name
def file(self):
value = os.path.basename(self.profile_url.name)
return value
This diff is collapsed.
p{
color: white;
font-weight: bold;
font-family: Helvetica;
font-size:25px;
}
h1 {
position: sticky;
text-align: left;
color: white;
font-size: 55px;
font-family: Helvetica;
}
body {
background-image: url("/static/bg.png");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
background-attachment: fixed;
font-family: Helvetica;
}
a{
color: white;
font-family: Helvetica;
font-weight: bold;
}
ol {
font-size:35px;
font-family: Helvetica;
color:white;
font-weight: bold;
}
a:link {
text-decoration: none;
}
img{
position: relative;
top: 150px;
}
\ 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">
<link rel="stylesheet" type="text/css"
href="{% static 'homepage/style.css' %}">
<title>Website</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "homepage/base.html" %}
{% block content %}
<div>
<ul>
<p style="font-size:50px; position: relative; top:70px;">
{{details.last_name}}, {{details.first_name}} {{details.middle_name}}
</p>
<p style="position: absolute; top:150px">
ID Number: {{ details.id_num }}
</p>
<p style="position: absolute; top:180px">
Email Address: {{ details.email }}
</p>
<p style="position: absolute; top:210px">
Department: {{ details.department.dept_name }}
</p>
<p style="position: absolute; top:240px">
Home Unit: {{ details.department.home_unit }}
</p>
<img src = "/static/{{ details.file }} " width="250" height="250">
</ul>
</div>
{% endblock %}
{% extends "homepage/base.html" %}
{% block content %}
<div style = "position: relative; left:80px; top:30px;">
<h1>WELCOME TO WIDGET!</h1>
</div>
<div style = "position:relative; left:80px; top:35px;">
<p>Widget Users:
<ol>
{% for user in widget_user %}
<li><a href="/users/{{ user.id_num }}/details/">
{{ user.last_name }}, {{ user.first_name }} {{ user.middle_name }}
</a></li>
{% endfor %}
</ol>
</p>
</div>
{% endblock %}
......@@ -2,6 +2,7 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('welcome', views.welcome, name='welcome')
path('homepage/', views.index, name='index'),
path('welcome', views.welcome, name='welcome'),
path("users/<int:id_num>/details/", views.details, name='details')
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponse, Http404
from .models import Department, WidgetUser
# Create your views here.
......@@ -7,8 +7,19 @@ def welcome(request):
return HttpResponse('Welcome to Widget!')
def index(request):
widget_user = WidgetUser.objects.order_by("last_name")
context = {
"widget_user": widget_user
}
return render(request, "homepage/index.html", context)
'''
NOTE: Clean code dictates that
code be deleted. For grading purposes,
previous code will only be commented out.
widget_user_view = 'WIDGET USERS: '
widget_user = WidgetUser.objects.all()
for user in widget_user:
widget_user_view += "<br/> {}, {} {}: {}, {}, {}, {}".\
......@@ -21,3 +32,11 @@ def index(request):
user.department.home_unit)
return HttpResponse(widget_user_view)
'''
def details(request, id_num):
try:
details = WidgetUser.objects.get(pk=id_num)
except WidgetUser.DoesNotExist:
raise Http404("User does not exist.")
return render(request, "homepage/details.html", {"details": details})
\ No newline at end of file
......@@ -19,7 +19,6 @@ load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
......@@ -31,7 +30,6 @@ DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
......
......@@ -15,11 +15,13 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import include, path
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
path('homepage/', include('homepage.urls')),
path('', include('homepage.urls')),
path('admin/', admin.site.urls),
path('announcements/', include('announcements.urls')),
path('forum/', include('forum.urls')),
path('assignments/', include('assignments.urls'))
]
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