Commit 277d640f authored by Jose Gabriel L. Salas's avatar Jose Gabriel L. Salas

updated calendar models and admin

parent da7556e1
from django.contrib import admin from django.contrib import admin
# Register your models here. from .models import Event, Location
class EventAdmin(admin.ModelAdmin):
model = Event
search_fields = ('activity','target_datetime','course', )
list_display = ('activity','target_datetime', )
list_filter = ('target_datetime','course', )
fieldsets = [
('Activity', {
'fields':[('activity','course' ),
'target_datetime','location','estimated_hours']
}),
]
class LocationAdmin(admin.ModelAdmin):
model = Location
search_fields = ('venue','mode', )
list_display = ('venue','mode', )
list_filter = ('mode', )
class EventInline(admin.TabularInline):
model = Event
class LocationInline(admin.TabularInline):
model = Location
admin.site.register(Event, EventAdmin)
admin.site.register(Location, LocationAdmin)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-04 14:12
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=[('OS', 'Onsite'), ('OL', 'Online'), ('HB', 'Hybrid')], default='OS', max_length=2)),
('venue', models.CharField(max_length=100)),
],
),
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(max_length=255)),
('estimated_hours', models.FloatField()),
('course', models.CharField(max_length=100)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_calendar.location')),
],
),
]
from django.db import models from django.db import models
# Create your models here.
class Location(models.Model):
onsite = 'OS'
online = 'OL'
hybrid = 'HB'
mode_choices = [
(onsite, 'Onsite'),
(online, 'Online'),
(hybrid, 'Hybrid'),
]
mode = models.CharField(max_length=2, choices=mode_choices, default=onsite, )
venue = models.CharField(max_length=100)
def __str__(self):
return '{}, {}'.format(self.mode, self.venue)
class Event(models.Model):
target_datetime = models.DateTimeField()
activity = models.CharField(max_length=255)
estimated_hours = models.FloatField()
location = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.CharField(max_length=100)
def __str__(self):
return '{}, {}'.format(self.activity, self.target_datetime)
\ 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