Commit 92f042e7 authored by Almira Redoble's avatar Almira Redoble

Implemented dashboard page. This includes modifying views.py and moving the...

Implemented dashboard page. This includes modifying views.py and moving the index view's contents into dashboard.html, a newly-created template for the implementation. Additionally, base.html, the app-level base template, was created.
parent afb30f8e
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="/static/style.css">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div id="heading">
{% block heading %}{% endblock %}
</div>
<div id="content">
{% block content %}{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget v2{% endblock %}
{% block heading %}Welcome to Widget!{% endblock %}
{% block content %}
<p div="heading">Widget Users:</p>
<ul>
{% for user in users %}
<li>
<a href="#">
{{ user.last_name }}, {{ user.first_name }}</a>
</li>
{% endfor %}
</ul>
<button onclick="window.location.href='#';">
Add Widget User
</button>
<div id="footer">
<a href="{% url 'announcementBoard:index' %}">Announcement Board</a>
<a href="{% url 'forum:index' %}">Forum</a>
<a href="{% url 'assignments:homePage' %}">Assignments</a>
<a href="{% url 'widget_calendar:index' %}">Calendar</a>
</div>
{% endblock %}
\ No newline at end of file
...@@ -3,7 +3,7 @@ from .views import index ...@@ -3,7 +3,7 @@ from .views import index
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('dashboard/', index, name='index'),
] ]
......
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.views.generic.detail import DetailView
from .models import WidgetUser from .models import WidgetUser
def index(request): def index(request):
users = WidgetUser.objects.all()
head = "<h1 style='border-bottom:4px solid lightgray;\ return render(request, 'dashboard/dashboard.html', {'users': users, })
padding-bottom:30px;\
font-size:500%;'>\
Welcome to Widget!\
</h1>"
body = "<h2>WIDGET USERS:</h2>"
for user in WidgetUser.objects.all():
body += "<p style='border: 2px solid gray;\
border-radius:5px;\
padding:20px 30px;'>\
{}: {}<br>\
</p>".format(user, user.department)
return_string = "<html>\
<body style = 'font-family:helvetica;\
padding:30px;'>\
{}{}\
</body></html>".format(head, body)
return HttpResponse(return_string)
...@@ -18,7 +18,7 @@ from django.urls import include, path ...@@ -18,7 +18,7 @@ from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('dashboard/', include('dashboard.urls', namespace="dashboard")), path('', include('dashboard.urls', namespace="dashboard")),
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")), path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('assignments/', include('assignments.urls', namespace="assignments")), path('assignments/', include('assignments.urls', namespace="assignments")),
path('announcementBoard/', include('announcementBoard.urls', namespace="announcementBoard")), path('announcementBoard/', include('announcementBoard.urls', namespace="announcementBoard")),
......
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