Commit 8848e08d authored by nheoxoz's avatar nheoxoz

Merge branch 'staging' into announcements

parents 074879db ee93308a
from django.contrib import admin
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
list_display = ('dept_name', 'home_unit',)
search_fields = ('dept_name', 'home_unit',)
list_filter = ('dept_name', 'home_unit',)
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
list_display = ('last_name', 'first_name', 'middle_name', 'department')
search_fields = ('last_name', 'first_name', 'middle_name', 'department')
list_filter = ('last_name', 'first_name', 'middle_name', 'department')
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
from django.apps import AppConfig
class DashboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'dashboard'
# Generated by Django 4.1.7 on 2023-03-03 16:35
from django.db import migrations, models
import django.db.models.deletion
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=255)),
('home_unit', models.CharField(max_length=255)),
],
),
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=255)),
('middle_name', models.CharField(max_length=255)),
('last_name', models.CharField(max_length=255)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.department')),
],
),
]
from django.db import models
class Department(models.Model):
dept_name = models.CharField(max_length=255)
home_unit = models.CharField(max_length=255)
def __str__(self):
return '{}, {}'.format(self.dept_name, self.home_unit)
class WidgetUser(models.Model):
first_name = models.CharField(max_length=255)
middle_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
department = models.ForeignKey(Department, on_delete=models.CASCADE)
def __str__(self):
return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name)
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = "dashboard"
from django.shortcuts import HttpResponse
from .models import Department, WidgetUser
def index(request):
return_string = '<p>Welcome to Widget!</p>WIDGET USERS:<ul style="list-style: none; padding: 0; margin: 0;">'
for user in WidgetUser.objects.all():
return_string += '<li>{}: {}</li>'.format(user, user.department)
return_string += '</ul>'
html_string = '<html><body>{}</body></html>'.format(return_string)
return HttpResponse(html_string)
......@@ -40,6 +40,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard',
'announcements',
]
......
......@@ -17,6 +17,7 @@ from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('dashboard/', include('dashboard.urls', namespace="dashboard")),
path('announcements/', include('announcements.urls', namespace="announcements")),
path('admin/', admin.site.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