admin

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package admin defines admin routes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoRejudge added in v0.4.1

func DoRejudge(db db.DBContext, id []int, stage string) error

DoRejudge performs rejudge on a given stage and list of IDs.

Types

type ContestCtx

type ContestCtx struct {
	*models.Contest
	FormError error
	Form      ContestForm

	Problems         []*models.Problem
	ProblemForm      ProblemForm
	ProblemFormError error
}

ContestCtx is the context for rendering admin/contest.

func (*ContestCtx) Render added in v0.4.1

func (ctx *ContestCtx) Render(c echo.Context) error

type ContestForm

type ContestForm struct {
	Name                 string                      `form:"name"`
	StartTime            Timestamp                   `form:"start_time"`
	EndTime              Timestamp                   `form:"end_time"`
	ContestType          models.ContestType          `form:"contest_type"`
	ScoreboardViewStatus models.ScoreboardViewStatus `form:"scoreboard_view_status"`
}

ContestForm is a form for uploading a new contest.

func ContestToForm

func ContestToForm(c *models.Contest) *ContestForm

ContestToForm creates a form with the initial values of the contest.

func (*ContestForm) Bind

func (f *ContestForm) Bind(c *models.Contest)

Bind binds the form's content to the contest's.

type ContestWithProblems

type ContestWithProblems struct {
	*models.Contest
	Problems []*models.Problem
}

ContestWithProblems is a contest with embedded problems.

type ContestsCtx

type ContestsCtx struct {
	Contests []*models.Contest

	FormError error
	Form      ContestForm
}

ContestsCtx is a context for rendering contests.

type Group

type Group struct {
	*echo.Group
	// contains filtered or unexported fields
}

Group represents a router Group with handling functions.

func New

func New(db *db.DB, unauthed *echo.Group) (*Group, error)

New creates a new group.

func (*Group) ContestAddProblem

func (g *Group) ContestAddProblem(c echo.Context) error

ContestAddProblem implements POST /admin/contest/:id/add_problem

func (*Group) ContestDelete

func (g *Group) ContestDelete(c echo.Context) error

ContestDelete implement POST /admin/contest/:id/delete

func (*Group) ContestEdit

func (g *Group) ContestEdit(c echo.Context) error

ContestEdit implements POST /admin/contest/:id

func (*Group) ContestGet

func (g *Group) ContestGet(c echo.Context) error

ContestGet implements GET /admin/contest/:id

func (*Group) ContestRejudgePost added in v0.4.1

func (g *Group) ContestRejudgePost(c echo.Context) error

ContestRejudgePost implements POST /admin/contests/:id/rejudge

func (*Group) ContestSubmissionsGet

func (g *Group) ContestSubmissionsGet(c echo.Context) error

ContestSubmissionsGet implements GET /admin/contests/:id/submissions.

func (*Group) ContestsGet

func (g *Group) ContestsGet(c echo.Context) error

ContestsGet handles GET /admin/contests

func (*Group) ContestsPost

func (g *Group) ContestsPost(c echo.Context) error

ContestsPost handles POST /admin/contests.

func (*Group) FileDelete

func (g *Group) FileDelete(c echo.Context) error

FileDelete implements POST /admin/files/:id/delete

func (*Group) FileGet

func (g *Group) FileGet(c echo.Context) error

FileGet implements GET /admin/files/:id

func (*Group) Home

func (g *Group) Home(c echo.Context) error

Home renders the home page.

func (*Group) JobsGet added in v0.2.0

func (g *Group) JobsGet(c echo.Context) error

JobsGet implements GET "/admin/jobs".

func (*Group) LoginGet

func (g *Group) LoginGet(c echo.Context) error

LoginGet implements GET /admin/login.

func (*Group) LoginPost

func (g *Group) LoginPost(c echo.Context) error

LoginPost implements POST /admin/login.

func (*Group) LogoutPost

func (g *Group) LogoutPost(c echo.Context) error

LogoutPost implements GET/POST /admin/logout.

func (*Group) ProblemAddFile

func (g *Group) ProblemAddFile(c echo.Context) error

ProblemAddFile implements POST /admin/problems/:id/add_file

func (*Group) ProblemAddTestGroup

func (g *Group) ProblemAddTestGroup(c echo.Context) error

ProblemAddTestGroup implements /admin/problems/:id/add_test_group

func (*Group) ProblemDelete

func (g *Group) ProblemDelete(c echo.Context) error

ProblemDelete implements POST /admin/problems/:id/delete

func (*Group) ProblemEdit

func (g *Group) ProblemEdit(c echo.Context) error

ProblemEdit implements POST /admin/problems/:id

func (*Group) ProblemGet

func (g *Group) ProblemGet(c echo.Context) error

ProblemGet implements GET /admin/problems/:id

func (*Group) ProblemRejudgePost added in v0.4.1

func (g *Group) ProblemRejudgePost(c echo.Context) error

ProblemRejudgePost implements POST /admin/problems/:id/rejudge

func (*Group) ProblemSubmissionsGet

func (g *Group) ProblemSubmissionsGet(c echo.Context) error

ProblemSubmissionsGet implements GET /admin/problems/:id/submissions.

func (*Group) RejudgePost

func (g *Group) RejudgePost(c echo.Context) error

RejudgePost implements POST /admin/rejudge.

func (*Group) ScoreboardCSVGet added in v0.4.1

func (g *Group) ScoreboardCSVGet(c echo.Context) error

ScoreboardCSVGet implements GET /admin/contests/:id/scoreboard/csv

func (*Group) ScoreboardGet added in v0.4.1

func (g *Group) ScoreboardGet(c echo.Context) error

ScoreboardGet implements GET /admin/contests/:id/scoreboard

func (*Group) ScoreboardJSONGet added in v0.4.1

func (g *Group) ScoreboardJSONGet(c echo.Context) error

ScoreboardJSONGet implements GET /admin/contests/:id/scoreboard/json

func (*Group) SubmissionBinaryGet

func (g *Group) SubmissionBinaryGet(c echo.Context) error

SubmissionBinaryGet implements GET /admin/submissions/:id/binary

func (*Group) SubmissionGet

func (g *Group) SubmissionGet(c echo.Context) error

SubmissionGet implement GET /admin/submissions/:id

func (*Group) SubmissionVerdictGet

func (g *Group) SubmissionVerdictGet(c echo.Context) error

SubmissionVerdictGet implements GET /admin/submissions/:id/verdict

func (*Group) SubmissionsGet

func (g *Group) SubmissionsGet(c echo.Context) error

SubmissionsGet implements GET /admin/submissions

func (*Group) TestDelete

func (g *Group) TestDelete(c echo.Context) error

TestDelete implements GET /admin/tests/:id/delete

func (*Group) TestGroupDelete

func (g *Group) TestGroupDelete(c echo.Context) error

TestGroupDelete implements POST /admin/test_groups/:id/delete

func (*Group) TestGroupEdit

func (g *Group) TestGroupEdit(c echo.Context) error

TestGroupEdit implements POST /admin/test_groups/:id

func (*Group) TestGroupGet added in v0.4.1

func (g *Group) TestGroupGet(c echo.Context) error

TestGroupGet implements GET /admin/test_groups/:id

func (*Group) TestGroupRejudgePost added in v0.4.1

func (g *Group) TestGroupRejudgePost(c echo.Context) error

TestGroupRejudgePost implements POST /admin/test_groups/:id/rejudge

func (*Group) TestGroupUploadMultiple

func (g *Group) TestGroupUploadMultiple(c echo.Context) error

TestGroupUploadMultiple implements POST /admin/test_groups/:id/upload_multiple

func (*Group) TestGroupUploadSingle

func (g *Group) TestGroupUploadSingle(c echo.Context) error

TestGroupUploadSingle implements POST /admin/test_groups/:id/upload_single.

func (*Group) TestInput

func (g *Group) TestInput(c echo.Context) error

TestInput implements GET /admin/tests/:id/input

func (*Group) TestOutput

func (g *Group) TestOutput(c echo.Context) error

TestOutput implements GET /admin/tests/:id/output

func (*Group) ToggleEnableRegistration

func (g *Group) ToggleEnableRegistration(c echo.Context) error

ToggleEnableRegistration implements POST /admin/config/toggle_enable_registration

func (*Group) UserDelete

func (g *Group) UserDelete(c echo.Context) error

UserDelete implement POST /admin/users/:id/delete

func (*Group) UserEdit

func (g *Group) UserEdit(c echo.Context) error

UserEdit implements POST /admin/user/:id

func (*Group) UserGet

func (g *Group) UserGet(c echo.Context) error

UserGet implements GET /admin/user/:id

func (*Group) UsersAdd

func (g *Group) UsersAdd(c echo.Context) error

func (*Group) UsersGet

func (g *Group) UsersGet(c echo.Context) error

UsersGet implements GET /admin/users.

type HomeCtx

type HomeCtx struct {
	Contests []*models.Contest
	Queue    *models.QueueOverview
}

HomeCtx is a context for rendering Home page.

type JobsCtx added in v0.2.0

type JobsCtx struct {
	Jobs []*models.Job

	Tests      map[int]*models.Test
	TestGroups map[int]*models.TestGroup
	Problems   map[int]*models.Problem
}

JobsCtx is a context for rendering jobs.

func (*JobsCtx) Render added in v0.2.0

func (j *JobsCtx) Render(c echo.Context) error

Render renders the context.

type LoginCtx

type LoginCtx struct {
	Error error
}

LoginCtx is the context for rendering the login page.

func (*LoginCtx) Render

func (l *LoginCtx) Render(c echo.Context) error

Render renders the context.

type OptionalInt64

type OptionalInt64 struct {
	sql.NullInt64
}

OptionalInt64 implements a NullInt64 with binding capabilities.

func (OptionalInt64) String

func (o OptionalInt64) String() string

func (*OptionalInt64) UnmarshalParam

func (o *OptionalInt64) UnmarshalParam(src string) error

UnmarshalParam implement echo's Bind.

type ProblemCtx

type ProblemCtx struct {
	*models.Problem
	Contest    *models.Contest
	TestGroups []*models.TestGroupWithTests
	Files      []*models.File

	// Edit Problem Form
	EditForm      ProblemForm
	EditFormError error

	// New TestGroup form
	TestGroupForm      TestGroupForm
	TestGroupFormError error
}

ProblemCtx is the context for rendering admin/problem.

type ProblemForm

type ProblemForm struct {
	DisplayName   string               `form:"display_name"`
	MemoryLimit   int                  `form:"memory_limit"`
	Name          string               `form:"name"`
	PenaltyPolicy models.PenaltyPolicy `form:"penalty_policy"`
	ScoringMode   models.ScoringMode   `form:"scoring_mode"`
	TimeLimit     int                  `form:"time_limit"`
}

ProblemForm is a form for creating/updating a problem.

func ProblemToForm

func ProblemToForm(p *models.Problem) ProblemForm

ProblemForm produces an edit form from the problem.

func (*ProblemForm) Bind

func (f *ProblemForm) Bind(p *models.Problem)

Bind binds the form's content into the Problem.

type ScoreboardCtx added in v0.4.1

type ScoreboardCtx struct {
	*models.Scoreboard
}

ScoreboardCtx is the context required to display the scoreboard page

func (s *ScoreboardCtx) JSONLink() string

JSONLink returns the link to the JSON scoreboard.

func (*ScoreboardCtx) Render added in v0.4.1

func (s *ScoreboardCtx) Render(c echo.Context, wide bool) error

Render renders the scoreboard context

func (*ScoreboardCtx) RenderJSON added in v0.4.1

func (s *ScoreboardCtx) RenderJSON(c echo.Context) error

RenderJSON renders a scoreboard in JSON.

func (*ScoreboardCtx) Show added in v0.4.1

func (s *ScoreboardCtx) Show() error

Show decides whether the scoreboard can be shown. For compability with contests.ScoreboardCtx

type SubmissionCtx

type SubmissionCtx struct {
	Submission *models.Submission

	Problem     *models.Problem
	Contest     *models.Contest
	TestGroups  []*models.TestGroupWithTests
	TestResults map[int]*models.TestResult
}

SubmissionCtx is the context for rendering the submission interface.

func (*SubmissionCtx) Render

func (s *SubmissionCtx) Render(c echo.Context) error

Render renders the context.

type SubmissionsCtx

type SubmissionsCtx struct {
	User  *models.User // or
	Users map[string]*models.User

	Problem     *models.Problem         // or
	ProblemsMap map[int]*models.Problem // AND one of
	Contest     *ContestWithProblems
	Contests    []*ContestWithProblems

	Submissions []*models.Submission
}

SubmissionsCtx is a context for *listing submissions*.

func SubmissionsAll

func SubmissionsAll(db db.DBContext) (*SubmissionsCtx, error)

SubmissionsAll returns a context of all submissions.

func SubmissionsBy

func SubmissionsBy(db db.DBContext, u *models.User, c *models.Contest, p *models.Problem) (*SubmissionsCtx, error)

SubmissionsBy applies a filter to the submission list: - either with an user (if u != nil) - or with a contest... (if c != nil) - or with a single problem (if p != nil, overrides contest).

type TestGroupCtx added in v0.4.1

type TestGroupCtx struct {
	*models.TestGroupWithTests
	Contest *models.Contest
	Problem *models.Problem
}

TestGroupCtx is the context for rendering test-group.

func (*TestGroupCtx) Render added in v0.4.1

func (ctx *TestGroupCtx) Render(c echo.Context) error

Render renders the context.

func (*TestGroupCtx) ToForm added in v0.4.1

func (ctx *TestGroupCtx) ToForm() TestGroupForm

ToForm converts the context into a nicer form format.

type TestGroupForm

type TestGroupForm struct {
	MemoryLimit OptionalInt64          `form:"memory_limit"`
	Name        string                 `form:"name"`
	Score       float64                `form:"score"`
	ScoringMode models.TestScoringMode `form:"scoring_mode"`
	TimeLimit   OptionalInt64          `form:"time_limit"`
}

func (*TestGroupForm) Bind

func (f *TestGroupForm) Bind(t *models.TestGroup)

Bind binds the form's values to the TestGroup.

type Timestamp

type Timestamp time.Time

Timestamp is a wrapped time.Time for form-parsing.

func (Timestamp) String

func (t Timestamp) String() string

String formats the timestamp as RFC3339.

func (*Timestamp) UnmarshalParam

func (t *Timestamp) UnmarshalParam(src string) error

UnmarshalParam implement echo's Bind.

type UserCtx

type UserCtx struct {
	*models.User

	Submissions *SubmissionsCtx

	EditForm      *UserForm
	EditFormError error
}

UserCtx is a context for rendering an user.

func (*UserCtx) Render

func (u *UserCtx) Render(db db.DBContext, c echo.Context) error

Render renders the context.

type UserForm

type UserForm struct {
	ID       string `form:"id"`
	Password string `form:"password"`
	Hidden   bool   `form:"hidden"`

	IsUpdate bool
}

UserForm is a form for adding or editing an user.

func UserToForm

func UserToForm(u *models.User) *UserForm

func (*UserForm) Bind

func (f *UserForm) Bind(u *models.User) error

Bind binds the form's values to the model.

type UsersCtx

type UsersCtx struct {
	Users []*models.User

	Config *models.Config

	FormError error
	Form      UserForm
}

UsersCtx provides a context for rendering /admin/users.

Jump to

Keyboard shortcuts

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