utils

package
v0.0.0-...-802508d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	UserSessionKey  Key = "u"
	TokenSessionKey Key = "at"
	StateSessionKey Key = "state"
	SessionTempAge  Age = 60 * 15   // 15 minutes
	SessionMaxAge   Age = 86400 * 2 // 2 days

)
View Source
const MaxProjectLinkLength = 500

MaxProjectLinkLength caps what we store. Real GitHub and Drive links are far shorter; the limit exists so a pasted essay can't fill a row.

Variables

This section is empty.

Functions

func AbstractExists

func AbstractExists(team *models.DashboardTeam, event string) bool

func AbstractPath

func AbstractPath(teamId int, event string) (string, bool)

AbstractPath returns where a team's abstract for an event lives, and whether that file actually exists. Anything that links to a PDF must gate on the boolean: the abstract table records a submission, but the file can be gone.

func AbstractUploadedAt

func AbstractUploadedAt(teamId int, event string) time.Time

AbstractUploadedAt returns when a team's abstract file was last written, or the zero time when there is none.

func BadRequestError

func BadRequestError(c echo.Context, msg string, err *error) error

func ForbiddenError

func ForbiddenError(c echo.Context, msg string, err *error) error

ForbiddenError is for a signed-in person asking for something the server deliberately refuses - a closed submission window, for example. It is not a client mistake, so it must not read as a 400.

func GetAbstractFile

func GetAbstractFile(strTeamId string) (string, error)

GetAbstractFile finds a team's abstract file. Only the three events with an abstract round are searched; Logical Rhythm has none, so nothing can exist under files/abstracts/logical.

func GetAllotmentCSV

func GetAllotmentCSV(userId int, event string) (string, error)

func GetSession

func GetSession(c echo.Context) (*sessions.Session, error)

func InternalError

func InternalError(c echo.Context, msg string, err *error) error

func InvalidateSession

func InvalidateSession(c echo.Context) error

func IsPDF

func IsPDF(file *multipart.FileHeader) bool

IsPDF checks the upload really is a PDF by its first bytes, not its name.

func NormaliseProjectLinks(githubRaw string, videoRaw string) (string, string, error)

NormaliseProjectLinks cleans and checks a team's final submission: a GitHub repository link and a Google Drive link to a short demo video. Both are required. It returns the links in the form they should be stored, or a message written for the person who typed them.

func SaveAbstract

func SaveAbstract(file *multipart.FileHeader, event dao.Event, teamId int) error

func SaveMidTermCSV

func SaveMidTermCSV(file *multipart.FileHeader, userId int, event string) error

func SetSession

func SetSession(c echo.Context, maxAge Age, values *map[Key]interface{}) error

func SetSessionWith

func SetSessionWith(sess *sessions.Session, c echo.Context, maxAge Age, values *map[Key]interface{}) error

func UnauthorizedError

func UnauthorizedError(c echo.Context, msg string, err *error) error

func UploadMidTermScores

func UploadMidTermScores(userId int, event string) error

Types

type Age

type Age int

type Key

type Key string

type ProjectLinkError

type ProjectLinkError struct {
	Field   string
	Message string
}

func (*ProjectLinkError) Error

func (e *ProjectLinkError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL