Commit e882c8f0 authored by Christianneil Emmanuel Ocampo's avatar Christianneil Emmanuel Ocampo

Merge branch 'calendar_feature' into 'master'

Calendar feature merged to master

See merge request !1
parents 01434ef2 b6d19d85
from django.contrib import admin
from .models import Event, Location
class EventAdmin(admin.ModelAdmin):
model = Event
search_fields = ('activity', 'course',)
list_display = ('activity', 'target_datetime','estimated_hours','location','course',)
list_filter = ('activity','location','course',)
class LocationAdmin(admin.ModelAdmin):
model = Location
search_fields = ('venue','mode',)
list_display = ('venue', 'mode',)
list_filter = ('venue',)
admin.site.register(Event, EventAdmin)
admin.site.register(Location, LocationAdmin)
\ No newline at end of file
from django.apps import AppConfig
class WidgetCalendarConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'widget_calendar'
# Generated by Django 4.1.7 on 2023-03-05 10:51
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField(default='')),
('activity', models.TextField(default='')),
('estimated_hours', models.FloatField(default='')),
('location', models.CharField(default='', max_length=255)),
('course', models.CharField(default='', max_length=255)),
],
),
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('OS', 'Onsite'), ('OL', 'Online'), ('HY', 'Hybrid')], default='OS', max_length=2)),
('venue', models.TextField(default='')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-05 11:49
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='event',
name='location',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_calendar.location'),
),
]
# Generated by Django 4.1.7 on 2023-03-05 12:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0002_alter_event_location'),
]
operations = [
migrations.AlterField(
model_name='location',
name='mode',
field=models.CharField(choices=[('onsite', 'Onsite'), ('online', 'Online'), ('hybrid', 'Hybrid')], default='onsite', max_length=6),
),
]
# Generated by Django 4.1.7 on 2023-03-05 12:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0003_alter_location_mode'),
]
operations = [
migrations.AlterField(
model_name='location',
name='mode',
field=models.CharField(choices=[('Onsite', 'Onsite'), ('Online', 'Online'), ('Hybrid', 'Hybrid')], default='Onsite', max_length=6),
),
]
# Generated by Django 4.1.7 on 2023-03-05 12:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0004_alter_location_mode'),
]
operations = [
migrations.AlterField(
model_name='location',
name='mode',
field=models.CharField(choices=[('onsite', 'Onsite'), ('online', 'Online'), ('hybrid', 'Hybrid')], default='onsite', max_length=6),
),
]
# Generated by Django 4.1.7 on 2023-03-05 18:22
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0003_alter_assignment_passing_score_and_more'),
('widget_calendar', '0005_alter_location_mode'),
]
operations = [
migrations.AlterField(
model_name='event',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
]
from django.db import models
from django.utils.translation import gettext_lazy as _
class Location(models.Model):
class Modality(models.TextChoices):
onsite = 'onsite', _('Onsite')
online = 'online', _('Online')
hybrid = 'hybrid', _('Hybrid')
mode = models.CharField(
max_length=6,
choices=Modality.choices,
default=Modality.onsite
)
venue = models.TextField(default='')
def __str__(self):
return '{} ({})'.format(self.venue, self.mode)
class Event(models.Model):
target_datetime = models.DateTimeField(default='')
activity = models.TextField(default='')
estimated_hours = models.FloatField(default='')
location = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.CharField(max_length=255, default='')
def __str__(self):
return '{} on {} at {}'.format(
self.activity,
self.target_datetime.strftime("%m/%d/%y"),
self.target_datetime.strftime("%I:%M %p"),
)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = "widget_calendar"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Event
def index(request):
return_string = '<p>Widget`s Calendar of Activities<br><br>'
for event in Event.objects.all():
event_string = '''
Date and Time: {}, {}<br>
Activity: {}<br>
Estimated Hours: {}<br>
Course/Section: {}<br>
Mode: {}<br>
Venue: {}<br>
'''.format(
event.target_datetime.strftime("%m/%d/%y"),
event.target_datetime.strftime("%I:%M %p"),
event.activity,
event.estimated_hours,
event.course,
event.location.mode,
event.location.venue
)
return_string += event_string
return_string += '</p>'
html_string = '<html><body>{}</body></html>'.format(return_string)
return HttpResponse(html_string)
\ No newline at end of file
......@@ -45,7 +45,7 @@ INSTALLED_APPS = [
#for announcement board
#for forum
'assignments',
#for calendar
'widget_calendar',
]
MIDDLEWARE = [
......
......@@ -21,6 +21,7 @@ urlpatterns = [
path('dashboard/', include('dashboard.urls', namespace='dashboard')),
#for announcement board
#for forum
#for assignments
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('assignments/', include('assignments.urls', namespace='assignments')),
#for calendar
]
\ No newline at end of file
]
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