Commit c0e3e259 authored by Nics De Vega's avatar Nics De Vega

merged changes from master to announcement_board

parents 2f59c8f5 9327ad66
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 = ('first_name', 'middle_name', 'last_name', 'department',)
search_fields = ('first_name', 'last_name', 'department',)
list_filter = ('first_name', 'last_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 3.2 on 2023-03-06 02:48
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(default='', max_length=100, unique=True)),
('home_unit', models.CharField(default='', max_length=100, unique=True)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(default='', max_length=100)),
('middle_name', models.CharField(default='', max_length=100)),
('last_name', models.CharField(default='', max_length=100)),
('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=100,unique=True,default="")
home_unit = models.CharField(max_length=100,unique=True,default="")
def __str__(self):
return '{}'.format(self.dept_name)
class WidgetUser(models.Model):
first_name = models.CharField(max_length=100,default="")
middle_name = models.CharField(max_length=100,default="")
last_name = models.CharField(max_length=100,default="")
department = models.ForeignKey(Department,on_delete=models.CASCADE)
def __str__(self):
return '{} {}'.format(self.first_name, self.last_name)
\ No newline at end of file
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 = 'announcement_board'
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import WidgetUser
def index(request):
return_string = '<body>'
for user in WidgetUser.objects.all():
user_string = '{}, {} {}'.format(
user.last_name, user.first_name, user.middle_name
)
dept_string = '{}: {}'.format(
user.department.dept_name, user.department.home_unit
)
return_string += user_string + " from the " + dept_string + "<br>"
html_string = '<html>{}</html>'.format(return_string)
return HttpResponse("Welcome to Widget! <br> <br>WIDGET USERS: <br>" + html_string)
\ No newline at end of file
...@@ -42,6 +42,7 @@ INSTALLED_APPS = [ ...@@ -42,6 +42,7 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'announcement_board', 'announcement_board',
'dashboard',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -17,6 +17,7 @@ from django.contrib import admin ...@@ -17,6 +17,7 @@ from django.contrib import admin
from django.urls import path, include from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('dashboard/', include('dashboard.urls', namespace="dashboard")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('announcements/', include('announcement_board.urls', namespace="announcement_board")), path('announcements/', include('announcement_board.urls', namespace="announcement_board")),
] ]
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