Commit 11d8cae9 authored by justin's avatar justin

feat: added forms for user updating

parent b525594f
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit User {% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes" />
</form>
Ito ay test!!!
{% endblock %}
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
<h2>{{ object.department.dept_name }}</h2> <h2>{{ object.department.dept_name }}</h2>
<h2>{{ object.department.home_unit }}</h2> <h2>{{ object.department.home_unit }}</h2>
</div> </div>
<a href="./edit">Edit Widget User</a> <a href="../edit">Edit Widget User</a>
{% endblock %} {% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit User {% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes" />
</form>
{% endblock %}
...@@ -5,15 +5,20 @@ from . import views ...@@ -5,15 +5,20 @@ from . import views
urlpatterns = [ urlpatterns = [
path("", views.dashboard, name="dashboard"), path("", views.dashboard, name="dashboard"),
path( path(
"<int:pk>/details", "<int:pk>/details/",
views.WidgetUserDetailView.as_view(), views.WidgetUserDetailView.as_view(),
name="user-detail", name="user-detail",
), ),
path( path(
"add", "add/",
views.WidgetUserDetailView.as_view(), views.WidgetUserDetailView.as_view(),
name="user-add", name="user-add",
), ),
path(
"<int:pk>/edit/",
views.WidgetUserUpdateView.as_view(),
name="user-edit",
),
] ]
......
...@@ -6,16 +6,13 @@ from django.shortcuts import render ...@@ -6,16 +6,13 @@ from django.shortcuts import render
def dashboard(request): def dashboard(request):
# content = "Welcome to Widget! <br><br> WIDGET USERS: <br>"
# users = WidgetUser.objects.all()
#
# for user in users:
# content += str(user) + ": " + str(user.department) + "<br>"
#
# return HttpResponse(content)
users = WidgetUser.objects.all() users = WidgetUser.objects.all()
context = {"users": users} context = {"users": users}
return render(request, "dashboard/dashboard.html", context) return render(
request,
"dashboard/dashboard.html",
context,
)
class WidgetUserDetailView(DetailView): class WidgetUserDetailView(DetailView):
...@@ -25,7 +22,11 @@ class WidgetUserDetailView(DetailView): ...@@ -25,7 +22,11 @@ class WidgetUserDetailView(DetailView):
class WidgetUserUpdateView(UpdateView): class WidgetUserUpdateView(UpdateView):
model = WidgetUser model = WidgetUser
fields = "__all__"
template_name = "dashboard/widgetuser-edit.html"
class WidgetUserCreateView(CreateView): class WidgetUserCreateView(CreateView):
model = WidgetUser model = WidgetUser
fields = "__all__"
template_name = "dashboard/widgetuser-add.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