Verified Commit 747e094a authored by Angelo Esteban's avatar Angelo Esteban

Merge branch 'master' into esteban/assignments

parents f5ef7048 01b3b775
...@@ -11,6 +11,7 @@ media ...@@ -11,6 +11,7 @@ media
# Environments # Environments
.env .env
/widgetenv
# .vscode # .vscode
.vscode .vscode
......
# Generated by Django 4.0.4 on 2022-05-14 12:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0003_alter_widgetuser_email_alter_widgetuser_id_num'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='profile_pic',
field=models.FileField(blank=True, null=True, upload_to='static'),
),
]
# Generated by Django 4.0.4 on 2022-05-14 12:48
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0004_widgetuser_profile_pic'),
]
operations = [
migrations.RemoveField(
model_name='widgetuser',
name='profile_pic',
),
]
# Generated by Django 4.0.4 on 2022-05-14 12:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0005_remove_widgetuser_profile_pic'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='profile_pic',
field=models.FileField(blank=True, null=True, upload_to='uploads'),
),
]
from django.db import models from django.db import models
# Model for Department # Model for Department
class Department(models.Model): class Department(models.Model):
dept_name = models.CharField(max_length=100) dept_name = models.CharField(max_length=100)
home_unit = models.CharField(max_length=100) home_unit = models.CharField(max_length=100)
# Model for Widget User # Model for Widget User
class WidgetUser(models.Model): class WidgetUser(models.Model):
first_name = models.CharField(max_length=100) first_name = models.CharField(max_length=100)
middle_name = models.CharField(max_length=100) middle_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100)
id_num = models.CharField(max_length=7, default="123456") id_num = models.CharField(max_length=7, default="123456")
email = models.EmailField(max_length=256, default="john.appleseed@gmail.com") email = models.EmailField(
max_length=256, default="john.appleseed@gmail.com")
profile_pic = models.FileField(
upload_to="uploads", null=True, blank=True)
department = models.ForeignKey( department = models.ForeignKey(
Department, Department,
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
......
<!-- homepage/widgetuser_detail.html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Homepage{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static '/widgetuser_details.css' %}">
{% endblock %}
{% block header %}
<img width=60 height=60 src="{% static '/default_profilepic.png' %}"/>
{{object.last_name}}, {{object.first_name}} {{object.middle_name}}
{% endblock %}
{% block content %}
<p> Student ID: {{object.id_num}}</p>
<p> Email: {{object.email}}</p>
<p> Department and Course: {{object.department.home_unit}}, {{object.department.dept_name}}</p>
{% endblock %}
\ No newline at end of file
<!-- homepage/index.html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Homepage{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static '/homepage.css' %}">
{% endblock %}
{% block header %}
Welcome to Widget!
{% endblock %}
{% block content %}
{% for user in all_widgetusers %}
<a class="details" href="{{user.id}}/details">{{forloop.counter}}. {{user.last_name}}, {{user.first_name}} {{user.middle_name}}</a> </br>
{% endfor %}
{% 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, WidgetUserDetailView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', HomepageView.as_view(), name='index'),
path('<int:pk>/details', WidgetUserDetailView.as_view(),name='widgetuser_detail'),
] ]
app_name = "homepage" app_name = "homepage"
from django.shortcuts import render from django.shortcuts import render
from django.views import View
from django.views.generic.detail import DetailView
from .models import Department, WidgetUser
from forum.views import display_forumposts
from .models import WidgetUser, Department
from django.http import HttpResponse
def index(request): class HomepageView(View):
return HttpResponse(display_homepage(WidgetUser.objects.all(), Department.objects.all())) def get(self, request):
objects_set = {
"all_widgetusers": [obj for obj in WidgetUser.objects.all().order_by('last_name')]
}
return render(request, 'index.html', objects_set)
# View for HomePage
def display_homepage(widgetuser_data, department_data):
display_output = "WIDGET USERS: <br>"
for object in widgetuser_data: class WidgetUserDetailView(DetailView):
first_name = object.first_name model = WidgetUser
middle_name = object.middle_name
last_name = object.last_name
id_num = object.id_num
department_object = Department.objects.filter(id=object.department_id).first()
if (department_object != None):
dept_name = department_object.dept_name
home_unit = department_object.home_unit
else:
dept_name = "NONE"
home_unit = "NONE"
display_output += f'''
{last_name}, {first_name} {middle_name}: {id_num}, {dept_name}, {home_unit}<br>
'''
return display_output
@font-face {
font-family: 'Khula';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(https://fonts.gstatic.com/s/khula/v12/OpNPnoEOns3V7G-ljBvTpi8.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: 'Comfortaa';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(https://fonts.gstatic.com/s/comfortaa/v38/1Pt_g8LJRfWJmhDAuUsSQamb1W0lwk4S4Y_LDrMfIA.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
nav:focus {
outline:0 !important;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: row;
width: 100%;
background-color: #bb00ff;
}
ul li {
padding: 20px;
}
.links {
padding: 21px;
text-decoration: none;
font-size: 15px;
color: white;
font-family: Comfortaa;
transition: background-color 0.2s ease-in-out;
}
.links:hover {
background-color: #410178;
}
body {
margin: 0;
}
.content {
display: flex;
flex-direction: column;
margin: 16px 0 0 25px;
}
.header {
margin: 0;
padding: 0;
font-size: 50px;
font-family: Khula;
margin-bottom: 10px;
}
\ No newline at end of file
@font-face {
font-family: 'Oxygen';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/oxygen/v15/2sDfZG1Wl4LcnbuKjk0m.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
.details {
color: black;
padding: 10px 20px 10px 20px;
text-decoration: none;
font-family: Oxygen;
width: fit-content;
background-size: 200% 100%;
background-image: linear-gradient(to right, #ffffff 50%, #000000 50%);
transition: background-position 0.3s ease-in-out, color 0.2s ease-in-out;
}
.details:hover {
background-color: black;
background-position: -100% 0;
color: white;
}
\ No newline at end of file
@font-face {
font-family: 'Oxygen';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/oxygen/v15/2sDfZG1Wl4LcnbuKjk0m.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
p {
margin-top: 0;
margin-bottom: 20px;
font-family: Oxygen;
}
h1 {
display: flex;
flex-direction: row;
align-items: center;
}
img {
border-radius: 50%;
border: 1px solid black;
margin-right: 30px;
margin-top: -10px;
}
\ No newline at end of file
<!-- project/template/base.html -->
{% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
<link href="{% static 'base_style.css' %}" rel="stylesheet" />
{% block styles %}{% endblock %} {% block styles %}{% endblock %}
</head> </head>
<body> <body>
<nav>
<ul>
<li><a class="links" href="/homepage">HOMEPAGE</a></li>
<li><a class="links" href="/assignments">ASSIGNMENTS</a></li>
<li><a class="links" href="/forum">FORUM</a></li>
<li><a class="links" href="/announcements">ANNOUNCEMENTS</a></li>
</ul>
</nav>
<div class="content">
<h1 class="header">{% block header %}{% endblock %}</h1>
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body> </body>
</html> </html>
...@@ -42,10 +42,11 @@ INSTALLED_APPS = [ ...@@ -42,10 +42,11 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'widget_father_when_can_i_be_on_my_own_i_have_the_hello_world_to_see',
'forum', 'forum',
'assignments', 'assignments',
'homepage', 'homepage',
'announcement_board', 'announcement_board'
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -127,6 +128,8 @@ USE_TZ = True ...@@ -127,6 +128,8 @@ USE_TZ = True
STATIC_URL = 'static/' STATIC_URL = 'static/'
STATICFILES_DIRS = [ STATICFILES_DIRS = [
BASE_DIR / "static", BASE_DIR / "static",
"assignments/templates",
"homepage/templates"
] ]
# Default primary key field type # Default primary key field type
......
<!-- project/template/base.html -->
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
<link href="{% static 'base_style.css' %}" rel="stylesheet" />
{% block styles %}{% endblock %}
</head>
<body>
<nav>
<ul>
<li><a class="links" href="/homepage">HOMEPAGE</a></li>
<li><a class="links" href="/assignments">ASSIGNMENTS</a></li>
<li><a class="links" href="/forum">FORUM</a></li>
<li><a class="links" href="/announcements">ANNOUNCEMENTS</a></li>
</ul>
</nav>
<div class="content">
<h1 class="header">{% block header %}{% endblock %}</h1>
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
...@@ -20,6 +20,7 @@ urlpatterns = [ ...@@ -20,6 +20,7 @@ urlpatterns = [
path('homepage/', include("homepage.urls", namespace='homepage')), path('homepage/', include("homepage.urls", namespace='homepage')),
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('announcements/', include("announcement_board.urls", namespace='announcement_board')), path('announcements/', include("announcement_board.urls",
namespace='announcement_board')),
path('assignments/', include("assignments.urls", namespace='assignments')), path('assignments/', include("assignments.urls", namespace='assignments')),
] ]
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