Commit 1a5a2375 authored by mantlei's avatar mantlei

merged master to forum_app

parents f0dde999 737ffb5b
...@@ -7,6 +7,8 @@ BS Computer Science CSCI 40-E ...@@ -7,6 +7,8 @@ BS Computer Science CSCI 40-E
Amador, John Michael T. 206105 Amador, John Michael T. 206105
Andrada, Alvin Joshua M. 195478 Andrada, Alvin Joshua M. 195478
Rodillas, Ron Lawrence C. 204364 Rodillas, Ron Lawrence C. 204364
Fausto, Brendan Gabrielle M. 202033
Paeldon, Marco Anton O. 193752
# project title; # project title;
Widget v1 Widget v1
...@@ -16,6 +18,9 @@ Amador - Assignments App ...@@ -16,6 +18,9 @@ Amador - Assignments App
Andrada - Calendar App Andrada - Calendar App
Fausto - Dashboard App Fausto - Dashboard App
Rodillas - Forum App Rodillas - Forum App
Paeldon- Announcements App
>>>>>>> master
# date of submission; # date of submission;
...@@ -29,3 +34,5 @@ This project was accomplished truthfully only by the people whose names are list ...@@ -29,3 +34,5 @@ This project was accomplished truthfully only by the people whose names are list
John Michael T. Amador (sgd) February 28, 2023 John Michael T. Amador (sgd) February 28, 2023
Alvin Joshua M. Andrada (sgd) March 2, 2023 Alvin Joshua M. Andrada (sgd) March 2, 2023
Ron Lawrence C. Rodillas (sgd) March 5, 2023 Ron Lawrence C. Rodillas (sgd) March 5, 2023
Brendan Gabrielle M. Fausto (sgd) March 6, 2023
Marco Anton O. Paeldon (sgd) March 6, 2023
from django.contrib import admin
from .models import Assignment, Course
# Register your models here.
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
class CourseAdmin(admin.ModelAdmin):
model = Course
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(Course, CourseAdmin)
from django.apps import AppConfig
class AssignmentsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Assignments'
# Generated by Django 4.1.7 on 2023-02-28 07:09
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='IndexCard',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.CharField(max_length=10000)),
('course', models.CharField(max_length=10000)),
('perfect_score', models.IntegerField()),
('passing_score', models.IntegerField()),
],
),
]
# Generated by Django 4.1.7 on 2023-03-01 08:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Assignments',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.CharField(max_length=10000)),
('course', models.CharField(max_length=10000)),
],
),
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=10000)),
('section', models.CharField(max_length=3)),
],
),
migrations.DeleteModel(
name='IndexCard',
),
]
# Generated by Django 4.1.7 on 2023-03-01 08:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0002_assignments_course_delete_indexcard'),
]
operations = [
migrations.AddField(
model_name='assignments',
name='perfect_score',
field=models.IntegerField(default=10),
preserve_default=False,
),
]
# Generated by Django 4.1.7 on 2023-03-02 20:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0003_assignments_perfect_score'),
]
operations = [
migrations.AddField(
model_name='assignments',
name='course_stuff',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='Assignments.course'),
preserve_default=False,
),
]
# Generated by Django 4.1.7 on 2023-03-02 21:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0004_assignments_course_stuff'),
]
operations = [
migrations.RenameModel(
old_name='Assignments',
new_name='Assignment',
),
]
from django.db import models
from django.urls import reverse
# Create your models here.
class Course(models.Model):
code = models.CharField(max_length=10)
title = models.CharField(max_length=10000)
section = models.CharField(max_length=3)
def __str__(self):
return '{} {} {}'.format(self.code, self.title, self.section)
def get_absolute_url(self):
return reverse('course_detail', args=[str(self.section)])
class Assignment(models.Model):
name = models.CharField(max_length=100)
description = models.CharField(max_length=10000)
course = models.CharField(max_length=10000)
perfect_score = models.IntegerField()
course_stuff = models.ForeignKey(Course, on_delete=models.CASCADE)
def __str__(self):
return '{}: {}'.format(self.name, self.course)
def get_absolute_url(self):
return reverse('perfect_score_detail', args=[str(self.perfect_score)])
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
# This might be needed, depending on your Django version
app_name = "Assignment"
from django.http import HttpResponse
from .models import Assignment
# Create your view here.
def index(request):
overall_assignments = "<html><title>Assignments</title><body>" \
"<h1> Widget's Assignments Page!</h1>"
for assignment in Assignment.objects.all():
overall_assignments += "<p><b>Assignment Name: %s</b><br>" %assignment.name
overall_assignments += "Description: %s<br>" %assignment.description
overall_assignments += "Perfect Score: %i<br>" %assignment.perfect_score
perfect_s = float(assignment.perfect_score)
overall_assignments += "Passing Score: %i<br>" %(float(perfect_s)*0.6)
overall_assignments += "Course/Section: %s" %assignment.course_stuff
overall_assignments += "</body></html>"
return HttpResponse(overall_assignments)
\ 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',)
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 AnnouncementsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'announcements'
# Generated by Django 4.1.7 on 2023-03-05 14:22
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=255, null=True)),
('body', models.TextField(null=True)),
('pub_datetime', models.DateTimeField(null=True)),
('author', models.ForeignKey(null=True, 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(max_length=255, null=True)),
('tally', models.IntegerField(null=True)),
('announcement', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
from django.db import models
from dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=255, null=True)
body = models.TextField(null=True)
author = models.ForeignKey('dashboard.WidgetUser', on_delete=models.CASCADE, null=True)
pub_datetime = models.DateTimeField(null=True)
def __str__(self):
return f"{self.title}"
class Reaction(models.Model):
name = models.CharField(max_length=255, null=True)
tally = models.IntegerField(null=True)
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, null=True)
def __str__(self):
return f"{self.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 = "announcements"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Announcement, Reaction
import datetime
def index(request):
overall_board = "<html><title>Announcement Board</title><body>" \
"<h1> Widget's Announcement Board</h1>"
overall_board += "Announcements:"
for announcement in Announcement.objects.all():
overall_board += "<br>%s by " %announcement.title
overall_board += "%s " %announcement.author.first_name
overall_board += "%s published " %announcement.author.last_name
overall_board += "%s, " %announcement.pub_datetime.date().strftime("%m/%d/%Y")
overall_board += "%s<br>" %announcement.pub_datetime.time().strftime("%I:%M %p")
overall_board += "%s<br>" %announcement.body
for reaction in Reaction.objects.all():
if reaction.announcement == announcement:
overall_board += "%s: " %reaction.name
overall_board += "%i<br>" %reaction.tally
overall_board += "</body></html>"
return HttpResponse(overall_board)
\ No newline at end of file
from django.contrib import admin
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
search_fields = ('dept_name','home_unit',)
list_display = ('dept_name','home_unit',)
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
search_fields = ('first_name','middle_name','last_name','department',)
list_display = ('first_name','middle_name','last_name','department',)
list_filter = ('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-05 03:39
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=255)),
('home_unit', models.CharField(max_length=255)),
],
),
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=255)),
('middle_name', models.CharField(max_length=255)),
('last_name', models.CharField(max_length=255)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='dashboard.department')),
],
),
]
from django.db import models
class Department(models.Model):
dept_name = models.CharField(max_length=255)
home_unit = models.CharField(max_length=255)
class WidgetUser(models.Model):
first_name = models.CharField(max_length=255)
middle_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
department = models.ForeignKey('Department', on_delete=models.PROTECT)
@property
def dept_name(self):
return self.department.dept_name
@property
def home_unit(self):
return self.department.home_unit
def __str__(self):
return '{}, {} {}: {}, {}'.format(self.last_name, self.first_name, self.middle_name, self.dept_name, self.home_unit)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
# dashboard/urls.py
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.http import HttpResponse
from .models import WidgetUser
# Create your views here.
def index(request):
return_string = '<body>Welcome to Widget!<br><br>WIDGET USERS:<br><ul>'
for user in WidgetUser.objects.all():
user_string = '<li>{}</li>'.format(user.__str__())
return_string += user_string
return_string += '</ul></body>'
html_string = '<html>{}</html>'.format(return_string)
return HttpResponse(html_string)
...@@ -38,6 +38,9 @@ INSTALLED_APPS = [ ...@@ -38,6 +38,9 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'forum', 'forum',
'Assignments',
'dashboard',
'announcements',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -18,5 +18,8 @@ from django.urls import include, path ...@@ -18,5 +18,8 @@ from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('forum/', include('forum.urls', namespace="forum")), path('forum/', include('forum.urls', namespace="forum")),
path('Assignments/', include('Assignments.urls', namespace="Assignments")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('dashboard/', include('dashboard.urls', namespace="dashboard")),
path('announcements/', include('announcements.urls', namespace="announcements")),
] ]
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