Commit 4a9db365 authored by Alvin Joshua Andrada's avatar Alvin Joshua Andrada

merged with assignments app and fixed errors

parents 1e41567f 23487061
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
# Generated by Django 4.1.7 on 2023-03-02 22:05
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0005_rename_assignments_assignment'),
('calendar_app', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='event',
name='course',
field=models.ForeignKey(default='1', on_delete=django.db.models.deletion.CASCADE, to='Assignments.course'),
preserve_default=False,
),
]
from django.db import models from django.db import models
# from Assignments.models import Course from Assignments.models import Course
class Event(models.Model): class Event(models.Model):
target_datetime = models.DateTimeField() target_datetime = models.DateTimeField()
...@@ -9,10 +9,10 @@ class Event(models.Model): ...@@ -9,10 +9,10 @@ class Event(models.Model):
'Location', 'Location',
on_delete = models.CASCADE, on_delete = models.CASCADE,
) )
# course = models.ForeignKey( course = models.ForeignKey(
# 'Assignments.Course', 'Assignments.Course',
# on_delete = models.CASCADE, on_delete = models.CASCADE,
# ) )
def __str__(self): def __str__(self):
return '{} on {}'.format(self.activity, self.target_datetime) return '{} on {}'.format(self.activity, self.target_datetime)
......
...@@ -26,9 +26,9 @@ def display_details(index): ...@@ -26,9 +26,9 @@ def display_details(index):
time = event.target_datetime.time().strftime("%I:%M %p") time = event.target_datetime.time().strftime("%I:%M %p")
activity = event.activity activity = event.activity
estimated_hours = event.estimated_hours estimated_hours = event.estimated_hours
# course_code = event.course.code course_code = event.course.code
# course_title = event.course.title course_title = event.course.title
# section = event.course.section section = event.course.section
mode = event.location.mode mode = event.location.mode
venue = event.location.venue venue = event.location.venue
...@@ -36,7 +36,7 @@ def display_details(index): ...@@ -36,7 +36,7 @@ def display_details(index):
display = 'Date and Time: {}, {} <br>'.format(date,time) display = 'Date and Time: {}, {} <br>'.format(date,time)
display += 'Activity: {} <br>'.format(activity) display += 'Activity: {} <br>'.format(activity)
display += 'Estimated Hours {} <br>'.format(estimated_hours) display += 'Estimated Hours {} <br>'.format(estimated_hours)
display += 'Course/Section: {} {}-{} <br>' #.format(course_code,course_title,section) display += 'Course/Section: {} {}-{} <br>'.format(course_code,course_title,section)
display += 'Mode: {} <br>'.format(mode) display += 'Mode: {} <br>'.format(mode)
display += 'Venue: {} <br>'.format(venue) display += 'Venue: {} <br>'.format(venue)
return display return display
\ No newline at end of file
No preview for this file type
...@@ -38,6 +38,7 @@ INSTALLED_APPS = [ ...@@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'calendar_app', 'calendar_app',
'Assignments',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -17,6 +17,7 @@ from django.contrib import admin ...@@ -17,6 +17,7 @@ from django.contrib import admin
from django.urls import path, include from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('assignments/', include('Assignments.urls', namespace="Assignments")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('calendar/', include('calendar_app.urls', namespace="calendar_app")) path('calendar/', include('calendar_app.urls', namespace="calendar_app"))
] ]
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