Commit 315f6a32 authored by Ian Rafael T. Aragoza's avatar Ian Rafael T. Aragoza

Update README.txt, clean more code to PEP8 standards, change announcementboard app URL

parent 3fcde7bc
...@@ -6,7 +6,7 @@ from .models import Announcement, Reaction ...@@ -6,7 +6,7 @@ from .models import Announcement, Reaction
class AnnouncementAdmin(admin.ModelAdmin): class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement model = Announcement
search_fields = ('title','author') search_fields = ('title', 'author')
list_display = ('title', 'author', 'pub_datetime', 'body') list_display = ('title', 'author', 'pub_datetime', 'body')
...@@ -21,4 +21,4 @@ class ReactionAdmin(admin.ModelAdmin): ...@@ -21,4 +21,4 @@ class ReactionAdmin(admin.ModelAdmin):
# Register your models here. # Register your models here.
admin.site.register(Announcement, AnnouncementAdmin) admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin) admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
...@@ -9,7 +9,7 @@ class Announcement(models.Model): ...@@ -9,7 +9,7 @@ class Announcement(models.Model):
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
body = models.TextField() body = models.TextField()
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, related_name="announcements") author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, related_name="announcements")
pub_datetime = models.DateTimeField(verbose_name="Posted On", auto_now_add=True) pub_datetime = models.DateTimeField(verbose_name="Posted On", auto_now_add=True)
def __str__(self): def __str__(self):
return '{}'.format(self.title) return '{}'.format(self.title)
......
...@@ -7,4 +7,4 @@ urlpatterns = [ ...@@ -7,4 +7,4 @@ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
] ]
app_name = "announcementboard" app_name = "announcementboard"
\ No newline at end of file
from django.contrib import admin from django.contrib import admin
from .models import Department, WidgetUser from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin): class DepartmentAdmin(admin.ModelAdmin):
model = Department model = Department
list_display = ('dept_name', 'home_unit',) list_display = ('dept_name', 'home_unit',)
search_fields = ('dept_name',) search_fields = ('dept_name',)
list_filter = ('home_unit',) list_filter = ('home_unit',)
class UserAdmin(admin.ModelAdmin): class UserAdmin(admin.ModelAdmin):
model = WidgetUser model = WidgetUser
list_display = ('last_name', 'first_name', 'middle_name', 'department',) list_display = ('last_name', 'first_name', 'middle_name', 'department',)
...@@ -14,13 +16,13 @@ class UserAdmin(admin.ModelAdmin): ...@@ -14,13 +16,13 @@ class UserAdmin(admin.ModelAdmin):
list_filter = ('department',) list_filter = ('department',)
fieldsets = [ fieldsets = [
('Name', { ('Name', {
'fields': [ 'fields': [
# the tuple puts these fields in a single line ('last_name', 'first_name', 'middle_name'), 'department'
('last_name', 'first_name', 'middle_name'), 'department'
] ]
}), }),
] ]
admin.site.register(Department, DepartmentAdmin) admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, UserAdmin) admin.site.register(WidgetUser, UserAdmin)
\ No newline at end of file
...@@ -7,4 +7,4 @@ urlpatterns = [ ...@@ -7,4 +7,4 @@ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
] ]
app_name = "dashboard" app_name = "dashboard"
\ No newline at end of file
...@@ -6,7 +6,7 @@ from .models import WidgetUser ...@@ -6,7 +6,7 @@ from .models import WidgetUser
# Create your views here. # Create your views here.
def index(request): def index(request):
output = "Welcome to Widget!<br><br> WIDGET USERS:<br>" output = "<h1>Welcome to Widget!</h1><h3>WIDGET USERS:</h3>"
userList = WidgetUser.objects.order_by('last_name') userList = WidgetUser.objects.order_by('last_name')
output += '<br>'.join(['{}, {} {}: {}, {}'.format(user.last_name, user.first_name, user.middle_name, user.department, user.department.home_unit) for user in userList]) output += '<br>'.join(['{}, {} {}: {}, {}'.format(user.last_name, user.first_name, user.middle_name, user.department, user.department.home_unit) for user in userList])
return HttpResponse(output) return HttpResponse(output)
...@@ -18,7 +18,7 @@ from django.urls import include, path ...@@ -18,7 +18,7 @@ from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('dashboard/', include('dashboard.urls', namespace="dashboard")), path('dashboard/', include('dashboard.urls', namespace="dashboard")),
path('announcementboard/', include('announcementboard.urls', namespace="announcementboard")), path('announcements/', include('announcementboard.urls', namespace="announcements")),
path('forum/', include('forum.urls', namespace="forum")), path('forum/', include('forum.urls', namespace="forum")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
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