View Source ZoonkWeb.Plugs.School (Zoonk v0.2.0-alpha)

This is a multi-tenant app where we assign schools depending on the host value.

examples

Examples

  • app.zoonk.org -> zoonk school
  • davinci.zoonk.org -> davinci school
  • interactive.harvard.edu -> harvard school

This means we need to fetch the app school's data when starting this application.

Link to this section Summary

Functions

Fetches the school's data from the database.

Only allows a route if coming from the marketplace.

Handles mounting the school data to a LiveView.

When running the app for the first time, there won't be any schools assigned to the host. In those cases, we need to redirect the user to the setup page instead.

Requires authentication for private schools. Some schools set their visibility to false through school.public?. In those cases none of the school pages should be publicly visible.

Requires manager permissions to access a certain route.

Requires manager or teacher permissions to access a certain route.

Requires a subscription for private schools.

Link to this section Functions

Link to this function

fetch_school(conn, opts)

View Source
@spec fetch_school(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t()

Fetches the school's data from the database.

Link to this function

marketplace_only(conn, opts)

View Source
@spec marketplace_only(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t()

Only allows a route if coming from the marketplace.

Link to this function

on_mount(atom, params, session, socket)

View Source

Handles mounting the school data to a LiveView.

on_mount-options

on_mount options

  • :mount_school - Mounts the school from the school_username param and the host.
Link to this function

redirect_to_setup_school(conn, opts)

View Source
@spec redirect_to_setup_school(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t()

When running the app for the first time, there won't be any schools assigned to the host. In those cases, we need to redirect the user to the setup page instead.

Link to this function

require_auth_for_private_schools(conn, opts)

View Source
@spec require_auth_for_private_schools(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t()

Requires authentication for private schools. Some schools set their visibility to false through school.public?. In those cases none of the school pages should be publicly visible.

Link to this function

require_manager(conn, opts)

View Source
@spec require_manager(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t()

Requires manager permissions to access a certain route.

Link to this function

require_manager_or_teacher(conn, opts)

View Source
@spec require_manager_or_teacher(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t()

Requires manager or teacher permissions to access a certain route.

Link to this function

require_subscription_for_private_schools(conn, opts)

View Source
@spec require_subscription_for_private_schools(Plug.Conn.t(), Keyword.t()) ::
  Plug.Conn.t()

Requires a subscription for private schools.