Commit 48c53b1f authored by Gabriel Geraldo's avatar Gabriel Geraldo

implemented models of app widget_calendar

parent 598967ea
# Generated by Django 4.1.7 on 2023-03-06 07:35
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('assignments', '0002_alter_assignment_course'),
]
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')], default='onsite', max_length=6)),
('venue', models.CharField(max_length=255)),
],
),
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.TextField()),
('estimated_hours', models.FloatField()),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_calendar.location')),
],
),
]
from django.db import models
from assignments.models import Course
# Create your models here.
class Location(models.Model):
ONSITE = 'onsite'
ONLINE = 'online'
HYBRID = 'hybrid'
MODE_CHOICES = [
(ONSITE, 'Onsite'),
(ONLINE, 'Online'),
(HYBRID, 'Hybrid'),
]
mode = models.CharField(
max_length = 6,
choices = MODE_CHOICES,
default = ONSITE,
)
venue = models.CharField(max_length=255)
def __str__(self):
return '{} ({})'.format(
self.mode,
self.title
)
class Event(models.Model):
target_datetime = models.DateTimeField()
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 '{} by {}'.format(
self.activity,
self.course
)
\ 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