Commit 113e781b authored by Charles Lim's avatar Charles Lim

Created base.html and base css for homepage app

parent 521cdd5e
...@@ -11,6 +11,7 @@ media ...@@ -11,6 +11,7 @@ media
# Environments # Environments
.env .env
/widgetenv
# .vscode # .vscode
.vscode .vscode
......
<!-- homepage/widgetuser_detail.html -->
{% extends 'base.html' %}
{% block title %}Homepage{% endblock %}
{% block content %}
<p> {{object.last_name}}, {{object.first_name}} {{object.middle_name}} </p>
<p> {{object.id_num}}</p>
<p> {{object.email}}</p>
<p> {{object.department.home_unit}}, {{object.department.dept_name}}</p>
{% endblock %}
\ No newline at end of file
<!-- homepage/index.html -->
{% extends 'base.html' %}
{% block title %}Homepage{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<h1>Welcome to Widget!</h1>
{% for user in all_widgetusers %}
<a href="{{user.id}}/details">{{forloop.counter}}. {{user.last_name}}, {{user.first_name}} {{user.middle_name}}</a> </br>
{% endfor %}
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import HomepageView, WidgetUserDetailView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', HomepageView.as_view(), name='index'),
path('<int:pk>/details', WidgetUserDetailView.as_view(),name='widgetuser_detail'),
] ]
app_name = "homepage" app_name = "homepage"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.views import View
from django.views.generic.detail import DetailView
from .models import Department, WidgetUser
from forum.views import display_forumposts
from .models import WidgetUser, Department
from django.http import HttpResponse
def index(request): class HomepageView(View):
return HttpResponse(display_homepage(WidgetUser.objects.all(), Department.objects.all())) def get(self, request):
objects_set = {
"all_widgetusers": [obj for obj in WidgetUser.objects.all().order_by('last_name')]
}
return render(request, 'index.html', objects_set)
# View for HomePage
def display_homepage(widgetuser_data, department_data):
display_output = "WIDGET USERS: <br>"
for object in widgetuser_data: class WidgetUserDetailView(DetailView):
first_name = object.first_name model = WidgetUser
middle_name = object.middle_name
last_name = object.last_name
id_num = object.id_num
department_object = Department.objects.filter(id=object.department_id).first()
if (department_object != None):
dept_name = department_object.dept_name
home_unit = department_object.home_unit
else:
dept_name = "NONE"
home_unit = "NONE"
display_output += f'''
{last_name}, {first_name} {middle_name}: {id_num}, {dept_name}, {home_unit}<br>
'''
return display_output
...@@ -42,10 +42,11 @@ INSTALLED_APPS = [ ...@@ -42,10 +42,11 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'widget_father_when_can_i_be_on_my_own_i_have_the_hello_world_to_see',
'forum', 'forum',
'assignments', 'assignments',
'homepage', 'homepage',
'announcement_board', 'announcement_board'
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -124,7 +125,8 @@ USE_TZ = True ...@@ -124,7 +125,8 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/ # https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
......
nav:focus {
outline:0 !important;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: row;
width: 100%;
background-color: #bb00ff;
}
ul li {
padding: 20px;
}
ul li a {
padding: 21px;
text-decoration: none;
color: white;
}
ul li a:hover {
background-color: #cc00ff
}
body {
margin: 0;
}
<!-- project/template/base.html -->
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
<link href="{% static 'base_style.css' %}" rel="stylesheet">
{% block styles %}{% endblock %}
</head>
<body>
<nav>
<ul>
<li><a href="/homepage">Homepage</a></li>
<li><a href="/assignments">Assignments</a></li>
<li><a href="/forum">Forum</a></li>
<li><a href="/announcements">Announcement Board</a></li>
</ul>
</nav>
<div id="content">
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
\ 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