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
Dayupay, Alec Isaiah, R. 211831
Siongco, Jose Enrique, D. 215504
Widget v1
Widget v2
Dashboard: Siongco
Announcement Board: Bicomong
Forum: Dayupay
Assignments: Ballesteros
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.
References:
https://www.geeksforgeeks.org/overriding-the-save-method-django-models/
<sgd> Neo Emmanuel D. Ballesteros, 3/2/2023
<sgd> Anthony P. Bicomong, 3/2/2023
<sgd> Kirsten Daena C. Chidrome, 3/2/2023
<sgd> Alec Isaiah R. Dayupay, 3/2/2023
<sgd> Jose Enrique D. Siongco, 3/2/2023
<sgd> Neo Emmanuel D. Ballesteros, 4/28/2023
<sgd> Anthony P. Bicomong, 4/28/2023
<sgd> Kirsten Daena C. Chidrome, 4/28/2023
<sgd> Alec Isaiah R. Dayupay, 4/28/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.urls import reverse
class Announcement(models.Model):
title = models.CharField(max_length = 50)
body = models.TextField()
author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
pub_datetime = models.DateTimeField(auto_now_add=True)
def __str__(self):
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):
Like = 'Like'
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 .views import index
from . import views
from .views import (AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView)
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"),
path('announcements/<int:pk>/edit/', AnnouncementUpdateView.as_view(), name="announcement-edit"),
]
\ No newline at end of file
app_name = "announcements"
from django.http import HttpResponse
from .models import Announcement, Reaction
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Announcement
def index(request):
announcements = Announcement.objects.all()
reactions = Reaction.objects.all()
return render(request, 'announcements/announcements.html', {'announcements': Announcement.objects.order_by('-pub_datetime')})
response = "Widget's Announcement Board<br><br>Announcements:<br>"
for announcement in announcements:
response += "{} by {} published {}:<br>{}<br>".format(
announcement.title,
announcement.author,
announcement.pub_datetime.strftime("%m/%d/%Y, %I:%M %p"),
announcement.body
)
class AnnouncementDetailView(DetailView):
model = Announcement
template_name = 'announcements/announcement-details.html'
for reaction in reactions:
if reaction.announcement == announcement:
response += "{}: {}<br>".format(
reaction.name,
str(reaction.tally)
)
response += "<br>"
return HttpResponse(response)
class AnnouncementCreateView(CreateView):
model = Announcement
fields = '__all__'
template_name = 'announcements/announcement-add.html'
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.urls import reverse
class Location(models.Model):
Onsite = 'Onsite'
......@@ -24,3 +25,6 @@ class Event(models.Model):
def __str__(self):
return self.activity
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 . import views
from .views import EventDetailView, EventCreateView, EventUpdateView
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
def index(request):
events = Event.objects.all()
def calendar(request):
return render(request, 'calendars/calendar.html', {'event': Event.objects.all()})
response ="Widgets's Calendar of Activities<br><br>Date and Time: "
for event in events:
response += "{}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {}<br>Mode: {}<br>Venue: {}<br>".format(
event.target_datetime.strftime("%m/%d/%Y, %I:%M %p"),
event.activity,
str(event.estimated_hours),
event.course,
event.locations.modes,
event.locations.venue
)
class EventDetailView(DetailView):
model = Event
template_name = 'calendars/event-details.html'
return HttpResponse(response)
\ No newline at end of file
class EventCreateView(CreateView):
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')),
],
),
]
......@@ -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
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