Commit 21fdc362 authored by Teo Quinto's avatar Teo Quinto

resolving merge conflict

parents fc46209f 1c40576b
from django.forms import ModelForm
from .models import Announcement
class AnnouncementForm(ModelForm):
class Meta:
model = Announcement
fields = ["announcement_title", "announcement_body", "author", "images"]
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-05-22 20:35
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0007_announcement_images'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_date',
field=models.DateField(default=datetime.datetime.now, verbose_name='Date Published'),
),
]
from datetime import datetime
from multiprocessing import allow_connection_pickling from multiprocessing import allow_connection_pickling
from django.db import models from django.db import models
from homepage.models import WidgetUser from homepage.models import WidgetUser
...@@ -8,10 +9,10 @@ class Announcement(models.Model): ...@@ -8,10 +9,10 @@ class Announcement(models.Model):
announcement_body = models.CharField(max_length=500) announcement_body = models.CharField(max_length=500)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE,default = 1) author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE,default = 1)
images = models.ImageField (upload_to="announcement", default = "default.jpg") images = models.ImageField (upload_to="announcement", default = "default.jpg")
pub_date = models.DateField("Date Published") pub_date = models.DateField("Date Published", default=datetime.now)
def __str__(self): def __str__(self):
return f"{self.announcement_title} {self.announcement_body} {self.pub_date}" return f"{self.announcement_title} {self.pub_date}"
class Reaction(models.Model): class Reaction(models.Model):
reaction_name = models.CharField(max_length=10) reaction_name = models.CharField(max_length=10)
...@@ -19,4 +20,4 @@ class Reaction(models.Model): ...@@ -19,4 +20,4 @@ class Reaction(models.Model):
announcement = models.ForeignKey(Announcement,on_delete=models.CASCADE, default = 1) announcement = models.ForeignKey(Announcement,on_delete=models.CASCADE, default = 1)
def __str__(self): def __str__(self):
return f"{self.reaction_name} {self.tally}" return f"{self.reaction_name}"
\ No newline at end of file \ No newline at end of file
{% extends "announcements/base.html" %}
{% block title %}New Announcement{% endblock %}
{% block content %}
<h1>New Announcement</h1>
<form method="POST" action="{% url 'announcement:add' %}"
enctype="multipart/form-data">
{% csrf_token %}
{{ announcementForm.as_p }}
<button class="button" type="submit">Save Announcement</button>
<button onclick="window.location.href='../';">Back to Announcement Board</button>
</form>
{% endblock %}
\ No newline at end of file
...@@ -12,4 +12,5 @@ ...@@ -12,4 +12,5 @@
<li>{{ reaction.reaction_name }}: {{reaction.tally}}</li> <li>{{ reaction.reaction_name }}: {{reaction.tally}}</li>
{% endfor %} {% endfor %}
</ul></p> </ul></p>
<button onclick="window.location.href='../../';">Back to Announcement Board</button>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}
<p>No users are available</p> <p>No announcements are available</p>
{% endif %} {% endif %}
<button onclick="window.location.href='add/';">New Announcement</button>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -3,9 +3,11 @@ from django.urls import path ...@@ -3,9 +3,11 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='announcementboardIndex'), path('', views.index, name="index"),
# announcement/1/details # announcement/1/details
path("<int:announcement_id>/details/", views.details, name="details") path("<int:announcement_id>/details/", views.details, name="details"),
# announcement/add/
path("add/", views.add, name="add")
] ]
app_name = "announcement" app_name = "announcement"
\ 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 .forms import AnnouncementForm
from .models import Announcement, Reaction from .models import Announcement, Reaction
announcementList = Announcement.objects.order_by("pub_date")
reactionList = Reaction.objects.all()
# Create your views here. # Create your views here.
def index(request): def index(request):
announcementList = Announcement.objects.order_by("pub_date")
reactionList = Reaction.objects.all()
context = { context = {
"announcementList": announcementList, "announcementList": announcementList,
} }
...@@ -14,6 +16,9 @@ def index(request): ...@@ -14,6 +16,9 @@ def index(request):
def details(request, announcement_id): def details(request, announcement_id):
announcementList = Announcement.objects.order_by("pub_date")
reactionList = Reaction.objects.all()
try: try:
announcement = Announcement.objects.get(pk=announcement_id) announcement = Announcement.objects.get(pk=announcement_id)
except Announcement.DoesNotExist: except Announcement.DoesNotExist:
...@@ -26,4 +31,15 @@ def details(request, announcement_id): ...@@ -26,4 +31,15 @@ def details(request, announcement_id):
"announcement": announcement, "announcement": announcement,
"reactionList": reactionList, "reactionList": reactionList,
} }
return render(request, "announcements/details.html", context) return render(request, "announcements/details.html", context)
\ No newline at end of file
def add(request):
if request.method == "POST":
announcementForm = AnnouncementForm(request.POST)
if announcementForm.is_valid():
new_announcement = announcementForm.save()
return redirect("announcement:index")
else:
announcementForm = AnnouncementForm()
return render(request, "announcements/add.html",
{"announcementForm":AnnouncementForm})
\ No newline at end of file
from django.forms import ModelForm
from .models import Assignment
class AssignmentForm(ModelForm):
class Meta:
model = Assignment
fields = ["name", "description", "max_points", "course", "hwPicture"]
\ No newline at end of file
h1 { h1 {
text-align: center; text-align: center;
color:rgb(3, 4, 94); color:rgb(240, 108, 196);
text-shadow:2px 2px 5px rgb(101, 15, 158); text-shadow:2px 2px 5px rgb(101, 15, 158);
font-family: "Brush Script MT", "Brush Script Std", cursive; font-family: "Brush Script MT", "Brush Script Std", cursive;
font-size: 50px; font-size: 50px;
...@@ -11,10 +11,10 @@ h2 { ...@@ -11,10 +11,10 @@ h2 {
font-family: "Arial Narrow", sans-serif; font-family: "Arial Narrow", sans-serif;
} }
body { body {
background-color: rgb(202, 240, 248); background-color: rgb(248, 234, 202);
} }
p { p {
color:rgb(0, 180, 216); color:rgb(250, 155, 12);
font-size: 25px; font-size: 25px;
font-family: "New Century Schoolbook", "TeX Gyre Schola", serif; font-family: "New Century Schoolbook", "TeX Gyre Schola", serif;
} }
......
{% extends 'assignments/base.html' %}
{% block title %}New Assignment{% endblock %}
{% block content %}
<h1>New Assignment</h1>
<form method="POST" action="{% url 'assignments:newAssignment' %}"
enctype="multipart/form-data">
{% csrf_token %}
{{ assignmentForm.as_p }}
<button class="button" type="submit">Save Assignment</button>
<button onclick="window.location.href='../';">Back to assignment page</button>
</form>
{% endblock %}
\ No newline at end of file
...@@ -13,4 +13,5 @@ ...@@ -13,4 +13,5 @@
{% load static %} {% load static %}
<br /><br /><br /><img src="{{ taskWork.hwPicture.url }}" alt="{{taskWork.name}}" style="width:50%"> <br /><br /><br /><img src="{{ taskWork.hwPicture.url }}" alt="{{taskWork.name}}" style="width:50%">
</p> </p>
<button onclick="window.location.href='../..';">Back to assignment page</button>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -7,14 +7,19 @@ ...@@ -7,14 +7,19 @@
<p>List of Courses:</p> <p>List of Courses:</p>
{% if assignmentList %} {% if assignmentList %}
<ul> <ul>
{% for taskWork in assignmentList %} {% for course in courseList %}
<li>{{ taskWork.course.course_code }}, {{ taskWork.course.course_title }}, - Section: {{ taskWork.course.section }}</li> <li>{{ course.course_code }}, {{ course.course_title }}, - Section: {{ course.section }}</li>
<ul> <ul>
<li><a href="{{ taskWork.id }}/details/">{{ taskWork.name }}</a></li> {% for taskWork in assignmentList %}
{% if taskWork.course == course %}
<li><a href="{{ taskWork.id }}/details/">{{ taskWork.name }}</a></li>
{% endif %}
{% endfor %}
</ul> </ul>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}
<p>No users are available</p> <p>No assignments are available</p>
{% endif %} {% endif %}
<button onclick="window.location.href='add/';">New Assignment</button>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -5,5 +5,9 @@ from . import views ...@@ -5,5 +5,9 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='announcementIndex'), path('', views.index, name='announcementIndex'),
# assignments/1/details # assignments/1/details
path("<int:assignment_id>/details/", views.details, name="details") path("<int:assignment_id>/details/", views.details, name="details"),
] # assignments/add
\ No newline at end of file path("add/", views.newAssignment, name="newAssignment" ),
]
app_name = "assignments"
\ 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 .models import Course, Assignment from .models import Course, Assignment
from .forms import AssignmentForm
assignmentList = Assignment.objects.order_by("course") assignmentList = Assignment.objects.order_by("course")
courseList = Course.objects.order_by("course_code")
# Create your views here. # Create your views here.
def index(request): def index(request):
#return HttpResponse(displayText) #return HttpResponse(displayText)
assignmentList = Assignment.objects.order_by("course")
courseList = Course.objects.order_by("course_code")
context = { context = {
"assignmentList": assignmentList, "assignmentList": assignmentList,
"courseList": courseList,
} }
return render(request, "assignments/index.html", context) return render(request, "assignments/index.html", context)
def details(request, assignment_id): def details(request, assignment_id):
#return HttpResponse("This is assignment # %s." % assignment_id) #return HttpResponse("This is assignment # %s." % assignment_id)
assignmentList = Assignment.objects.order_by("course")
try: try:
taskWork = Assignment.objects.get(pk=assignment_id) taskWork = Assignment.objects.get(pk=assignment_id)
except Assignment.DoesNotExist: except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!") raise Http404("Assignment does not exist!")
for assignmentWork in assignmentList: for assignmentWork in assignmentList:
if assignmentWork.id == assignment_id: if assignmentWork.id == assignment_id:
taskWork = assignmentWork taskWork = assignmentWork
break break
context = { context = {
"taskWork": taskWork, "taskWork": taskWork,
"assignment_id": assignment_id "assignment_id": assignment_id
} }
return render(request, "assignments/details.html", context) return render(request, "assignments/details.html", context)
\ No newline at end of file
def newAssignment(request):
if request.method == "POST":
assignmentForm = AssignmentForm(request.POST, request.FILES)
if assignmentForm.is_valid():
new_assignment = assignmentForm.save()
return redirect("assignments:newAssignment")
else:
assignmentForm = AssignmentForm()
return render(request, "assignments/add.html", {"assignmentForm": assignmentForm})
\ No newline at end of file
from django.forms import ModelForm
from .models import Post
class PostForm(ModelForm):
class Meta:
model = Post
fields = ["post_title", "post_body", "author", "images"]
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-05-22 20:14
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0006_remove_reply_images_post_images'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateTimeField(default=datetime.datetime.now, verbose_name='date published'),
),
migrations.AlterField(
model_name='reply',
name='pub_date',
field=models.DateTimeField(default=datetime.datetime.now, verbose_name='date published'),
),
]
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