Updated FBV implementation to use template

parent dbf1408f
from django.shortcuts import render
from .models import WidgetUser from .models import WidgetUser
from django.http import HttpResponse from django.http import HttpResponse
from django.views import generic from django.views import generic
...@@ -5,29 +6,13 @@ from django.urls import reverse ...@@ -5,29 +6,13 @@ from django.urls import reverse
def Dashboard_list_view(request): def Dashboard_list_view(request):
html_string_1 = '<html lang="en"><head><meta charset="UTF-8">' \ users = WidgetUser.objects.all()
'<h1>Welcome to Widget</h1>' \ context = {
'<h2>WIDGET USERS</h2></head><ul>' 'users': users
html_string_2 = '' }
for wu in WidgetUser.objects.all(): return render(request, 'dashboard/dashboard.html', context)
number = str(wu.pk)
href = '<a href="/Widgetusers/' + number + '/details">'
html_string_2 += '<li>' + href + '{}, {} {}: {}, {}' .format(
wu.last_name,
wu.first_name,
wu.middle_name,
wu.department.dept_name,
wu.department.home_unit
)
html_string_2 += '</ul></li>'
html_string_3 = '<a href="/Widgetusers/add"><button value="click here" > Add Widget User</button></a><br><br>'
html_string_3 += '<a href="/announcements/">Announcement Board</a><br>'
html_string_3 += '<a href="/forum/">Forum</a><br>'
html_string_3 += '<a href="/assignments">Assignment</a><br>'
html_string_3 += '<a href="/widget_Calendar/">Calendar</a><br>'
html_string_final = html_string_1 + html_string_2 + html_string_3 + '</html>'
return HttpResponse(html_string_final)
class WidgetUserDetailView(generic.DetailView): class WidgetUserDetailView(generic.DetailView):
......
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