Commit 88d787c1 authored by Jonathan Talbot's avatar Jonathan Talbot

stuff

parent d7c88b7b
No preview for this file type
from django.contrib import admin
from .models import WidgetUser, Forum, Announcement, Assignment
from .models import WidgetUser, Forum, Announcement, Assignment, Department
# Classes
class DepartmentInline(admin.TabularInline):
model = Department
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
......@@ -14,13 +17,20 @@ class WidgetUserAdmin(admin.ModelAdmin):
fieldsets = [
('Widget User Data', {
'fields': [
'id_num',
'first_name',
'middle_name',
'last_name'
'last_name',
'email'
]
}),
]
inlines = [DepartmentInline,]
class DepartmentAdmin(admin.ModelAdmin):
model = Department
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
......
# Generated by Django 4.0.3 on 2022-04-07 06:21
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Announcement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('announcement_title', models.CharField(max_length=50)),
('announcement_body', models.CharField(max_length=200)),
('pub_date', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.CharField(max_length=200)),
('max_points', models.IntegerField()),
],
),
migrations.CreateModel(
name='Forum',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('post_title', models.CharField(max_length=50)),
('post_body', models.CharField(max_length=100)),
('pub_date', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id_num', models.IntegerField()),
('first_name', models.CharField(max_length=100)),
('middle_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
('email', models.EmailField(max_length=254)),
],
),
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)),
('widget_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_group3.widgetuser')),
],
),
]
from django.db import models
from django.urls import reverse
class WidgetUser(models.Model):
id_num = models.IntegerField()
first_name = models.CharField(max_length=100)
middle_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
email = models.EmailField()
def __str__(self):
return self.full_name
return '{}, {} {}: {}, {}'.format(self.last_name, self.first_name, self.middle_name, self.id_num, self.email)
def get_absolute_url(self):
return reverse('widget_user', args=[(self.full_name)])
......@@ -16,6 +19,17 @@ class WidgetUser(models.Model):
def full_name(self):
return '{} {} {}'.format(self.first_name, self.middle_name, self.last_name)
# Department used for widget user
class Department(models.Model):
dept_name = models.CharField(max_length=100)
home_unit = models.CharField(max_length=100)
widget_user = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
def __str__(self):
return '{}, {}'.format(self.dept_name, self.home_unit)
class Announcement(models.Model):
announcement_title= models.CharField(max_length=50)
announcement_body = models.CharField(max_length=200)
......
from django.http import HttpResponse
from .models import WidgetUser, Forum, Announcement, Assignment, Department
def homepage(request):
return HttpResponse('Welcome to Widget!')
widget_users = WidgetUser.objects.all()
output = "WIDGET USERS:\n" + "\n".join([str(user) for user in widget_users])
return HttpResponse(output, content_type="text/plain")
def assignments(request):
return HttpResponse('This is the Assignments page!')
......
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