Commit 7eb9caa4 authored by Eury See's avatar Eury See
parents 23908c11 045a43b6
CSCI 40-F
Group Members:
CASTILLO, Gareth Xerxes
205828 CASTILLO, Gareth Xerxes
GARCIA, Ann Colleen
OLIVARES, Christian Louis
193636 OLIVARES, Christian Louis
204374 RODRIGUEZ, Neal Luigi D.
204655 SEE, Eurydice Gabrielle Madison O.
......@@ -20,3 +20,8 @@ CALENDAR-Olivares
[References]
[Signatures]
(sgd) Gareth Xerxes Yap Castillo March 5, 2023
(sgd) Neal Luigi RODRIGUEZ March 5, 2023
(sgd) Christian Louis Olivares March 5, 2023
(sgd) Ann Colleen Garcia March 5, 2023
(sgd) Eurydice Gabrielle Madison See March 5, 2023
\ No newline at end of file
from django.contrib import admin
from .models import Announcement, Reaction
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
list_display = ('title','body','author','pub_datetime',)
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
list_display = ('name','tally','announcement',)
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
from django.apps import AppConfig
class AnnouncementBoardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Announcement_Board'
# Generated by Django 4.1.6 on 2023-03-05 04:32
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
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=100)),
('body', models.CharField(max_length=2000)),
('author', models.CharField(max_length=50)),
('pub_datetime', models.CharField(max_length=700)),
],
),
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')], max_length=100)),
('tally', models.IntegerField()),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Announcement_Board.announcement')),
],
),
]
# Generated by Django 4.1.6 on 2023-03-05 07:46
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Dashboard', '0001_initial'),
('Announcement_Board', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.widgetuser'),
),
]
from django.db import models
from Dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=100)
body = models.CharField(max_length=2000)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.CharField(max_length=700)
def __str__(self):
return self.title
class Reaction(models.Model):
name_choices = (
('like','like'),
('love','love'),
('angry','angry'),
)
name = models.CharField(max_length=100, choices=name_choices)
tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete = models.CASCADE)
def __str__(self):
return self.name
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name = 'index'),
]
app_name = "AnnouncementBoard"
\ No newline at end of file
from django.shortcuts import render
from django.shortcuts import HttpResponse
from .models import Announcement, Reaction
def index(request):
return_string = '<ul>'
for announcement in Announcement.objects.all():
return_string += '{} by {}: <br> published {}:<br>{} <br>'.format(
announcement.title, announcement.author,
announcement.pub_datetime,announcement.body,
)
announced = announcement
like = 0
love = 0
angry = 0
for reaction in Reaction.objects.all():
if reaction.name == "like" and reaction.announcement == announced:
like += reaction.tally
if reaction.name == "love" and reaction.announcement == announced:
love += reaction.tally
if reaction.name == "angry" and reaction.announcement == announced:
angry += reaction.tally
return_string += 'like: {} <br> love: {} <br> angry: {}<br><br>'.format(
like, love, angry,
)
return_string += '</ul>'
html_string = '<html><head>Widget’s Announcement Board<br><br>Announcements:</head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
from django.contrib import admin
from .models import Course, Assignment
# Register your models here.
class CourseAdmin(admin.ModelAdmin):
model = Course
search_fields = ('code', 'title')
list_display = ('code', 'title', 'section')
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
search_fields = ('name', 'course')
list_display = ('name', 'description', 'course', 'perfect_score', 'passing_score')
admin.site.register(Course, CourseAdmin)
admin.site.register(Assignment, AssignmentAdmin)
\ No newline at end of file
from django.apps import AppConfig
class AssignmentsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Assignments'
# Generated by Django 3.2 on 2023-03-03 15:51
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=100)),
('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=100)),
('description', models.TextField()),
('perfect_score', models.IntegerField()),
('course', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Assignments.course')),
],
),
]
from django.db import models
# Create your models here.
class Course(models.Model):
code = models.CharField(max_length=10)
title = models.CharField(max_length=100)
section = models.CharField(max_length=3)
def __str__(self):
return '{}'.format(self.code)
class Assignment(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
course = models.ForeignKey(
Course,
on_delete=models.PROTECT,
)
perfect_score = models.IntegerField()
@property
def passing_score(self):
return self.perfect_score*0.60
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name="index")
]
app_name = "Assignments"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course
# Create your views here.
def index(request):
head_string = "<h1>Widget's Assignment Page</h1>"
body_string = ""
for assignment in Assignment.objects.all():
body_string += '<p>Assignment Name: {}</br>'.format(assignment.name)
body_string += 'Description: {}</br>'.format(assignment.description)
body_string += 'Perfect Score: {}</br>'.format(assignment.perfect_score)
body_string += 'Passing Score: {}</br>'.format(assignment.passing_score)
body_string += 'Course/Section: {} {}-{}</br>'.format(assignment.course.code, assignment.course.title, assignment.course.section)
body_string += "</p>"
html_string = '<html><head>{}</head><body>{}</body></html>'.format(head_string, body_string)
return HttpResponse(html_string)
\ No newline at end of file
from django.contrib import admin
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
list_display = ('dept_name', 'home_unit')
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
list_display = ('first_name', 'middle_name', 'last_name', 'department')
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
\ No newline at end of file
from django.apps import AppConfig
class DashboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Dashboard'
# Generated by Django 4.1.6 on 2023-03-02 13:32
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(default='', max_length=50)),
('home_unit', models.CharField(default='', 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(default='', max_length=50)),
('middle_name', models.CharField(default='', max_length=50)),
('last_name', models.CharField(default='', max_length=50)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.department')),
],
),
]
from django.db import models
class Department(models.Model):
default_string = ""
dept_name = models.CharField(max_length = 50, default = default_string)
home_unit = models.CharField(max_length = 50, default = default_string)
def __str__(self):
return '{}'.format(self.dept_name)
class WidgetUser(models.Model):
default_string = ""
first_name = models.CharField(max_length = 50, default = default_string)
middle_name = models.CharField(max_length = 50, default = default_string)
last_name = models.CharField(max_length = 50, default = default_string)
department = models.ForeignKey(Department, on_delete = models.CASCADE)
def __str__(self):
return '{}'.format(self.first_name)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name = 'index'),
]
app_name = "Dashboard"
\ No newline at end of file
from django.shortcuts import render
from django.shortcuts import HttpResponse
from .models import Department, WidgetUser
def index(request):
return_string = '<ul>'
for user in WidgetUser.objects.all():
return_string += '<li>{}, {} {}: {}, {}</li>'.format(
user.last_name, user.first_name, user.middle_name, user.department, user.department.home_unit
)
return_string += '</ul>'
html_string = '<html><head>Welcome to Widget!<br> <br> WIDGET USERS:</head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
\ No newline at end of file
from django.contrib import admin
from .models import Location, Event
class LocationAdmin(admin.ModelAdmin):
model = Location
list_display = ('mode', 'venue')
class Eventadmin(admin.ModelAdmin):
model = Event
list_display = ('target_datetime', 'activity', 'estimated_hours', 'location', 'course')
# registering the model and the admin is what tells
# Django that admin pages must be generated for the models specified
admin.site.register(Location, LocationAdmin)
admin.site.register(Event, Eventadmin)
\ No newline at end of file
from django.apps import AppConfig
class WidgetcalendarConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'widgetcalendar'
# Generated by Django 4.1.7 on 2023-03-02 12:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('onsite', 'onsite'), ('online', 'online'), ('hybrid', 'hybrid')], max_length=6)),
('venue', models.CharField(default='', 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(default='', max_length=100)),
('estimated_hours', models.FloatField()),
('course', models.CharField(max_length=50)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='course_name', to='widgetcalendar.location')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-04 06:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widgetcalendar', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='location',
name='venue',
field=models.TextField(default='', max_length=200),
),
]
# Generated by Django 4.1.6 on 2023-03-05 08:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widgetcalendar', '0002_alter_location_venue'),
]
operations = [
migrations.AlterField(
model_name='event',
name='activity',
field=models.TextField(default='', max_length=200),
),
]
from django.db import models
from django.urls import reverse
#FOR LUIGI: PLS UNCOMMENT WHEN YOU'RE DONE WITH YOUR APPS
#from assignments.models import Course
class Location(models.Model):
MODE_CHOICES = (
('onsite', 'onsite'),
('online', 'online'),
('hybrid', 'hybrid'),
)
mode = models.CharField(max_length=6, choices=MODE_CHOICES)
venue = models.TextField(max_length=200, default='')
def __str__(self):
return '{}, {} mode'.format(self.venue, self.mode)
def get_absolute_url(self):
return reverse('location_detail', args=[str(self.venue)])
class Event(models.Model):
target_datetime= models.DateTimeField()
activity = models.TextField(max_length=200, default='')
estimated_hours = models.FloatField()
location = models.ForeignKey(
Location,
on_delete=models.CASCADE,
related_name='course_name'
)
#FOR LUIGI: IF YOU'RE DONE PLS REPLACE THE CURRENT CODE FOR COURSE WITH THE COMMENTED ONE
# course = models.ForeignKey(
# Course,
# on_delete=models.CASCADE,
# related_name='course_name'
# )
course = models.CharField(max_length=50)
def __str__(self):
return '{}'.format(self.activity)
def get_absolute_url(self):
return reverse('event_detail', args=[str(self.activity)])
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = "widgetcalendar"
\ No newline at end of file
from django.http import HttpResponse
from .models import Event
#Date format source: https://ourcodeworld.com/articles/read/555/how-to-format-datetime-objects-in-the-view-and-template-in-django
def index(request):
return_string = ''
for events in Event.objects.all():
return_string += 'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Secion: {}<br>Mode: {}<br>Venue: {}<br></br>'.format(
events.target_datetime.strftime("%x, %I:%M %p"), events.activity, events.estimated_hours, events.course, events.location.mode, events.location.venue
)
html_string = '<html><head>Widget\'s Calendar of Activities<br></br></head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
\ 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