Commit f6d978b6 authored by Gabriel G. Garrero's avatar Gabriel G. Garrero

created dashboard.html, updated models.py, views.py, urls.py to account for new dashboard page

parent 4005cf20
from django.db import models from django.db import models
from django.urls import reverse
# Create your models here. # Create your models here.
...@@ -17,3 +18,6 @@ class WidgetUser(models.Model): ...@@ -17,3 +18,6 @@ class WidgetUser(models.Model):
def __str__(self): def __str__(self):
return self.first_name + ' ' + self.last_name return self.first_name + ' ' + self.last_name
def get_absolute_url(self):
return reverse("widgetusers:user-details", kwargs={"pk": self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget v2{% endblock %}
{% block content %}
<h1>Welcome to Widget!</h1>
<h2>Widget Users:</h2>
<ul>
{% for user in users %}
<li>
<a href = "{{ user.get_absoluteurl }}">{{ user.last_name }}, {{ user.first_name }}</a>
</li>
{% endfor %}
</ul>
<a href = "../widgetusers/add">Add Widget User</a>
<div>
<a href = "../announcements">Announcement Board</a>
<a href = "../forum">Forum</a>
<a href = "../assignments">Assignments</a>
<a href = "../calendar">Calendar</a>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import dashboard
urlpatterns = [ urlpatterns = [
path('', index, name = 'index') path('', dashboard, name = 'dashboard'),
] ]
app_name = "dashboard" app_name = "dashboard"
\ No newline at end of file
...@@ -3,14 +3,10 @@ from django.http import HttpResponse ...@@ -3,14 +3,10 @@ from django.http import HttpResponse
from .models import Department, WidgetUser from .models import Department, WidgetUser
def index(request): def dashboard(request):
users = WidgetUser.objects.all() users = WidgetUser.objects.all()
context = {
"users": users
}
welcomeMessage = 'Welcome to Widget!<br><br>WIDGET USERS:<br>' return render(request, 'dashboard/dashboard.html', context)
widgetusers = '' \ No newline at end of file
for user in users:
widgetusers += user.last_name + ', ' + user.first_name + ' ' + user.middle_name + ': '
widgetusers += user.department.dept_name + ', ' + user.department.home_unit + '<br>'
return HttpResponse(welcomeMessage + widgetusers)
\ 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