Finalize views and htmls

parent 69dd52d5
from django.db import models from django.db import models
from django.urls import reverse
class Department(models.Model): class Department(models.Model):
default_string = "" default_string = ""
...@@ -20,4 +21,4 @@ class WidgetUser(models.Model): ...@@ -20,4 +21,4 @@ class WidgetUser(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('Dashboard:user_details', kwargs={'pk': self.pk}) return reverse('Dashboard:user_details', kwargs={'user_id': self.id})
\ No newline at end of file \ No newline at end of file
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
{% block content %} {% block content %}
<h> Welcome to Widget! </h> <h> Welcome to Widget! </h>
<ul> <ul>
{% for object in object_list %} {% for user in users %}
<li><a href = "{{ object.id }}/details/">{{ object.last_name }} {{ object.first_name }}</a></li> <li><a href = "../widgetusers/{{ user.id }}/details/">{{ user.last_name }} {{ user.first_name }}</a></li>
{% empty %} {% empty %}
<li>No users registered.</li> <li>No users registered.</li>
{% endfor %} {% endfor %}
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
{% block content %} {% block content %}
<h style = "text-transform: uppercase"> {{user.first_name}} {{user.middle_name}} {{user.last_name}} </h> <h style = "text-transform: uppercase"> {{user.first_name}} {{user.middle_name}} {{user.last_name}} </h>
<p> <p>
<br />{{user.department.dept_name}} {{user.department.dept_name}}
<br />{{user.department.home_unit}} <br />{{user.department.home_unit}}
<button onclick="window.location.href='../../../widgetusers/{{author.id}}/edit/';">Edit Author</button> <br /> <br> <button onclick="window.location.href='../../../widgetusers/{{user.id}}/edit/';">Edit Author</button> <br />
</p> </p>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -3,9 +3,14 @@ from django.http import HttpResponse, Http404 ...@@ -3,9 +3,14 @@ from django.http import HttpResponse, Http404
from django.shortcuts import render from django.shortcuts import render
from django.views import View from django.views import View
from .models import Department, WidgetUser from .models import Department, WidgetUser
from django.views.generic.list import ListView
def dashboard_view(request): def dashboard_view(request):
return render(request, 'Dashboard/dashboard.html') users = WidgetUser.objects.all()
context = {
'users': users
}
return render(request, 'Dashboard/dashboard.html', context)
class userdetails_view(View): class userdetails_view(View):
def get(self, request, user_id): def get(self, request, user_id):
...@@ -23,6 +28,9 @@ class userdetails_view(View): ...@@ -23,6 +28,9 @@ class userdetails_view(View):
"user_id": user_id "user_id": user_id
} }
return render(request, 'Dashboard/widgetuser-details.html', context) return render(request, 'Dashboard/widgetuser-details.html', context)
class IndexView(ListView):
queryset = WidgetUser.objects.order_by("last_name")
class adduser_view(CreateView): class adduser_view(CreateView):
model = WidgetUser model = WidgetUser
......
No preview for this file type
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