Commit 56e03e5d authored by Jose Enrique D. Siongco's avatar Jose Enrique D. Siongco

Merge branch 'dashboardv2'

parents db44e158 04bb77ae
......@@ -16,3 +16,6 @@ class WidgetUser(models.Model):
def __str__(self):
return '{} {}'.format(self.first_name, self.last_name)
def get_absolute_url(self):
return reverse("widgetuser-details", kwargs={'pk': self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Forum{% endblock %}
{% block heading %}Welcome to Widget's Forum!{% endblock %}
{% block content %}
<p>Forum posts:</p>
{% for user in WidgetUser %}
<p><a href="{{ user.get_absolute_url }}">{{ user.last_name }}, {{ user.first_name }}</a></p>
{% endfor %}
<input type="button" value="Add Widget User" onclick="location.href='{% url 'widgetuser-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="../announcements/">Announcement</a></p>
<p><a href="../forum/">Forum</a></p>
<p><a href="../assignments/">Assignment</a></p>
<p><a href="../calendar/">Calendar</a></p>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% endblock %}
{% block heading %}Add a new widget user:{% endblock %}
{% block content %}
<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' %}
{% load static %}
{% block title %}{{ object.last_name }}, {{ object.first_name }}{% endblock %}
{% block heading %}{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}{% endblock %}
{% block content %}
<p>{{ object.department }}</p>
<p>{{ object.department.home_unit }}</p>
<input type="button" value="Edit Widget User" onclick="location.href='{% url 'widgetuser-edit' object.pk %}'"/>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Post{% endblock %}
{% block content %}
<p>Edit Widget User:</p>
<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
from django.urls import path
from .views import dashboard
from .views import (
dashboard, WidgetuserDetailView, WidgetuserCreateView, WidgetuserUpdateView
)
urlpatterns = [
path('', dashboard, name = "dashboard")
path('', dashboard, name="dashboard"),
path('widgetuser/add', WidgetuserCreateView.as_view(), name = "widgetuser-add"),
path('widgetuser/<int:pk>/details/', WidgetuserDetailView.as_view(), name="widgetuser-details"),
path('widgetuser/<int:pk>/edit/', WidgetuserUpdateView.as_view(), name="widgetuser-edit"),
]
\ No newline at end of file
app_name = "dashboard"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Department, WidgetUser
def dashboard(request):
widgetusers = WidgetUser.objects.all()
response = "Welcome to Widget!<br><br>WIDGET USERS:<br>"
for user in widgetusers:
response += "{}, {} {}: {}, {}<br>".format(
user.last_name,
user.first_name,
user.middle_name,
user.department,
user.department.home_unit
)
return HttpResponse(response)
\ No newline at end of file
return render(request, 'dashboard/dashboard.html', {'WidgetUser': WidgetUser.objects.all()})
class WidgetuserDetailView(DetailView):
model = WidgetUser
template_name ='dashboard/widgetuser-details.html'
fields = '__all__'
class WidgetuserCreateView(CreateView):
model = WidgetUser
fields = '__all__'
template_name ='dashboard/widgetuser-add.html'
class WidgetuserUpdateView(UpdateView):
model = WidgetUser
fields = '__all__'
template_name ='dashboard/widgetuser-edit.html'
\ 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