Commit 80831ae4 authored by Bianca Aguilar's avatar Bianca Aguilar

Fixing merge conflicts

parent 3d214b09
......@@ -7,6 +7,9 @@
+ Forum View (Midterm)
+ Announcements Models (Midterm)
+ Announcements View (Midterm)
+ Forum HTML (Lab 3)
+ Forum CSS (Lab 3)
**Alissandra Tanaliga:**
+ Announcements (Lab 1)
......@@ -17,10 +20,16 @@
+ Assignments View (Midterm)
+ Homepage Models (Midterm)
+ Homepage View (Midterm)
+ Assignments HTML (Lab 3)
+ Assignments CSS (Lab 3)
**Nicolas Reichert:**
+ Announcements Models (Lab 2)
+ Announcements HTML (Lab 3)
+ Announcements CSS (Lab 3)
**Video Links:**
+ Lab 1: https://youtu.be/2P8rq0mgeQU
+ Lab 2: https://youtu.be/jam_e42FojI
+ Lab 3: https://youtu.be/Nlmw_ZFxhl8
\ No newline at end of file
# Generated by Django 3.2.12 on 2022-05-23 07:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0004_alter_reaction_announcement'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='image',
field=models.ImageField(default=1, upload_to='announcements/'),
preserve_default=False,
),
]
......@@ -11,6 +11,7 @@ class Announcement(models.Model):
on_delete=models.CASCADE
)
image = models.ImageField(upload_to='announcements/')
def __str__(self):
return '{}'.format(self.announcement_title)
......@@ -44,7 +45,7 @@ class Reaction(models.Model):
@property
def reaction_detail(self):
reaction = '<br>{}: {}'.format(self.reaction_name, self.tally)
reaction = '{}: {}'.format(self.reaction_name, self.tally)
return reaction
......
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/announcements_stylesheet.css' %}">
{% endblock %}
{% block app_header %}Announcement Board{% endblock %}
{% block content %}
<p class="head">Important announcements:</p>
<ul class="announcements">
{% for a in announcement_list %}
<li>
<a href="{% url 'announcements:announcement-detail' pk=a.pk %}">
<p><span class="title">{{ a.announcement_title }}</span> <br/> by <span class="author">{{ a.author.first_name }} {{ a.author.last_name }}</span> dated {{ a.pub_date|date:"d/m/Y" }}</p>
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/announcements_stylesheet.css' %}">
{% endblock %}
{% block content %}
<h3>{{ object.announcement_title }}</h3>
<h2 class="subtitle">by {{ object.author.first_name }} {{ object.author.last_name }}, {{ object.pub_date|date:"d/m/Y" }}</h2>
<p>{{ object.announcement_body }}</p>
<div class="reactions">
{% for r in object.reacts.all %}
<p class="reaction">{{ r.reaction_detail }} </p>
{% endfor %}
</div>
<img src= "{{ object.image.url }}">
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import AnnouncementPageView, AnnouncementDetailView
urlpatterns = [
path('', index, name="index"),
path('', AnnouncementPageView.as_view(), name='index'),
path('announcement/<int:pk>/details', AnnouncementDetailView.as_view(), name='announcement-detail'),
]
app_name = "announcements"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views import View
from django.views.generic.detail import DetailView
from .models import Announcement, Reaction
# Create your views here.
def index(request):
def announcement_list():
final_list = ''
for p in range(len(Announcement.objects.all())):
final_list += '{}'.format(Announcement.objects.get(pk=p+1).announcement_detail)
reaction_list = list(Reaction.objects.filter(announcement=Announcement.objects.get(pk=p+1)))
lk_tally = 0
lv_tally = 0
ag_tally = 0
for r in range(len(reaction_list)):
if str(reaction_list[r]) == 'LK':
lk_tally += reaction_list[r].reaction_tally
elif str(reaction_list[r]) == 'LV':
lv_tally += reaction_list[r].reaction_tally
elif str(reaction_list[r]) == 'AG':
ag_tally += reaction_list[r].reaction_tally
final_list += f'<br>Like: {lk_tally}'
final_list += f'<br>Love: {lv_tally}'
final_list += f'<br>Angry: {ag_tally}<br>'
class AnnouncementPageView(View):
def get(self, request):
return render(request, 'announcements/announcement.html', {
'announcement_list': Announcement.objects.all().order_by('-id'),
'reaction_list': Reaction.objects.all().order_by('-id')
})
return final_list
html = f'''
<html>
<body>
<h1>ANNOUNCEMENTS:</h1>
<main>
<p>{announcement_list()}</p>
</main>
</body>
</html>
'''
return HttpResponse(html)
\ No newline at end of file
class AnnouncementDetailView(DetailView):
model = Announcement
......@@ -8,9 +8,9 @@
{% block app_header %}Assignments Per Course{% endblock %}
{% block content %}
<ul>
{% for c in course_list|dictsort:"course_code" %}
<li><p class="course_section">{{ c.course_code }} {{ c.course_title }} {{ c.section }}</p>
{% for c in course_list|dictsort:"course_code" %}
<div class="course_block">
<p class="course_section">{{ c.course_code }} {{ c.course_title }} {{ c.section }}</p>
<ul class="course_assignments">
{% for a in assignment_list %}
{% if a.course.course_code == c.course_code %}
......@@ -20,7 +20,6 @@
{% endif %}
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
......@@ -5,13 +5,19 @@
<link rel="stylesheet" href="{% static 'css/assignments_stylesheet.css' %}">
{% endblock %}
{% block app_header %}
{{ object.name }}
{% endblock %}
{% block content %}
<div class="assignment_page">
<p class="course">{{ object.course.course_code }} {{ object.course.course_title }} {{ object.course.section }}</p>
<p class="title">{{ object.name }}</p>
<img src= "{{ object.image.url }}">
<img class="assign_img" src= "{{ object.image.url }}">
<div class="assign_details">
<p class="desc">{{ object.description }}</p>
<p class="instructions">Instructions:</p>
<p>{{ object.description }}</p>
<p class="score">Perfect Score: {{ object.max_points }}</p>
<p class="score">Passing Score: {{ object.passing_score }}</p>
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -4,6 +4,8 @@ from django.views.generic.detail import DetailView
from .models import Assignment, Course
from .models import Assignment
# Create your views here.
class AssignmentsPageView(View):
def get(self, request):
......
body {
background-color: #f8e2e2;
color: #222;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
}
header {
font-size: 32px;
font-weight: bold;
margin: 32px 0px 32px 0px;
text-align: center;
}
img {
height: 50%;
width: 50%;
}
h3 {
font-size: 36px;
}
.head {
font-size: 24px;
margin: 32px 0px 32px 0px;
text-align: center;
}
.author {
font-weight: bold;
}
.announcement {
background-color: #FFF;
border-radius: 8px;
padding: 32px;
}
.announcements {
margin: 0 auto;
padding-left: 0px;
width: 80%;
}
.announcements li {
list-style: none;
margin-bottom: 24px;
}
.announcements li a {
color: #222;
line-height: 175%;
text-decoration:none;
}
.announcements li a:hover {
color: cornflowerblue !important;
}
.announcements li a p {
background-color: #FFF;
border-radius: 8px;
padding: 32px 24px 32px 24px;
}
.title {
font-size: 20px;
font-weight: bold;
}
\ No newline at end of file
body {
font-family: Tahoma, sans-serif;
background-color: darkgray;
}
header {
font-size: 25px;
font-size: 50px;
font-weight: bold;
padding: 1vh 2vw;
text-align: center;
}
.course_block {
border: 1px solid black;
background-color: aliceblue;
padding: 1vh 2vw;
margin: 2vh 2vw;
}
.course_section {
font-weight: bold;
}
.course, .title {
.assignment_page {
border: 1px solid black;
background-color: aliceblue;
padding: 1vh 2vw;
margin: 2vh 2vw;
display: grid;
}
.course {
grid-column: 1 / 3;
grid-row: 1;
text-align: center;
font-weight: bold;
}
.assign_img {
grid-column: 1;
grid-row: 2;
padding: 1vh 1vw;
margin: 1vh 1vw;
width: 40vw;
}
.assign_details {
grid-column: 2;
grid-row: 2;
}
.instructions {
font-weight: bold;
}
.score {
font-weight: bold;
}
\ No newline at end of file
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