finals requirements

parent 822901d2
# Generated by Django 3.2.12 on 2022-05-18 03:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0006_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='course',
name='course_code',
field=models.CharField(max_length=10, unique=True),
),
migrations.AlterField(
model_name='course',
name='course_title',
field=models.CharField(max_length=500, unique=True),
),
]
......@@ -5,9 +5,6 @@ class Department(models.Model):
dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=50)
def __str__(self):
return self.dept_name
class WidgetUser(models.Model):
first_name = models.CharField(max_length=50, default="A")
middle_name = models.CharField(max_length=50, default="B")
......@@ -15,7 +12,6 @@ class WidgetUser(models.Model):
id_num = models.CharField(max_length=7, default = "")
email = models.CharField(max_length=100, default = "")
department = models.ForeignKey(Department, on_delete = models.CASCADE, null=True)
pfp = models.ImageField(upload_to="userpfp/", default="userpfp/default.png")
def __str__(self):
return self.first_name
\ No newline at end of file
return self.first_name
......@@ -6,13 +6,11 @@
<link rel="stylesheet" type="text/css" href="{%static 'homepage/css/details.css'%}">
<div class="container main">
<img id="profilepic" src="{{imgurl}}"> <br><br>
<img id="profilepic" src="{%static imgurl%}"> <br><br>
<h1>{{widget_user.last_name}}, {{widget_user.first_name}} {{widget_user.middle_name}}</h1>
<h2>{{widget_user.id_num}}</h2>
<h3>{{widget_user.email}}</h3>
<h4>{{widget_user.department.dept_name}}</h4>
<h4>{{widget_user.department.home_unit}}</h4> <br>
<a href="{%url 'homepage'%}"> Return to Homepage </a>
<h4>{{widget_user.department.home_unit}}</h4>
</div>
{%endblock%}
\ No newline at end of file
......@@ -12,8 +12,6 @@
{%for w in widget_users%}
<li><a href="{%url 'details' w.id_num%}">{{w.last_name}}, {{w.first_name}} {{w.middle_name}}</a></li>
{%endfor%}
</ol> <br>
<h2><a href="{%url 'adduser'%}">Add User</a></h2>
</ol>
</div>
{%endblock%}
\ No newline at end of file
from django.urls import path
from . import views
from .views import UserDetailsView
urlpatterns = [
path('', views.homepage_view, name='homepage'),
path('users/<user_id>/details', UserDetailsView.as_view(), name='details'),
path('users/add', views.addUser, name='adduser')
path('users/<user_id>/details', views.details, name='details')
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views import View
from .models import Department, WidgetUser
from .homepage_forms import AddUserForm
# Create your views here.
"""
......@@ -26,36 +24,12 @@ def homepage_view(request):
}
return render(request, "homepage/home.html", homepage_dict)
#CBV
"""
def details(request, user_id):
widget_user = WidgetUser.objects.get(id_num=user_id)
imgurl = f"../../../media/userpfp/{user_id}.png"
imgurl = f"homepage/images/{user_id}.png"
details_dict = {
"widget_user" : widget_user,
"imgurl" : imgurl
}
return render(request, "homepage/details.html", details_dict)
"""
class UserDetailsView(View):
def get(self, request, user_id):
widget_user = WidgetUser.objects.get(id_num=user_id)
imgurl = f"../../../media/userpfp/{user_id}.png"
details_dict = {
"widget_user" : widget_user,
"imgurl" : imgurl
}
return render(request, "homepage/details.html", details_dict)
#FBV
def addUser(request):
form = AddUserForm()
if request.method == 'POST':
form = AddUserForm(request.POST, request.FILES)
if form.is_valid():
form.save()
context = {
"form" : form
}
return render(request, "homepage/adduser.html", context)
return render(request, "homepage/details.html", details_dict)
\ 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