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

resolved changes

parents 7f1f3feb 56568e5b
p{
color: black;
font-weight: bold;
font-family: Helvetica;
font-family: papyrus;
font-size:25px;
}
h1 {
......@@ -9,24 +9,24 @@ h1 {
text-align: left;
color: black;
font-size: 55px;
font-family: Helvetica;
font-family: papyrus;
}
body {
background-image: url("/static/announcements/bg.png");
background-image: url("/static/announcements/bg.jpg");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
background-attachment: fixed;
font-family: Helvetica;
font-family: papyrus;
}
a{
color: black;
font-family: Helvetica;
font-family: papyrus;
font-weight: bold;
}
ol {
font-size:35px;
font-family: Helvetica;
font-family: papyrus;
color:black;
font-weight: bold;
}
......
......@@ -8,7 +8,9 @@
<h2>by {{ announcement.author.first_name }} {{ announcement.author.last_name }}, {{ announcement.pub_date|date:"d-m-Y" }}</h2>
</head>
<body>
<div style="max-width:800px; word-wrap:break-word;">
<p>{{ announcement.announcement_body }}</p>
</div>
<p>Like: {{ like_tally }}</p>
<p>Love: {{ love_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'),
),
]
......@@ -7,17 +7,24 @@ class Course(models.Model):
course_title = models.CharField(max_length=255)
section = models.CharField(max_length=3)
def __str__(self):
return self.course_code + '/' + self.course_title + '/' + self.section
class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=50)
description = models.CharField(max_length=500)
max_points = 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
def file(self):
value = os.path.basename(self.image.name)
return value
def save(self):
self.passing_score = self.max_points*0.6
super(Assignment, self).save()
......@@ -21,4 +21,5 @@
{% else %}
<p>No course available.</p>
{% endif %}
<a href="{% url 'assignments:newassignment' %}">New Assignment</a>
{% 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 . import views
from .views import IndexView
app_name = "assignments"
urlpatterns = [
# assignments/
path('', views.index, name='index'),
path('', IndexView.as_view(), name='index'),
# assignments/<assignment_id>/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.shortcuts import render
from django.shortcuts import render, redirect
from django.views import View
from assignments.models import Assignment, Course
from assignments.forms import AssignmentForm
# Create your views here.
def index(request):
class IndexView(View):
def get(self, request):
course_list = Course.objects.order_by("course_code")
assignment_list = Assignment.objects.all()
context = {
......@@ -18,16 +21,36 @@ def details(request, assignment_id):
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist.")
score = assignment.max_points
assignment.passing_score = (score*60) // 100
context = {
"assignment" : assignment,
"course" : assignment.course,
}
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):
# assignments_view = "ASSIGNMENTS: <br>"
......
......@@ -12,7 +12,7 @@ h1 {
font-family: Helvetica;
}
body {
background-image: url("/static/bg.png");
background-image: url("/static/homepage/lenibg.jpg");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
......
{% extends "homepage/base.html" %}
{% block page-title %}Widget User Homepage{% endblock %}
{% 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