Commit c38544fa authored by Brendan Fausto's avatar Brendan Fausto

Added widgetuser edit page and corresponding template

parent eea1aff3
...@@ -7,6 +7,8 @@ class Department(models.Model): ...@@ -7,6 +7,8 @@ class Department(models.Model):
dept_name = models.CharField(max_length=255) dept_name = models.CharField(max_length=255)
home_unit = models.CharField(max_length=255) home_unit = models.CharField(max_length=255)
def __str__(self):
return '{} - {}'.format(self.dept_name, self.home_unit)
class WidgetUser(models.Model): class WidgetUser(models.Model):
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</ul> </ul>
<p> <p>
<button onclick="window.location.href='../../../dashboard/widgetusers/{{object.pk}}/edit';">Edit Activity</button><br/> <button onclick="window.location.href='../../../dashboard/widgetusers/{{object.pk}}/edit';">Edit Widget User</button><br/>
</p> </p>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}
Edit Widget User
{% endblock %}
{% block header %}
<h1>Edit 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 = "Save Changes to Widget User">
</form>
{% endblock %}
\ No newline at end of file
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
from django.urls import path from django.urls import path
from .views import dashboard, WidgetUserCreateView, WidgetUserDetailView from .views import dashboard, WidgetUserCreateView, WidgetUserDetailView, WidgetUserUpdateView
urlpatterns = [ urlpatterns = [
path('', dashboard, name='index'), path('', dashboard, name='index'),
path('widgetusers/add', WidgetUserCreateView.as_view(), name='widgetuser-add'), path('widgetusers/add', WidgetUserCreateView.as_view(), name='widgetuser-add'),
path('widgetusers/<int:pk>/details', WidgetUserDetailView.as_view(), name='widgetuser-details'), path('widgetusers/<int:pk>/details', WidgetUserDetailView.as_view(), name='widgetuser-details'),
path('widgetusers/<int:pk>/edit', WidgetUserUpdateView.as_view(), name='widgetuser-edit'),
] ]
......
...@@ -25,6 +25,12 @@ class WidgetUserCreateView(CreateView): ...@@ -25,6 +25,12 @@ class WidgetUserCreateView(CreateView):
template_name = 'dashboard/widgetuser-add.html' template_name = 'dashboard/widgetuser-add.html'
class WidgetUserUpdateView(UpdateView):
model = WidgetUser
fields = '__all__'
template_name = 'dashboard/widgetuser-edit.html'
class WidgetUserDetailView(DetailView): class WidgetUserDetailView(DetailView):
model = WidgetUser model = WidgetUser
template_name = 'dashboard/widgetuser-details.html' template_name = 'dashboard/widgetuser-details.html'
......
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