Commit 48d84356 authored by Brescia Amandy's avatar Brescia Amandy

Merge branch 'dashboardv2' into 'master'

parents 9ec65c4d 5167149d
...@@ -4,24 +4,21 @@ group members’ full name, ID number; ...@@ -4,24 +4,21 @@ group members’ full name, ID number;
Amandy, Brescia V. - Amandy, Brescia V. -
Muncal, Izaac Daniel B. - 214138 Muncal, Izaac Daniel B. - 214138
Silang, Anchilla Vera Marie C. - 204714 Silang, Anchilla Vera Marie C. - 204714
Villareal, Athena Ricci V. -
full name format → last name, first name, M.I. full name format → last name, first name, M.I.
in alphabetical order by last name in alphabetical order by last name
Midterm Project: Widget Final Project: Widgetv2
members’ app assignments; members’ app assignments;
dani - dashboard dani - dashboard
richie - announcement board
anchie - forum anchie - forum
brescia - assignments brescia - assignments
date of submission; March 6 date of submission; May 12, 2023
We did our project on our own, asking help from only members of Huli - Dani, Richie, Anchie, and Brescia We did our project on our own, asking help from only members of Huli - Dani, Anchie, and Brescia
Amandy, Brescia V. March 6 (sgd) Amandy, Brescia V. March 6 (sgd)
Muncal, Izaac Daniel B. March 6 (sgd) Muncal, Izaac Daniel B. March 6 (sgd)
Silang, Anchilla Vera Marie C. March 6 (sgd) Silang, Anchilla Vera Marie C. March 6 (sgd)
Villareal, Athena Ricci V. March 6 (sgd)
from django.db import models from django.db import models
from django.urls import reverse
class Department(models.Model): class Department(models.Model):
...@@ -16,4 +17,11 @@ class WidgetUser(models.Model): ...@@ -16,4 +17,11 @@ class WidgetUser(models.Model):
department = models.ForeignKey(Department, null=True, on_delete=models.CASCADE) department = models.ForeignKey(Department, null=True, on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return '{}, {} {} : {}'.format(self.last_name, self.first_name, self.middle_name, self.department) return '{}, {} {} : {}'.format(self.last_name, self.first_name, self.middle_name, self.department)
\ No newline at end of file
def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs={'pk': self.pk})
def get_update_url(self):
return reverse('dashboard:widgetuser-edit', kwargs={'pk': self.pk})
{% extends 'base.html' %}
{% block title %} Widget v2 {% endblock %}
{% block header %} Welcome to Widget!{% endblock %}
{% block body %}
<p> Widget User:</p>
<ul>
{% for name in widgetuser_list %}
<li>
<a href="dashboard/widgetusers/{{ name.pk }}/details"> {{ name.last_name }}, {{name.first_name }} </a><br>
</li>
{% endfor %}
</ul>
<button><a href = "dashboard/widgetusers/add">Add Widget User</a></button>
</p>
<a href = "/forum/">Forum</a> <br>
<a href = "/assignments/">Assignments</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User {% endblock %}
{% block header %}Add a new Widget user:{% endblock %}
{% block body %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<ul>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form method = "post">
{% csrf_token %}
{% for field in form %}
{{field.label}}: {{field}}<br><br>
{% endfor %}
&nbsp; &nbsp; &nbsp; &nbsp;<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 header %}{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}{% endblock %}
{% block body %}
<p>{{object.department.dept_name}}</p>
<p>{{object.department.home_unit}}</p>
<button>
<a href="edit">Edit Widget User</a></button>
<button><a href = "/dashboard">Dashboard</a></button>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Widget User{% endblock %}
{% block header %}Edit Widget User:{% endblock %}
{% block body %}
<form method = "post">
{% csrf_token %}
{% for field in form %}
{{field.label}}: {{field}}<br><br>
{% endfor %}
&nbsp; &nbsp; &nbsp; &nbsp; <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_view, WidgetUserView, WidgetUserCreateView, WidgetUserUpdateView
from .views import index
urlpatterns = [ urlpatterns = [
path('',index, name = 'index'), path('',dashboard_view, name = 'dashboard'),
path('/widgetusers/<pk>/details', WidgetUserView.as_view(), name='widgetuser-details'),
path('/widgetusers/add', WidgetUserCreateView.as_view(), name='widgetuser-add'),
path('/widgetusers/<pk>/edit', WidgetUserUpdateView.as_view(), name='widgetuser-edit'),
] ]
dashboard = "Dashboard" app_name = "dashboard"
\ No newline at end of file \ No newline at end of file
from django.shortcuts import render 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 WidgetUser, Department from .models import WidgetUser, Department
def index(request): def dashboard_view(request):
text_in_http = "Welcome to Widget! <br> <br> WIDGET USERS: <br> <ul>" context = {}
for user in WidgetUser.objects.all(): context["widgetuser_list"] = WidgetUser.objects.all()
text_in_http += "<li>{}, {} {} : {}</li>".format(user.last_name, user.first_name, return render(request, 'dashboard/dashboard.html',context)
user.middle_name, user.department
)
text_in_http += "</ul>" class WidgetUserView(DetailView):
html_string = '<html><body>{}</body></html>'.format(text_in_http) model = WidgetUser
template_name = 'dashboard/widgetuser-details.html'
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'
return HttpResponse(html_string)
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