Commit 2b315eeb authored by Andrew Justin C. Idquival's avatar Andrew Justin C. Idquival

Merged calendar branch with main

parents 5a3036e9 9c69f268
<<<<<<< HEAD
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env .env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
=======
.env
*.pyc
>>>>>>> forum
from django.contrib import admin
from .models import Announcement, Reaction
class ReactionInline(admin.TabularInline):
model = Reaction
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
list_display = ('title', 'author', )
search_fields = ('title', 'body', 'author', )
list_filter = ('title', 'author')
fieldsets = [
('Announcement', {
'fields':
('title', 'body','author')
})
]
inlines = [ReactionInline]
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
list_display = ('name', 'tally', 'annoucement')
search_fields = ('name', 'annoucement')
list_filter = ('name', 'annoucement')
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
from django.apps import AppConfig
class AnnouncementboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'announcementBoard'
# Generated by Django 3.2 on 2023-03-04 07:17
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(default='', max_length=250)),
('body', models.TextField(blank=True, null=True)),
('pub_datetime', models.DateTimeField(auto_now_add=True)),
('author', models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, 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=10)),
('tally', models.IntegerField(default=0)),
('annoucement', models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='announcementBoard.announcement')),
],
),
]
# Generated by Django 3.2 on 2023-03-05 07:28
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0001_initial'),
('announcementBoard', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='announcements', to='dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reaction',
name='annoucement',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reactions', to='announcementBoard.announcement'),
),
migrations.AlterField(
model_name='reaction',
name='name',
field=models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], default='Like', max_length=5),
),
migrations.AlterField(
model_name='reaction',
name='tally',
field=models.PositiveIntegerField(default=0),
),
]
# Generated by Django 3.2 on 2023-03-05 09:46
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0001_initial'),
('announcementBoard', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='announcements', to='dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reaction',
name='annoucement',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reactions', to='announcementBoard.announcement'),
),
migrations.AlterField(
model_name='reaction',
name='name',
field=models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], default='Like', max_length=5),
),
migrations.AlterField(
model_name='reaction',
name='tally',
field=models.PositiveIntegerField(default=0),
),
]
# Generated by Django 3.2 on 2023-03-05 11:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('announcementBoard', '0002_auto_20230305_1528'),
('announcementBoard', '0002_auto_20230305_1746'),
]
operations = [
]
from django.db import models
from dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=250, default="")
body = models.TextField(null=True, blank=True)
author = models.ForeignKey(
WidgetUser,
null=True,
default=True,
on_delete=models.CASCADE,
related_name='announcements',
)
pub_datetime = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
def format_pub_datetime(self):
return self.pub_datetime.strftime('%m/%d/%Y, %I:%M %p')
class Reaction(models.Model):
name = models.CharField(max_length=5, choices=[('Like', 'Like'),
('Love', 'Love'),
('Angry', 'Angry')], default='Like')
tally = models.PositiveIntegerField(default=0)
annoucement = models.ForeignKey(
Announcement,
null=True,
default=True,
on_delete=models.CASCADE,
related_name='reactions'
)
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.http import HttpResponse
from .models import Announcement
from dashboard.models import WidgetUser
def index(request):
head = "<h1 style='border-bottom:4px solid lightgray;\
padding-bottom:30px;\
font-size:450%;'>\
Widget's Announcement Board\
</h1>"
body = "<h2>Announcements:</h2>"
for x in Announcement.objects.all():
reaction = x.reactions.all()
body += "<p style='border: 2px solid gray;\
border-radius:5px;\
padding:20px 30px;'>\
{} by {} {} published {}:\
<br>\
{}\
</p>".format(x.title, x.author.first_name, x.author.last_name,
x.format_pub_datetime(), x.body)
for y in reaction:
body += "<p>{}: {}\
</p>".format(y.name, y.tally)
body += '<p>&nbsp;</p>'
return_string = "<html>\
<body style = 'font-family:helvetica;\
padding:30px;'>\
{}{}\
</body></html>".format(head, body)
return HttpResponse(return_string)
from django.contrib import admin
from .models import Assignment, Course
class AssignmentInline(admin.StackedInline):
model = Assignment
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
list_display = ('assignment_name', 'section')
search_fields = ('course',)
list_filter = ('section', 'perfect_score', 'passing_score')
class CourseAdmin(admin.ModelAdmin):
model = Course
list_display = ('course_code', 'course_title',)
search_fields = ('course_code', 'course_title',)
list_filter = ('course_code', 'course_title',)
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-05 06:23
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')),
('course_code', models.CharField(default='', max_length=50, unique=True)),
('course_title', models.CharField(default='', max_length=50, unique=True)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('assignment_name', models.CharField(default='', max_length=50, unique=True)),
('description', models.TextField(default='')),
('perfect_score', models.IntegerField(default=0)),
('passing_score', models.IntegerField(default=0)),
('section', models.CharField(max_length=16, unique=True)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subject', to='assignments.course')),
],
),
]
# Generated by Django 3.2 on 2023-03-05 09:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='course',
name='course_code',
field=models.CharField(default='', max_length=10, unique=True),
),
]
from django.db import models
class Course(models.Model):
course_code = models.CharField(unique=True, default="", max_length=10,)
course_title = models.CharField(unique=True, default="", max_length=50,)
def __str__(self):
return '{} {}'.format(self.course_code, self.course_title,)
class Assignment(models.Model):
assignment_name = models.CharField(unique=True, default="", max_length=50,)
description = models.TextField(default="")
perfect_score = models.IntegerField(default=0)
passing_score = models.IntegerField(default=0)
section = models.CharField(unique=True, max_length=16,)
course = models.ForeignKey(
Course,
on_delete=models.CASCADE,
related_name='subject'
)
def __str__(self):
return '{} {}-'.format(self.assignment_name, self.section,)
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
def index(request):
head = "<h1 style='border-bottom:4px solid lightgray;\
padding-bottom:30px;\
font-size:500%;'>\
Widget's assignment page\
</h1>\n"
body = ""
for subject in Assignment.objects.all():
body += "<p style='border: 2px solid gray;\
border-radius:5px;\
padding:20px 30px;'>\
<b> Assignment Name: "+subject.assignment_name+" </b> <br>\
Description: "+subject.description+" <br>\
Perfect Score: "+str(subject.perfect_score)+" <br>\
Passing Score: "+str(subject.passing_score)+" <br>\
Course/Section: "+str(subject.course)+" /"+str(subject.section)+" <br>\
</p>"
return_string = "<html>\
<body>\
{}{}\
</body></html>".format(head, body)
return HttpResponse(return_string)
from django.contrib import admin
from .models import ForumPost, Reply
class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost
list_display = ('title', 'body', 'author', 'pub_datetime')
search_fields = ('title', 'author', 'pub_datetime',)
list_filter = ('title', 'author', 'pub_datetime',)
class ReplyAdmin(admin.ModelAdmin):
model = Reply
list_display = ('body', 'post', 'author', 'pub_datetime',)
search_fields = ('author', 'pub_datetime',)
list_filter = ('author', 'pub_datetime',)
admin.site.register(ForumPost, ForumPostAdmin)
admin.site.register(Reply, ReplyAdmin)
from django.apps import AppConfig
class ForumConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'forum'
# Generated by Django 3.2 on 2023-03-05 07:28
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='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('body', models.CharField(max_length=200)),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='ForumPost',
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=200)),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
]
# Generated by Django 3.2 on 2023-03-05 08:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('forum', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='reply',
name='post',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost'),
),
]
# forum/models.py
from django.db import models
from dashboard.models import WidgetUser
class ForumPost(models.Model):
title = models.CharField(max_length=100)
body = models.CharField(max_length=200)
author = models.ForeignKey(
WidgetUser,
null=True,
default=True,
on_delete=models.CASCADE,
)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.title
def format_pub_datetime(self):
return self.pub_datetime.strftime('%m/%d/%Y %I:%M %p')
class Reply(models.Model):
post = models.ForeignKey(
ForumPost,
null=True,
default=True,
on_delete=models.CASCADE,
)
body = models.CharField(max_length=200)
author = models.ForeignKey(
WidgetUser,
null=True,
default=True,
on_delete=models.CASCADE,
)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.body
def format_pub_datetime(self):
return self.pub_datetime.strftime('%m/%d/%Y %I:%M %p')
from django.test import TestCase
# Create your tests here.
# forum/urls.py
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 = "forum"
# appname/views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import ForumPost, Reply
from dashboard.models import WidgetUser
def index(request):
head = "<h1 style='border-bottom:4px solid lightgray;\
padding-bottom:30px;\
font-size:450%;'>\
Widget Forum\
</h1>"
body = "<h2>Forum Posts:</h2>"
for post in ForumPost.objects.all():
body += "<div style='border: 2px solid gray; border-radius:5px; padding:20px 30px;'>\
<b>{}</b> by {} {} posted {}:\
<br>\
{}".format(post.title, post.author.first_name, post.author.last_name, post.format_pub_datetime(), post.body)
for reply in Reply.objects.all():
if reply.post == post:
body += "<p style='border: 1px dashed gray; border-radius:5px; padding:20px 30px;'>\
Reply by {} {} posted {}:\
<br>\
{}".format(reply.author.first_name, reply.author.last_name, reply.format_pub_datetime(), reply.body)
body += "</div>"
body += "<p>&nbsp;</p>"
return_string = "<html>\
<body style = 'font-family:helvetica;\
padding:30px;'>\
{}{}\
</body></html>".format(head, body)
return HttpResponse(return_string)
...@@ -41,7 +41,13 @@ INSTALLED_APPS = [ ...@@ -41,7 +41,13 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'dashboard', 'dashboard',
<<<<<<< HEAD
'widget_calendar', 'widget_calendar',
=======
'assignments',
'announcementBoard',
'forum',
>>>>>>> 9c69f26864be05db435049d9b3356488faefbbbc
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -19,5 +19,11 @@ from django.urls import include, path ...@@ -19,5 +19,11 @@ from django.urls import include, path
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")),
<<<<<<< HEAD
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")), path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
=======
path('assignments/', include('assignments.urls', namespace="assignments")),
path('announcementBoard/', include('announcementBoard.urls', namespace="announcementBoard")),
path('forum/', include('forum.urls', namespace="forum")),
>>>>>>> 9c69f26864be05db435049d9b3356488faefbbbc
] ]
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