Commit 4ea9aa33 authored by Stefan Gomez's avatar Stefan Gomez

Implemented the "Per Widget User Details Page".

parent c939e1c1
......@@ -20,4 +20,10 @@ class WidgetUser(models.Model):
return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name)
def name_shortcut(self):
return '{}, {}'.format(self.last_name, self.first_name)
\ No newline at end of file
return '{}, {}'.format(self.last_name, self.first_name)
def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs={'pk':self.pk})
def name_shortcut2(self):
return '{} {} {}'.format(self.first_name, self.middle_name, self.last_name)
\ No newline at end of file
......@@ -6,7 +6,7 @@
<h1>Widget Users:</h1>
<h3>
{% for widgetuser in widgetusers %}
{{ widgetuser.name_shortcut }}<br>
<a href="{{ widgetuser.get_absolute_url }}">{{ widgetuser.name_shortcut }}</a><br>
{% endfor %}
</h3>
{% endblock %}
......
{% extends 'base.html' %}
{% block title %}{{ widgetuser.name_shortcut }}{% endblock %}
{% block content %}
<h1>{{ widgetuser.name_shortcut2 }}</h1>
<h3>{{ widgetuser.department.dept_name}}</h3>
<h3>{{ widgetuser.department.home_unit}}</h3>
{% endblock %}
{% block scripts %}
<input type="submit" value="Edit Widget User">
{% endblock %}
\ No newline at end of file
from django.contrib import admin
from django.urls import path
from .views import index
from .views import index, WidgetUserDetailView
urlpatterns = [
path('', index, name='index'),
path('<int:pk>/details', WidgetUserDetailView.as_view(), name='widgetuser-details'),
]
app_name = "dashboard"
\ No newline at end of file
from django.shortcuts import render
from django.views.generic.detail import DetailView
from.models import Department, WidgetUser
from.models import WidgetUser
def index(request):
return render(request, 'dashboard/dashboard.html', {'widgetusers': WidgetUser.objects.all()})
class WidgetUserDetailView(DetailView):
model = WidgetUser
def get(self, request, pk):
return render(request, 'dashboard/widgetuser-details.html', {'widgetuser': self.model.objects.get(pk=pk)})
\ 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