Changed output views and added admin

parent 2bf6795a
......@@ -2,4 +2,20 @@ from django.contrib import admin
from .models import Event, Location
class EventInline(admin.TabularInline):
model = Event
class WidgetUserAdmin(admin.ModelAdmin):
model = Event
list_display = ('last_name', 'first_name', 'department')
search_fields = ('last_name', 'first_name', 'department')
list_filter = ('last_name', 'department')
fieldsets = [
('Name', {
'fields':
(('last_name', 'first_name'), 'middle_name', 'department',),
}),
]
from django.db import models
from datetime import datetime
class Event(models.Model):
target_datetime = models.CharField(max_length=100, default="")
target_datetime = models.DateTimeField(default=datetime.now())
activity = models.CharField(max_length=100, default="")
estimated_hours = models.FloatField(default=0)
location = models.CharField(max_length=100, default="")
course = models.CharField(max_length=100, default="")
def __str__(self):
return '{}, {}'.format(self.dept_name, self.home_unit)
return "Widget’s Calendar of Activities"
"Date and Time: {}"
'Activity: {}'
'Estimated Hours: {}'
'Course/Section: {}'.format(self.target_datetime, self.activity, self.estimated_hours, self.course)
class Location(models.Model):
......@@ -17,4 +22,4 @@ class Location(models.Model):
venue = models.CharField(max_length=100, default="")
def __str__(self):
return '{}, {}'.format(self.mode, self.venue)
\ No newline at end of file
return '{} {}'.format(self.mode, self.venue)
from django.shortcuts import render
from django.http import HttpResponse
from .models import Event, Location
def index(request):
......@@ -12,16 +14,17 @@ def index(request):
body = ""
for event in Event.objects.all():
body += "<p style='border: 2px solid gray;\
border-radius:5px;\
padding:20px 30px;'>\
{}<br>\
</p>".format(event)
return_string = "<html>\
<body style = 'font-family:helvetica;\
padding:30px;'>\
{}{}\
</body></html>".format(head, body)
return HttpResponse("Widget’s Calendar of Activities<br>"
"Date and Time: <target date>, <target time><br>"
"Activity: <activity><br>"
"Estimated Hours: <estimated hours><br>"
"Course/Section: <course_code> <course_title>-<section><br>"
"Mode: <mode><br>"
"Venue: <venue><br>")
return HttpResponse(return_string)
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