Commit 4a267379 authored by Star Neptune R. Sy's avatar Star Neptune R. Sy
parents 598c0b1f 038151c3
......@@ -58,8 +58,8 @@ cover/
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
#db.sqlite3
#db.sqlite3-journal
# Flask stuff:
instance/
......
......@@ -17,6 +17,8 @@ and Neptune Sy.;
https://www.w3schools.com/html/html_css.asp
https://www.w3schools.com/html/html_styles.asp
https://github.com/github/gitignore/blob/main/Python.gitignore;
https://www.onespacemedia.com/news/getting-started-generic-class-based-views-django/
(sgd) Joaquin Crisologo, 28 February, 2023
(sgd) Andrew Idquival, 28 February, 2023
(sgd) Jayson Lim, 28 February, 2023
......
# Generated by Django 3.2 on 2023-04-29 09:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_alter_course_course_code'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=80),
),
migrations.AlterField(
model_name='assignment',
name='perfect_score',
field=models.IntegerField(default=100),
),
migrations.AlterField(
model_name='assignment',
name='section',
field=models.CharField(max_length=16),
),
]
......@@ -10,11 +10,11 @@ class Course(models.Model):
class Assignment(models.Model):
assignment_name = models.CharField(unique=True, default="", max_length=50,)
assignment_name = models.CharField("Name", unique=True, default="", max_length=50,)
description = models.TextField(default="")
perfect_score = models.IntegerField(default=0)
passing_score = models.IntegerField(default=0)
section = models.CharField(unique=True, max_length=16,)
perfect_score = models.IntegerField(default=100)
passing_score = models.IntegerField(default=80)
section = models.CharField(max_length=16,)
course = models.ForeignKey(
Course,
on_delete=models.CASCADE,
......@@ -24,5 +24,9 @@ class Assignment(models.Model):
def __str__(self):
return '{} {}-'.format(self.assignment_name, self.section,)
def get_absolute_url(self):
return '{}'.format(self.pk)
body {
background-color:rgb(167, 36, 75)
}
div.pageTitle{
text-align: center;
background-color: rgb(214, 255, 246);
margin-left: 20%;
margin-right: 20%;
padding-top: 10px;
padding-bottom: 15px;
border-radius: 0.5cm;
border-width: 15px;
border-style:groove double;
border-color: rgb(138, 0, 0);
box-shadow: 0px 20px 40px 0px rgb(65, 2, 23),
0px 0px 40px 0px rgb(175, 212, 204) inset;
}
h1.pageTitle{
font-family: Helvetica;
font-size: 40pt;
}
div.content{
background-color: rgb(214, 255, 246);
margin-left: 30%;
margin-right: 30%;
padding-top: 10px;
padding-left: 5%;
padding-right: 5%;
padding-bottom: 15px;
border-radius: 10px;
border-width: 9px;
border-style: outset;
border-color: rgb(138, 0, 0);
box-shadow: 0px 20px 40px 0px rgb(65, 2, 23);
}
li{
background-color: rgb(214, 255, 246);
font-size: 14pt;
transition: all 0.5s;
}
li:hover{
background-color: rgb(255, 209, 228);
font-size: 20pt;
transition: all 0.5s;
}
div.navButtons{
background-color: rgb(255, 248, 238);
border-radius: 5px;
border-width: 12px;
border-style: ridge;
border-color: rgb(167, 16, 66) ;
text-align: left;
margin-right: 50%;
padding: 15px;
}
button.buttonLink{
padding: 15px;
font-size: 12pt;
scale: 100%;
background-color: rgb(5, 233, 157);
}
button.buttonLink:hover{
background-color: aquamarine;
scale: 105%;
transition: all 100ms;
}
button.buttonLink:active{
background-color: rgb(201, 226, 218);
}
label {
width: 180px;
}
textarea{
vertical-align: top;
}
\ No newline at end of file
{% load static %}
<head>
<link rel="stylesheet" href="{% static '/makeItBeautiful.css' %}">
<title>{% block webTitle %}{% endblock %}</title>
</head>
<body>
<div class="pageTitle"> <h1 class="pageTitle"> {% block pageTitle %}{% endblock %} </h1> </div>
<br><br><br>
<div class="content">
{% block content %}{% endblock %}
<div class="navButtons">
{% block otherButtons %} {% endblock %}
</div>
</div>
</body>
\ No newline at end of file
{% extends 'base.html' %}
{% block webTitle %} Add Assignment {% endblock %}
{% block pageTitle %} Add a new assignment {% endblock %}
{% block content %}
<form id="addAssignment" method="post">
<b>
{% csrf_token %}
{{ form.as_p }}
</b>
</form>
{% endblock %}
{% block otherButtons %}
<button class="buttonLink" form="addAssignment" onclick="window.location.href='assignments/';"> <b> Add assignment </b> </button>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block webTitle %} {{object.assignment_name}} {% endblock %}
{% block pageTitle %} {{object.assignment_name}} {% endblock %}
{% block content %}
<h2> {{object.course}} - {{object.section}} </h2>
<p> <b>Description:</b> {{object.description}} <br>
<b>Perfect Score:</b> {{object.perfect_score}} <br>
<b>Passing Score:</b> {{object.passing_score}} <br>
</p>
{% endblock %}
{% block otherButtons %}
<button class="buttonLink" onclick="window.location.href='../../{{ object.get_absolute_url }}/edit';"> <b>Edit Assignment</b> </button>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block webTitle %} Edit Assignment {% endblock %}
{% block pageTitle %} Edit Assignment {% endblock %}
{% block content %}
<form id="editAssignment" method="post">
<b>
{% csrf_token %}
{{ form.as_p }}
</b>
</form>
{% endblock %}
{% block otherButtons %}
<button class="buttonLink" form="editAssignment" onclick="window.location.href='assignments/';"> <b>Save changes to assignment</b> </button>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block webTitle %} Widget's Assignments {% endblock %}
{% block pageTitle %} Welcome to Widget's assignments {% endblock %}
{% block content %}
<ul style='list-style-type:square;'>
{% for assignment in assignmentsList %}
<li> <div class='assignmentLink'> <a href="{{ assignment.get_absolute_url }}/details"> {{ assignment.assignment_name }} </a> </div> </li>
{% endfor %}
</ul>
{% endblock %}
{% block otherButtons %}
<button class="buttonLink" onclick="window.location.href='add/';"> <b>New Assignment</b> </button><br><br>
<a class="miniLink" href="/dashboard"> Dashboard </a> <br>
<a class="miniLink" href="/announcementBoard"> Announcements </a> <br>
<a class="miniLink" href="/forum"> Forum </a> <br>
<a class="miniLink" href="/widget_calendar"> Calendar </a> <br>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import homeAssignmentsPage, AssignmentsDetailView, AssignmentsUpdateView, AssignmentsCreateView
urlpatterns = [
path('', index, name='index'),
path('', homeAssignmentsPage, name='homePage'),
path('add/', AssignmentsCreateView.as_view(), name='assignment_add'),
path('<int:pk>/details/', AssignmentsDetailView.as_view(), name='assignment_details'),
path('<int:pk>/edit/', AssignmentsUpdateView.as_view(), name='assignment_update'),
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render
from django.forms.models import BaseModelForm
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView
from django.urls import reverse, reverse_lazy
from .models import Assignment
def index(request):
def homeAssignmentsPage(request):
return render(request, 'templates/assignments.html', {"assignmentsList":Assignment.objects.all()}) #you can pass an entire list of model instances to the html
class AssignmentsDetailView(DetailView):
model = Assignment
template_name = "templates/assignment-details.html"
head = "<h1 style='border-bottom:4px solid lightgray;\
padding-bottom:30px;\
font-size:500%;'>\
Widget's assignment page\
</h1>\n"
class AssignmentsUpdateView(UpdateView):
model = Assignment
fields = ["assignment_name","description","course","perfect_score" ]
template_name = "templates/assignment-edit.html"
body = ""
success_url = "../details"
for subject in Assignment.objects.all():
body += "<p style='border: 2px solid gray;\
border-radius:5px;\
padding:20px 30px;'>\
<b> Assignment Name: "+subject.assignment_name+" </b> <br>\
Description: "+subject.description+" <br>\
Perfect Score: "+str(subject.perfect_score)+" <br>\
Passing Score: "+str(subject.passing_score)+" <br>\
Course/Section: "+str(subject.course)+" /"+str(subject.section)+" <br>\
</p>"
return_string = "<html>\
<body>\
{}{}\
</body></html>".format(head, body)
class AssignmentsCreateView(CreateView):
model = Assignment
fields = ["assignment_name","description","course","perfect_score" ]
template_name = "templates/assignment-add.html"
return HttpResponse(return_string)
def get_success_url(self):
return reverse('assignments:assignment_details', kwargs={ #appName:pathName
'pk': self.object.pk,
})
# Generated by Django 3.2 on 2023-04-29 07:07
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0006_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 4, 29, 15, 7, 16, 727183)),
),
]
# Generated by Django 3.2 on 2023-04-29 09:12
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0007_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 4, 29, 17, 12, 10, 865421)),
),
]
......@@ -62,7 +62,7 @@ ROOT_URLCONF = 'widget_vincentdjango.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......@@ -126,6 +126,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
......
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