Commit eea1aff3 authored by Brendan Fausto's avatar Brendan Fausto

Added widgetuser details page and corresponding template

parent 5c33f14c
from django.db import models
from django.urls import reverse
class Department(models.Model):
......@@ -23,7 +25,7 @@ class WidgetUser(models.Model):
def __str__(self):
return '{}, {} {}: {}, {}'.format(self.last_name, self.first_name, self.middle_name, self.dept_name, self.home_unit)
'''
def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs = {'pk': self.id})
'''
\ No newline at end of file
\ No newline at end of file
......@@ -17,11 +17,11 @@
<ul>
{% for object in users %}
<li>
<a href = "{{ object.get_absolute_url }}">{{ object.activity }}</a>
<a href = "{{ object.get_absolute_url }}">{{ object.last_name }}, {{ object.first_name }}</a>
</li>
{% endfor %}
</ul>
<form action = "http://127.0.0.1:8000/widgetusers/add">
<form action = "http://127.0.0.1:8000/dashboard/widgetusers/add">
<input type = "submit" value = "Add Widget User" />
</form>
<p>
......
{% extends 'base.html' %}
{% block title %}
Add Widget User
{% endblock %}
{% block header %}
<h1>Add a new Widget User:</h1>
{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>{{ field.label }} has the following errors:</p>
<ul>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form method = "POST">
{% csrf_token %}
{{ form.as_p }}
<input type = "submit" value = "Add Widget User">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}
{{ object.last_name }}, {{ object.first_name }}
{% endblock %}
{% block header %}
<h1>{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}</h1>
{% endblock %}
{% block content %}
<ul>
<li>{{ object.department.dept_name }}</li>
<li>{{ object.department.home_unit }}</li>
<br>
</ul>
<p>
<button onclick="window.location.href='../../../dashboard/widgetusers/{{object.pk}}/edit';">Edit Activity</button><br/>
</p>
{% endblock %}
\ No newline at end of file
......@@ -2,12 +2,13 @@
from django.urls import path
from .views import dashboard
from .views import dashboard, WidgetUserCreateView, WidgetUserDetailView
urlpatterns = [
path('', dashboard, name='index'),
path('widgetusers/add', WidgetUserCreateView.as_view(), name='widgetuser-add'),
path('widgetusers/<int:pk>/details', WidgetUserDetailView.as_view(), name='widgetuser-details'),
]
......
......@@ -18,3 +18,18 @@ def dashboard(request):
'users': users
})
class WidgetUserCreateView(CreateView):
model = WidgetUser
fields = '__all__'
template_name = 'dashboard/widgetuser-add.html'
class WidgetUserDetailView(DetailView):
model = WidgetUser
template_name = 'dashboard/widgetuser-details.html'
def get(self, request, *args, **kwargs):
print("ActivityDetailView is being called")
return super().get(request, *args, **kwargs)
......@@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
......
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