Commit 8915b544 authored by Deokhyun Lee's avatar Deokhyun Lee

Merge branch 'master' into 'calendar_wip'

# Conflicts:
#   widget_aguandhischipmunks/widget_aguandhischipmunks/urls.py
parents 930c651e aa888c8e
from django.contrib import admin from django.contrib import admin
from .models import Department, WidgetUser
# admin panel for Department model
class DepartmentAdmin(admin.ModelAdmin):
model = Department
search_fields = ("dept_name", "home_unit",)
list_display = ("dept_name", "home_unit",)
list_filter = ("dept_name",)
# admin panel for WidgetUser model
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
search_fields = ("first_name", "middle_name", "last_name", "department",)
list_display = ("first_name", "middle_name", "last_name", "department",)
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
# Register your models here.
# Generated by Django 4.1.7 on 2023-03-05 08:41
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
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=100)),
("home_unit", models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name="WidgetUser",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("first_name", models.CharField(max_length=50)),
("middle_name", models.CharField(max_length=50)),
("last_name", models.CharField(max_length=50)),
("department", models.CharField(max_length=50)),
],
),
]
# Generated by Django 4.1.7 on 2023-03-05 08:42
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("dashboard", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="widgetuser",
name="department",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="dashboard.department"
),
),
]
from django.db import models from django.db import models
# Create your models here. # Created Department model
class Department(models.Model):
dept_name = models.CharField(max_length = 100)
home_unit = models.CharField(max_length = 100)
def __str__(self):
return self.dept_name + ', ' + self.home_unit
# Created WidgetUser model
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)
department = models.ForeignKey(Department, on_delete = models.CASCADE)
def __str__(self):
username = self.last_name + ", " + self.first_name + " " + self.middle_name
return username
#dashboard/urls.py
from django.urls import path
from .import views
urlpatterns = [
path("", views.dashboardIndex, name = "dashboardIndex")
]
app_name = "dashboard"
\ No newline at end of file
from django.shortcuts import render from django.http import HttpResponse
from .models import Department, WidgetUser
def dashboardIndex(request):
users = WidgetUser.objects.all()
departments = Department.objects.all()
dashboard_output = "Welcome to Widget! <br><br> WIDGET USERS: <br><br>"
for user in users:
username = str(user)
home_department = str(user.department)
dashboard_output = dashboard_output + username + ": " + home_department + "<br>"
return HttpResponse(dashboard_output)
# Create your views here.
...@@ -18,6 +18,7 @@ from django.urls import path, include ...@@ -18,6 +18,7 @@ from django.urls import path, include
urlpatterns = [ urlpatterns = [
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
path("dashboard/", include("dashboard.urls", namespace="dashboard")),
path("assignments/", include("assignments.urls")), path("assignments/", include("assignments.urls")),
path("calendar/", include("calendar_app.urls")) path("calendar/", include("calendar_app.urls"))
] ]
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