Commit 23ff524b authored by Ian Rafael T. Aragoza's avatar Ian Rafael T. Aragoza

Merge branch 'announcementboard_feature' into dashboard_feature

parents d68c8695 b35c0529
from django.contrib import admin from django.contrib import admin
from .models import Announcement, Reaction
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
search_fields = ('title','author')
list_display = ('title', 'author', 'pub_datetime', 'body')
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
search_fields = ('name', 'announcement')
list_display = ('announcement', 'name', 'tally')
# Register your models here. # Register your models here.
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
from django.db import models from django.db import models
from django.urls import reverse
from dashboard.models import WidgetUser
# Create your models here. # Create your models here.
class Announcement(models.Model):
title = models.CharField(max_length=255)
body = models.TextField()
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
def __str__(self):
return '{}'.format(self.title)
def get_absolute_url(self):
return reverse('announcement_detail', args=[str(self.title)])
class Reaction(models.Model):
name = models.CharField(max_length=255)
tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE)
def __str__(self):
return '{}'.format(self.name)
def get_absolute_url(self):
return reverse('reaction_detail', args=[str(self.name)])
...@@ -4,4 +4,4 @@ from django.http import HttpResponse ...@@ -4,4 +4,4 @@ from django.http import HttpResponse
# Create your views here. # Create your views here.
def index(request): def index(request):
return HttpResponse('Announcement Board app.') return HttpResponse("Widget's Announcement Board <br> Announcements: <br>")
...@@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/4.1/ref/settings/ ...@@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv from dotenv import load_dotenv
import os import os
load_dotenv() load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
......
...@@ -17,8 +17,8 @@ from django.contrib import admin ...@@ -17,8 +17,8 @@ from django.contrib import admin
from django.urls import include, path 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('announcementboard/', include('announcementboard.urls', namespace="announcementboard")),
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