controllers

package
v0.0.0-...-be230c0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IndexEvents is the name of the events index route.
	IndexEvents = "index_events"
	// ShowEvent is the name of the event show route.
	ShowEvent = "show_event"
	// EditEvent is the name of the event edit route.
	EditEvent = "edit_event"
)
View Source
const (
	// IndexFencers is the name of the index fencers route.
	IndexFencers = "index_fencers"
	// ShowFencer is the name of the show fencer route.
	ShowFencer = "show_fencer"
	// EditFencer is the name of the edit fencer route.
	EditFencer = "edit_fencer"
)
View Source
const (
	// ShowMatch is the name of the show match route.
	ShowMatch = "show_match"
	// EditMatch is the name of the edit match route.
	EditMatch = "edit_match"
)
View Source
const (
	// IndexSchools is the name of the schools index route.
	IndexSchools = "index_schools"
	// ShowSchool is the name of the school show route.
	ShowSchool = "show_school"
	// EditSchool is the name of the school edit route.
	EditSchool = "edit_school"
)
View Source
const (
	// ShowSquad is the name of the squad show route.
	ShowSquad = "show_squad"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EventForm

type EventForm struct {
	Name   string `scheme:"name"`
	Date   string `scheme:"date"`
	Rounds uint   `scheme:"rounds"`
}

EventForm holds and maps data from the new event form.

type Events

type Events struct {
	IndexView *views.View
	New       *views.View
	ShowView  *views.View
	EditView  *views.View
	// contains filtered or unexported fields
}

Events holds a models.EventService and a mux.Router.

func NewEvents

func NewEvents(es models.EventService, r *mux.Router) *Events

NewEvents returns a *Events, for use as an Events controller.

func (*Events) Create

func (e *Events) Create(w http.ResponseWriter, r *http.Request)

Create proceses the new event form and creates a new event.

POST /event

func (*Events) Delete

func (e *Events) Delete(w http.ResponseWriter, r *http.Request)

Delete removes an event from the database.

POST /event/:id/delete

func (*Events) Edit

func (e *Events) Edit(w http.ResponseWriter, r *http.Request)

Edit renders the details of an event in the event form for editing.

GET /event/:id/edit

func (*Events) Index

func (e *Events) Index(w http.ResponseWriter, r *http.Request)

Index renders the events index page with all of the events.

GET /events

func (*Events) Show

func (e *Events) Show(w http.ResponseWriter, r *http.Request)

Show renders the details of an event.

GET /event/:id

func (*Events) Update

func (e *Events) Update(w http.ResponseWriter, r *http.Request)

Update processes the submission of an event edit form and saves the event.

POST /event/:id/update

type FencerForm

type FencerForm struct {
	Name            string          `schema:"name"`
	SchoolID        uint            `schema:"school"`
	Category        models.Category `schema:"category"`
	SchoolOptions   []models.School
	CategoryOptions [6]models.Category
}

FencerForm holds and maps data from the new fencer form.

type FencerList

type FencerList struct {
	Fencers []models.Fencer
}

FencerList is a slice of fencers using the models.Fencer.

type Fencers

type Fencers struct {
	NewView   *views.View
	IndexView *views.View
	ShowView  *views.View
	EditView  *views.View
	// contains filtered or unexported fields
}

Fencers holds a models.FencerService, a mux.Router, and all of the fencer-related views.

func NewFencers

NewFencers returns a *Fencers, for use as a FencersController (e.g., for routing).

func (*Fencers) Create

func (f *Fencers) Create(w http.ResponseWriter, r *http.Request)

Create is used to process the new fencer form when a user tries to create a new fencer.

POST /fencers

func (*Fencers) Delete

func (f *Fencers) Delete(w http.ResponseWriter, r *http.Request)

Delete is used to trigger deletion of a particular fencer in the models package. TODO: Enforce permissions on fencer being deleted.

POST /fencers/:id/delete

func (*Fencers) Edit

func (f *Fencers) Edit(w http.ResponseWriter, r *http.Request)

Edit is used to edit a particular fencer's details.

GET /fencers/:id/edit

func (*Fencers) Index

func (f *Fencers) Index(w http.ResponseWriter, r *http.Request)

Index is used to list all of the created fencers.

GET /fencers

func (*Fencers) New

func (f *Fencers) New(w http.ResponseWriter, r *http.Request)

New is used to render the new fencer form.

GET /fencers/new

func (*Fencers) Show

func (f *Fencers) Show(w http.ResponseWriter, r *http.Request)

Show is used to show a particular fencer's details, including the bouts in which the fencer has participated.

GET /fencers/:id

func (*Fencers) Update

func (f *Fencers) Update(w http.ResponseWriter, r *http.Request)

Update is used to process the edit form and send updates to the models package. TODO: Enforce permissions on fencer being updated.

POST /fencers/:id/update

type LoadMatchForm

type LoadMatchForm struct {
	ID           uint
	Event        *models.Event
	Round        uint `schema:"round"`
	Category     models.Category
	SquadLeft    *models.Squad
	SquadRight   *models.Squad
	Bouts        []models.Bout
	FencersLeft  []models.Fencer
	FencersRight []models.Fencer
}

LoadMatchForm contains the data needed to render the match form.

type LoginForm

type LoginForm struct {
	Email    string `schema:"email"`
	Password string `schema:"password"`
}

LoginForm contains the data used to log in a user via the LoginView.

type MatchForm

type MatchForm struct {
	Bouts []models.Bout
}

MatchForm contains the data submitted by the match form, used by the Update action.

type Matches

type Matches struct {
	NewView  *views.View
	ShowView *views.View
	EditView *views.View
	// contains filtered or unexported fields
}

Matches holds a models.MatchService, a *mux.Router, and all of the match-related views.

func NewMatches

NewMatches returns a *Matches, for use as a Matches controller.

func (*Matches) Create

func (m *Matches) Create(w http.ResponseWriter, r *http.Request)

Create processes the new match form and saves the match.

POST /matches

func (*Matches) Delete

func (m *Matches) Delete(w http.ResponseWriter, r *http.Request)

Delete is used to delete a particular match.

POST /matches/:id/delete

func (*Matches) Edit

func (m *Matches) Edit(w http.ResponseWriter, r *http.Request)

Edit renders the match form, where match details and scores are entered.

GET /matches/:id/edit

func (*Matches) New

func (m *Matches) New(w http.ResponseWriter, r *http.Request)

New renders the new match form.

GET /matches/new

func (*Matches) Show

func (m *Matches) Show(w http.ResponseWriter, r *http.Request)

Show renders the match show view.

GET /matches/:id

func (*Matches) Update

func (m *Matches) Update(w http.ResponseWriter, r *http.Request)

Update processes the match form and saves the bouts and scores to the database.

POST /matches/:id/update

type NewMatchForm

type NewMatchForm struct {
	Events        []models.Event
	EventID       uint `schema:"event"`
	Round         uint `schema:"round"`
	Categories    [6]models.Category
	Category      models.Category `schema:"category"`
	Schools       []models.School
	SchoolIDLeft  uint `schema:"school_left"`
	SchoolIDRight uint `schema:"school_right"`
}

NewMatchForm is used to load data for the New action and process for the Create action.

type RegisterForm

type RegisterForm struct {
	Name     string `schema:"name"`
	Email    string `schema:"email"`
	Password string `schema:"password"`
}

RegisterForm contains the data used to create a new user, entered on NewView and processed by Create.

type ResetPwForm

type ResetPwForm struct {
	Email    string `schema:"email"`
	Token    string `schema:"token"`
	Password string `schema:"password"`
}

ResetPwForm is used to process the forgot password form // and the reset password form.

type SchoolForm

type SchoolForm struct {
	ID   uint
	Name string `scheme:"name"`
}

SchoolForm holds and maps data from the new school form.

type Schools

type Schools struct {
	IndexView *views.View
	New       *views.View
	ShowView  *views.View
	EditView  *views.View
	// contains filtered or unexported fields
}

Schools holds a models.SchoolService, a models.SquadService (to manage squads), a mux.Router, and all of the school-related views.

func NewSchools

func NewSchools(ss models.SchoolService, sqs models.SquadService, r *mux.Router) *Schools

NewSchools returns a *Schools, for use as a SchoolsControllers.

func (*Schools) Create

func (s *Schools) Create(w http.ResponseWriter, r *http.Request)

Create is used to process a new school form submission to create a new school and the associated squads.

POST /schools

func (*Schools) Delete

func (s *Schools) Delete(w http.ResponseWriter, r *http.Request)

Delete is used to delete a school. TODO: Enforce permissions on school being deleted.

POST /schools/:id/delete

func (*Schools) Edit

func (s *Schools) Edit(w http.ResponseWriter, r *http.Request)

Edit is used to edit a particular school's details using the edit form. TODO: Enforce permissions on school being updated.

GET /schools/:id/edit

func (*Schools) Index

func (s *Schools) Index(w http.ResponseWriter, r *http.Request)

Index is used to list all of the created schools.

GET /schools

func (*Schools) Show

func (s *Schools) Show(w http.ResponseWriter, r *http.Request)

Show is used to show a particular school's details.

GET /schools/:id

func (*Schools) Update

func (s *Schools) Update(w http.ResponseWriter, r *http.Request)

Update is used to process edit form submissions.

POST /schools/:id/update

type Seeding

type Seeding struct {
	NewView *views.View
	// contains filtered or unexported fields
}

Seeding holds all services needed to build seedings and a mux.Router.

func NewSeeding

func NewSeeding(ss models.SeedingService, r *mux.Router) *Seeding

NewSeeding returns a *Seeding, for use as a SeedingController (e.g., for routing).

func (*Seeding) Create

func (s *Seeding) Create(w http.ResponseWriter, r *http.Request)

Create processes the new seeding form when a user tries to create a new seeding. Create will generate a table of competitors sorted by their rankings in a CSV file which can be downloaded and imported into Fencing Time (or other tournament software) by the user.

POST /seeding

func (*Seeding) New

func (s *Seeding) New(w http.ResponseWriter, r *http.Request)

New renders the NewView.

GET /seeding/new

type SeedingForm

type SeedingForm struct {
	Category         models.Category  `schema:"category"`
	Plurality        models.Plurality `schema:"plurality"`
	CategoryOptions  [6]models.Category
	PluralityOptions [2]models.Plurality
}

SeedingForm holds and maps data from the new seeding form.

type Squads

type Squads struct {
	ShowView *views.View
	// contains filtered or unexported fields
}

Squads holds a models.SquadService, a mux.Router, and all of the squad-related views.

func NewSquads

func NewSquads(sqs models.SquadService, r *mux.Router) *Squads

NewSquads returns a *Squads, for use as a Squads controller.

func (*Squads) Show

func (s *Squads) Show(w http.ResponseWriter, r *http.Request)

Show is used to show a particular squad's detials, including its fencers.

GET /squads/:id

type Static

type Static struct {
	Home    *views.View
	Contact *views.View
}

func NewStatic

func NewStatic() *Static

type UserList

type UserList struct {
	Users []models.User
}

UserList is a slice of users using the models.User.

type Users

type Users struct {
	NewView      *views.View
	LoginView    *views.View
	ForgotPwView *views.View
	ResetPwView  *views.View
	IndexView    *views.View
	// contains filtered or unexported fields
}

Users holds a models.UserService and all of the user-related views.

func NewUsers

func NewUsers(us models.UserService) *Users

NewUsers returns *Users, for use as a Users controller.

func (*Users) CompleteReset

func (u *Users) CompleteReset(w http.ResponseWriter, r *http.Request)

CompleteReset processed the reset password form

POST /reset

func (*Users) Create

func (u *Users) Create(w http.ResponseWriter, r *http.Request)

Create is used to process the register form when a user tries to create a new user account.

POST /register

func (*Users) Demote

func (u *Users) Demote(w http.ResponseWriter, r *http.Request)

Demote changes a user's role from Admin to User Or updates user Permissionlvl from 0 to 1

POST /demote/{email}

func (*Users) Index

func (u *Users) Index(w http.ResponseWriter, r *http.Request)

Index renders the page to manage user permissions When only admins are implemented, admin can promote but not demote users When superadmins are implemented, superadmins can promote and demote

GET /users

func (*Users) InitiateReset

func (u *Users) InitiateReset(w http.ResponseWriter, r *http.Request)

POST /forgot

func (*Users) Login

func (u *Users) Login(w http.ResponseWriter, r *http.Request)

Login is used to process the login form when a user tries to log in as an existing user with email and password.

POST /login

func (*Users) Logout

func (u *Users) Logout(w http.ResponseWriter, r *http.Request)

Logout is used to delete a user's session cookie and invalidate their current remember token, which will sign-out the current user.

POST /logout

func (*Users) New

func (u *Users) New(w http.ResponseWriter, r *http.Request)

New is used to render the form where a user can create a new user account.

GET /register

func (*Users) Promote

func (u *Users) Promote(w http.ResponseWriter, r *http.Request)

Promote changes a user's role from User to Admin Or updates user Permissionlvl from 0 to 1

POST /promote/{email}

func (*Users) ResetPw

func (u *Users) ResetPw(w http.ResponseWriter, r *http.Request)

ResetPw displays the reset password form and has a method so that we can prefill the form data with a token provided via the URL query params.

GET /reset

Jump to

Keyboard shortcuts

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