Commit ed1bf67c authored by Miguel Luis D. Bandelaria's avatar Miguel Luis D. Bandelaria

resolved changes

parents 7f1f3feb 56568e5b
p{ p{
color: black; color: black;
font-weight: bold; font-weight: bold;
font-family: Helvetica; font-family: papyrus;
font-size:25px; font-size:25px;
} }
h1 { h1 {
...@@ -9,24 +9,24 @@ h1 { ...@@ -9,24 +9,24 @@ h1 {
text-align: left; text-align: left;
color: black; color: black;
font-size: 55px; font-size: 55px;
font-family: Helvetica; font-family: papyrus;
} }
body { body {
background-image: url("/static/announcements/bg.png"); background-image: url("/static/announcements/bg.jpg");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
background-attachment: fixed; background-attachment: fixed;
font-family: Helvetica; font-family: papyrus;
} }
a{ a{
color: black; color: black;
font-family: Helvetica; font-family: papyrus;
font-weight: bold; font-weight: bold;
} }
ol { ol {
font-size:35px; font-size:35px;
font-family: Helvetica; font-family: papyrus;
color:black; color:black;
font-weight: bold; font-weight: bold;
} }
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
<h2>by {{ announcement.author.first_name }} {{ announcement.author.last_name }}, {{ announcement.pub_date|date:"d-m-Y" }}</h2> <h2>by {{ announcement.author.first_name }} {{ announcement.author.last_name }}, {{ announcement.pub_date|date:"d-m-Y" }}</h2>
</head> </head>
<body> <body>
<div style="max-width:800px; word-wrap:break-word;">
<p>{{ announcement.announcement_body }}</p> <p>{{ announcement.announcement_body }}</p>
</div>
<p>Like: {{ like_tally }}</p> <p>Like: {{ like_tally }}</p>
<p>Love: {{ love_tally }}</p> <p>Love: {{ love_tally }}</p>
<p>Angry: {{ angry_tally }}</p> <p>Angry: {{ angry_tally }}</p>
......
from django.forms import ModelForm
from .models import Assignment, Course
class AssignmentForm(ModelForm):
class Meta:
model = Assignment
fields = ["name", "description", "max_points", "course", "image"]
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-05-24 08:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0006_alter_assignment_image'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='image',
field=models.FileField(null=True, upload_to='static/assignments'),
),
]
...@@ -6,6 +6,9 @@ class Course(models.Model): ...@@ -6,6 +6,9 @@ class Course(models.Model):
course_code = models.CharField(max_length=10) course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=255) course_title = models.CharField(max_length=255)
section = models.CharField(max_length=3) section = models.CharField(max_length=3)
def __str__(self):
return self.course_code + '/' + self.course_title + '/' + self.section
class Assignment(models.Model): class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete=models.CASCADE, null=True) course = models.ForeignKey(Course, on_delete=models.CASCADE, null=True)
...@@ -13,11 +16,15 @@ class Assignment(models.Model): ...@@ -13,11 +16,15 @@ class Assignment(models.Model):
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) passing_score = models.IntegerField(default=0)
image = models.FileField(upload_to='static/assignments/', null=True) image = models.FileField(upload_to='static/assignments', null=True)
def _str_(self): def __str__(self):
return self.name return self.name
def file(self): def file(self):
value = os.path.basename(self.image.name) value = os.path.basename(self.image.name)
return value return value
\ No newline at end of file
def save(self):
self.passing_score = self.max_points*0.6
super(Assignment, self).save()
...@@ -21,4 +21,5 @@ ...@@ -21,4 +21,5 @@
{% else %} {% else %}
<p>No course available.</p> <p>No course available.</p>
{% endif %} {% endif %}
<a href="{% url 'assignments:newassignment' %}">New Assignment</a>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends "assignments/base.html" %}
{% block page-title %}New Assignment{% endblock %}
{% block content %}
<h1>New Assignment</h1>
<a href="{% url 'assignments:index' %}">Assignments Per Course</a>
<form method="POST" action="{% url 'assignments:newassignment' %}" enctype="multipart/form-data">
{% csrf_token %}
{{ assignment_form.as_p }}
<button class="button" type="submit">Save Assignment</button>
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
from .views import IndexView
app_name = "assignments" app_name = "assignments"
urlpatterns = [ urlpatterns = [
# assignments/ # assignments/
path('', views.index, name='index'), path('', IndexView.as_view(), name='index'),
# assignments/<assignment_id>/details/ # assignments/<assignment_id>/details/
path('<int:assignment_id>/details/', views.details, name='details'), path('<int:assignment_id>/details/', views.details, name='details'),
# assignments/add/
path('add/', views.newassignment, name='newassignment'),
] ]
\ No newline at end of file
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.shortcuts import render from django.shortcuts import render, redirect
from django.views import View
from assignments.models import Assignment, Course from assignments.models import Assignment, Course
from assignments.forms import AssignmentForm
# Create your views here. # Create your views here.
def index(request): class IndexView(View):
course_list = Course.objects.order_by("course_code") def get(self, request):
assignment_list = Assignment.objects.all() course_list = Course.objects.order_by("course_code")
context = { assignment_list = Assignment.objects.all()
"course_list" : course_list, context = {
"assignment_list" : assignment_list, "course_list" : course_list,
} "assignment_list" : assignment_list,
return render(request, "assignments/index.html", context) }
return render(request, "assignments/index.html", context)
def details(request, assignment_id): def details(request, assignment_id):
try: try:
assignment = Assignment.objects.get(pk=assignment_id) assignment = Assignment.objects.get(pk=assignment_id)
except Assignment.DoesNotExist: except Assignment.DoesNotExist:
raise Http404("Assignment does not exist.") raise Http404("Assignment does not exist.")
score = assignment.max_points
assignment.passing_score = (score*60) // 100
context = { context = {
"assignment" : assignment, "assignment" : assignment,
...@@ -27,7 +27,30 @@ def details(request, assignment_id): ...@@ -27,7 +27,30 @@ def details(request, assignment_id):
} }
return render(request, "assignments/details.html", context) return render(request, "assignments/details.html", context)
# Code from previous labs: def newassignment(request):
if request.method == "POST":
assignment_form = AssignmentForm(request.POST, request.FILES)
if assignment_form.is_valid():
new_assignment = assignment_form.save()
return redirect("assignments:newassignment")
else:
assignment_form = AssignmentForm()
return render(request, "assignments/newassignment.html", {"assignment_form":assignment_form})
# Code from Lab 3:
#
# def index(request):
# course_list = Course.objects.order_by("course_code")
# assignment_list = Assignment.objects.all()
# context = {
# "course_list" : course_list,
# "assignment_list" : assignment_list,
# }
# return render(request, "assignments/index.html", context)
# Code from Midterm Project and earlier labs:
# #
# def index(request): # def index(request):
# assignments_view = "ASSIGNMENTS: <br>" # assignments_view = "ASSIGNMENTS: <br>"
......
...@@ -12,7 +12,7 @@ h1 { ...@@ -12,7 +12,7 @@ h1 {
font-family: Helvetica; font-family: Helvetica;
} }
body { body {
background-image: url("/static/bg.png"); background-image: url("/static/homepage/lenibg.jpg");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
......
{% extends "homepage/base.html" %} {% extends "homepage/base.html" %}
{% block page-title %}Widget User Homepage{% endblock %} {% block page-title %}Widget User Homepage{% endblock %}
{% block content %} {% block content %}
......
This diff is collapsed.
This diff is collapsed.
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