Commit 9b6930eb authored by Raul Jarod Conanan's avatar Raul Jarod Conanan

Merge branch '2-dashboard' into 'dev'

2 dashboard

See merge request !9
parents 39cda890 45fadfc1
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (midterm_robo_mommy)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
SECRET_KEY = 'django-insecure-t*s#_++5=ze%3#*ns6vcmt8a5bw6249en-!ek7*#3=p-dkhl_f'
from django.contrib import admin
from .models import Department
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
......@@ -11,4 +11,9 @@ class DepartmentAdmin(admin.ModelAdmin):
search_fields = ('dept_name', 'home_unit')
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
# Generated by Django 3.2 on 2023-03-04 15:37
# Generated by Django 4.1.6 on 2023-03-04 16:34
import django.contrib.auth.models
from django.db import migrations, models
import django.db.models.deletion
......@@ -8,7 +7,6 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
('Dashboard', '0001_initial'),
]
......@@ -16,16 +14,11 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='WidgetUser',
fields=[
('user_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='auth.user')),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
bases=('auth.user',),
managers=[
('objects', django.contrib.auth.models.UserManager()),
('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.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.department')),
],
),
]
from django.db import models
from django.contrib.auth.models import User
class Department(models.Model):
dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=100)
class WidgetUser(User):
pass
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)
\ No newline at end of file
<!DOCTYPE HTML>
<HTML>
<Head>
<h1>Welcome to Widget!</h1>
</Head>
<h2>WIDGET USERS</h2>
<ul>
{% for Department in object_list %}
<li>{{Department.dept_name}}, {{Department.home_unit}}</li>
{% endfor %}
</ul>
</HTML>
from django.urls import path
from .views import DashboardView
from .views import Dashboard_list_view
urlpatterns = [
path('', DashboardView.as_view()),
path('', Dashboard_list_view, name='Dashboard_list_view'),
]
app_name = "Dashboard"
\ No newline at end of file
from .models import Department
from django.views import generic
from .models import WidgetUser, Department
from django.http import HttpResponse
from django.shortcuts import render
class DashboardView(generic.ListView):
model = Department
template_name = 'Dashboard/Dashboard.html'
def Dashboard_list_view(request):
html_string_1 = '<html lang="en"><head><meta charset="UTF-8">' \
'<h1>Welcome to Widget</h1>' \
'<h2>WIDGET USERS</h2></head><ul>'
html_string_2 = ''
for wu in WidgetUser.objects.all():
html_string_2 += '<li>{}, {} {}: {}, {}' .format(wu.last_name,
wu.first_name,
wu.middle_name,
wu.department.dept_name,
wu.department.home_unit)
html_string_2 += '</ul></li>'
html_string_final = html_string_1 + html_string_2 + '</html>'
return HttpResponse(html_string_final)
from django.contrib import admin
from .models import ForumPost, Reply, WidgetUser
from .models import ForumPost, Reply
# Register your models here.
admin.site.register(ForumPost)
admin.site.register(Reply)
admin.site.register(WidgetUser)
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