Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

app.models

Seamus Smith edited this page Apr 29, 2022 · 13 revisions

app.models

All the models for our app. Diagram

class Schedule(django.db.models.Model)

Inner Classes

class Visibility(models.TextChoices)

  • PUBLIC: 'A'
  • UNLISTED: 'U'
  • PRIVATE: 'P'

Properties

  • id: models.AutoField(primary_key=True)
  • owner: models.ForeignKey(to=User, on_delete=models.CASCADE)
  • visibility: models.CharField(max_length=1, choices=Visibility.choices, default=Visibility.PUBLIC)
  • name: models.CharField(max_length=64)
  • is_locked: models.BooleanField()
  • auto_lock_after: models.DateTimeField()
  • calendar_id = models.CharField(max_length=1024)
  • calendar_meet_data = models.JSONField()

Methods

get_calendar_url(self) -> str

Returns a link to the schedule in Google Calendar

class TimeSlot(django.db.models.Model)

Properties

  • id: models.AutoField(primary_key=True)
  • schedule: models.ForeignKey(to=Schedule, on_delete=models.CASCADE)
  • time_from: models.DateTimeField()
  • time_to: models.DateTimeField()
  • auto_lock_after: models.DateTimeField()
  • is_locked: models.BooleanField()
  • reservation_limit: models.IntegerField()

class Reservation(django.db.models.Model)

Properties

  • id: models.AutoField(primary_key=True)
  • name: models.CharField(max_length=747)
  • time_slot: models.ForeignKey(to=TimeSlot, on_delete=models.CASCADE)
  • email: models.EmailField()
  • comment: models.CharField(max_length=256)

class ScheduleSubscription(django.db.models.Model)

Properties

  • id: models.AutoField(primary_key=True)
  • schedule: models.ForeignKey(to=Schedule, on_delete=models.CASCADE)
  • user: models.ForeignKey(to=User, on_delete=models.CASCADE)
  • add_as_guest: models.BooleanField(default=False)

on_schedule_create(sender, instance, **kwargs)

Hooks onto Schedule's pre_save signal. Adds relevant Google Calendar data to the model instance before comiting it to the database.

on_schedule_delete(sender, instance, **kwargs)

Hooks onto Schedule's post_delete signal. Deletes the Google Calendar for the schedule.

on_reservation_create(sender, instance, **kwargs)

Hooks onto the Reservation's post_save signal to update the Calendar event associated with the reservation's timeslot.

on_reservation_delete(sender, instance, **kwargs)

Hooks onto the Reservation's post_delete signal to update the Calendar event associated with the reservation's timeslot.

on_timeslot_delete(sender, instance, **kwargs)

Hooks onto each timeslot's delete signal after they are deleted. Deletes all events related to the timeslot.

Clone this wiki locally