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

app.views

Jack Richard edited this page Apr 1, 2022 · 15 revisions

app.views

All the views in the app

index(request)

/

Template: app/pages/index.html
Methods: GET

GET

The index for the website. Displays every schedule.

create_schedule(request)

/schedule/create

Template: app/pages/create_schedule.html
Methods: GET, POST

Raises PermissionDenied if not authenticated.

GET

The form for creating a schedule.

POST

Expects the following data:

should_lock_automatically: bool
auto_lock_after: ISO Timestamp (optional)
name: string

Creates a new schedule using the data given then redirects the user to the newly created schedule.

schedule(request, schedule_id)

/schedule/<int:schedule_id>

Template: app/pages/schedule.html
Methods: GET, POST

GET

Displays to the user every day there are timeslots. Each card links to their corresponding schedule-day page. Has a form used by the owner for locking/deleting/editing their timeslots.

POST

Updates the schedule with the given information.

timeslot_id: int list
timeslot_date: ISO 8601 date list
action: "lock" | "unlock" | "delete"
next: url path string

edit_schedule(request, schedule_id)

/schedule/<int:schedule_id>/edit

Template: app/pages/schedule_edit.html
Methods: GET, POST

Raises PermissionDenied if not authenticated.

GET

Displays the form to edit the schedule name and description.

POST

Expects the following data:

name: string
description: string

copy_timeslots(request, schedule_id)

/schedule/<int:schedule_id>/copy

Template: N/A Methods: POST Form Model: app.forms.CopyTimeslotsForm

Raises PermissionDenied if the user is not the owner of the schedule. Also raises UnsupportedOperation if form data is not valid.

POST

Expects the following data:

action: string
timeslots: string (list of TimeSlot primary keys, separated by commas)
to_date: string
to_time: string

Form converts string timeslots variable to list of TimeSlot objects. to_date and to_time are also converted to DateField and TimeField.

view_schedule_reservations(request, schedule_id)

/schedule/<int:schedule_id>/reservations

Template: app/pages/reservations_view_schedule.html Methods: GET, POST

Raises PermissionDenied if the user is not the owner of the schedule.

GET

Views the current reservations for the entire schedule.

POST

Expects the following data:

action: string
id: int

create_timeslots(request, schedule_id)

schedule/<int:schedule_id>/create-timeslots

Template: app/pages/create_timeslots.html
Methods: GET, POST
Form Model: app.forms.TimeslotGenerationForm

GET

The form for generating a range of timeslots.

POST

If the form is invalid, render the template with the bad data. Else, generates the range of timeslots given the form data then redirects the user back to the schedule page.

schedule_day(request, schedule_id, date)

/schedule/<int:schedule_id>/<datetime:date>

Template: app/pages/schedule_day.html
Methods: GET, POST

GET

Displays every timeslot for the given day. Each timeslot card links to their corresponding reservation form.

POST

Updates the timeslots selected.

timeslot_id: int list
timeslot_date: ISO 8601 date list
action: "lock" | "unlock" | "delete"
next: url path string

reserve_timeslot(request, schedule_id, date, timeslot_id)

schedule/<int:schedule_id>/<datetime:date>/reserve/<int:timeslot_id>

Template: app/pages/reserve_timeslot.html
Methods: GET, POST
Form Model: app.forms.ReservationForm

GET

The reservation form.

POST

Creates a timeslot reservation object for the timeslot and then redirects the user to the reserve-confirmed page.

view_reservations(request, schedule, date, timeslot)

schedule/<schedule:schedule>/<datetime:date>/view/<timeslot:timeslot>

Template: app/pages/reservations_view.html Methods: GET, POST

GET

View and manage the reservations for the given timeslot.

POST

Expects the following data:

action: string
id: Reservation ID

Deletes the reservation associated with the given ID

find_reservation(request)

reservation/find

Template: app/pages/find_reservation.html
Methods: GET, POST

GET

Shows the form to find your reservation, using your name and email.

POST

There are two types of POSTs for this view. The first type expects:

name: string
email: string

and the second expects:

action: string
id: int

confirm_reservation(request, reservation)

reservation/<reservation:reservation>/confirm

Templates: app/pages/reserve_confirmed.html, app/pages/reserve_failed.html Methods: GET

GET

Tries to confirm the reservation. If the resevervation limit has been hit, the view directs the user to the reserve_failed template, else it set's the reservation's confirmed property to true and sends the user to the reserve_confirmed template.

cancel_reservation(request, reservation)

reservation/<reservation:reservation>/cancel

Templates: app/pages/reserve_cancelled.html Methods: GET, POST

GET

An "are you sure" page that when "yes" is clicked, will delete the reservation.

POST

Deletes the reservation and redirects user to /.

reserve_confirmed(request)

schedule/reserve-confirmed

Template: app/pages/reserve_confirmed.html
Methods: GET

GET

The reservation confirmed page. Also features our mascot "rat a toster ski" (working title)

user_schedules(request, user_id)

schedules/<int:user_id>

Template: app/pages/schedules.html Methods: GET

GET

Shows all schedules associated with user_id.

Clone this wiki locally