Commit 46290b7e authored by Joan Denise Nocos's avatar Joan Denise Nocos

fix: resolved issue with merging local branch to main branch

parents aff8fa19 00357543
from django.contrib import admin from django.contrib import admin
# Register your models here. # Register your models here.
from .models import Assignment from .models import Assignment, Course
admin.site.register(Assignment) admin.site.register(Assignment)
\ No newline at end of file admin.site.register(Course)
\ No newline at end of file
# Generated by Django 3.2.12 on 2022-04-05 04:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0),
),
]
# Generated by Django 3.2.12 on 2022-04-05 04:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_assignment_passing_score'),
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('course_code', models.CharField(max_length=10)),
('course_title', models.CharField(max_length=256)),
('section', models.CharField(max_length=3)),
],
),
]
# Generated by Django 3.2.12 on 2022-04-05 19:29
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0003_course'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='course',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
migrations.AlterField(
model_name='course',
name='course_title',
field=models.CharField(max_length=255),
),
]
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class Course(models.Model):
course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=255)
section = models.CharField(max_length=3)
class Assignment(models.Model): class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
description = models.CharField(max_length=500) description = models.CharField(max_length=500)
max_points = models.IntegerField(default=0) max_points = models.IntegerField(default=0)
passing_score = models.IntegerField(default=0)
def _str_(self): def _str_(self):
return self.name return self.name
\ No newline at end of file
from django.http import HttpResponse from django.http import HttpResponse
from assignments.models import Assignment, Course
# Create your views here. # Create your views here.
def index(request): def index(request):
return HttpResponse("This is the Assignments page!") assignments_view = "ASSIGNMENTS: <br>"
\ No newline at end of file schoolwork = Assignment.objects.all()
for assignment in schoolwork:
assignments_view += "Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {} {} {}<br><br>".\
format(assignment.name,
assignment.description,
assignment.max_points,
assignment.passing_score,
assignment.course.course_code,
assignment.course.course_title,
assignment.course.section)
return HttpResponse(assignments_view)
\ 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