Commit da596da1 authored by Deokhyun Lee's avatar Deokhyun Lee

code general format is now clear and concise.

parent f88bc03e
File added
from django.contrib import admin
from .models import Announcement, Reaction
class ReactionInline(admin.TabularInline):
model = Reaction
# admin panel for Announcemnet model
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
......@@ -12,6 +14,7 @@ class AnnouncementAdmin(admin.ModelAdmin):
list_filter = ('title', 'author', 'pub_datetime',)
inlines = [ReactionInline,]
# admin panel for Reaction model
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
......@@ -19,6 +22,5 @@ class ReactionAdmin(admin.ModelAdmin):
list_display = ('name', 'tally', 'announcement',)
list_filter = ('name', 'tally',)
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
from django.db import models
from dashboard.models import WidgetUser
# Announcement
# title; body; author; pub_datetime
class Announcement(models.Model):
title = models.CharField(max_length=50)
body = models.TextField(max_length=420)
......@@ -10,6 +12,9 @@ class Announcement(models.Model):
def __str__(self):
return self.title
# Reaction
# name; tally; announcement;
class Reaction(models.Model):
name = models.CharField(max_length=100)
tally = models.IntegerField(default=0)
......
#announcements/urls.py
from django.urls import path
from .import views
urlpatterns = [
# url for announcement
urlpatterns = [
path("", views.announcement_boardIndex, name = "announcement_boardIndex")
]
app_name = "announcement_board"
\ No newline at end of file
......@@ -2,6 +2,7 @@ from django.http import HttpResponse
from .models import Announcement, Reaction
# announcemnet view from .models
def announcement_boardIndex(request):
announcements = Announcement.objects.all()
reactions = Reaction.objects.all()
......
from django.urls import path
from . import views
# url for homepage
# url for assignments
urlpatterns = [
path('', views.index, name='index'),
path('', views.assignmentIndex, name='assignmentIndex'),
]
\ No newline at end of file
from django.http import HttpResponse
from .models import Assignment, Course
from .models import Assignment
# Create your views here.
def index(request):
# assignment view from .models
def assignmentIndex(request):
title = "Widget's Assignments Page" + "<br><br>"
assignments = Assignment.objects.all()
# courses = Course.objects.all()
output_view = ""
for assignment in assignments:
name = "Assignment Name: " + assignment.name + "<br>"
......
from django.db import models
from assignments.models import Course
#Location Choices
# Location Choices
location_choices = [
('onsite', 'ONSITE'),
('online', 'ONLINE'),
......@@ -11,9 +11,8 @@ location_choices = [
# Location
# mode; venue;
class Location(models.Model):
mode = models.CharField(max_length=50, choices = location_choices, default = 'onsite')
venue = models.TextField(max_length=50)
mode = models.CharField(max_length = 50, choices = location_choices, default = 'onsite')
venue = models.TextField(max_length = 50)
def __str__(self):
return self.venue
......@@ -21,11 +20,11 @@ class Location(models.Model):
# Event
# target_datetime; activity; estimated_hours; location; course
class Event(models.Model):
target_datetime = models.DateTimeField("Date and Time: ", max_length=50)
activity = models.CharField("Activity: ",max_length=50)
estimated_hours = models.FloatField("Estimated Hours: ",max_length=50)
location = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.ForeignKey(Course, on_delete=models.CASCADE)
target_datetime = models.DateTimeField("Date and Time: ", max_length = 50)
activity = models.CharField("Activity: ", max_length = 50)
estimated_hours = models.FloatField("Estimated Hours: ", max_length = 50)
location = models.ForeignKey(Location, on_delete = models.CASCADE)
course = models.ForeignKey(Course, on_delete = models.CASCADE)
def __str__(self):
return self.activity
......
from django.urls import path
from . import views
# url for homepage
# url for calendar
urlpatterns = [
path('', views.calendarIndex, name='calendarIndex'),
]
\ No newline at end of file
from django.http import HttpResponse
from .models import Event, Location
# calendar view from .models
def calendarIndex(request):
title = 'Widget’s Calendar of Activities<br><br>'
events = Event.objects.all()
......
from django.db import models
# Created Department model
# Department
# dept_name; home_unit
class Department(models.Model):
dept_name = models.CharField(max_length = 100)
home_unit = models.CharField(max_length = 100)
......@@ -10,7 +11,8 @@ class Department(models.Model):
# Created WidgetUser model
# WidgetUser
# first_name; middle_name; last_name; department;
class WidgetUser(models.Model):
first_name = models.CharField(max_length = 50)
middle_name = models.CharField(max_length = 50)
......
......@@ -3,9 +3,8 @@
from django.urls import path
from .import views
# url for dashboard
urlpatterns = [
path("", views.dashboardIndex, name = "dashboardIndex")
]
app_name = "dashboard"
\ No newline at end of file
from django.http import HttpResponse
from .models import Department, WidgetUser
# dashboard view from .models
def dashboardIndex(request):
users = WidgetUser.objects.all()
departments = Department.objects.all()
......@@ -11,9 +12,6 @@ def dashboardIndex(request):
home_department = str(user.department)
dashboard_output = dashboard_output + username + ": " + home_department + "<br>"
return HttpResponse(dashboard_output)
......
......@@ -4,13 +4,13 @@ from .models import ForumPost, Reply
class ReplyInLine(admin.TabularInline):
model = Reply
# admin panel for Forum model
class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost
list_display = ("title", "author", "body", "pub_datetime")
inlines = [ReplyInLine]
# admin panel for Reply model
class ReplyAdmin(admin.ModelAdmin):
list_display = ("forum_post", "author", "body", "pub_datetime")
......
from django.db import models
from dashboard.models import WidgetUser
# Forum Post
# title; body; author; pub_datetime;
class ForumPost(models.Model):
title = models.CharField(max_length = 50)
body = models.TextField(max_length = 1000)
......@@ -10,7 +12,8 @@ class ForumPost(models.Model):
def __str__(self):
return self.title
# Reply
# body; author; pub_datetime; forum_post;
class Reply(models.Model):
body = models.CharField(max_length=1000)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
......
from django.urls import path
from . import views
# url for forum
urlpatterns = [
path("", views.forumIndex, name="forumIndex"),
]
\ No newline at end of file
from django.http import HttpResponse
from .models import ForumPost, Reply
# forum view from .models
def forumIndex(request):
# fetch forum posts and 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