components

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContestAccessRegister = iota
	ContestAccessPrivate
	TableContest             = "contest"
	TableContestNotification = "contest_notification"
	TableRelContestAdmin     = "rel_contest_admin"
	TableContestRank         = "contest_rank"
)
View Source
const (
	FlagTypeStatic = "static"
	TableFlag      = "flag"
)
View Source
const (
	TableProblem          = "problem"
	TableProblemTag       = "problem_tag"
	TableRelProblemTag    = "rel_problem_tag"
	TableRelProblemSolver = "rel_problem_solver"
)
View Source
const (
	Correct = iota + 1
	Wrong
	TableSubmission = "submission"
)
View Source
const (
	TableTeam                  = "team"
	TableRelTeamAdmin          = "rel_team_admin"
	TableTeamSnapshot          = "team_snapshot"
	TableRelTeamSnapshotMember = "rel_team_snapshot_member"
	TableTeamInvitation        = "team_invitation"
	TableTeamApplication       = "team_application"
)
View Source
const (
	InvitationPending = iota + 1
	InvitationAccepted
	InvitationRejected
	InvitationFailed
)
View Source
const (
	ApplicationPending = iota + 1
	ApplicationAccepted
	ApplicationRejected
	ApplicationFailed
)
View Source
const (
	DefaultUserTeamPrefix      = "~FlagField__defaultTeam"
	DefaultUserTeamDescription = "This is the default team for a single user."
	TableUser                  = "user"
	TableUserProfile           = "user_profile"
	TableRelUserTeam           = "rel_user_team"
	TableRelUserUnlockedHint   = "rel_user_unlocked_hint"
)
View Source
const (
	TableConfig = "config"
)
View Source
const (
	TableHint = "hint"
)
View Source
const (
	TableNotification = "notification"
)
View Source
const (
	TableResource = "resource"
)
View Source
const (
	TableSession = "session"
)

Variables

View Source
var (
	DefaultContest = Contest{
		Name:        "~FlagField__defaultContest",
		Description: "This is the default contest for Practice. Please do not delete this.",
		StartTime:   time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
		EndTime:     constants.MaxTime,
		Access:      0,
		IsHidden:    true,
		CreatorID:   0,
	}
)
View Source
var (
	DefaultUser = User{
		Username:     "~FlagField__guest",
		PasswordHash: "",
	}
)

Functions

func GenerateResourceUUID

func GenerateResourceUUID() string

func GenerateSalt

func GenerateSalt() string

func GetConfig

func GetConfig(db *gorm.DB, key string) string

func GetContestCount

func GetContestCount(db *gorm.DB) uint

func GetPasswordHash

func GetPasswordHash(password string, salt string) string

func GetProblemID

func GetProblemID(db *gorm.DB, contestID uint, alias string) (uint, error)

func GetSubmissionCount

func GetSubmissionCount(db *gorm.DB) uint

func GetUserCount

func GetUserCount(db *gorm.DB) uint

func HasEmail

func HasEmail(db *gorm.DB, email string) bool

func HasPendingApplication

func HasPendingApplication(db *gorm.DB, teamID, userID uint) bool

func HasPendingInvitation

func HasPendingInvitation(db *gorm.DB, teamID, userID uint) bool

func HasProblemAlias

func HasProblemAlias(db *gorm.DB, contestID uint, alias string) bool

func HasTeamName

func HasTeamName(db *gorm.DB, name string) bool

func HasUsername

func HasUsername(db *gorm.DB, username string) bool

func IsContestAdmin

func IsContestAdmin(db *gorm.DB, contestID, userID uint) bool

func IsTeamMemberByUserID

func IsTeamMemberByUserID(db *gorm.DB, teamID uint, userID uint) bool

func MigrateSystem

func MigrateSystem(db *gorm.DB)

func SetConfig

func SetConfig(db *gorm.DB, key string, value string)

func SetItem

func SetItem()

Types

type Config

type Config struct {
	gorm.Model
	Key   string `gorm:"size:100"`
	Value string `gorm:"type:longtext"`
}

func GetConfigs

func GetConfigs(db *gorm.DB) []Config

type Contest

type Contest struct {
	gorm.Model
	Name          string `gorm:"size:50;not null"`
	Description   string `gorm:"type:longtext"`
	StartTime     time.Time
	EndTime       time.Time
	Access        uint
	IsHidden      bool
	CreatorID     uint
	Problems      []*Problem
	Admins        []*User         `gorm:"many2many:rel_contest_admin"`
	TeamSnapshots []*TeamSnapshot `gorm:"foreignkey:ContestID"`
	Resources     []*Resource
	Notifications []*ContestNotification
}

func GetContestByID

func GetContestByID(db *gorm.DB, id uint) (*Contest, error)

func GetContests

func GetContests(db *gorm.DB) []Contest

func GetContestsFilterByStatus

func GetContestsFilterByStatus(db *gorm.DB, status uint) []Contest

func GetDefaultContest

func GetDefaultContest(db *gorm.DB) *Contest

func NewContest

func NewContest(db *gorm.DB, name string, description string, startTime time.Time, endTime time.Time, access uint, creatorID uint) *Contest

func (*Contest) AddAdmin

func (c *Contest) AddAdmin(db *gorm.DB, user *User)

func (*Contest) AddNotification

func (c *Contest) AddNotification(db *gorm.DB, content string) int

func (*Contest) AddProblem

func (c *Contest) AddProblem(db *gorm.DB, problem *Problem)

Add association

func (*Contest) AddResource

func (c *Contest) AddResource(db *gorm.DB, res *Resource)

func (*Contest) AddTeam

func (c *Contest) AddTeam(db *gorm.DB, team *Team, usersID []uint) error

func (*Contest) Delete

func (c *Contest) Delete(db *gorm.DB)

func (*Contest) DeleteAdmin

func (c *Contest) DeleteAdmin(db *gorm.DB, user *User)

func (*Contest) DeleteTeamByID

func (c *Contest) DeleteTeamByID(db *gorm.DB, teamID uint) error

TeamDelete association

func (*Contest) GenerateRank

func (c *Contest) GenerateRank(db *gorm.DB)

Data proceed

func (*Contest) GetAdmins

func (c *Contest) GetAdmins(db *gorm.DB) []User

func (*Contest) GetNotificationByOrder

func (c *Contest) GetNotificationByOrder(db *gorm.DB, order int) (*ContestNotification, error)

Get association

func (*Contest) GetNotifications

func (c *Contest) GetNotifications(db *gorm.DB, from time.Time, offset uint) []ContestNotification

func (*Contest) GetProblems

func (c *Contest) GetProblems(db *gorm.DB) []Problem

func (*Contest) GetTeamSnapshots

func (c *Contest) GetTeamSnapshots(db *gorm.DB) []TeamSnapshot

func (*Contest) GetTeams

func (c *Contest) GetTeams(db *gorm.DB) []Team

func (*Contest) GetUserTeam

func (c *Contest) GetUserTeam(db *gorm.DB, user *User) (*Team, error)

func (*Contest) HasPlayerByUserID

func (c *Contest) HasPlayerByUserID(db *gorm.DB, usersID []uint) bool

func (*Contest) HasTeamByTeamID

func (c *Contest) HasTeamByTeamID(db *gorm.DB, teamID uint) bool

func (*Contest) IsAdmin

func (c *Contest) IsAdmin(db *gorm.DB, user *User) bool

Permission check

func (*Contest) IsPlayer

func (c *Contest) IsPlayer(db *gorm.DB, user *User) bool

func (*Contest) Update

func (c *Contest) Update(db *gorm.DB)

type ContestNotification

type ContestNotification struct {
	gorm.Model
	ContestID uint
	Content   string
}

func (*ContestNotification) Delete

func (n *ContestNotification) Delete(db *gorm.DB)

type ContestRank

type ContestRank struct {
	gorm.Model
	ContestID uint
	TeamID    uint
	Points    uint
	Rank      uint
}

type Flag

type Flag struct {
	gorm.Model
	ProblemID     uint
	Type          string       `gorm:"not null"`
	SettingsPlain []byte       `gorm:"column:settings,type:longtext"`
	Settings      FlagSettings `gorm:"-"`
}

func (*Flag) AfterFind

func (f *Flag) AfterFind() (err error)

func (*Flag) BeforeSave

func (f *Flag) BeforeSave() (err error)

func (*Flag) Check

func (f *Flag) Check(s string) bool

func (*Flag) Delete

func (f *Flag) Delete(db *gorm.DB)

func (*Flag) Update

func (f *Flag) Update(db *gorm.DB)

type FlagSettings

type FlagSettings interface {
	Type() string
	FromMap(*map[string][]string) error
	FromPlain([]byte) error
	Plain() []byte
	Check(string) bool
	IsValid() bool
}

func NewFlagSettingsFromMap

func NewFlagSettingsFromMap(ft FlagType, m map[string]interface{}) (fs FlagSettings, err error)

type FlagStatic

type FlagStatic struct {
	Flag string `json:"flag"`
}

func (*FlagStatic) Check

func (f *FlagStatic) Check(s string) bool

func (*FlagStatic) FromMap

func (f *FlagStatic) FromMap(m *map[string][]string) error

func (*FlagStatic) FromPlain

func (f *FlagStatic) FromPlain(b []byte) error

func (*FlagStatic) IsValid

func (f *FlagStatic) IsValid() bool

func (*FlagStatic) Plain

func (f *FlagStatic) Plain() (j []byte)

func (*FlagStatic) Type

func (f *FlagStatic) Type() string

type FlagType

type FlagType string

type Hint

type Hint struct {
	gorm.Model
	ProblemID     uint
	Cost          uint
	Content       string  `gorm:"type:longtext"`
	UnlockedUsers []*User `gorm:"many2many:rel_user_unlocked_hint"`
}

func (*Hint) Delete

func (h *Hint) Delete(db *gorm.DB)

func (*Hint) IsUnlocked

func (h *Hint) IsUnlocked(db *gorm.DB, contest *Contest, problem *Problem, user *User) bool

func (*Hint) Unlock

func (h *Hint) Unlock(db *gorm.DB, contest *Contest, problem *Problem, user *User) error

func (*Hint) Update

func (h *Hint) Update(db *gorm.DB)

type Notification

type Notification struct {
	gorm.Model
	UserID    uint
	Content   string `gorm:"type:longtext"`
	IsRead    bool
	CreatorID uint
}

func GetNotificationByID

func GetNotificationByID(db *gorm.DB, id uint) (*Notification, error)

func GetNotifications

func GetNotifications(db *gorm.DB, offset uint, limit uint) []Notification

func GetUserNotifications

func GetUserNotifications(db *gorm.DB, user *User, offset uint) []Notification

func NewNotification

func NewNotification(db *gorm.DB, userID uint, content string, creatorID uint) *Notification

func (*Notification) Delete

func (n *Notification) Delete(db *gorm.DB)

func (*Notification) Update

func (n *Notification) Update(db *gorm.DB)

type Problem

type Problem struct {
	gorm.Model
	Name        string `gorm:"size:50;not null"`
	Description string `gorm:"type:longtext"`
	Alias       string `gorm:"size:50;not null"`
	ContestID   uint
	Points      uint
	Type        string `gorm:"size:50;not null"`
	IsHidden    bool
	CreatorID   uint
	Flags       []*Flag
	Hints       []*Hint
	Resources   []*Resource
	Submissions []*Submission
	Solvers     []*User       `gorm:"many2many:rel_problem_solver"`
	Tags        []*ProblemTag `gorm:"many2many:rel_problem_tag"`
}

func GetProblemByAliasAndContestID

func GetProblemByAliasAndContestID(db *gorm.DB, alias string, contestID uint) (*Problem, error)

func NewProblem

func NewProblem(db *gorm.DB, name string, description string, alias string, contestID uint, points uint, typ string, creatorID uint) *Problem

func (*Problem) AddFlag

func (p *Problem) AddFlag(db *gorm.DB, ft FlagType, fs FlagSettings) int

func (*Problem) AddFlagWithSettingsMap

func (p *Problem) AddFlagWithSettingsMap(db *gorm.DB, ft FlagType, m map[string]interface{}) (int, error)

func (*Problem) AddHint

func (p *Problem) AddHint(db *gorm.DB, cost uint, content string) int

func (*Problem) AddResource

func (p *Problem) AddResource(db *gorm.DB, res *Resource)

func (*Problem) AddSolver

func (p *Problem) AddSolver(db *gorm.DB, u *User)

func (*Problem) AddTag

func (p *Problem) AddTag(db *gorm.DB, tag string)

func (*Problem) Delete

func (p *Problem) Delete(db *gorm.DB)

func (*Problem) DeleteTag

func (p *Problem) DeleteTag(db *gorm.DB, tagName string)

func (*Problem) GetFlagByOrder

func (p *Problem) GetFlagByOrder(db *gorm.DB, order int) (*Flag, error)

func (*Problem) GetFlags

func (p *Problem) GetFlags(db *gorm.DB) []Flag

func (*Problem) GetHintByOrder

func (p *Problem) GetHintByOrder(db *gorm.DB, order int) (*Hint, error)

func (*Problem) GetHints

func (p *Problem) GetHints(db *gorm.DB) []Hint

func (*Problem) GetResources

func (p *Problem) GetResources(db *gorm.DB) []Resource

func (*Problem) GetSolvers

func (p *Problem) GetSolvers(db *gorm.DB) []User

func (*Problem) GetTags

func (p *Problem) GetTags(db *gorm.DB) []ProblemTag

func (*Problem) GetTagsName

func (p *Problem) GetTagsName(db *gorm.DB) []string

func (*Problem) Update

func (p *Problem) Update(db *gorm.DB)

type ProblemTag

type ProblemTag struct {
	gorm.Model
	Name     string     `gorm:"not null"`
	Problems []*Problem `gorm:"many2many:rel_problem_tag"`
}

type Resource

type Resource struct {
	gorm.Model
	UUID        string `gorm:"unique;not null"`
	Name        string `gorm:"size:255;not null"`
	Path        string `gorm:"size:4096;not null"`
	ContentType string `gorm:"not null"`
	ExpiredAt   time.Time
	IsHidden    bool
	CreatorID   uint
	ContestID   uint
	ProblemID   uint
}

func GetContestResources

func GetContestResources(db *gorm.DB, contestID uint) []Resource

func GetProblemResources

func GetProblemResources(db *gorm.DB, problemID uint) []Resource

func GetResourceByUUID

func GetResourceByUUID(db *gorm.DB, resourceUUID string) (*Resource, error)

func GetResources

func GetResources(db *gorm.DB) []Resource

func NewResourceWithReader

func NewResourceWithReader(db *gorm.DB, baseDir string, name string, contentType string, src io.Reader, userID uint) *Resource

func (*Resource) Delete

func (res *Resource) Delete(db *gorm.DB)

func (*Resource) Update

func (res *Resource) Update(db *gorm.DB)

type Session

type Session struct {
	gorm.Model
	SessionID string `gorm:"size:32;unique;not null"`
	User      *User
	UserID    uint
	ExpireAt  time.Time
}

func GetSessionBySessionID

func GetSessionBySessionID(db *gorm.DB, sessionID string) (*Session, error)

func GetSessions

func GetSessions(db *gorm.DB) []Session

func NewSession

func NewSession(db *gorm.DB, u *User, maxAge int) *Session

func (*Session) Del

func (s *Session) Del(rp *redis.Pool, key string)

func (*Session) Destroy

func (s *Session) Destroy(db *gorm.DB, rp *redis.Pool)

func (*Session) Get

func (s *Session) Get(rp *redis.Pool, key string, value interface{})

func (*Session) IsExpired

func (s *Session) IsExpired() bool

func (*Session) IsLoggedIn

func (s *Session) IsLoggedIn() bool

func (*Session) Renew

func (s *Session) Renew(db *gorm.DB, d time.Duration)

func (*Session) Set

func (s *Session) Set(rp *redis.Pool, key string, value interface{})

value must have JSON tag in order to marshal into a JSON string

func (*Session) Update

func (s *Session) Update(db *gorm.DB)

type Submission

type Submission struct {
	gorm.Model
	Flag      string `gorm:"type:longtext"`
	Result    uint
	ProblemID uint
	CreatorID uint
}

func GetSubmissions

func GetSubmissions(db *gorm.DB) []Submission

func NewSubmission

func NewSubmission(db *gorm.DB, flag string, problem *Problem, user *User) *Submission

type System

type System struct {
	gorm.Model
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Team

type Team struct {
	gorm.Model
	Name            string          `gorm:"size:50;unique;not null"`
	Description     string          `gorm:"type:longtext"`
	Members         []*User         `gorm:"many2many:rel_user_team"`
	Admins          []*User         `gorm:"many2many:rel_team_admin"`
	Snapshots       []*TeamSnapshot `gorm:"foreignkey:TeamID"`
	CreatorID       uint
	IsDefault       bool
	InvitationToken string `gorm:"size:32"`
}

func GetTeamByID

func GetTeamByID(db *gorm.DB, id uint) (*Team, error)

func GetTeams

func GetTeams(db *gorm.DB, query string) []Team

func GetUserTeams

func GetUserTeams(db *gorm.DB, userID uint, admin bool, query string) []Team

func NewTeam

func NewTeam(db *gorm.DB, name string, description string, creatorID uint) *Team

func (*Team) AddAdmin

func (t *Team) AddAdmin(db *gorm.DB, user *User)

func (*Team) AddMember

func (t *Team) AddMember(db *gorm.DB, user *User)

Add associations

func (*Team) CalcContestPoints

func (t *Team) CalcContestPoints(db *gorm.DB, contest *Contest) (points uint)

Calculate points in contest

func (*Team) Delete

func (t *Team) Delete(db *gorm.DB)

func (*Team) DeleteAdmin

func (t *Team) DeleteAdmin(db *gorm.DB, user *User)

func (*Team) DeleteMember

func (t *Team) DeleteMember(db *gorm.DB, user *User)

TeamDelete associations

func (*Team) GenerateInvitationToken

func (t *Team) GenerateInvitationToken(db *gorm.DB)

Invitation token

func (*Team) GetAdmins

func (t *Team) GetAdmins(db *gorm.DB) []User

func (*Team) GetContestRank

func (t *Team) GetContestRank(db *gorm.DB, contest *Contest) (*ContestRank, error)

func (*Team) GetContests

func (t *Team) GetContests(db *gorm.DB) []Contest

func (*Team) GetCorrectSubmissions

func (t *Team) GetCorrectSubmissions(db *gorm.DB, contest *Contest) []Submission

func (*Team) GetMembers

func (t *Team) GetMembers(db *gorm.DB, query string) []User

Get associations

func (*Team) GetMembersCount

func (t *Team) GetMembersCount(db *gorm.DB) uint

func (*Team) GetSnapshotByContestID

func (t *Team) GetSnapshotByContestID(db *gorm.DB, contestID uint) (*TeamSnapshot, error)

func (*Team) GetSnapshots

func (t *Team) GetSnapshots(db *gorm.DB) []TeamSnapshot

func (*Team) GetSolvedProblems

func (t *Team) GetSolvedProblems(db *gorm.DB, contest *Contest) []Problem

func (*Team) GetUnlockedHints

func (t *Team) GetUnlockedHints(db *gorm.DB, contest *Contest) []Hint

func (*Team) IsAdmin

func (t *Team) IsAdmin(db *gorm.DB, user *User) bool

func (*Team) IsAdminByUserID

func (t *Team) IsAdminByUserID(db *gorm.DB, userID uint) bool

func (*Team) IsAllMemberByUserID

func (t *Team) IsAllMemberByUserID(db *gorm.DB, userID []uint) bool

Permission check

func (*Team) IsMember

func (t *Team) IsMember(db *gorm.DB, user *User) bool

func (*Team) IsMemberByUserID

func (t *Team) IsMemberByUserID(db *gorm.DB, userID uint) bool

func (*Team) NewSnapshot

func (t *Team) NewSnapshot(db *gorm.DB, contest *Contest, usersID []uint) (*TeamSnapshot, error)

func (*Team) Update

func (t *Team) Update(db *gorm.DB)

type TeamApplication

type TeamApplication struct {
	gorm.Model
	TeamID uint
	UserID uint
	Status uint
}

func GetPendingApplication

func GetPendingApplication(db *gorm.DB, teamID, userID uint) (*TeamApplication, error)

func GetTeamApplications

func GetTeamApplications(db *gorm.DB, teamID uint) []TeamApplication

func GetUserApplications

func GetUserApplications(db *gorm.DB, userID uint) []TeamApplication

func NewTeamApplication

func NewTeamApplication(db *gorm.DB, team *Team, userID uint) *TeamApplication

func (*TeamApplication) Accept

func (app *TeamApplication) Accept(db *gorm.DB) error

func (*TeamApplication) Delete

func (app *TeamApplication) Delete(db *gorm.DB)

func (*TeamApplication) Reject

func (app *TeamApplication) Reject(db *gorm.DB) error

func (*TeamApplication) Update

func (app *TeamApplication) Update(db *gorm.DB)

type TeamInvitation

type TeamInvitation struct {
	gorm.Model
	TeamID   uint
	ToUser   uint
	FromUser uint
	Status   uint
}

func GetPendingInvitation

func GetPendingInvitation(db *gorm.DB, teamID, userID uint) (*TeamInvitation, error)

func GetTeamInvitations

func GetTeamInvitations(db *gorm.DB, teamID uint) []TeamInvitation

func GetUserInvitations

func GetUserInvitations(db *gorm.DB, userID uint) []TeamInvitation

func NewTeamInvitation

func NewTeamInvitation(db *gorm.DB, team *Team, toUserID, fromUserID uint) *TeamInvitation

func (*TeamInvitation) Accept

func (inv *TeamInvitation) Accept(db *gorm.DB) error

func (*TeamInvitation) Delete

func (inv *TeamInvitation) Delete(db *gorm.DB)

func (*TeamInvitation) Reject

func (inv *TeamInvitation) Reject(db *gorm.DB) error

func (*TeamInvitation) Update

func (inv *TeamInvitation) Update(db *gorm.DB)

type TeamSnapshot

type TeamSnapshot struct {
	gorm.Model
	TeamID    uint
	ContestID uint
	Members   []*User `gorm:"many2many:rel_team_snapshot_member"`
}

func (*TeamSnapshot) Delete

func (ts *TeamSnapshot) Delete(db *gorm.DB)

func (*TeamSnapshot) GetMembers

func (ts *TeamSnapshot) GetMembers(db *gorm.DB) []User

type User

type User struct {
	gorm.Model
	Username         string `gorm:"size:20;unique;not null"`
	PasswordHash     string `gorm:"not null"`
	Email            string `gorm:"size:100"`
	Profile          *UserProfile
	IsAdmin          bool
	IsHidden         bool
	IsBanned         bool
	DefaultTeam      uint
	AsContestAdmin   []*Contest      `gorm:"many2many:rel_contest_admin"`
	AsTeamAdmin      []*Team         `gorm:"many2many:rel_team_admin"`
	SolvedProblems   []*Problem      `gorm:"many2many:rel_problem_solver"`
	UnlockedHints    []*Hint         `gorm:"many2many:rel_user_unlocked_hint"`
	Submissions      []*Submission   `gorm:"foreignkey:CreatorID"`
	CreatedContests  []*Contest      `gorm:"foreignkey:CreatorID"`
	CreatedProblems  []*Problem      `gorm:"foreignkey:CreatorID"`
	CreatedTeams     []*Team         `gorm:"foreignkey:CreatorID"`
	CreatedResources []*Resource     `gorm:"foreignkey:CreatorID"`
	Teams            []*Team         `gorm:"many2many:rel_user_team"`
	TeamSnapshots    []*TeamSnapshot `gorm:"many2many:rel_team_snapshot_member"`
}

func GetAdmins

func GetAdmins(db *gorm.DB) []User

func GetUserByID

func GetUserByID(db *gorm.DB, id uint) (*User, error)

func GetUserByUsername

func GetUserByUsername(db *gorm.DB, username string) (*User, error)

func GetUsers

func GetUsers(db *gorm.DB) []User

func GetUsersByID

func GetUsersByID(db *gorm.DB, id []uint) []User

func GetUsersWithQuery

func GetUsersWithQuery(db *gorm.DB, offset, limit uint, query string) []User

func NewUser

func NewUser(db *gorm.DB, username string, password string) (*User, error)

func (*User) CalcPersonalContestPoints

func (u *User) CalcPersonalContestPoints(db *gorm.DB, contest *Contest) (points uint)

func (*User) CalcTeamContestPoints

func (u *User) CalcTeamContestPoints(db *gorm.DB, contest *Contest) (uint, error)

func (*User) ChangePassword

func (u *User) ChangePassword(db *gorm.DB, password string)

func (*User) Delete

func (u *User) Delete(db *gorm.DB)

func (*User) GetContestTeam

func (u *User) GetContestTeam(db *gorm.DB, contest *Contest) (*Team, error)

func (*User) GetSolvedProblems

func (u *User) GetSolvedProblems(db *gorm.DB, contest *Contest) []Problem

Get associations

func (*User) HasContestAccess

func (u *User) HasContestAccess(db *gorm.DB, contest *Contest) bool

func (*User) HasResourceAccess

func (u *User) HasResourceAccess(db *gorm.DB, res *Resource) bool

func (*User) HasTeamAccess

func (u *User) HasTeamAccess(db *gorm.DB, team *Team) bool

func (*User) IsContestAdmin

func (u *User) IsContestAdmin(db *gorm.DB, contest *Contest) bool

Permission check

func (*User) IsResourceAdmin

func (u *User) IsResourceAdmin(res *Resource) bool

func (*User) IsTeamAdmin

func (u *User) IsTeamAdmin(db *gorm.DB, team *Team) bool

func (*User) MatchPassword

func (u *User) MatchPassword(password string) bool

Information control

func (*User) Update

func (u *User) Update(db *gorm.DB)

type UserProfile

type UserProfile struct {
	gorm.Model
	Nickname    string `gorm:"size:20"`
	Page        string `gorm:"size:100"`
	Description string `gorm:"size:1000"`
	UserID      uint
}

Jump to

Keyboard shortcuts

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