Commit 5c68a48e authored by Nicolas Reichert's avatar Nicolas Reichert

help

parent 39490954
# widget_group 23
**Bianca Aguilar:**
+ Homepage
+ Forum
+ Homepage (Lab 1)
+ Forum (Lab 1)
+ Forum Models (Lab 2)
+ Forum Models (Midterm)
+ Forum View (Midterm)
+ Announcements Models (Midterm)
+ Announcements View (Midterm)
**Alissandra Tanaliga:**
+ Announcements (Lab 1)
+ Assignments (Lab 1)
+ Assignments Models (Lab 2)
+ Homepage Models (Lab 2)
+ Assignments Models (Midterm)
+ Assignments View (Midterm)
+ Homepage Models (Midterm)
+ Homepage View (Midterm)
**Nicolas Reichert:**
+ Announcements Models (Lab 2)
**Video Links:**
+ Lab 1: https://youtu.be/2P8rq0mgeQU
+ Lab 2: https://youtu.be/jam_e42FojI
\ No newline at end of file
......@@ -27,6 +27,9 @@ def index(request):
html = f'''
<html>
<head>
Announcement Board
</head>
<body>
<h1>ANNOUNCEMENTS:</h1>
<main>
......
from django.contrib import admin
from .models import Assignment
from .models import Assignment, Course
# Register your models here.
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
admin.site.register(Assignment, AssignmentAdmin)
\ No newline at end of file
class CourseAdmin(admin.ModelAdmin):
model = Course
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(Course, CourseAdmin)
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-04-04 09:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('course_code', models.CharField(max_length=10)),
('course_title', models.CharField(max_length=50)),
('section', models.CharField(max_length=3)),
],
),
]
# Generated by Django 4.0.3 on 2022-04-04 09:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_course'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='course',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
preserve_default=False,
),
]
from django.db import models
# Create your models here.
class Course(models.Model):
course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=50)
section = models.CharField(max_length=3)
@property
def course_info(self):
return '{} {} {}'.format(self.course_code, self.course_title, self.section)
@property
def course_shorthand(self):
return '{} {}'.format(self.course_code, self.section)
def __str__(self):
return '{} {}'.format(self.course_code, self.section)
class Assignment(models.Model):
name = models.CharField(max_length=50)
description = models.CharField(max_length=500)
max_points = models.IntegerField()
\ No newline at end of file
max_points = models.IntegerField()
course = models.ForeignKey(Course, on_delete = models.CASCADE)
@property
def passing_score(self):
return self.max_points * 0.60
@property
def assignment_info(self):
assignment = '<br>Assignment Name: {}'.format(self.name)
assignment += '<br>Description: {}'.format(self.description)
assignment += '<br>Perfect Score: {}'.format(self.max_points)
assignment += '<br>Passing Score: {}'.format(self.passing_score)
assignment += '<br>Course/Section: {}<br>'.format(self.course.course_info)
return assignment
def __str__(self):
return '{} - {}'.format(self.name, self.course.course_shorthand)
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment
# Create your views here.
def index(request):
return HttpResponse("This is the Assignments page!")
\ No newline at end of file
def assignment_list():
final_list = ''
for a in range(len(Assignment.objects.all())):
final_list += '{}'.format(Assignment.objects.get(pk=a+1).assignment_info)
return final_list
html = f'''
<html>
<body>
<header><h1>ASSIGNMENTS:</h1><header>
<main>
<p>{assignment_list()}</p>
</main>
</body>
</html>
'''
return HttpResponse(html)
\ No newline at end of file
import os, sys; sys.path.append(os.path.dirname(os.path.realpath(__file__)))
\ No newline at end of file
from django.contrib import admin
# Register your models here.
from .models import Post
from .models import Post, Reply
class PostAdmin(admin.ModelAdmin):
model = Post
class ReplyAdmin(admin.ModelAdmin):
model = Reply
admin.site.register(Post, PostAdmin)
admin.site.register(Reply, ReplyAdmin)
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-04-04 06:25
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
('forum', '0003_alter_post_pub_date'),
]
operations = [
migrations.AddField(
model_name='post',
name='author',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='posts', to='homepage.widgetuser'),
),
migrations.CreateModel(
name='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reply_body', models.CharField(max_length=500)),
('pub_date', models.DateTimeField(auto_now=True, verbose_name='Date Published')),
('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='replies', to='homepage.widgetuser')),
],
),
]
# Generated by Django 4.0.3 on 2022-04-04 16:06
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
('forum', '0004_post_author_reply'),
]
operations = [
migrations.AlterField(
model_name='post',
name='author',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='author',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
]
# Generated by Django 4.0.3 on 2022-04-04 17:31
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0003_widgetuser_department'),
('forum', '0005_alter_post_author_alter_reply_author'),
]
operations = [
migrations.AlterField(
model_name='post',
name='author',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
preserve_default=False,
),
migrations.AlterField(
model_name='reply',
name='author',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
preserve_default=False,
),
]
# Generated by Django 4.0.3 on 2022-04-05 04:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0006_alter_post_author_alter_reply_author'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateTimeField(auto_now=True),
),
migrations.AlterField(
model_name='reply',
name='pub_date',
field=models.DateTimeField(auto_now=True),
),
]
# Generated by Django 4.0.3 on 2022-04-05 05:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('forum', '0007_alter_post_pub_date_alter_reply_pub_date'),
]
operations = [
migrations.AddField(
model_name='reply',
name='post',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='forum.post'),
preserve_default=False,
),
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateField(auto_now=True),
),
migrations.AlterField(
model_name='reply',
name='pub_date',
field=models.DateField(auto_now=True),
),
]
# Generated by Django 4.0.3 on 2022-04-05 05:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0008_reply_post_alter_post_pub_date_alter_reply_pub_date'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateTimeField(auto_now=True),
),
migrations.AlterField(
model_name='reply',
name='pub_date',
field=models.DateTimeField(auto_now=True),
),
]
# Generated by Django 4.0.3 on 2022-04-05 05:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0009_alter_post_pub_date_alter_reply_pub_date'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateField(auto_now=True),
),
migrations.AlterField(
model_name='reply',
name='pub_date',
field=models.DateField(auto_now=True),
),
]
from django.db import models
from homepage.models import WidgetUser
# Create your models here.
class Post(models.Model):
post_title = models.CharField(max_length=50)
post_body = models.CharField(max_length=500)
pub_date = models.DateTimeField("Date Published", auto_now=True)
pub_date = models.DateField(auto_now=True)
author = models.ForeignKey(
'homepage.WidgetUser',
on_delete=models.CASCADE
)
def __str__(self):
return '{}'.format(self.post_title)
\ No newline at end of file
return '{}'.format(self.post_title)
@property
def post_detail(self):
post = '<br>{} by {} dated {}:'.format(self.post_title, self.author.forum_name, self.pub_date)
post += '<br>{}'.format(self.post_body)
return post
class Reply(models.Model):
reply_body = models.CharField(max_length=500)
pub_date = models.DateField(auto_now=True)
author = models.ForeignKey(
'homepage.WidgetUser',
on_delete=models.CASCADE
)
post = models.ForeignKey(
Post,
on_delete=models.CASCADE,
related_name="comments"
)
def __str__(self):
return 'Reply dated {}'.format(self.pub_date)
@property
def reply_detail(self):
reply = '<br>Reply by {} {} dated {}:'.format(self.author.first_name, self.author.last_name, self.pub_date)
reply += '<br>{}'.format(self.reply_body)
return reply
@property
def associated_post(self):
return '{}'.format(self.post.__str__)
from django.shortcuts import render
from django.http import HttpResponse
from .models import Post, Reply
# Create your views here.
def index(request):
return HttpResponse("Welcome to Widget's Forum!")
def post_list():
final_list = ''
for p in range(len(Post.objects.all())):
final_list += '{}'.format(Post.objects.get(pk=p+1).post_detail)
reply_list = list(Reply.objects.filter(post__exact=Post.objects.get(pk=p+1)))
for r in range(len(reply_list)):
final_list += '{}'.format(reply_list[r].reply_detail)
final_list += '<br>'
return final_list
html = f'''
<html>
<body>
<h1>FORUM POSTS:</h1>
<main>
<p>{post_list()}</p>
</main>
</body>
</html>
'''
return HttpResponse(html)
from django.contrib import admin
from .models import WidgetUser, Department
# Register your models here.
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Department, DepartmentAdmin)
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-03-23 14:37
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
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)),
],
),
]
# Generated by Django 4.0.3 on 2022-04-04 12:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
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=50)),
('home_unit', models.CharField(max_length=50)),
],
),
migrations.AddField(
model_name='widgetuser',
name='email',
field=models.EmailField(default=1, max_length=254),
preserve_default=False,
),
migrations.AddField(
model_name='widgetuser',
name='id_num',
field=models.CharField(default=1, max_length=7),
preserve_default=False,
),
]
# Generated by Django 4.0.3 on 2022-04-04 12:47
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_department_widgetuser_email_widgetuser_id_num'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='homepage.department'),
preserve_default=False,
),
]
from django.db import models
# Create your models here.
class Department(models.Model):
dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=50)
@property
def dept_info(self):
return '{}, {}'.format(self.dept_name, self.home_unit)
def __str__(self):
return '{}'.format(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)
id_num = models.CharField(max_length=7)
email = models.EmailField()
department = models.ForeignKey(Department, on_delete = models.CASCADE)
@property
def forum_name(self):
return '{} {}'.format(self.first_name, self.last_name)
@property
def user_info(self):
user = '<br>{}, {} {}: '.format(self.last_name, self.first_name, self.middle_name)
user += '{}, {}, {}'.format(self.id_num, self.email, self.department.dept_info)
return user
def __str__(self):
return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name)
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import WidgetUser
def index(request):
return HttpResponse('Welcome to Widget!')
def user_list():
final_list = ''
for u in range(len(WidgetUser.objects.all())):
final_list += '{}'.format(WidgetUser.objects.get(pk=u+1).user_info)
return final_list
html = f'''
<html>
<body>
<header><h1>WIDGET USERS:</h1><header>
<main>
<p>{user_list()}</p>
</main>
</body>
</html>
'''
return HttpResponse(html)
......@@ -62,7 +62,7 @@ ROOT_URLCONF = 'widget_group_23.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......
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