Commit 4c50943b authored by Joshua Son's avatar Joshua Son

Update: photos re-added to announcements

parents c807747e a2d20cfa
# Generated by Django 3.2.12 on 2022-05-25 16:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0027_alter_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-25 16:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0028_alter_widgetuser_profile_pic'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_pic',
field=models.ImageField(blank=True, default='static/faceless.png', null=True, upload_to=''),
),
]
# Generated by Django 3.2.12 on 2022-05-25 16:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0029_alter_widgetuser_profile_pic'),
]
operations = [
migrations.AlterField(
model_name='department',
name='dept_name',
field=models.CharField(default='none', max_length=50, null=True),
),
migrations.AlterField(
model_name='department',
name='home_unit',
field=models.CharField(default='none', max_length=50, null=True),
),
]
# Generated by Django 3.2.12 on 2022-05-25 16:43
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0030_auto_20220525_1935'),
]
operations = [
migrations.RemoveField(
model_name='department',
name='widgetuser',
),
migrations.AddField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(default='1', on_delete=django.db.models.deletion.CASCADE, to='homepage.department'),
),
]
# Generated by Django 3.2.12 on 2022-05-25 17:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0031_auto_20220525_1943'),
]
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-25 19:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0032_alter_widgetuser_profile_pic'),
]
operations = [
migrations.AlterField(
model_name='department',
name='dept_name',
field=models.CharField(default='none', max_length=50),
),
migrations.AlterField(
model_name='department',
name='home_unit',
field=models.CharField(default='none', max_length=50),
),
migrations.AlterField(
model_name='widgetuser',
name='profile_pic',
field=models.ImageField(default='faceless.png', upload_to=''),
),
]
# Generated by Django 3.2.12 on 2022-05-25 19:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0033_auto_20220525_2249'),
]
operations = [
migrations.AlterField(
model_name='department',
name='dept_name',
field=models.CharField(default='none', max_length=50, null=True),
),
migrations.AlterField(
model_name='department',
name='home_unit',
field=models.CharField(default='none', max_length=50, null=True),
),
]
......@@ -2,21 +2,22 @@ from email.policy import default
from django.db import models
# Create your models here.
class Department(models.Model):
dept_name = models.CharField(max_length=50, null=True, default='none')
home_unit = models.CharField(max_length=50, null=True, default='none')
def __str__(self):
return self.dept_name
class WidgetUser(models.Model):
first_name = models.CharField(max_length=50, default='first_name')
middle_name = models.CharField(max_length=50, default='middle_name')
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
class Department(models.Model):
widgetuser = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=False, blank=False)
dept_name = models.CharField(max_length=50, default='none')
home_unit = models.CharField(max_length=50, default='none')
profile_pic = models.ImageField(default="faceless.png")
department = models.ForeignKey(Department, on_delete=models.CASCADE, default="1")
def __str__(self):
return self.dept_name
\ No newline at end of file
return self.last_name
\ No newline at end of file
......@@ -6,7 +6,8 @@
<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 'homepage/style.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}">
<title> Homepage </title>
</head>
<body>
{% block content %}
......
{% extends "homepage/base.html" %}
{% block content %}
<form action="newUser/" method="POST">
{% csrf_token %}
<h3> Enter Last Name: </h3> <input type="text" name="Last name">
<h3> Enter First Name: </h3> <input type="text" name="First name">
<h3> Enter Middle Name: </h3> <input type="text" name="Middle name">
<h3> Enter ID Number: </h3> <input type="text" name="ID Number">
<h3> Enter Email address: </h3> <input type="text" name="Email address">
<br>
<br>
<select class="custom-select mb-4" name="newDepartment">
<option selected> Select your department </option>
{% for department in Department %}
<option value="{{ department.pk }}"> {{ department.dept_name }} </option>
{% endfor %}
</select>
<br>
<br>
<button class="button" type="submit"> Save New User </button>
</form>
{% endblock %}
\ No newline at end of file
{% extends "homepage/base.html" %}
{% block content %}
<h2>
{{ Department.widgetuser.last_name }},
{{ Department.widgetuser.first_name }}
{{ Department.widgetuser.middle_name }}
</h2>
<ul>
<li>{{ Department.widgetuser.id_num }}</li>
<li>{{ Department.widgetuser.email }}</li>
<li>{{ Department.dept_name }}</li>
<li>{{ Department.home_unit }}</li>
</ul>
<h2>
{{ WidgetUser.last_name }},
{{ WidgetUser.first_name }}
{{ WidgetUser.middle_name }}
</h2>
<ul>
<li>{{ WidgetUser.id_num }}</li>
<li>{{ WidgetUser.email }}</li>
<li>{{ WidgetUser.department.dept_name }}</li>
<li>{{ WidgetUser.department.home_unit }}</li>
</ul>
<br>
<br>
<img src="{{ Department.widgetuser.profile_pic.url }}" width="20%">
<img src="{{ WidgetUser.profile_pic.url }}" width="20%">
{% endblock %}
\ No newline at end of file
{% extends "homepage/base.html" %}
{% block content %}
<p>
<h1>Welcome to Widget!</h1>
<h2>WIDGET USERS:</h2>
{% if WidgetUser %}
<ol>
{% for widgetUser in WidgetUser %}
<li>
<a href="{% url 'homepage:details' widgetUser.id_num %}">
{{ widgetUser.last_name }},
{{ widgetUser.first_name }}
{{ widgetUser.middle_name }}
</a>
</li>
{% endfor %}
</ol>
{% else %}
<p>No widget users registered.</p>
{% endif %}
</p>
<p>
<h1>Welcome to Widget!</h1>
<h2>WIDGET USERS:</h2>
{% if WidgetUser %}
<ol>
{% for widgetUser in WidgetUser %}
<li>
<a href="{% url 'homepage:details' widgetUser.id %}">
{{ widgetUser.last_name }},
{{ widgetUser.first_name }}
{{ widgetUser.middle_name }}
</a>
</li>
{% endfor %}
</ol>
{% else %}
<h1>No widget users registered.</h1>
{% endif %}
<a href="{% url 'homepage:createUser' %}"> Add Widget User </a>
</p>
{% endblock %}
......@@ -5,6 +5,8 @@ from . import views
app_name = "homepage"
urlpatterns = [
path('', views.index, name='index'),
path('users/add/newUser/', views.newUser, name='newUser'),
path('users/add/', views.createUser, name='createUser'),
path("users/<int:widgetuser_id>/details/", views.detail, name='details')
]
\ No newline at end of file
from .models import Department
from .models import WidgetUser
from django.http import Http404
from django.http import HttpResponse, Http404
from django.shortcuts import render
widgetUser = WidgetUser.objects.order_by("last_name")
def index(request):
widgetUser = WidgetUser.objects.order_by("last_name")
context = {
"WidgetUser": widgetUser
}
return render(request, "homepage/widgetusers_orderedlist.html", context)
def createUser(request):
department = Department.objects.all()
context = {
"Department": department
}
return render(request, "homepage/createUser_form.html", context)
def newUser(request):
if request.method == "POST":
first_name = request.POST.get("First name")
middle_name = request.POST.get("Middle name")
last_name = request.POST.get("Last name")
id_num = request.POST.get("ID Number")
email = request.POST.get("Email address")
dept_Value = request.POST.get("newDepartment")
widgetUser = WidgetUser.objects.create(first_name=first_name, middle_name=middle_name, last_name=last_name, id_num=id_num, email=email, department_id=dept_Value)
return HttpResponse("User Added")
def detail(request, widgetuser_id):
try:
department = Department.objects.get(pk=widgetuser_id)
except Department.DoesNotExist:
widgetUser = WidgetUser.objects.get(pk=widgetuser_id)
except WidgetUser.DoesNotExist:
raise Http404("User does not exist!")
return render(request, "homepage/details.html", {"Department": department})
\ No newline at end of file
return render(request, "homepage/details.html", {"WidgetUser": widgetUser})
\ No newline at end of file
......@@ -6,6 +6,10 @@ h2 {
color: palevioletred;
font-weight: bold;
}
h3 {
color: palevioletred;
font-weight: bold;
}
ol {
color: wheat;
font-weight: bold;
......
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