Commit e785edfd authored by Colleen's avatar Colleen

Merge branch 'main' of...

Merge branch 'main' of https://gitlab.discs.ateneo.edu/nealrodriguez/midterm_gitgud into add_announcement
parents 10200956 d7e22042
......@@ -2,7 +2,7 @@ CSCI 40-F
Group Members:
205828 CASTILLO, Gareth Xerxes
GARCIA, Ann Colleen
OLIVARES, Christian Louis
193636 OLIVARES, Christian Louis
204374 RODRIGUEZ, Neal Luigi D.
204655 SEE, Eurydice Gabrielle Madison O.
......@@ -22,3 +22,4 @@ CALENDAR-Olivares
[Signatures]
(sgd) Gareth Xerxes Yap Castillo March 5, 2023
(sgd) Neal Luigi RODRIGUEZ March 5, 2023
(sgd) Christian Louis Olivares March 5, 2023
\ No newline at end of file
......@@ -41,6 +41,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'Dashboard',
'widgetcalendar',
'Announcement_Board',
]
......
......@@ -3,6 +3,7 @@ from django.urls import include, path
urlpatterns = [
path('Dashboard/', include('Dashboard.urls', namespace="Dashboard")),
path('widgetcalendar/', include('widgetcalendar.urls', namespace="calendar")),
path('Announcement/', include('Announcement_Board.urls', namespace="Announcement_Board")),
path('admin/', admin.site.urls),
]
\ No newline at end of file
from django.contrib import admin
from .models import Location, Event
class LocationAdmin(admin.ModelAdmin):
model = Location
list_display = ('mode', 'venue')
class Eventadmin(admin.ModelAdmin):
model = Event
list_display = ('target_datetime', 'activity', 'estimated_hours', 'location', 'course')
# registering the model and the admin is what tells
# Django that admin pages must be generated for the models specified
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 = 'widgetcalendar'
# Generated by Django 4.1.7 on 2023-03-02 12:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('onsite', 'onsite'), ('online', 'online'), ('hybrid', 'hybrid')], max_length=6)),
('venue', models.CharField(default='', max_length=50)),
],
),
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField()),
('activity', models.CharField(default='', max_length=100)),
('estimated_hours', models.FloatField()),
('course', models.CharField(max_length=50)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='course_name', to='widgetcalendar.location')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-04 06:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widgetcalendar', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='location',
name='venue',
field=models.TextField(default='', max_length=200),
),
]
from django.db import models
from django.urls import reverse
#FOR LUIGI: PLS UNCOMMENT WHEN YOU'RE DONE WITH YOUR APPS
#from assignments.models import Course
class Location(models.Model):
MODE_CHOICES = (
('onsite', 'onsite'),
('online', 'online'),
('hybrid', 'hybrid'),
)
mode = models.CharField(max_length=6, choices=MODE_CHOICES)
venue = models.TextField(max_length=200, default='')
def __str__(self):
return '{}, {} mode'.format(self.venue, self.mode)
def get_absolute_url(self):
return reverse('location_detail', args=[str(self.venue)])
class Event(models.Model):
target_datetime= models.DateTimeField()
activity = models.TextField(max_length=200, default='')
estimated_hours = models.FloatField()
location = models.ForeignKey(
Location,
on_delete=models.CASCADE,
related_name='course_name'
)
#FOR LUIGI: IF YOU'RE DONE PLS REPLACE THE CURRENT CODE FOR COURSE WITH THE COMMENTED ONE
# course = models.ForeignKey(
# Course,
# on_delete=models.CASCADE,
# related_name='course_name'
# )
course = models.CharField(max_length=50)
def __str__(self):
return '{}'.format(self.activity)
def get_absolute_url(self):
return reverse('event_detail', args=[str(self.activity)])
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 = "widgetcalendar"
\ No newline at end of file
from django.http import HttpResponse
from .models import Event
#Date format source: https://ourcodeworld.com/articles/read/555/how-to-format-datetime-objects-in-the-view-and-template-in-django
def index(request):
return_string = ''
for events in Event.objects.all():
return_string += 'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Secion: {}<br>Mode: {}<br>Venue: {}<br></br>'.format(
events.target_datetime.strftime("%x, %I:%M %p"), events.activity, events.estimated_hours, events.course, events.location.mode, events.location.venue
)
html_string = '<html><head>Widget\'s Calendar of Activities<br></br></head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
\ 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