Commit e6b25bc9 authored by John Tamano's avatar John Tamano

Added lab3 changes to homepage

parent 59c7eb01
{% block content %}
<h1>WIDGET USERS:</h1>
{% for WidgetUser in displayWidgetUsers %}
<p>
{{WidgetUser.last_name}}, {{WidgetUser.first_name}} {{WidgetUser.middle_name}}:
{{WidgetUser.id_num}}, {{WidgetUser.email}}, {{WidgetUser.department}}, {{WidgetUser.department.home_unit}}
</p>
{% endfor %}
{% endblock %}
<html>
<h1>Welcome to Widget!</h1>
<p1>Widget Users:</p1>
<ol>
{% for WidgetUser in WidgetUsers %}
<p1>
<li><a href = "/users/{{ WidgetUser.id }}/details">{{WidgetUser.last_name}}, {{WidgetUser.first_name}} {{WidgetUser.middle_name}}</a></li>
</p1>
{% endfor %}
</ol>
</html>
\ No newline at end of file
<p1>
{{widgetuserdetails.last_name}},
{{widgetuserdetails.first_name}}
{{widgetuserdetails.middle_name}}
<br>
<li>{{widgetuserdetails.id_num}}</li>
<li>{{widgetuserdetails.email}}</li>
<li>{{widgetuserdetails.department.dept_name}}</li>
<li>{{widgetuserdetails.department.home_unit}}</li>
</p1>
<img src="https://thumbs.dreamstime.com/b/default-avatar-profile-vector-user-profile-default-avatar-profile-vector-user-profile-profile-179376714.jpg" style="width: 100px;height: 100px;">
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import displayWidgetUsers, index from .views import displayWidgetUsers, displayUserDetails
urlpatterns = [ urlpatterns = [
path('',displayWidgetUsers, name='displayWidgetUsers') path('homepage/',displayWidgetUsers, name='displayWidgetUsers'),
path('users/<int:user_id>/details',displayUserDetails, name='displayUserDetails')
] ]
app_name = "homepage" app_name = "homepage"
\ No newline at end of file
...@@ -3,13 +3,32 @@ from django.shortcuts import render ...@@ -3,13 +3,32 @@ from django.shortcuts import render
from django.template.loader import get_template from django.template.loader import get_template
from homepage.models import Department, WidgetUser from homepage.models import Department, WidgetUser
from django.template import Template, Context from django.template import Template, Context
from django.http import HttpResponse from django.http import Http404, HttpResponse
from . import models from . import models
def index(request): def index(request):
return HttpResponse('Welcome to Widget!') return HttpResponse('Welcome to Widget!')
def displayWidgetUsers(request):
WidgetUsers = models.WidgetUser.objects.order_by("last_name")
context = {
"WidgetUsers": WidgetUsers
}
return render(request, "homepage/homepage.html", context)
def displayUserDetails(request, user_id):
try:
widgetuserdetails = WidgetUser.objects.get(pk=user_id)
except WidgetUser.DoesNotExist:
raise Http404("This User Does Not Exist!")
context = {
"widgetuserdetails" : widgetuserdetails
}
return render(request, "users/details.html", context)
'''
def displayWidgetUsers(request): def displayWidgetUsers(request):
WidgetUsers = models.WidgetUser.objects.all() WidgetUsers = models.WidgetUser.objects.all()
WidgetUserInfo = "" WidgetUserInfo = ""
...@@ -24,5 +43,5 @@ def displayWidgetUsers(request): ...@@ -24,5 +43,5 @@ def displayWidgetUsers(request):
temp = last_name + ", " + first_name + " " + middle_name + ": " + id_number + ", " + email + ", " + dept + ", " + home_unit temp = last_name + ", " + first_name + " " + middle_name + ": " + id_number + ", " + email + ", " + dept + ", " + home_unit
WidgetUserInfo += "<br>" + temp WidgetUserInfo += "<br>" + temp
return HttpResponse("WIDGET USERS:\n" + WidgetUserInfo) return HttpResponse("WIDGET USERS:\n" + WidgetUserInfo)
'''
# Create your views here. # Create your views here.
...@@ -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('homepage/', include('homepage.urls', namespace="homepage")), path('', include('homepage.urls', namespace="homepage")),
path('announcements/', include('announcements.urls', namespace = "announcements")), path('announcements/', include('announcements.urls', namespace = "announcements")),
path('forum/',include('forum.urls',namespace="forum")), path('forum/',include('forum.urls',namespace="forum")),
path('assignments/', include('assignments.urls', namespace="assignments")), path('assignments/', include('assignments.urls', namespace="assignments")),
......
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