Commit 318e225a authored by Ian Rafael T. Aragoza's avatar Ian Rafael T. Aragoza

Added bootstrap styling, links for dashboard main page

parent e5514ee5
...@@ -11,7 +11,7 @@ class Department(models.Model): ...@@ -11,7 +11,7 @@ class Department(models.Model):
return '{}'.format(self.dept_name) return '{}'.format(self.dept_name)
def get_absolute_url(self): def get_absolute_url(self):
return reverse('department_detail', args=[str(self.dept_name)]) return f"{self.pk}"
class WidgetUser(models.Model): class WidgetUser(models.Model):
...@@ -24,4 +24,4 @@ class WidgetUser(models.Model): ...@@ -24,4 +24,4 @@ class WidgetUser(models.Model):
return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name) return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name)
def get_absolute_url(self): def get_absolute_url(self):
return reverse('user_detail', args=[str(self.last_name)]) return f"{self.pk}"
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget v2{% endblock %}
{% block content %}
<div class="container-fluid p-3 bg-dark text-white text-center">
<br>
<h1 class="display-4">Welcome to Widget!</h1>
<br>
</div>
<div class="container my-5 text-center">
<h3 class="display-6">Widget Users:</h3>
<br>
{% for object in object_list %}
<p><a href="{{ object.get_absolute_url }}/details/">{{ object.last_name }}, {{ object.first_name }}</a></p>
{% endfor %}
<br><br>
<div class="container">
<div class="row">
<div class="col-6">
<a href="/widgetusers/add"><button type="button" class="btn btn-primary">Add Widget User</button></a>
</div>
<div class="col-6">
<a href="/announcements"><button type="button" class="btn btn-primary">Announcements</button></a>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.urls import path from django.urls import path
from .views import index from .views import dashboard, addUser, userDetails
# Create your views here. # Create your views here.
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', dashboard, name='index'),
path('widgetusers/add/', addUser, name='add-user'),
path('widgetusers/<int:pk>/details/', userDetails, name='user-details'),
] ]
app_name = "dashboard" app_name = "dashboard"
...@@ -5,8 +5,15 @@ from .models import WidgetUser ...@@ -5,8 +5,15 @@ from .models import WidgetUser
# Create your views here. # Create your views here.
def index(request): def dashboard(request):
output = "<h1>Welcome to Widget!</h1><h3>WIDGET USERS:</h3>" users = WidgetUser.objects.all()
userList = WidgetUser.objects.order_by('last_name') context = {
output += '<br>'.join(['{}, {} {}: {}, {}'.format(user.last_name, user.first_name, user.middle_name, user.department, user.department.home_unit) for user in userList]) 'object_list': users
return HttpResponse(output) }
return render(request, 'dashboard/dashboard.html', context)
def addUser(request):
return render(request, 'dashboard.html')
def userDetails(request):
return render(request, 'dashboard.html')
...@@ -43,7 +43,7 @@ INSTALLED_APPS = [ ...@@ -43,7 +43,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'dashboard', 'dashboard',
'announcementboard', 'announcementboard',
'forum', 'bootstrap5',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
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