models

package
v0.0.0-...-e75809f Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: GPL-3.0 Imports: 14 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TeamRoleValues = [...]string{
	"Member",
	"Manager",
	"Admin",
}

TeamRoleValues ...

Functions

func GetUserFieldMeta

func GetUserFieldMeta(fieldName string) admin.Meta

GetUserFieldMeta ...

func RegisterOTPToAdmin

func RegisterOTPToAdmin(Admin *admin.Admin, config admin.Config)

RegisterOTPToAdmin ...

func RegisterTeamToAdmin

func RegisterTeamToAdmin(Admin *admin.Admin, config admin.Config)

RegisterTeamToAdmin ...

func RegisterUserProfileToAdmin

func RegisterUserProfileToAdmin(Admin *admin.Admin, config admin.Config)

RegisterUserProfileToAdmin ...

func RegisterUserTeamToAdmin

func RegisterUserTeamToAdmin(Admin *admin.Admin, config admin.Config)

RegisterUserTeamToAdmin ...

func RegisterUserToAdmin

func RegisterUserToAdmin(Admin *admin.Admin, config admin.Config)

RegisterUserToAdmin ...

Types

type OTP

type OTP struct {
	Code     string `gorm:"type:varchar(16);primary_key"`
	ExpiryAt time.Time
	User     User
	UserID   uint `gorm:"unique"`
}

OTP ...

func (*OTP) BeforeCreate

func (otp *OTP) BeforeCreate(scope *gorm.Scope) error

BeforeCreate ...

func (OTP) GetReSendTime

func (otp OTP) GetReSendTime() int

GetReSendTime ...

type Role

type Role struct {
	gorm.Model
	Name string `gorm:"type:varchar(64)"`
}

Role represent supported user roles

type Team

type Team struct {
	gorm.Model
	Name             string `gorm:"type:varchar(64);not null"`
	Description      string `gorm:"type:text"`
	Active           bool   `gorm:"default:true; not null"`
	TimeProviderName string `gorm:"not null"`
	Users            []User
}

Team represent a team/project comprising a set of user

func (*Team) BeforeSave

func (team *Team) BeforeSave(scope *gorm.Scope) error

BeforeSave ...

type TeamRole

type TeamRole int8

TeamRole ...

const (
	MemberRole TeamRole = iota
	ManagerRole
	AdminRole
)

TeamRole ...

func (TeamRole) String

func (teamRole TeamRole) String() string

type TimeProviderConfig

type TimeProviderConfig struct {
	Data interface{} `json:"data"`
	Type string      `json:"type"`
}

TimeProviderConfig ...

type User

type User struct {
	gorm.Model
	Email              string       `gorm:"type:varchar(255); not null; unique_index"`
	FirstName          string       `gorm:"type:varchar(30); not null"`
	LastName           string       `gorm:"type:varchar(150)"`
	Password           []byte       `gorm:"type:bytea"`
	Active             bool         `gorm:"default:true; not null"`
	TimeProviderConfig fields.JSONB `gorm:"type:jsonb; not null; default:'{}'::jsonb"`
	IsAdmin            bool         `gorm:"default:false; not null"`
	Teams              []Team
	Profiles           []UserProfile
}

User represent the app user in system

func (*User) BeforeSave

func (user *User) BeforeSave() error

BeforeSave ...

func (*User) CleanUserData

func (user *User) CleanUserData() error

CleanUserData ...

func (User) DisplayName

func (user User) DisplayName() string

DisplayName ...

func (User) Stringify

func (user User) Stringify() string

Stringify ...

type UserProfile

type UserProfile struct {
	gorm.Model
	User   User
	UserID uint `gorm:"not null"`
	Role   Role
	RoleID uint `gorm:"not null"`
	Active bool `gorm:"default:false; not null"`
}

UserProfile associated to app users A user can have multiple profile, but only one of them could be active at any moment

type UserTeam

type UserTeam struct {
	gorm.Model
	User     User
	UserID   uint `gorm:"not null"`
	Team     Team
	TeamID   uint      `gorm:"not null"`
	Role     TeamRole  `gorm:"default:0; not null"`
	JoinedAt time.Time `gorm:"not null"`
	LeavedAt *time.Time
}

UserTeam represent team associations of a users

func (*UserTeam) BeforeSave

func (userTeam *UserTeam) BeforeSave(db *gorm.DB) (err error)

BeforeSave ...

Jump to

Keyboard shortcuts

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