Commit 21c92230 authored by Raul Jarod Conanan's avatar Raul Jarod Conanan

Merge branch '5-Calendar' into 'dev'

5 calendar

See merge request !10
parents 70e63ef9 60d5c1da
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (midterm_robo_mommy)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
from django.contrib import admin
from .models import Location, Event
class LocationAdmin(admin.ModelAdmin):
model = Location
class EventAdmin(admin.ModelAdmin):
model = Event
admin.site.register(Location, LocationAdmin)
admin.site.register(Event, EventAdmin)
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 14:22
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='IndexCard',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('section', models.CharField(max_length=5)),
('age', models.IntegerField()),
],
),
]
# Generated by Django 4.1.7 on 2023-03-05 16:24
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('widget_Calendar', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.CharField(max_length=20)),
('activity', models.CharField(max_length=100)),
('estimated_hours', models.FloatField()),
('course', models.CharField(max_length=20)),
],
),
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(max_length=100)),
],
),
migrations.DeleteModel(
name='IndexCard',
),
migrations.AddField(
model_name='event',
name='location',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_Calendar.location'),
),
]
from django.db import models
MODE_TYPES = (
('onsite', 'Onsite'),
('online', 'Online'),
('hybrid', 'Hybrid'),
)
class Location(models.Model):
mode = models.CharField(max_length=6, choices=MODE_TYPES)
venue = models.CharField(max_length=100)
def __str__(self):
return 'Mode: {} || Venue: {}'.format(self.mode, self.venue)
class Event(models.Model):
target_datetime = models.CharField(max_length=20)
activity = models.CharField(max_length=100)
estimated_hours = models.FloatField()
location = models.ForeignKey(
Location,
on_delete=models.CASCADE
)
course = models.CharField(max_length=20)
def __str__(self):
return '{} on {}'.format(self.activity, self.target_datetime)
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"
from .models import Event, Location
from django.http import HttpResponse
def index(request):
html_string = 'robo_mommy’s Calendar of Activities<br>'
for eventItem in Event.objects.all():
html_string += '''
<br>
Date and Time: {}<br>
Activity: {}<br>
Estimated Hours: {}<br>
Course/Section: {}<br>
Mode: {}<br>
Venue: {}<br><br>
'''.format(
eventItem.target_datetime,
eventItem.activity,
eventItem.estimated_hours,
eventItem.course,
eventItem.location.mode,
eventItem.location.venue,
)
return HttpResponse(html_string)
......@@ -47,6 +47,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'widget_Calendar',
'tz_detect',
]
......
......@@ -15,10 +15,11 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import include, path
from django.urls import path, include
urlpatterns = [
path('announcements/', include('announcements.urls', namespace="announcements")),
path('widget_Calendar/', include('widget_Calendar.urls', namespace="widget_Calendar")),
path('admin/', admin.site.urls),
path('Assignments/', include('Assignments.urls', namespace="Assignments")),
path('', include(('forum.urls', 'forum'), namespace='forum')),
......
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