Commit 4ad3ae3d authored by Trisha Angel Millena's avatar Trisha Angel Millena

made migrations

parents 1bae86f7 2d557470
......@@ -32,3 +32,4 @@ Signatures:
(sgd) Julia Anishka M. Espera, March 3, 2023
(sgd) Gabriel G. Garrero, March 3, 2023
(sgd) Trisha Angel P. Millena, March 3, 2023
(sgd) Caryn Bryne C. Lopez-Go, March 4, 2023
\ No newline at end of file
from django.contrib import admin
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
list_display = ("dept_name", "home_unit")
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
list_display = ("first_name", "middle_name", "last_name", "department")
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
\ No newline at end of file
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-03 13:41
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=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.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.department')),
],
),
]
from django.db import models
# Create your models here.
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
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):
return 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 = "dashboard"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Department, WidgetUser
def index(request):
users = WidgetUser.objects.all()
WelcomeMessage = "Welcome to Widget!<br><br>WIDGET USERS:<br>"
for user in users:
WelcomeMessage = WelcomeMessage + user.last_name + ", " + user.first_name + " " + user.middle_name + ": " + user.department.dept_name + ", " + user.department.home_unit + "<br>"
return HttpResponse(WelcomeMessage)
\ No newline at end of file
# Generated by Django 3.2 on 2023-03-04 15:37
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('dashboard', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='ForumPost',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=300)),
('body', models.TextField(max_length=500)),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('body', models.CharField(max_length=300)),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost')),
],
),
]
from django.db import models
from dashboard.models import WidgetUser
# Create your models here.
......
......@@ -4,10 +4,15 @@ from .models import ForumPost, Reply
# Create your views here.
for post in posts:
def index(request):
posts = ForumPost.objects.all()
replies = Reply.objects.all()
welcoming = "Widget's Forum<br><br>Forum Posts:<br>"
for post in posts:
for reply in replies:
if reply.post.title == post.title:
welcoming = welcoming + post.title + " by " + " posted " + post.pub_datetime.strftime('%I:%M %p') + ":<br>" + post.body + "<br>" + "Reply by " + " posted " + reply.pub_datetime.strftime('%I:%M %p') + ":<br>" + reply.body + "<br>"
welcoming = welcoming + post.title + " by " + " posted " + post.pub_datetime.strftime('%I:%M %p') + ":<br>" + post.body + "<br>"
return HttpResponse(welcoming)
return HttpResponse(welcoming)
......@@ -36,6 +36,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'forum',
'dashboard',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
......
......@@ -18,5 +18,6 @@ from django.urls import include, path
urlpatterns = [
path('forum/', include("forum.urls", namespace = "forum")),
path('dashboard/', include('dashboard.urls', namespace = "dashboard")),
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