Commit d7592357 authored by Sumawang, Tee Jay Jr. C.'s avatar Sumawang, Tee Jay Jr. C.

Cache commit :>

parents b28ddf50 b6a849d5
widget_tee_jays_angelos/homepage/__pycache__/
widget_tee_jays_angelos/homepage/migrations/__pycache__/
widget_tee_jays_angelos/announcements/__pycache__/
widget_tee_jays_angelos/announcements/migrations/__pycache__/
widget_tee_jays_angelos/forum/__pycache__/
widget_tee_jays_angelos/forum/migrations/__pycache__/
widget_tee_jays_angelos/assignments/__pycache__/
widget_tee_jays_angelos/assignments/migrations/__pycache__/
......@@ -8,4 +8,6 @@ LIM, Ryan Angelo G. - Forum
SY, Paul Angelo G. - Assignments
LAB 1 DEMO LINK: https://youtu.be/jNdRMSFblpw
\ No newline at end of file
LAB 1 DEMO LINK: https://youtu.be/jNdRMSFblpw
LAB 2 DEMO LINK: https://youtu.be/c7grjkmlyRI
\ No newline at end of file
from django.contrib import admin
from .models import WidgetUser
from .models import WidgetUser, Department
# Register your models here.
admin.site.register(WidgetUser)
class DepartmentAdminInline(admin.TabularInline):
model = Department
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
inlines = [DepartmentAdminInline]
class DepartmentAdmin(admin.ModelAdmin):
model = Department
admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Department, DepartmentAdmin)
# Generated by Django 4.0.3 on 2022-03-25 18:37
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='email',
field=models.CharField(max_length=50, null=True),
),
migrations.AddField(
model_name='widgetuser',
name='id_num',
field=models.CharField(max_length=7, null=True),
),
migrations.CreateModel(
name='Department',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('dept_name', models.CharField(max_length=50)),
('home_unit', models.CharField(max_length=50)),
('widget_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser')),
],
),
]
......@@ -6,6 +6,18 @@ class WidgetUser(models.Model):
first_name = models.CharField(max_length=50)
middle_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
id_num = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, null=True)
def __str__(self):
return self.first_name + " " + self.last_name
return self.last_name + ", " + self.first_name
class Department(models.Model):
widget_user = models.ForeignKey(WidgetUser, on_delete=models.CASCADE,
blank=True, null=True)
dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=50)
def __str__(self):
return self.dept_name + ", " + self.home_unit
from django.http import HttpResponse
from homepage.models import WidgetUser, Department
# Create your views here.
def index(request):
return HttpResponse("Welcome to Widget!")
entries = WidgetUser.objects.all().count()
n = 1
users = "WIDGET USERS:<br/>"
while (n <= entries):
userLastName = WidgetUser.objects.get(pk=n).last_name
userFirstName = WidgetUser.objects.get(pk=n).first_name
userMiddleName = WidgetUser.objects.get(pk=n).middle_name
userIdNum = WidgetUser.objects.get(pk=n).id_num
userEmail = WidgetUser.objects.get(pk=n).email
userDept = Department.objects.get(widget_user=n).dept_name
userHome = Department.objects.get(widget_user=n).home_unit
users = users + userLastName + ", " + userFirstName + " " + userMiddleName + ": " + userIdNum + ", " + userEmail + ", " + userDept + ", " + userHome + "<br/>"
n += 1
return HttpResponse(users)
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