Commit 7a7145c0 authored by Ysabella Panghulan's avatar Ysabella Panghulan

Merged widget_calendar branch to main

parents 0eb6540c 1ebdde8c
from django.contrib import admin
from .models import Event, Location
# Register your models here.
class LocationAdmin(admin.ModelAdmin):
model = Location
list_display = ('mode', 'venue',)
search_fields = ('venue',)
list_filter = ('mode',)
class EventAdmin(admin.ModelAdmin):
model = Event
list_display = ('activity','target_datetime', 'estimated_hours','location', 'course',)
search_fields = ('activity','course','location',)
list_filter = ('activity','target_datetime', 'course','location',)
admin.site.register(Location, LocationAdmin)
admin.site.register(Event, EventAdmin)
\ No newline at end of file
from django.apps import AppConfig
class WidgetCalendarConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'widget_calendar'
from django.db import models
from assignments.models import Course
# Create your models here.
class Location(models.Model):
LOCATION_CHOICES = (
('onsite', 'Onsite'),
('online', 'Online'),
('hybrid', 'Hybrid'),
)
mode = models.CharField(max_length = 10, choices = LOCATION_CHOICES)
venue = models.TextField(null = True, blank = True)
def __str__(self):
return self.venue
class Event(models.Model):
target_datetime = models.DateTimeField('target date')
activity = models.TextField()
estimated_hours = models.FloatField()
location = models.ForeignKey(Location, on_delete = models.CASCADE)
course = models.ForeignKey(Course, on_delete = models.CASCADE)
def __str__(self):
return self.activity
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='calendar'),
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Location, Event
# Create your views here.
def index(request):
events = Event.objects.all()
welcomeMessage = 'Widget’\s Calendar of Activities <br><br>'
activities = ''
for event in events:
activities += 'Date and Time: ' + event.target_datetime.strftime('%m/%d/%Y, %I:%M%p') + '<br>'
activities += 'Activity: '+ event.activity + '<br>'
activities += 'Estimated Hours: ' + str(event.estimated_hours) + '<br>'
activities += 'Course/Section: ' + event.course.code + ' ' + event.course.title + '-' + event.course.section + '<br>'
activities += 'Mode: ' + event.location.mode + '<br>'
activities += 'Venue: ' + event.location.venue + '<br><br>'
return HttpResponse(welcomeMessage + activities)
\ No newline at end of file
...@@ -35,7 +35,11 @@ ALLOWED_HOSTS = [] ...@@ -35,7 +35,11 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
<<<<<<< HEAD
'dashboard', 'dashboard',
=======
'widget_calendar.apps.WidgetCalendarConfig',
>>>>>>> widget_calendar
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
......
...@@ -17,7 +17,11 @@ from django.contrib import admin ...@@ -17,7 +17,11 @@ from django.contrib import admin
from django.urls import include, path from django.urls import include, path
urlpatterns = [ urlpatterns = [
<<<<<<< HEAD
path('forum/', include("forum.urls", namespace = "forum")), path('forum/', include("forum.urls", namespace = "forum")),
path('dashboard/', include('dashboard.urls', namespace = "dashboard")), path('dashboard/', include('dashboard.urls', namespace = "dashboard")),
=======
path('calendar/', include('widget_calendar.urls')),
>>>>>>> widget_calendar
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