Commit 5c33f14c authored by Brendan Fausto's avatar Brendan Fausto

Created list view of dashboard users and correspoding template

parent 5ec7a86c
...@@ -23,4 +23,7 @@ class WidgetUser(models.Model): ...@@ -23,4 +23,7 @@ class WidgetUser(models.Model):
def __str__(self): def __str__(self):
return '{}, {} {}: {}, {}'.format(self.last_name, self.first_name, self.middle_name, self.dept_name, self.home_unit) return '{}, {} {}: {}, {}'.format(self.last_name, self.first_name, self.middle_name, self.dept_name, self.home_unit)
'''
\ No newline at end of file def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs = {'pk': self.id})
'''
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}
Widget v2
{% endblock %}
{% block header %}
<h1>Welcome to Widget!</h1>
{% endblock %}
{% block content %}
Widget Users:
<br>
<ul>
{% for object in users %}
<li>
<a href = "{{ object.get_absolute_url }}">{{ object.activity }}</a>
</li>
{% endfor %}
</ul>
<form action = "http://127.0.0.1:8000/widgetusers/add">
<input type = "submit" value = "Add Widget User" />
</form>
<p>
<a href = "http://127.0.0.1:8000/announcements">Announcements</a>
<a href = "http://127.0.0.1:8000/forum">Forum</a>
<a href = "http://127.0.0.1:8000/assignments">Assignments</a>
<a href = "http://127.0.0.1:8000/calendar">Calendar</a>
</p>
{% endblock %}
\ No newline at end of file
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
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='index'),
] ]
......
from django.shortcuts import render from django.shortcuts import render, redirect
from django.views import View
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import UpdateView
from django.shortcuts import get_object_or_404
from django.views.generic.edit import CreateView, UpdateView
from django.forms import formset_factory, BaseFormSet, HiddenInput, modelform_factory
from django.http import HttpResponse from django.http import HttpResponse
from .models import WidgetUser from .models import WidgetUser
# Create your views here. # Create your views here.
def index(request): def dashboard(request):
return_string = '<body>Welcome to Widget!<br><br>WIDGET USERS:<br><ul>' users = WidgetUser.objects.all()
for user in WidgetUser.objects.all(): return render(request, 'dashboard/dashboard.html', {
user_string = '<li>{}</li>'.format(user.__str__()) 'users': users
return_string += user_string })
return_string += '</ul></body>'
html_string = '<html>{}</html>'.format(return_string)
return HttpResponse(html_string)
<!-- bookshelf/template/base.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<title>{% block title %}{% endblock %}</title>
</head>
<body style = "background-color:#F0FFFF;">
{% block header %}
{% endblock %}
<br>
{% block content %}
{% endblock %}
</div>
</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