Commit e844388d authored by Ciella's avatar Ciella

Edited the Assignment views and its admin views

parent acf19b8b
from django.contrib import admin from django.contrib import admin
# Register your models here. from .models import Course, Assignment
class CourseAdmin(admin.ModelAdmin):
model = Course
search_fields = ('code', 'title', 'section')
list_display = ('code', 'title', 'section')
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
search_fields = ('name', 'description', 'course')
list_display = ('name', 'course')
admin.site.register(Course, CourseAdmin)
admin.site.register(Assignment, AssignmentAdmin)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-05 16:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=1, editable=False),
),
migrations.AlterField(
model_name='assignment',
name='perfect_score',
field=models.IntegerField(default=100),
),
]
# Generated by Django 4.1.7 on 2023-03-05 16:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_alter_assignment_passing_score_and_more'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(editable=False),
),
migrations.AlterField(
model_name='assignment',
name='perfect_score',
field=models.IntegerField(),
),
]
...@@ -18,7 +18,7 @@ class Assignment(models.Model): ...@@ -18,7 +18,7 @@ class Assignment(models.Model):
passing_score = models.IntegerField(editable=False) passing_score = models.IntegerField(editable=False)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
self.passing_score = int(self.perfect_score*0.6) self.passing_score = int((self.perfect_score)*(0.60))
super(Assignment, self).save(*args, **kwargs) super(Assignment, self).save(*args, **kwargs)
def __str__(self): def __str__(self):
......
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Assignment
# Create your views here. # Create your views here.
def index(request): def index(request):
return HttpResponse('Assignments owo') return_string = '<p>Widget\'s Assignments Page<br>'
\ No newline at end of file
for work in Assignment.objects.all():
work_string = '<br>Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {} {}-{}<br>'.format(
work.name, work.description, work.perfect_score, work.passing_score, work.course.code, work.course.title, work.course.section)
return_string += work_string
return_string += '</p>'
html_string = '<html><body>{}</body></html>'.format(return_string)
return HttpResponse(html_string)
\ 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