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): ...@@ -16,3 +16,6 @@ class WidgetUser(models.Model):
def __str__(self): def __str__(self):
return '{} {}'.format(self.first_name, self.last_name) 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 django.urls import path
from .views import dashboard from .views import (
dashboard, WidgetuserDetailView, WidgetuserCreateView, WidgetuserUpdateView
)
urlpatterns = [ 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.shortcuts import render
from django.http import HttpResponse 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 from .models import Department, WidgetUser
def dashboard(request): def dashboard(request):
widgetusers = WidgetUser.objects.all() return render(request, 'dashboard/dashboard.html', {'WidgetUser': WidgetUser.objects.all()})
response = "Welcome to Widget!<br><br>WIDGET USERS:<br>"
for user in widgetusers: class WidgetuserDetailView(DetailView):
response += "{}, {} {}: {}, {}<br>".format( model = WidgetUser
user.last_name, template_name ='dashboard/widgetuser-details.html'
user.first_name, fields = '__all__'
user.middle_name,
user.department,
user.department.home_unit class WidgetuserCreateView(CreateView):
) model = WidgetUser
fields = '__all__'
return HttpResponse(response) template_name ='dashboard/widgetuser-add.html'
\ No newline at end of file
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