Manually merged all the apps into one project to push into the assignments...

Manually merged all the apps into one project to push into the assignments branch before merging with master
parent f6bb21db
SECRET_KEY = 'django-insecure--4$e*nub=h-)k*y!7kid5dz=3g$f5_n2zn&yv(dmupxd-c=m6)'
\ 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 = ["announcement", "name", "tally"]
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 19:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("announcements", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="reaction",
name="name",
field=models.CharField(
choices=[("Like", "Like"), ("Love", "Love"), ("Angry", "Angry")],
max_length=5,
),
),
]
from django.db import models
from dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=50)
body = models.TextField(max_length=1024)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.title
class Reaction(models.Model):
LIKE = 'Like'
LOVE = 'Love'
ANGR = 'Angry'
namechoices = [
(LIKE, 'Like'),
(LOVE, 'Love'),
(ANGR, 'Angry')
]
name = models.CharField(
max_length=5,
choices=namechoices,
)
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 pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "announcements"
\ No newline at end of file
from .models import Announcement, Reaction
from django.http import HttpResponse
def pageview(request):
announcements = Announcement.objects.all()
reactions = Reaction.objects.all()
string_builder = "Widget's Announcement Board <br> <br> Announcements: <br> "
for announcement in announcements:
string_builder = "{} <br> {} by {} published {} <br> {}".format(
string_builder, announcement.title, announcement.author,
announcement.pub_datetime.strftime("%m/%d/%Y, %I:%M %p:"),
announcement.body
)
for reaction in reactions:
if reaction.announcement == announcement:
string_builder = "{} <br> {}: {}".format(string_builder, reaction.name, reaction.tally)
string_builder += "<br>"
return HttpResponse(string_builder)
from django.contrib import admin
# Register your models here.
from .models import Assignment, Course
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
class CourseAdmin(admin.ModelAdmin):
model = Course
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(Course, CourseAdmin)
\ 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 4.1.7 on 2023-03-05 19:21
import django.core.validators
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(default="", max_length=10)),
("title", models.CharField(default="", max_length=50)),
(
"section",
models.CharField(
default="",
max_length=3,
unique=True,
validators=[
django.core.validators.RegexValidator(
"^[a-zA-Z]*$", message="Only letters are allowed"
)
],
),
),
],
),
migrations.CreateModel(
name="Assignment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(default="", max_length=50)),
("description", models.TextField(default="", max_length=700)),
("perfect_score", models.PositiveIntegerField(default=0)),
(
"course",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="assignments.course",
),
),
],
),
]
from django.db import models
from django.core.validators import RegexValidator
# Create your models here.
class Course(models.Model):
code = models.CharField(default="", max_length=10)
title = models.CharField(default="", max_length=50)
section = models.CharField(
default="",max_length=3,
unique=True,
validators=[RegexValidator(r'^[a-zA-Z]*$',
message='Only letters are allowed')])
def __str__(self):
return "%s %s %s" % (self.code, self.title, self.section)
class Assignment(models.Model):
name = models.CharField(default="", max_length=50)
description = models.TextField(default="", max_length=700)
course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.PositiveIntegerField(default=0)
def __str__(self):
return self.name
def get_passing_score(self):
pass_score = self.perfect_score * (60/100)
return pass_score
@property
def passing_score(self):
return self.get_passing_score()
\ No newline at end of file
<p>
{{"Widget's Assignments Page"}}
</p><br>
{% for data in assignment %}
<p>Assignment name: {{data.name}}</p>
<p>Description: {{data.description}}</p>
<p>Perfect Score: {{data.perfect_score}}</p>
<p>Passing Score: {{data.passing_score}}</p>
<p>Course/Section: {{data.course}}</p>
<br>
{% endfor %}
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render
from .models import Assignment, Course
def pageview(request):
num_assignment = Assignment.objects.all()
num_course = Course.objects.all()
return render(request, 'assignments/assignments.html', {'assignment': num_assignment, 'course': num_course})
from django.contrib import admin
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
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.7 on 2023-03-04 07:48
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=300)),
('home_unit', models.CharField(max_length=300)),
],
),
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=300)),
('middle_name', models.CharField(max_length=300)),
('last_name', models.CharField(max_length=300)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.department')),
],
),
]
from django.db import models
# Create your models here.
class Department(models.Model):
dept_name = models.CharField(max_length=300)
home_unit = models.CharField(max_length=300)
def __str__(self):
return self.dept_name
class WidgetUser(models.Model):
first_name = models.CharField(max_length=300)
middle_name = models.CharField(max_length=300)
last_name = models.CharField(max_length=300)
department = models.ForeignKey(Department, on_delete=models.CASCADE)
def __str__(self):
return '{} {} {}'.format(self.first_name, self.middle_name, self.last_name)
\ No newline at end of file
<p>Welcome to Widget!</p>
<p>WIDGET USERS:<br>
{% for user in widgetusers %}
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}: {{user.department.dept_name}}, {{user.department.home_unit}}<br>
{% endfor %}
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "dashboard"
\ No newline at end of file
from django.shortcuts import render
from .models import Department, WidgetUser
def pageview(request):
departments = Department.objects.all()
widgetusers = WidgetUser.objects.all()
return render(request, 'dashboard/dashboard.html', {'departments': departments, 'widgetusers': widgetusers})
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ForumConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'forum'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "forum"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
def pageview(request):
return HttpResponse()
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'widget_quintupoltrobol.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
from django.contrib import admin
from .models import Event, Location
class EventAdmin(admin.ModelAdmin):
model = Event
class LocationAdmin(admin.ModelAdmin):
model = Location
admin.site.register(Event, EventAdmin)
admin.site.register(Location, LocationAdmin)
\ No newline at end of file
from django.apps import AppConfig
class WidgetCalendarConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'widget_calendar'
from django.db import models
class Location(models.Model):
modechoices = [
('onsite', 'onsite'),
('online', 'online'),
('hybrid', 'hybrid')
]
mode = models.CharField(
max_length=6,
choices=modechoices,
default='onsite'
)
venue = models.TextField()
def __str__(self):
return '{}, {}'.format(self.mode, self.venue)
class Event(models.Model):
target_datetime = models.CharField(max_length=50)
activity = models.TextField(max_length=300)
estimated_hours = models.FloatField()
location = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.CharField(max_length=150)
def __str__(self):
return self.activity
\ No newline at end of file
<p>Widget's Calendar of Activities<br /><br /></p>
{% for event in events %}
<p>
{{ event.target_datetime }}<br />
Activity: {{ event.activity }}<br />
Estimated Hours: {{ event.estimated_hours }}<br />
Course/Section: {{ event.course }}<br />
Mode: {{ event.location.mode }}<br />
Venue: {{ event.location.venue }}
</p>
{% endfor %}
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import pageview
urlpatterns = [
path('', pageview, name='pageview')
]
app_name = "widget_calendar"
\ No newline at end of file
from django.shortcuts import render
from .models import Event, Location
def pageview(request):
events = Event.objects.all()
locations = Location.objects.all()
return render(request, 'widget_calendar/widget_calendar.html', {'events': events, 'locations': locations})
"""
ASGI config for widget_quintupoltrobol project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'widget_quintupoltrobol.settings')
application = get_asgi_application()
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = os.getenv('SECRET_KEY')
DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard',
'announcements',
'forum',
'assignments',
'widget_calendar',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'widget_quintupoltrobol.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'widget_quintupoltrobol.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Manila'
USE_I18N = True
USE_TZ = True
STATIC_URL = 'static/'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('dashboard/', include('dashboard.urls', namespace="dashboard")),
path('announcements/', include('announcements.urls', namespace="announcements")),
path('forum/', include('forum.urls', namespace="forum")),
path('assignments/', include('assignments.urls', namespace="assignments")),
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('admin/', admin.site.urls),
]
"""
WSGI config for widget_quintupoltrobol project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'widget_quintupoltrobol.settings')
application = get_wsgi_application()
from django.contrib import admin from django.contrib import admin
from .models import Announcement, Reaction
# Register your models here. class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
list_display = ["title", "body", "author"]
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
list_display = ["announcement", "name", "tally"]
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
# Generated by Django 4.1.6 on 2023-03-04 17:46 # Generated by Django 4.1.7 on 2023-03-05 19:50
from django.db import migrations, models from django.db import migrations, models
...@@ -6,13 +6,13 @@ from django.db import migrations, models ...@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('widget_calendar', '0001_initial'), ('announcements', '0001_initial'),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='event', model_name='reaction',
name='target_datetime', name='name',
field=models.CharField(max_length=50), field=models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], max_length=5),
), ),
] ]
from django.db import models from django.db import models
from dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=50)
body = models.TextField(max_length=1024)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.title
class Reaction(models.Model):
LIKE = 'Like'
LOVE = 'Love'
ANGR = 'Angry'
namechoices = [
(LIKE, 'Like'),
(LOVE, 'Love'),
(ANGR, 'Angry')
]
name = models.CharField(
max_length=5,
choices=namechoices,
)
tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE)
def __str__(self):
return self.name
# Create your models here.
from django.shortcuts import render from .models import Announcement, Reaction
from django.http import HttpResponse from django.http import HttpResponse
def pageview(request): def pageview(request):
return HttpResponse() announcements = Announcement.objects.all()
reactions = Reaction.objects.all()
string_builder = "Widget's Announcement Board <br> <br> Announcements: <br> "
for announcement in announcements:
string_builder = "{} <br> {} by {} published {} <br> {}".format(
string_builder, announcement.title, announcement.author,
announcement.pub_datetime.strftime("%m/%d/%Y, %I:%M %p:"),
announcement.body
)
for reaction in reactions:
if reaction.announcement == announcement:
string_builder = "{} <br> {}: {}".format(string_builder, reaction.name, reaction.tally)
string_builder += "<br>"
return HttpResponse(string_builder)
from django.contrib import admin from django.contrib import admin
from .models import ForumPost, Reply
class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost
list_display = ["title", "body", "author"]
class ReplyAdmin(admin.ModelAdmin):
model = Reply
list_display = ["body", "author", "forumpost"]
admin.site.register(ForumPost, ForumPostAdmin)
admin.site.register(Reply, ReplyAdmin)
# Register your models here. # Register your models here.
\ No newline at end of file
# Generated by Django 4.1.6 on 2023-03-04 15:07 # Generated by Django 4.1.7 on 2023-03-05 19:50
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
...@@ -9,26 +9,28 @@ class Migration(migrations.Migration): ...@@ -9,26 +9,28 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
('dashboard', '0001_initial'),
] ]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Location', name='ForumPost',
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('onsite', 'onsite'), ('online', 'online'), ('hybrid', 'hybrid')], default='onsite', max_length=6)), ('title', models.CharField(max_length=100)),
('venue', models.TextField()), ('body', models.TextField()),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
], ],
), ),
migrations.CreateModel( migrations.CreateModel(
name='Event', name='Reply',
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField()), ('body', models.TextField()),
('activity', models.TextField(max_length=300)), ('pub_datetime', models.DateTimeField()),
('estimated_hours', models.FloatField()), ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
('course', models.CharField(max_length=150)), ('forumpost', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost')),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_calendar.location')),
], ],
), ),
] ]
from django.db import models from django.db import models
from dashboard.models import WidgetUser
class ForumPost(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.title
class Reply(models.Model):
body = models.TextField()
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
forumpost = models.ForeignKey(ForumPost, on_delete=models.CASCADE)
def __str__(self):
return self.body
# Create your models here. # Create your models here.
from django.shortcuts import render from django.shortcuts import render
from .models import ForumPost, Reply
from django.http import HttpResponse from django.http import HttpResponse
def pageview(request): def pageview(request):
return HttpResponse() forumposts = ForumPost.objects.all()
replys = Reply.objects.all()
string_builder = "Widget's Forum <br> <br> Forum Posts: <br> "
for forumpost in forumposts:
string_builder = "{} <br> {} by {} posted {} <br> {}".format(
string_builder, forumpost.title, forumpost.author,
forumpost.pub_datetime.strftime("%m/%d/%Y, %I:%M %p:"), forumpost.body
)
for reply in replys:
if reply.forumpost == forumpost:
string_builder = "{} <br> Reply by {} posted {} <br> {}".format(
string_builder, reply.author,
reply.pub_datetime.strftime("%m/%d/%Y, %I:%M %p:"), reply.body
)
string_builder += "<br>"
return HttpResponse(string_builder)
<p>Widget's Calendar of Activities<br><br></p> <p>Widget's Calendar of Activities<br /><br /></p>
{% for event in events %} {% for event in events %}
<p> <p>
Date and Time: {{ event.target_datetime }}<br> {{ event.target_datetime }}<br />
Activity: {{ event.activity }}<br> Activity: {{ event.activity }}<br />
Estimated Hours: {{ event.estimated_hours }}<br> Estimated Hours: {{ event.estimated_hours }}<br />
Course/Section: {{ event.course }}<br> Course/Section: {{ event.course }}<br />
Mode: {{ event.location.mode }}<br> Mode: {{ event.location.mode }}<br />
Venue: {{ event.location.venue }} Venue: {{ event.location.venue }}
</p> </p>
{% endfor %} {% endfor %}
...@@ -84,7 +84,7 @@ AUTH_PASSWORD_VALIDATORS = [ ...@@ -84,7 +84,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC' TIME_ZONE = 'Asia/Manila'
USE_I18N = True USE_I18N = True
...@@ -93,5 +93,4 @@ USE_TZ = True ...@@ -93,5 +93,4 @@ USE_TZ = True
STATIC_URL = 'static/' STATIC_URL = 'static/'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
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