Commit 62282de2 authored by Adrian Lance Damalerio's avatar Adrian Lance Damalerio

Merge branch 'dashboardv2' into 'master'

Dashboardv2

See merge request !12
parents 6902d76f 0bcfb985
File deleted
...@@ -233,3 +233,5 @@ $RECYCLE.BIN/ ...@@ -233,3 +233,5 @@ $RECYCLE.BIN/
*.lnk *.lnk
# End of https://www.toptal.com/developers/gitignore/api/django,macos,windows # End of https://www.toptal.com/developers/gitignore/api/django,macos,windows
myenv/
\ No newline at end of file
{% extends 'base.html'%}
{% block title %}
{% if assignment %}
{{assignment.title}}
{% else %}
<p>No Available assignment.</p>
{% endif %}
{% endblock %}
{% block content %}
{% if assignment %}
<h1>{{assignment.name}}</h1>
<ul>
<h2>{{assignment.course.code}} {{assignment.course.title}} - {{assignment.course.section}} </h2>
<br>
<h2>Description: {{assignment.description}}</h2><br>
<h2>Description: {{assignment.description}}</h2><br>
<h2>Description: {{assignment.description}}</h2><br>
</ul>
{% else %}
<p>No Available Books.</p>
{% endif %}
<ul>
<li ><button type="button" onclick="window.location.href='/assignments/{{assignments.pk}}/edit'">Edit Assignments</button></li>
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html'%}
{% block title %}
Widget's Assignments
{% endblock %}
{% block content %}
<h1>Welcome to Widget's Assignments!</h1>
{% if assignments %}
<ul>
{% for assignment in assignments %}
<a href={{assignment.id}}/details>{{ assignment.name }}</a><br>
{% endfor %}
</ul>
{% else %}
<p>No Available Assignments.</p>
{% endif %}
<ul>
<li><button type="button" onclick="window.location.href='/books/add'">New Assignments</button></li>
<li><a href="/dashboard">Dashboard</a></li>
<li><a href="/announcements">Announcements</a></li>
<li><a href="/forum">Forum</a></li>
<li><a href="/calendar">Calendar</a></li>
</ul>
{% endblock %}
\ No newline at end of file
...@@ -3,5 +3,5 @@ from . import views ...@@ -3,5 +3,5 @@ from . import views
# url for assignments # url for assignments
urlpatterns = [ urlpatterns = [
path('', views.assignmentIndex, name='assignmentIndex'), path('', views.assignments_view, name='assignment'),
] ]
\ No newline at end of file
from django.http import HttpResponse from django.shortcuts import render
from .models import Assignment from .models import Assignment
# assignment view from .models # assignment view for FBV implementation.
def assignmentIndex(request): def assignments_view(request):
title = "Widget's Assignments Page" + "<br><br>" assignments = Assignment.objects.all().order_by('id')
assignments = Assignment.objects.all() return render(request, 'assignments.html', {'assignments': assignments})
\ No newline at end of file
output_view = ""
for assignment in assignments:
name = "Assignment Name: " + assignment.name + "<br>"
description = "Description: " + assignment.description + "<br>"
perfect_score = "Perfect Score: " + str(assignment.perfect_score) + "<br>"
passing_score = "Passing Score: " + str(assignment.passing_score) + "<br>"
course_section = "Course/Section: " + assignment.course.code + " " + assignment.course.title + "-" + assignment.course.section + "<br><br>"
output_view = output_view + name + description + perfect_score + passing_score + course_section
return HttpResponse(title + output_view)
\ No newline at end of file
from django.db import models from django.db import models
from django.urls import reverse
# Department # Department
# dept_name; home_unit # dept_name; home_unit
...@@ -24,4 +25,7 @@ class WidgetUser(models.Model): ...@@ -24,4 +25,7 @@ class WidgetUser(models.Model):
username = self.last_name + ", " + self.first_name + " " + self.middle_name username = self.last_name + ", " + self.first_name + " " + self.middle_name
return username return username
def get_absolute_url(self):
return (reverse('widgetusers:user_details', kwargs={'pk' : self.pk}))
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget v2 {% endblock %}
{% block content %}
<h1>Welcome to Widget!</h1>
<h2>Widget Users:</h2>
<ul>
{% for user in users %}
<li>
<a href="{{user.get_absolute_url}}">
{{ user.last_name }}, {{ user.first_name }}
</a>
</li>
{% endfor %}
</ul>
<form action="/widgetusers/add">
<button type="submit">Add Widget User</button>
</form>
<li><a href="/announcements">Announcement Board</a> <br></li>
<li> <a href="/forum">Forum</a> <br></li>
<li> <a href="/assignments">Assignments</a> <br></li>
<li><a href="/calendar">Calendar</a> <br></li>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Widget User {% endblock %}
{% block content %}
<h1>Add a new Widger user:</h1>
<form method="POST">
{% csrf_token %}
{{form.as_p}}
<button type="submit">Add Widget User</button>
</form>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.last_name }}, {{ object.first_name }} {% endblock %}
{% block content %}
<h1>{{ object.last_name }} {{ object.middle_name }} {{ object.first_name }}</h1>
<h2>{{ object.department.dept_name }}</h2>
<h3>{{ object.department.home_unit }}</h3>
<form action="./edit">
<button type="submit">Edit Widget User</button>
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Widget User {% endblock %}
{% block content %}
<h1>Edit Widget User:</h1>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save Changes to Widget User</button>
</form>
{% endblock %}
\ No newline at end of file
#dashboard/urls.py #dashboard/urls.py
from django.urls import path from django.urls import path
from .import views from . import views
# url for dashboard # url for dashboard
urlpatterns = [ urlpatterns = [
path("", views.dashboardIndex, name = "dashboardIndex") path("", views.dashboard_view, name = "dashboard"),
path("<int:pk>/details", views.WidgetUserDetailView.as_view(), name="user_details"),
path("add/", views.WidgetUserCreateView.as_view(), name = "new_user"),
path("<int:pk>/edit", views.WidgetUserUpdateView.as_view(), name="update_author"),
] ]
app_name = "dashboard" app_name = "dashboard"
\ No newline at end of file
from django.http import HttpResponse from django.shortcuts import render, redirect
from django.views.generic import DetailView, CreateView, UpdateView, ListView
from .models import Department, WidgetUser from .models import Department, WidgetUser
# dashboard view from .models # dashboard view from .models
def dashboardIndex(request): def dashboard_view(request):
users = WidgetUser.objects.all() users = WidgetUser.objects.all()
departments = Department.objects.all() return render(request, 'dashboard.html', {'users': users})
dashboard_output = "Welcome to Widget! <br><br> WIDGET USERS: <br><br>"
for user in users:
username = str(user)
home_department = str(user.department)
dashboard_output = dashboard_output + username + ": " + home_department + "<br>"
return HttpResponse(dashboard_output) class WidgetUserDetailView(DetailView):
model = WidgetUser
template_name = "widgetuser-details.html"
class WidgetUserCreateView(CreateView):
model = WidgetUser
template_name = "widgetuser-add.html"
fields = "__all__"
class WidgetUserUpdateView(UpdateView):
model = WidgetUser
template_name = "widgetuser-edit.html"
fields = "__all__"
.row {
grid-row: 1 / span 2;
}
ul li {
list-style-type: none;
}
h1 {
font-size: 36px;
font-weight: bold;
margin: 0;
color: blue;
}
form {
background-color: blanchedalmond;
}
button {
background-color: #555;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
{% load static %}
<link rel="stylesheet" href="{% static 'styles.css' %}">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div class="container">
{% block content %}{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
...@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.1/ref/settings/ ...@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
""" """
from pathlib import Path from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
...@@ -57,18 +58,19 @@ MIDDLEWARE = [ ...@@ -57,18 +58,19 @@ MIDDLEWARE = [
] ]
ROOT_URLCONF = "widget_aguandhischipmunks.urls" ROOT_URLCONF = "widget_aguandhischipmunks.urls"
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / "static"]
TEMPLATES = [ TEMPLATES = [
{ {
"BACKEND": "django.template.backends.django.DjangoTemplates", 'BACKEND': 'django.template.backends.django.DjangoTemplates',
"DIRS": [], 'DIRS': [os.path.join(BASE_DIR, 'templates')],
"APP_DIRS": True, 'APP_DIRS': True,
"OPTIONS": { 'OPTIONS': {
"context_processors": [ 'context_processors': [
"django.template.context_processors.debug", 'django.template.context_processors.debug',
"django.template.context_processors.request", 'django.template.context_processors.request',
"django.contrib.auth.context_processors.auth", 'django.contrib.auth.context_processors.auth',
"django.contrib.messages.context_processors.messages", 'django.contrib.messages.context_processors.messages',
], ],
}, },
}, },
......
...@@ -19,6 +19,7 @@ from django.urls import path, include ...@@ -19,6 +19,7 @@ from django.urls import path, include
urlpatterns = [ urlpatterns = [
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
path("dashboard/", include("dashboard.urls", namespace="dashboard")), path("dashboard/", include("dashboard.urls", namespace="dashboard")),
path("widgetusers/", include("dashboard.urls", namespace="widgetusers")),
path("assignments/", include("assignments.urls")), path("assignments/", include("assignments.urls")),
path("forum/", include("forum.urls")), path("forum/", include("forum.urls")),
path("calendar/", include("calendar_app.urls")), path("calendar/", include("calendar_app.urls")),
......
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