Commit 39f72de6 authored by Jonathan Talbot's avatar Jonathan Talbot

Merge branch 'main' into 'devera/announcements'

# Conflicts:
#   widget_group3/widget_group3/admin.py
#   widget_group3/widget_group3/models.py
#   widget_group3/widget_group3/settings.py
parents 236751c1 b1fd71ae
No preview for this file type
from django.contrib import admin
from .models import Announcement
from .models import WidgetUser, Forum, Announcement
# Classes
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
......@@ -17,5 +20,29 @@ class AnnouncementAdmin(admin.ModelAdmin):
})
]
#Register models
admin.site.register(Announcement, AnnouncementAdmin)
\ No newline at end of file
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
search_fields = ('first_name', 'middle_name', 'last_name')
list_display = ('first_name', 'middle_name', 'last_name')
list_filter = ('first_name', 'middle_name', 'last_name')
fieldsets = [
('Widget User Data', {
'fields': [
'first_name',
'middle_name',
'last_name'
]
}),
]
# Register models
admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Forum, ForumAdmin)
admin.site.register(Announcement, AnnouncementAdmin)
......@@ -14,4 +14,42 @@ class Announcement(models.Model):
@property
def full_announcement(self):
return '{} {} {}'.format(self.announcement_title, self.announcement_body, self.pub_date)
\ No newline at end of file
return '{} {} {}'.format(self.announcement_title, self.announcement_body, self.pub_date)
class Forum(models.Model):
post_title = models.CharField(max_length=50)
post_body = models.CharField(max_length=100)
pub_date = models.DateTimeField(auto_now_add=True, editable=False)
def __str__(self):
return self.post_title
def get_absolute_url(self):
return reverse('forum', args=[(self.post_title)])
class WidgetUser(models.Model):
first_name = models.CharField(max_length=100)
middle_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
def __str__(self):
return self.full_name
def get_absolute_url(self):
return reverse('widget_user', args=[(self.full_name)])
@property
def full_name(self):
return '{} {} {}'.format(self.first_name, self.middle_name, self.last_name)
class Assignment(models.Model):
name = models.CharField(max_length = 100)
description = models.CharField(max_length = 200)
max_points = models.IntegerField()
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('assignment', args[(self.name)])
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