Changed admin properties and models string output

parent 1b927ea1
...@@ -6,16 +6,38 @@ class EventInline(admin.TabularInline): ...@@ -6,16 +6,38 @@ class EventInline(admin.TabularInline):
model = Event model = Event
class WidgetUserAdmin(admin.ModelAdmin): class EventAdmin(admin.ModelAdmin):
model = Event model = Event
list_display = ('last_name', 'first_name', 'department') list_display = ('target_datetime', 'activity', 'estimated_hours', 'location')
search_fields = ('last_name', 'first_name', 'department') search_fields = ('target_datetime', 'activity', 'estimated_hours', 'location')
list_filter = ('last_name', 'department') list_filter = ('target_datetime', 'location')
fieldsets = [ fieldsets = [
('Name', { ('Event', {
'fields': 'fields':
(('last_name', 'first_name'), 'middle_name', 'department',), (('target_datetime', 'activity'), 'estimated_hours', 'location',),
}), }),
] ]
class LocationAdmin(admin.ModelAdmin):
model = Location
list_display = ('mode', 'venue')
search_fields = ('mode', 'venue')
list_filter = ('mode', 'venue')
fieldsets = [
('Mode & Venue', {
'fields':
('mode', 'venue')
})
]
inlines = [EventInline, ]
admin.site.register(Event, EventAdmin)
admin.site.register(Location, LocationAdmin)
\ No newline at end of file
...@@ -2,24 +2,24 @@ from django.db import models ...@@ -2,24 +2,24 @@ from django.db import models
from datetime import datetime from datetime import datetime
class Location(models.Model):
mode = models.CharField(max_length=100, default="")
venue = models.CharField(max_length=100, default="")
def __str__(self):
return '{} {}'.format(self.mode, self.venue)
class Event(models.Model): class Event(models.Model):
target_datetime = models.DateTimeField(default=datetime.now()) target_datetime = models.DateTimeField(default=datetime.now())
activity = models.CharField(max_length=100, default="") activity = models.CharField(max_length=100, default="")
estimated_hours = models.FloatField(default=0) estimated_hours = models.FloatField(default=0)
location = models.CharField(max_length=100, default="")
course = models.CharField(max_length=100, default="") course = models.CharField(max_length=100, default="")
location = models.ForeignKey(
Location,
on_delete=models.CASCADE,
related_name='Venue'
)
def __str__(self): def __str__(self):
return "Widget’s Calendar of Activities" return "{} {} {} {}".format(self.target_datetime, self.activity, self.estimated_hours, self.course, self.location)
"Date and Time: {}"
'Activity: {}'
'Estimated Hours: {}'
'Course/Section: {}'.format(self.target_datetime, self.activity, self.estimated_hours, self.course)
class Location(models.Model):
mode = models.CharField(max_length=100, default="")
venue = models.CharField(max_length=100, default="")
def __str__(self):
return '{} {}'.format(self.mode, self.venue)
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