Finalize views and htmls

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