Commit d08eeb42 authored by Neo Emmanuel Ballesteros's avatar Neo Emmanuel Ballesteros

Deleted cache

parents a3a669a3 f677ebe2
...@@ -5,22 +5,22 @@ Chidrome, Kirsten Daena, C. 211445 ...@@ -5,22 +5,22 @@ Chidrome, Kirsten Daena, C. 211445
Dayupay, Alec Isaiah, R. 211831 Dayupay, Alec Isaiah, R. 211831
Siongco, Jose Enrique, D. 215504 Siongco, Jose Enrique, D. 215504
Widget v1 Widget v2
Dashboard: Siongco Dashboard: Siongco
Announcement Board: Bicomong Announcement Board: Bicomong
Forum: Dayupay Forum: Dayupay
Assignments: Ballesteros Assignments: Ballesteros
Calendar: Chidrome Calendar: Chidrome
Date of Submission: Monday, March 6, 2023 Date of Submission: Monday, May 15, 2023
With the power of Big Django Energy, we were able to complete this project effectively in compliance with the project specs. With the power of Big Django Energy, we were able to complete this project effectively in compliance with the project specs.
References: References:
https://www.geeksforgeeks.org/overriding-the-save-method-django-models/ https://www.geeksforgeeks.org/overriding-the-save-method-django-models/
<sgd> Neo Emmanuel D. Ballesteros, 3/2/2023 <sgd> Neo Emmanuel D. Ballesteros, 4/28/2023
<sgd> Anthony P. Bicomong, 3/2/2023 <sgd> Anthony P. Bicomong, 4/28/2023
<sgd> Kirsten Daena C. Chidrome, 3/2/2023 <sgd> Kirsten Daena C. Chidrome, 4/28/2023
<sgd> Alec Isaiah R. Dayupay, 3/2/2023 <sgd> Alec Isaiah R. Dayupay, 4/28/2023
<sgd> Jose Enrique D. Siongco, 3/2/2023 <sgd> Jose Enrique D. Siongco, 4/28/2023
from django.forms import ModelForm
from .models import Announcement
class AnnouncementForm(ModelForm):
class Meta:
model = Announcement
fields = '__all__'
# Generated by Django 3.2 on 2023-03-03 15:39
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('dashboard', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Announcement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50)),
('body', models.TextField()),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], default='Like', max_length=50)),
('tally', models.IntegerField(default=0)),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
from django.db import models from django.db import models
from django.urls import reverse
class Announcement(models.Model): class Announcement(models.Model):
title = models.CharField(max_length = 50) title = models.CharField(max_length = 50)
body = models.TextField() body = models.TextField()
author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE) author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField(auto_now_add=True)
def __str__(self): def __str__(self):
return self.title return self.title
def datetime(self):
return self.pub_datetime.strftime("%m/%d/%Y, %I:%M %p")
def get_absolute_url(self):
return reverse("announcement-details", kwargs={'pk': self.pk})
class Reaction(models.Model): class Reaction(models.Model):
Like = 'Like' Like = 'Like'
Love = 'Love' Love = 'Love'
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Announcement{% endblock %}
{% block content %}
<p>Add a new announcement:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Add Announcement">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.title }}{% endblock %}
{% block heading %}{{ object.title }}{% endblock %}
{% block content %}
<p>by {{ object.author }}</p>
<p>{{ object.datetime }}</p>
<p>{{ object.body }}<br></p>
{% for reac in object.reaction_set.all %}
<p>{{ reac.name }}: {{ reac.tally }}</p>
{% endfor %}
<input type="button" value="Edit Announcement" onclick="location.href='{% url 'announcement-edit' object.pk %}'"/>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Announcement{% endblock %}
{% block content %}
<p>Edit Announcement:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Save Changes to Announcement">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Announcement Board{% endblock %}
{% block heading %}Welcome to Widget's Announcement Board!{% endblock %}
{% block content %}
<p>Announcements:</p>
{% for ann in announcements %}
<p><a href="{% url 'announcement-details' ann.pk %}">{{ ann.title }} by {{ ann.author }}</a></p>
{% endfor %}
<input type="button" value="New Announcement" onclick="location.href='{% url 'announcement-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p>
<p><a href="http://localhost:8000/forum/">Forum</a></p>
<p><a href="http://localhost:8000/assignments/">Assignment</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from . import views
from .views import (AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView)
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', views.index, name='index'),
] path('announcements/<int:pk>/details/', AnnouncementDetailView.as_view(), name="announcement-details"),
path('announcements/add/', AnnouncementCreateView.as_view(), name="announcement-add"),
app_name = "announcements" path('announcements/<int:pk>/edit/', AnnouncementUpdateView.as_view(), name="announcement-edit"),
]
\ No newline at end of file
from django.http import HttpResponse from django.shortcuts import render
from .models import Announcement, Reaction from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Announcement
def index(request): def index(request):
announcements = Announcement.objects.all() return render(request, 'announcements/announcements.html', {'announcements': Announcement.objects.order_by('-pub_datetime')})
reactions = Reaction.objects.all()
response = "Widget's Announcement Board<br><br>Announcements:<br>" class AnnouncementDetailView(DetailView):
for announcement in announcements: model = Announcement
response += "{} by {} published {}:<br>{}<br>".format( template_name = 'announcements/announcement-details.html'
announcement.title,
announcement.author,
announcement.pub_datetime.strftime("%m/%d/%Y, %I:%M %p"),
announcement.body
)
for reaction in reactions: class AnnouncementCreateView(CreateView):
if reaction.announcement == announcement: model = Announcement
response += "{}: {}<br>".format( fields = '__all__'
reaction.name, template_name = 'announcements/announcement-add.html'
str(reaction.tally)
)
response += "<br>"
return HttpResponse(response)
class AnnouncementUpdateView(UpdateView):
model = Announcement
fields = '__all__'
template_name = 'announcements/announcement-edit.html'
# Generated by Django 3.2 on 2023-03-03 15:39
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=50)),
('section', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('description', models.TextField()),
('perfect_score', models.IntegerField(default=0)),
('passing_score', models.IntegerField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
from django.forms import ModelForm
from .models import Event
class EventForm(ModelForm):
class Meta:
model = Event
fields = "__all__"
\ No newline at end of file
# Generated by Django 3.2 on 2023-03-03 15:39
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('modes', models.CharField(choices=[('Onsite', 'Onsite'), ('Online', 'Online'), ('Hybrid', 'Hybrid')], default='Onsite', max_length=50)),
('venue', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField()),
('activity', models.CharField(max_length=50)),
('estimated_hours', models.FloatField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
('locations', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='calendars.location')),
],
),
]
from django.db import models from django.db import models
from django.urls import reverse
class Location(models.Model): class Location(models.Model):
Onsite = 'Onsite' Onsite = 'Onsite'
...@@ -23,4 +24,7 @@ class Event(models.Model): ...@@ -23,4 +24,7 @@ class Event(models.Model):
course = models.ForeignKey('assignments.Course', on_delete=models.CASCADE) course = models.ForeignKey('assignments.Course', on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return self.activity return self.activity
\ No newline at end of file
def get_absolute_url(self):
return reverse("event-details", kwargs={'pk': self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% block heading %}Widget's Calendar of Activities{% endblock %}
{% block content %}
{% for event in event %}
<p><a href="{% url 'event-details' event.pk %}">{{ event.activity }}</a></p>
{% endfor %}
<input type="button" value="New Activity" onclick="location.href='{% url 'event-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p>
<p><a href="http://localhost:8000/announcements/">Announcement</a></p>
<p><a href="http://localhost:8000/assignments/">Assignment</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Activity{% endblock %}
{% block content %}
<p>Add a new activity:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Save New Activity">
</form>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.activity }}{% endblock %}
{% block heading %}{{ object.activty }}{% endblock %}
{% block content %}
<p>Date and Time: {{ object.target_datetime }}</p>
<p>Estimated Hours: {{ object.estimated_hours }}</p>
<p>{{ object.course }}</p>
<p>Mode: {{ object.locations.modes }}</p>
<p>Venue: {{ object.locations.venue }}</p>
<input type="button" value="Edit Post" onclick="location.href='{% url 'event-edit' object.pk %}'"/>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Activity{% endblock %}
{% block content %}
<p>Edit Activity:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Save New Activity">
</form>
{% endblock %}
from django.urls import path from django.urls import path
from . import views from . import views
from .views import EventDetailView, EventCreateView, EventUpdateView
urlpatterns = [ urlpatterns = [
path('', views.index, name = "index") path('', views.calendar, name = "calendar"),
path('events/<int:pk>/details/', EventDetailView.as_view(), name = "event-details"),
path('events/add/', EventCreateView.as_view(), name = "event-add"),
path('events/<int:pk>/edit/', EventUpdateView.as_view(), name = "event-edit"),
] ]
\ No newline at end of file
from django.http import HttpResponse from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Event from .models import Event
def index(request): def calendar(request):
events = Event.objects.all() return render(request, 'calendars/calendar.html', {'event': Event.objects.all()})
response ="Widgets's Calendar of Activities<br><br>Date and Time: " class EventDetailView(DetailView):
for event in events: model = Event
response += "{}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {}<br>Mode: {}<br>Venue: {}<br>".format( template_name = 'calendars/event-details.html'
event.target_datetime.strftime("%m/%d/%Y, %I:%M %p"),
event.activity,
str(event.estimated_hours),
event.course,
event.locations.modes,
event.locations.venue
)
return HttpResponse(response) class EventCreateView(CreateView):
\ No newline at end of file model = Event
fields = '__all__'
template_name = 'calendars/event-add.html'
class EventUpdateView(UpdateView):
model = Event
fields = '__all__'
template_name = 'calendars/event-edit.html'
\ No newline at end of file
# Generated by Django 3.2 on 2023-03-03 15:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Department',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('dept_name', models.CharField(max_length=50)),
('home_unit', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=50)),
('middle_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.department')),
],
),
]
...@@ -15,4 +15,7 @@ class WidgetUser(models.Model): ...@@ -15,4 +15,7 @@ class WidgetUser(models.Model):
department = models.ForeignKey(Department, on_delete = models.CASCADE) department = models.ForeignKey(Department, on_delete = models.CASCADE)
def __str__(self): def __str__(self):
return '{} {}'.format(self.first_name, self.last_name) return '{} {}'.format(self.first_name, self.last_name)
\ No newline at end of file
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"),
app_name = "dashboard" path('widgetuser/<int:pk>/edit/', WidgetuserUpdateView.as_view(), name="widgetuser-edit"),
\ 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.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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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