Commit c7a6ef05 authored by Joshua Son's avatar Joshua Son

Update: Forum merge

parents 0c035904 cfaf9aba
# widget_django unchained
## master branch/main branch
## AUTHORS
1. John Raymon Yu - Assignments
......
# Generated by Django 3.2.12 on 2022-05-20 11:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0016_alter_announcement_author'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='announce_image',
field=models.ImageField(blank=True, default='faceless_9ltCukV.png', null=True, upload_to=''),
),
]
......@@ -8,7 +8,7 @@ class Announcement(models.Model):
announcement_body = models.CharField(max_length=500)
pub_date = models.DateTimeField("date published")
reaction_list = models.ForeignKey('Reaction', on_delete=models.CASCADE, related_name='+', default=1)
announce_image = models.ImageField(default="faceless_9ltCukV.png", null=True, blank=True)
def __str__(self):
return self.announcement_title
......
h1 {
color: purple;
font-weight:bold;
font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
p {
color: orange;
font-weight:bold;
font-family:'Courier New', Courier, monospace;
}
body {
background-color: beige;
font-family:'Courier New', Courier, monospace;
}
a {
color: orangered;
}
{% extends "announcement/base.html" %}
{% block content %}
<img src="{{announce.announce_image.url}}">
<h1> {{ announce.announcement_title }} </h1>
<p> <em> by {{ announce.author.first_name}} {{announce.author.last_name}}, {{announce.pub_date|date:"d/m/Y h:i:s A"}} </em> </p>
<p> {{announce.announcement_body}}</p>
<ul>
{% for react in reacts %}
<li> {{react.reaction_name}}:{{react.tally}} </li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends "announcement/base.html" %}
{% block content %}
<h1> Important Announcements </h1>
{% if announce_list %}
<ul>
{% for announce in announce_list %}
<li> <a href = "{% url 'detail' announce.id %}">{{ announce.announcement_title }} by {{announce.author.first_name}} {{announce.author.last_name}} dated {{announce.pub_date|date:"d/m/Y h:i:s A"}} </a></li>
{% endfor %}
</ul>
{% else %}
<p> No announcements here! </p>
{% endif %}
{% endblock %}
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{% static 'announcement/style.css' %}">
<title>Announcements</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
<p>
<h2>ANNOUNCEMENTS: </h2>
{% for announcement in announcements%}
<p><b>{{announcement.announcement_title}}</b> by {{announcement.author.first_name}} {{announcement.author.last_name}} dated {{announcement.pub_date}}</p>
<p>{{announcement.announcement_body}}</p>
<p>{% include "reactions_list.html" with reactions=announcement.reaction_list %}</p>
{{ value|linebreaks }}
{% endfor %}
</p>
\ No newline at end of file
<p>
<p>{{ reactions.reaction_name }} : {{reactions.tally}}</p>
{% if reactions.reaction_self != NULL %}
<p>{% include "reactions_list.html" with reactions=reactions.reaction_self %}</p>
{% endif %}
</p>
\ No newline at end of file
......@@ -3,5 +3,6 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.show_announcements, name='show_announcements')
path('', views.index, name='index'),
path("<int:announcement_id>", views.detail, name="detail"),
]
\ No newline at end of file
from django.http import HttpResponse
from django.http import Http404
from django.shortcuts import render
from .models import Announcement, Reaction
# Create your views here.
def show_announcements(request):
announcement = Announcement.objects.all()
return render(request, 'announcement_board.html', {'announcements': announcement})
\ No newline at end of file
#def show_announcements(request):
#announcement = Announcement.objects.all()
#return render(request, 'announcement/announcement_board.html', {'announcements': announcement})
def index(request):
announce_list = Announcement.objects.order_by("pub_date")
context = {
"announce_list": announce_list,
}
return render(request, "announcement/announcement_page.html", context)
def detail(request, announcement_id):
try:
announce = Announcement.objects.get(pk=announcement_id)
except Announcement.DoesNotExist:
raise Http404("Announcement does not exist!")
reacts = Reaction.objects.filter(announcement_id=announce).order_by("reaction_name")
return render(request, "announcement/announcement_board.html", {"announce": announce, "reacts": reacts})
\ No newline at end of file
from django import forms
from assignments.models import Course
class IndexCardForm(forms.Form):
name = forms.CharField(label='Full Name', max_length=100)
section = forms.CharField(label='CSCI40 Section', max_length=5)
age = forms.IntegerField(label='Current Age')
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-05-18 13:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0009_alter_assignment_assignment_passing_score'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='assignment_id',
field=models.IntegerField(default=0),
),
]
# Generated by Django 4.0.3 on 2022-05-19 05:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0010_assignment_assignment_id'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='assignment_image',
field=models.ImageField(blank=True, default='imgNotFound.png', null=True, upload_to=''),
),
]
# Generated by Django 4.0.3 on 2022-05-19 06:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0011_assignment_assignment_image'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_image',
field=models.ImageField(blank=True, default='assignments\\imgNotFound.png', null=True, upload_to=''),
),
]
# Generated by Django 4.0.3 on 2022-05-19 06:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0012_alter_assignment_assignment_image'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_image',
field=models.ImageField(blank=True, default='imgNotFound.png', null=True, upload_to=''),
),
]
......@@ -6,11 +6,13 @@ class Assignment(models.Model):
original_max_points = 0
assignment_id = models.IntegerField(default=0)
assignment_name = models.CharField(max_length=100)
assignment_description = models.CharField(max_length=1000)
assignment_max_points = models.IntegerField(default=0)
assignment_passing_score = models.IntegerField(editable=True)
assignment_course = models.ForeignKey('Course', on_delete=models.CASCADE, blank=True, null= True)
assignment_image = models.ImageField(default="imgNotFound.png", null=True, blank=True)
def __str__(self):
return self.assignment_name
......@@ -25,5 +27,6 @@ class Course(models.Model):
course_title = models.CharField(max_length=100)
course_section = models.CharField(max_length=3)
def __str__(self):
return self.course_code
{% load static %}
<p>
<h2>{{assignments.assignment_course.course_code}} {{assignments.assignment_course.course_title}} {{assignments.assignment_course.course_section}}</h2>
<p>Name: {{ assignments.assignment_name }} </p>
<p>Description: {{ assignments.assignment_description }}</p>
<p>Perfect Score: {{ assignments.assignment_max_points }}</p>
<p>Passing Score: {{ assignments.assignment_passing_score }}</p>
</p>
<br>
<img src="{{ assignments.assignment_image.url }}" width="20%">
<p>
{% if assignments %}
<ul>
{% for assignment in assignments %}
{% if assignment.assignment_course == course %}
<li>
<a href="{% url 'assignment:ShowAssignmentDetails' assignment.assignment_id %}">
○ {{assignment.assignment_name}}
</a>
</li>
{% else %}
{% endif %}
{% endfor %}
</ul>
{% else %}
<p>○ No Assignments registered</p>
{% endif %}
</p>
\ No newline at end of file
<p>
<h2>ASSIGNMENTS: </h2>
<h2>Assignments Per Course: </h2>
{% for course in course %}
<p>{{course_code}} {{course_title}} {{course_section}}</p>
{% include "assignment_Assignment.html" with courseVariable=course %}
{% for assignment in assignments %}
<p><b>Assignment Name: {{assignment.assignment_name}}</b></p>
<p>Description: {{assignment.assignment_description}}</p>
......
{% load static %}
<p>
<h2>Assignments Per Course: </h2>
{% if course %}
<ol>
{% for course in course %}
<li>
<p>{{course.course_code}} {{course.course_title}} {{course.course_section}}</p>
{% include "assignment_Assignment_Link.html" with course=course %}
</li>
{% endfor %}
</ol>
{% else %}
<p>No courses registered.</p>
{% endif %}
</p>
\ No newline at end of file
from django.urls import path
from . import views
from django.conf import settings
from django.conf.urls.static import static
app_name = "assignment"
urlpatterns = [
path('', views.show_assignments_page, name='Show Assignment Page')
path('', views.show_courses_page, name='ShowCoursesPage'),
path("assignment/<int:assignment_id>/details/", views.show_assignment_details, name='ShowAssignmentDetails')
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course
from django.shortcuts import render
from django.http import Http404
# Create your views here.
def show_assignments_page(request):
assignments = Assignment.objects.all()
return render(request, 'assignment_listing.html', {'assignments': assignments})
course = Course.objects.order_by("course_code")
def show_courses_page(request):
context = {
"course": course,
"assignments": Assignment.objects.all()
}
return render(request, 'assignment_Courses_Ordered.html', context)
def show_assignment_details(request, assignment_id):
try:
assignment = Assignment.objects.get(pk=assignment_id)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
context = {
"assignments": assignment
}
return render(request, "assignment_Assignment_Details.html", context)
<p>
<i> Reply by {{post.author.first_name}} {{post.author.last_name}} dated {{reply.pub_date|date:"d/m/Y h:i:s A"}}: </i>
</p>
<p>{{reply.reply_body}}</p>
{% if reply.reply_chain != NULL %}
<p>{% include "replychain_listing.html" with reply=reply.reply_chain %}</p>
{% endif %}
\ No newline at end of file
# Generated by Django 3.2.12 on 2022-05-17 16:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0023_remove_widgetuser_user_face'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='profile_pic',
field=models.ImageField(blank=True, null=True, upload_to=''),
),
]
# Generated by Django 3.2.12 on 2022-05-17 16:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0024_widgetuser_profile_pic'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_pic',
field=models.ImageField(blank=True, default='faceless.png', null=True, upload_to=''),
),
]
# Generated by Django 3.2.12 on 2022-05-17 17:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0025_alter_widgetuser_profile_pic'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_pic',
field=models.ImageField(blank=True, default='static/homepage/images/faceless.png', null=True, upload_to=''),
),
]
# Generated by Django 3.2.12 on 2022-05-17 18:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0026_alter_widgetuser_profile_pic'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_pic',
field=models.ImageField(blank=True, default='faceless_9ltCukV.png', null=True, upload_to=''),
),
]
......@@ -8,6 +8,7 @@ class WidgetUser(models.Model):
last_name = models.CharField(max_length=50, default='last_name')
id_num = models.CharField(max_length=7, default='1234567')
email = models.CharField(max_length=50, default='someemail@gmail.com')
profile_pic = models.ImageField(default="faceless_9ltCukV.png", null=True, blank=True)
def __str__(self):
return self.last_name
......
......@@ -12,4 +12,9 @@
<li>{{ Department.dept_name }}</li>
<li>{{ Department.home_unit }}</li>
</ul>
<br>
<img src="{{ Department.widgetuser.profile_pic.url }}" width="20%">
{% endblock %}
\ No newline at end of file
......@@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
from pathlib import Path
import environ
import os
......@@ -126,12 +126,22 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
<<<<<<< HEAD
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATICFILES_DIR = (
os.path.join(BASE_DIR, 'statics')
)
=======
MEDIA_URL = '/images/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')
>>>>>>> cfaf9ababe2607db22a5f225df2d8f007ea1dc50
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
......
......@@ -17,7 +17,10 @@ from django.contrib import admin
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static
<<<<<<< HEAD
=======
>>>>>>> cfaf9ababe2607db22a5f225df2d8f007ea1dc50
urlpatterns = [
path('announcements/', include('announcements.urls')),
......@@ -25,4 +28,8 @@ urlpatterns = [
path('forum/', include('forum.urls')),
path('assignments/', include('assignments.urls')),
path('admin/', admin.site.urls),
<<<<<<< HEAD
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
=======
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>>>>>>> cfaf9ababe2607db22a5f225df2d8f007ea1dc50
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