Commit 7d1800ca authored by Jonathan Talbot's avatar Jonathan Talbot

Merge branch 'main' into 'flores/forum'

# Conflicts:
#   widget_group3/widget_group3/admin.py
#   widget_group3/widget_group3/models.py
#   widget_group3/widget_group3/settings.py
parents fb55de3f ab46f8c2
No preview for this file type
from django.contrib import admin
from .models import Forum
from .models import WidgetUser, Forum
# Classes
class ForumAdmin(admin.ModelAdmin):
model = Forum
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
search_fields = ('post_title', 'post_body', 'pub_date')
list_display = ('post_title', 'post_body', 'pub_date')
list_filter = ('post_title', 'post_body', 'pub_date')
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 = [
('Forum Data', {
('Widget User Data', {
'fields': [
'post_title',
'post_body',
'first_name',
'middle_name',
'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)])
# Register models
admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Forum, ForumAdmin)
......@@ -12,3 +12,18 @@ class Forum(models.Model):
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)
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