cache commit:

parent 4009b2fb
......@@ -15,4 +15,4 @@ class ReactionAdmin(admin.ModelAdmin):
model = Reaction
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
admin.site.register(Reaction, ReactionAdmin )
\ No newline at end of file
# Generated by Django 3.2.12 on 2022-04-05 11:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0017_alter_announcement_pub_date'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_date',
field=models.DateField(auto_now_add=True, null=True, verbose_name='date published'),
),
]
# Generated by Django 3.2.12 on 2022-04-05 11:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0018_alter_announcement_pub_date'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_date',
field=models.DateTimeField(null=True, verbose_name='date published'),
),
]
# Generated by Django 3.2.12 on 2022-04-05 11:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0019_alter_announcement_pub_date'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_date',
field=models.DateField(auto_now_add=True, null=True, verbose_name='date published'),
),
]
# Generated by Django 3.2.12 on 2022-04-05 13:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0020_alter_announcement_pub_date'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_date',
field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='date published'),
),
]
# Generated by Django 3.2.12 on 2022-04-05 13:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0021_alter_announcement_pub_date'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_date',
field=models.DateField(auto_now_add=True, null=True, verbose_name='date published'),
),
]
......@@ -5,12 +5,12 @@ from homepage.models import WidgetUser
class Announcement(models.Model):
announcement_title = models.CharField(max_length=50)
announcement_body = models.CharField(max_length=500)
pub_date = models.DateTimeField("date published", null=True)
pub_date = models.DateField("date published", null=True, auto_now_add=True)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=True, related_name='author')
def __str__(self):
return self.announcement_title
class Reaction(models.Model):
Announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, null=True, related_name='announcements')
reaction_name = models.CharField(max_length=50)
......
......@@ -17,7 +17,7 @@ def getReactions(pk):
announcementReactions = ""
for reaction in Announcement.objects.get(pk=pk).announcements.all():
announcementReactions += "{}: {}<br/>" .format(reaction.reaction_name, reaction.tally)
announcementReactions += "<br/>"
announcementReactions += "<br/> "
return announcementReactions
# helper function that takes the data in an announcement and creates the header of the announcement
......
from django.contrib import admin
# Register your models here.
from .models import Assignment
from .models import Assignment, Course
admin.site.register(Assignment)
admin.site.register(Course)
# Generated by Django 3.2.12 on 2022-03-31 17:48
from django.db import migrations, models
import django.db.models.deletion
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=100)),
('section', models.CharField(max_length=3)),
],
),
migrations.AddField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='assignment',
name='course',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='assignments', to='assignments.course'),
),
]
# Generated by Django 3.2.12 on 2022-03-31 18:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_auto_20220401_0148'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0, null=True),
),
]
# Generated by Django 3.2.12 on 2022-03-31 18:02
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('assignments', '0003_alter_assignment_passing_score'),
]
operations = [
migrations.RemoveField(
model_name='assignment',
name='course',
),
migrations.RemoveField(
model_name='assignment',
name='passing_score',
),
migrations.DeleteModel(
name='Course',
),
]
# Generated by Django 3.2.12 on 2022-03-31 18:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0004_auto_20220401_0202'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0),
),
]
# Generated by Django 3.2.12 on 2022-03-31 18:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0005_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0, null=True),
),
]
# Generated by Django 3.2.12 on 2022-03-31 18:13
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0006_alter_assignment_passing_score'),
]
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=100)),
('section', models.CharField(max_length=3)),
],
),
migrations.AddField(
model_name='assignment',
name='course_code',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
]
# Generated by Django 3.2.12 on 2022-03-31 18:17
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0007_auto_20220401_0213'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='course_code',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
]
# Generated by Django 3.2.12 on 2022-03-31 18:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0008_alter_assignment_course_code'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0, editable=False),
),
]
# Generated by Django 3.2.12 on 2022-04-01 03:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0009_alter_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(),
),
]
# Generated by Django 3.2.12 on 2022-04-01 03:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0010_alter_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(editable=False),
),
]
# Generated by Django 3.2.12 on 2022-04-01 03:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0011_alter_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(editable=False, null=True),
),
]
# Generated by Django 3.2.12 on 2022-04-01 04:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0012_alter_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.FloatField(null=True),
),
]
# Generated by Django 3.2.12 on 2022-04-01 09:10
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('assignments', '0013_alter_assignment_passing_score'),
]
operations = [
migrations.RemoveField(
model_name='assignment',
name='passing_score',
),
]
# Generated by Django 3.2.12 on 2022-04-01 09:48
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('assignments', '0014_remove_assignment_passing_score'),
]
operations = [
migrations.RemoveField(
model_name='assignment',
name='max_points',
),
]
# Generated by Django 3.2.12 on 2022-04-01 09:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0015_remove_assignment_max_points'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='max_points',
field=models.IntegerField(default=0),
),
]
# Generated by Django 3.2.12 on 2022-04-01 11:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0016_assignment_max_points'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0),
),
]
# Generated by Django 4.0.3 on 2022-04-05 09:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0017_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0, editable=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 = 100)
section = models.CharField(max_length = 3)
def __str__(self):
return str(self.course_code)
class Assignment(models.Model):
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 500)
max_points = models.IntegerField(default=0)
passing_score = models.IntegerField(default = 0, editable =False)
course_code = models.ForeignKey(Course, on_delete=models.CASCADE, null = True, blank = True)
def save(self):
self.passing_score = int(self.max_points * 0.6)
return super(Assignment, self).save()
def __str__(self):
return self.name
return str(self.name)
from django.http import HttpResponse
from assignments.models import Assignment, Course
# Create your views here.
def index(request):
return HttpResponse("This is the Assignments page!")
assignmentCount = Assignment.objects.all().count()
assignmentOutput = "Assignments: <br/><br/>"
n = assignmentCount
for n in Assignment.objects.all():
assignmentOutput += ("Assignment Name: " + str(n.name) + "<br/>")
assignmentOutput += ("Description: " + n.description + "<br/>")
assignmentOutput += ("Perfect Score: " + str(n.max_points) + "<br/>")
assignmentOutput += ("Passing Score: " + str(n.passing_score) + "<br/>")
assignmentOutput += ("Course/Section: " + Course.objects.get(course_code = n.course_code).course_code + " ")
assignmentOutput += (Course.objects.get(course_code = n.course_code).course_title + " ")
assignmentOutput += (Course.objects.get(course_code = n.course_code).section + "<br/><br/>")
return HttpResponse(assignmentOutput)
from django.contrib import admin
# Register your models here.
from .models import Post
from .models import Post, Reply
admin.site.register(Post)
class ReplyAdminInline(admin.TabularInline):
model = Reply
class PostAdmin(admin.ModelAdmin):
model = Post
inlines = [ReplyAdminInline]
class ReplyAdmin(admin.ModelAdmin):
model = Reply
admin.site.register(Post, PostAdmin)
admin.site.register(Reply, ReplyAdmin)
# Generated by Django 4.0.3 on 2022-04-05 09:36
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_widgetuser_email_widgetuser_id_num_department'),
('forum', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='post',
name='author',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='post_author', 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)),
('reply_pub_date', models.DateTimeField(verbose_name='date published')),
('post', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='posts', to='forum.post')),
('reply_author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reply_author', to='homepage.widgetuser')),
],
),
]
# Generated by Django 4.0.3 on 2022-04-05 10:13
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('forum', '0002_post_author_reply'),
]
operations = [
migrations.RenameField(
model_name='post',
old_name='author',
new_name='post_author',
),
]
# Generated by Django 4.0.3 on 2022-04-05 10:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0003_rename_author_post_post_author'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateField(verbose_name='date published'),
),
migrations.AlterField(
model_name='reply',
name='reply_pub_date',
field=models.DateField(verbose_name='date published'),
),
]
# Generated by Django 4.0.3 on 2022-04-05 10:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0004_alter_post_pub_date_alter_reply_reply_pub_date'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateTimeField(verbose_name='date published'),
),
migrations.AlterField(
model_name='reply',
name='reply_pub_date',
field=models.DateTimeField(verbose_name='date published'),
),
]
# Generated by Django 4.0.3 on 2022-04-05 10:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0005_alter_post_pub_date_alter_reply_reply_pub_date'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateField(verbose_name='date published'),
),
migrations.AlterField(
model_name='reply',
name='reply_pub_date',
field=models.DateField(verbose_name='date published'),
),
]
# Generated by Django 4.0.3 on 2022-04-05 10:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0006_alter_post_pub_date_alter_reply_reply_pub_date'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateField(auto_now_add=True, verbose_name='date published'),
),
migrations.AlterField(
model_name='reply',
name='reply_pub_date',
field=models.DateField(auto_now_add=True, verbose_name='date published'),
),
]
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")
pub_date = models.DateField("date published", auto_now_add=True)
post_author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=True, related_name='post_author')
def __str__(self):
return self.post_title
class Reply(models.Model):
post = models.ForeignKey(Post, on_delete=models.CASCADE, null=True, related_name='posts')
reply_body = models.CharField(max_length=500)
reply_pub_date = models.DateField("date published", auto_now_add=True)
reply_author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=True, related_name='reply_author')
from django.http import HttpResponse
from forum.models import Post, Reply, WidgetUser
# Create your views here.
def index(request):
return HttpResponse("Welcome to Widget's Forum!")
entries = Post.objects.all().count()
n = 1
forum = "FORUM POSTS:<br/>"
while(n<=entries):
forum += getPost(n)
forum += getReply(n)
n += 1
return HttpResponse(forum)
def getPost(pk):
postFirstLine = ""
postSecondLine = ""
post = ""
postTitle = Post.objects.get(pk=pk).post_title
authorFirstName = Post.objects.get(pk=pk).post_author.first_name
authorLastName = Post.objects.get(pk=pk).post_author.last_name
publicationDate = Post.objects.get(pk=pk).pub_date
postBody = Post.objects.get(pk=pk).post_body
postFirstLine = "{} by {} {} dated {}:<br/>" .format(postTitle, authorFirstName, authorLastName, publicationDate)
postSecondLine = "{}<br/>" .format(postBody)
post += postFirstLine + postSecondLine
return post
def getReply(pk):
replies = ""
for reply in Post.objects.get(pk=pk).posts.all():
replies += "Reply by {} {} {}:<br/>{}" .format(reply.reply_author.first_name, reply.reply_author.last_name, reply.reply_pub_date, reply.reply_body)
replies += "<br/>"
replies += "<br/>"
return replies
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