Commit 340ca903 authored by Kyla Martin's avatar Kyla Martin

Merge branch 'master' into 'martin/announcements'

# Conflicts:
#   WidgetFEKK/WidgetFEKK/urls.py
parents d5f12d3e 5c3b03e1
No preview for this file type
body {
padding: 64px 160px;
}
#back {
margin: 0 0 32px;
display: flex;
align-items: center;
}
#back a {
color: black;
text-decoration: none;
margin-left: 8px;
}
#back a:hover {
text-decoration: underline;
}
#thumbnail {
width: 150px;
height: 150px;
object-fit: cover;
object-position: center;
margin: 0 0 16px;
}
#title {
margin: 0 0 16px;
}
#subtitle {
margin: 0 0 32px;
}
.body-text {
margin: 0 0 64px;
width: 80%;
}
.replies {
padding: 0;
}
.replies > li {
margin: 0 0 16px;
width: 60%;
}
\ No newline at end of file
body {
padding: 64px 160px;
}
#title {
margin: 0 0 64px;
}
#subtitle {
margin: 0 0 16px;
}
.posts {
padding: 0;
}
.posts > li {
margin: 0 0 16px;
width: 80%;
}
.posts > li a {
color: black;
text-decoration: none;
}
.posts > li a:hover {
text-decoration: underline;
}
\ No newline at end of file
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Montserrat:ital,wght@0,100;0,200;0,300;0,500;0,700;0,800;0,900;1,400;1,500&display=swap');
* {
font-family: 'Inter', sans-serif;
}
html,
body {
margin: 0;
}
h1 {
font-size: 61.04px;
}
h2 {
font-size: 48.83px;
}
h3 {
font-size: 39.06px;
}
h4 {
font-size: 31.25px;
}
h5 {
font-size: 25.00px;
}
h6 {
font-size: 16.00px;
}
:root {
font-size: 16.00px;
}
\ No newline at end of file
{% extends "base.html" %}
{% load static %}
{% block styles %}
<link rel="stylesheet" type="text/css" href="{% static 'Forum/styles.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'Forum/details.css' %}">
{% endblock %}
{% block title %}
{{ post.post_title }}
{% endblock %}
{% block content %}
<article>
<div id="back">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path
fill-rule="evenodd"
d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"
stroke="black"
/>
</svg>
<a href="/forum">Back to all posts</a>
</div>
<img id="thumbnail" src="{% static 'Forum/thumbnail.jpg' %}" alt="placeholder image" />
<h1 id="title">{{ post.post_title }}</h1>
<h4 id="subtitle">by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date|date:"d/m/Y" }}</h4>
<p class="body-text">{{ post.post_body }}</p>
<ul class="replies">
{% for reply in replies_sorted %}
<li><strong>{{ reply.author.first_name }} {{ reply.author.last_name }}, {{ reply.pub_date|date:"d/m/Y" }}:</strong> {{ reply.reply_body }}</li>
{% endfor %}
</ul>
</article>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% load static %}
{% block styles %}
<link rel="stylesheet" type="text/css" href="{% static 'Forum/styles.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'Forum/index.css' %}">
{% endblock %}
{% block title %}Widget's Forum{% endblock %}
{% block content %}
<main>
<h1 id="title">Welcome to Widget's Forum!</h1>
<h5 id="subtitle">Forum posts:</h5>
<ul class="posts">
{% for post in posts_sorted %}
<li><a href="/posts/{{ post.pk }}/details"><strong>{{ post.post_title }}</strong> by <strong>{{ post.author.first_name }} {{ post.author.last_name }}</strong> dated <strong>{{ post.pub_date|date:"d/m/Y" }}</strong></a></li>
{% endfor %}
</ul>
</main>
{% endblock %}
\ No newline at end of file
from django.http import HttpResponse from django.http import HttpResponse, Http404
from django.shortcuts import render
from .models import Post, Reply from .models import Post, Reply
def get_readable_time(timestamp): def get_readable_time(timestamp):
return timestamp.strftime("%m/%d/%Y") return timestamp.strftime("%m/%d/%Y")
def index(request): def index(request):
out = "FORUM POSTS: <br />" return render(request, 'Forum/index.html', {'posts_sorted': Post.objects.order_by('-pub_date')})
posts = Post.objects.all() def details(request, post_id):
try:
for post in posts: post = Post.objects.get(pk=post_id)
out += f'{post.post_title} by {post.author.first_name} {post.author.last_name} dated {get_readable_time(post.pub_date)}: <br />' except Post.DoesNotExist:
out += f'{post.post_body} <br />' raise Http404('Post does not exist')
return render(request, 'Forum/details.html', {'post': post, 'replies_sorted': post.reply_set.order_by('-pub_date')})
post_replies = post.reply_set.all() \ No newline at end of file
for reply in post_replies:
out += f'Reply by {reply.author.first_name} {reply.author.last_name} dated {get_readable_time(reply.pub_date)}: <br />'
out += f'{reply.reply_body} <br />'
out += '<br />'
return HttpResponse(out)
\ No newline at end of file
from django.db import models from django.db import models
from django.urls import reverse
""" """
A model for a school department in Widget. A model for a school department in Widget.
...@@ -29,4 +30,10 @@ class WidgetUser(models.Model): ...@@ -29,4 +30,10 @@ class WidgetUser(models.Model):
return f"""{self.last_name}, {self.first_name} {self.middle_name}: return f"""{self.last_name}, {self.first_name} {self.middle_name}:
{self.id_num}, {self.email}, {self.department}""" {self.id_num}, {self.email}, {self.department}"""
def get_absolute_url(self):
return f"users/{self.id_num}/details"
def get_name(self) -> str:
return f"{self.last_name}, {self.first_name} {self.middle_name}"
body {
font-family: Arial, Helvetica, sans-serif;
margin: 0 auto;
}
h1 {
color: white;
padding: 0.5em;
margin: auto;
text-align: center;
background-color: #365f90;
}
h2 {
margin: 0.25em;
}
.user-list {
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 0.25em;
margin: 1em;
}
.user-container {
background-color: #A7C7E7;
padding: 0.5em;
border-radius: 0.5em;
max-width: 50vw;
}
.user-container:not(:last-of-type) {
margin-bottom: 0.25em;
}
.user-container > h3 {
margin: 0;
margin-bottom: 0.125em;
}
.user-links {
display: flex;
justify-content: space-between;
}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget - Home {% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'Homepage/styles.css' %}">
{% endblock %}
{% block content %}
<h1> Welcome to Widget! </h1>
<h2> Users </h2>
<div class="user-list">
{% for user in users %}
{% include "user_details.html" with user=user counter=forloop.counter %}
{% empty %}
<h2> No Widget Users. </h2>
{% endfor %}
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget - Home {% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'Homepage/styles.css' %}">
<style>
.user-container a {
text-decoration: none;
}
.user-container a:hover {
text-decoration: underline;
transition: 0.1s;
}
</style>
{% endblock %}
{% block content %}
<div class="user-container">
<h3> {{ counter }}. {{ user.get_name }} </h3>
<div class="user-links">
<span> {{ user.id_num }} </span>
<a href="{{ user.get_absolute_url }}"> View Profile </a>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget - user.get_name {% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'Homepage/styles.css' %}">
<style>
h2 {
margin: 0;
}
img {
object-fit: cover;
border-radius: 0.5em;
}
.user-page-container {
display: flex;
gap: 0.5em;
justify-content: center;
margin: 1em;
}
.user-page-details {
display: flex;
flex-direction: column;
gap: 0.25em;
align-self: center;
}
</style>
{% endblock %}
{% block content %}
<h1> Widget User Profile </h1>
<div class="user-page-container">
<img src="{% static 'Homepage/3.JPG' %}" alt="Profile Image of {{ user.get_name }}" width="192" height="192">
<div class="user-page-details">
{{ user.id_num }}
<h2> {{ user.get_name }} </h2>
<a href="mailto:{{ user.email }}"> {{ user.email }}</a>
{{ user.department }}
</div>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import HomePageView, UserPageView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', HomePageView.as_view(), name='index'),
path('users/<int:user_id>/details', UserPageView.as_view(), name='user-details')
] ]
app_name = "Homepage" app_name = "Homepage"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.views import View
from .models import WidgetUser from .models import WidgetUser
def index(response): class HomePageView(View):
userString = "WIDGET USERS:<br>" def get(self, request):
users = WidgetUser.objects.all().order_by('last_name')
users = WidgetUser.objects.all() return render(request, 'index.html', {'users': users})
for user in users: class UserPageView(View):
userString += f"""{user}<br>""" def get(self, request, user_id):
user = WidgetUser.objects.get(id_num=user_id)
return HttpResponse( return render(request, 'user_page.html', {'user': user})
userString
)
...@@ -125,7 +125,7 @@ USE_TZ = True ...@@ -125,7 +125,7 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/ # https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = '/static/'
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
......
...@@ -16,10 +16,12 @@ Including another URLconf ...@@ -16,10 +16,12 @@ Including another URLconf
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
import Announcements.views as Announcements_views import Announcements.views as Announcements_views
import Forum.views as Forum_views
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('forum/', include('Forum.urls', namespace='Forum')), path('forum/', include('Forum.urls', namespace='Forum')),
path('posts/<int:post_id>/details/', Forum_views.details, name='post_details'),
path('homepage/', include('Homepage.urls', namespace="Homepage")), path('homepage/', include('Homepage.urls', namespace="Homepage")),
path('announcements/', include('Announcements.urls', namespace="Announcements")), path('announcements/', include('Announcements.urls', namespace="Announcements")),
path('announcements/<int:announcement_id>/details', Announcements_views.details, name='announcement_details'), path('announcements/<int:announcement_id>/details', Announcements_views.details, name='announcement_details'),
......
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