Commit c6a2efb8 authored by Alec Dayupay's avatar Alec Dayupay

Preparing to pull

parents c553ad9c d08eeb42
# Generated by Django 3.2 on 2023-03-03 15:39
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('dashboard', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Announcement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50)),
('body', models.TextField()),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], default='Like', max_length=50)),
('tally', models.IntegerField(default=0)),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
# Generated by Django 4.2.1 on 2023-05-04 04:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_datetime',
field=models.DateTimeField(auto_now_add=True),
),
]
from django.forms import ModelForm
from .models import Assignment
class AssignmentForm(ModelForm):
class Meta:
model = Assignment
fields = '__all__'
\ No newline at end of file
# Generated by Django 3.2 on 2023-03-03 15:39
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=50)),
('section', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('description', models.TextField()),
('perfect_score', models.IntegerField(default=0)),
('passing_score', models.IntegerField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
from django.db import models from django.db import models
from django.urls import reverse
class Course(models.Model): class Course(models.Model):
code = models.CharField(max_length = 10) code = models.CharField(max_length = 10)
...@@ -21,3 +22,6 @@ class Assignment(models.Model): ...@@ -21,3 +22,6 @@ class Assignment(models.Model):
def __str__(self): def __str__(self):
return self.name return self.name
def get_absolute_url(self):
return reverse("assignment-details", kwargs={'pk': self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Assignment:{% endblock %}
{% block content %}
<p>Add a new assignment:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Save New Assignment">
</form>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.name }}{% endblock %}
{% block heading %}{{ object.name }}{% endblock %}
{% block content %}
<p>{{ object.course.code }} {{ object.course.title }} - {{ object.course.section }}</p>
<p>Description: {{ object.description }}</p>
<p>Perfect Score: {{ object.perfect_score }}</p>
<p>Passing Score: {{ object.passing_score }}</p>
<input type="button" value="Edit Assignment" onclick="location.href='{% url 'assignment-edit' object.pk %}'"/>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Assignment{% endblock %}
{% block content %}
<p>Edit Assignment:</p>
<form method ="POST">
{% csrf_token %}
{{ form.as_p }}
<input type ="Submit" value="Save Changes to Assignment">
</form>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Assignments{% endblock %}
{% block heading %}Welcome to Widget's Assignments!{% endblock %}
{% block content %}
<p>Assignments posts:</p>
{% for assignment in assignments%}
<p><a href="{{assignment.get_absolute_url}}">{{ assignment.name }}</a></p>
{% endfor %}
<input type="button" value="New Assignment" onclick="location.href='{% url 'assignment-add' %}'"/>
{% endblock %}
{% block links %}
<p><a href="http://localhost:8000/dashboard/">Dashboard</a></p>
<p><a href="http://localhost:8000/announcements/">Announcement</a></p>
<p><a href="http://localhost:8000/forum/">Forum</a></p>
<p><a href="http://localhost:8000/calendar/">Calendar</a></p>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .import views
from .views import index from .views import (AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView)
urlpatterns = [ urlpatterns = [
path('', index, name = 'index'), path('', views.assignments, name="assignments"),
path('assignments/<int:pk>/details/', AssignmentDetailView.as_view(), name="assignment-details"),
path('assignment/add/', AssignmentCreateView.as_view(), name="assignment-add"),
path('assignments/<int:pk>/edit/', AssignmentUpdateView.as_view(), name="assignment-edit"),
] ]
\ No newline at end of file
app_name = "assignments"
\ No newline at end of file
from django.http import HttpResponse from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment from .models import Assignment
def index(request): def assignments(request):
assignments = Assignment.objects.all() return render(request, 'assignments/assignments.html', {'assignments': Assignment.objects.all()})
response = "Widget's Assignment Page<br><br>" class AssignmentDetailView(DetailView):
for assignment in assignments: model = Assignment
response += "Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {}<br><br>".format( template_name = 'assignments/assignment-details.html'
assignment.name,
assignment.description,
assignment.perfect_score,
assignment.passing_score,
assignment.course
)
return HttpResponse(response) class AssignmentCreateView(CreateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-add.html'
class AssignmentUpdateView(UpdateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-edit.html'
\ No newline at end of file
# Generated by Django 3.2 on 2023-03-03 15:39
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('modes', models.CharField(choices=[('Onsite', 'Onsite'), ('Online', 'Online'), ('Hybrid', 'Hybrid')], default='Onsite', max_length=50)),
('venue', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField()),
('activity', models.CharField(max_length=50)),
('estimated_hours', models.FloatField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
('locations', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='calendars.location')),
],
),
]
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