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 django.contrib import admin
from .models import Department from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin): class DepartmentAdmin(admin.ModelAdmin):
...@@ -11,4 +11,9 @@ class DepartmentAdmin(admin.ModelAdmin): ...@@ -11,4 +11,9 @@ class DepartmentAdmin(admin.ModelAdmin):
search_fields = ('dept_name', 'home_unit') search_fields = ('dept_name', 'home_unit')
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
admin.site.register(Department, DepartmentAdmin) 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 from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
...@@ -8,7 +7,6 @@ import django.db.models.deletion ...@@ -8,7 +7,6 @@ import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
('Dashboard', '0001_initial'), ('Dashboard', '0001_initial'),
] ]
...@@ -16,16 +14,11 @@ class Migration(migrations.Migration): ...@@ -16,16 +14,11 @@ class Migration(migrations.Migration):
migrations.CreateModel( migrations.CreateModel(
name='WidgetUser', name='WidgetUser',
fields=[ 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')), ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
], ('first_name', models.CharField(max_length=50)),
options={ ('middle_name', models.CharField(max_length=50)),
'verbose_name': 'user', ('last_name', models.CharField(max_length=50)),
'verbose_name_plural': 'users', ('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.department')),
'abstract': False,
},
bases=('auth.user',),
managers=[
('objects', django.contrib.auth.models.UserManager()),
], ],
), ),
] ]
from django.db import models from django.db import models
from django.contrib.auth.models import User
class Department(models.Model): class Department(models.Model):
dept_name = models.CharField(max_length=50) dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=100) 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 django.urls import path
from .views import DashboardView from .views import Dashboard_list_view
urlpatterns = [ urlpatterns = [
path('', DashboardView.as_view()), path('', Dashboard_list_view, name='Dashboard_list_view'),
] ]
app_name = "Dashboard" app_name = "Dashboard"
\ No newline at end of file
from .models import Department from .models import WidgetUser, Department
from django.views import generic from django.http import HttpResponse
from django.shortcuts import render
class DashboardView(generic.ListView): def Dashboard_list_view(request):
model = Department html_string_1 = '<html lang="en"><head><meta charset="UTF-8">' \
template_name = 'Dashboard/Dashboard.html' '<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 django.contrib import admin
from .models import ForumPost, Reply, WidgetUser from .models import ForumPost, Reply
# Register your models here. # Register your models here.
admin.site.register(ForumPost) admin.site.register(ForumPost)
admin.site.register(Reply) 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