Commit cf8522e9 authored by Gabriel G. Garrero's avatar Gabriel G. Garrero

fixed a typo in dashboard.html (get_absoluteurl -> get_absolute_url) and...

fixed a typo in dashboard.html (get_absoluteurl -> get_absolute_url) and updated path of Add Widget User button, created widgetuser-add.html, updated urls.py and views.py to account for new add widgetuser function
parent 88a309fc
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
<ul> <ul>
{% for user in users %} {% for user in users %}
<li> <li>
<a href = "{{ user.get_absoluteurl }}">{{ user.last_name }}, {{ user.first_name }}</a> <a href = "{{ user.get_absolute_url }}">{{ user.last_name }}, {{ user.first_name }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<a href = "../widgetusers/add">Add Widget User</a> <a href = "/dashboard/widgetusers/add">Add Widget User</a>
<div> <div>
<a href = "../announcements">Announcement Board</a> <a href = "../announcements">Announcement Board</a>
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% 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 %}
<h1>Add a new Widget user:</h1>
<form method = "POST">
{% csrf_token %}
{{ form.as_p }}
<input type = "submit" value = "Add Widget User">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import dashboard, WidgetUserDetailView from .views import dashboard, WidgetUserDetailView, WidgetUserCreateView
urlpatterns = [ urlpatterns = [
path('', dashboard, name = 'dashboard'), path('', dashboard, name = 'dashboard'),
path('widgetusers/<int:pk>/details', WidgetUserDetailView.as_view(), name = 'widgetuser-details'), path('widgetusers/<int:pk>/details', WidgetUserDetailView.as_view(), name = 'widgetuser-details'),
path('widgetusers/add', WidgetUserCreateView.as_view(), name = "widgetuser-add"),
] ]
app_name = "dashboard" app_name = "dashboard"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from .models import Department, WidgetUser from .models import Department, WidgetUser
...@@ -15,3 +16,8 @@ def dashboard(request): ...@@ -15,3 +16,8 @@ def dashboard(request):
class WidgetUserDetailView(DetailView): class WidgetUserDetailView(DetailView):
model = WidgetUser model = WidgetUser
template_name = 'dashboard/widgetuser-details.html' template_name = 'dashboard/widgetuser-details.html'
class WidgetUserCreateView(CreateView):
model = WidgetUser
template_name = 'dashboard/widgetuser-add.html'
fields = '__all__'
\ 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