models

package
v0.0.0-...-cde1f39 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TeamEntryRequestPending  = "pending"
	TeamEntryRequestApproved = "approved"
	TeamEntryRequestRejected = "rejected"
)
View Source
const (
	SuperAdminRole = "super_admin"
	AdminRole      = "admin"
	MemberRole     = "member"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider struct {
	gorm.Model
	ProviderKey  string `gorm:"size:255;not null"`
	UserID       uint   // Foreign key to the User model
	ProviderName string `gorm:"size:255;not null"`
}

type DeletionConfirmation

type DeletionConfirmation struct {
	gorm.Model
	Email     string `gorm:"unique"`
	OTP       string
	ValidTill time.Time
}

type ForgotPassword

type ForgotPassword struct {
	gorm.Model
	Email     string `gorm:"unique"`
	OTP       string
	ValidTill time.Time
}

type Location

type Location struct {
	Latitude  float64
	Longitude float64
	Altitude  float64
}

Location struct to hold lat long and alt for Meeting

type Meeting

type Meeting struct {
	gorm.Model
	TeamID           uint      `gorm:"not null"`
	Title            string    `gorm:"size:255;not null"`
	Description      string    `gorm:"size:255;not null"`
	Venue            string    `gorm:"size:255;not null"`
	Location         Location  `gorm:"embedded"`
	StartTime        time.Time `gorm:"not null"` // Unix timestamp, for info purposes only. Attendance will start on manual start.
	MeetingPeriod    bool      `gorm:"default:false"`
	AttendancePeriod bool      `gorm:"default:false"` // Members can mark attendance while true. Can only be started after meeting has started. Is ended alongside meeting end if not ended before.
	MeetingOver      bool      `gorm:"default:false"` // Will not show meeting on dashboard if true, can be seen in some history tab
	AttendanceOver   bool      `gorm:"default:false"`
}

Members can start marking attendance after meeting has been started (MeetingPeriod = true), and attendance is open (AttendancePeriod = true). Their attendance will be OnTime = true. If they mark attendance after attendance closed (AttendancePeriod = false), but while meeting still ongoing (MeetingPeriod = True), their attendance will be OnTime = false. They cannot mark attendance after meeting has ended (MeetingOver = true), which is set when MeetingPeriod = true -> false. A meeting can only be deleted if MeetingPeriod = false and AttendancePeriod = false and MeetingOver = false. I.e., meeting hasn't started yet.

func (*Meeting) BeforeCreate

func (m *Meeting) BeforeCreate(tx *gorm.DB) error

add isvalid check to model to check if venue, title, description are not empty strings or missing add isvalid check to model to check if location is valid add isvalid check to model to check if starttime is in the future all this in a beforecreate hook

type MeetingAttendance

type MeetingAttendance struct {
	gorm.Model
	UserID             uint      `gorm:"primaryKey;not null"`
	MeetingID          uint      `gorm:"primaryKey;not null"`
	AttendanceMarkedAt time.Time `gorm:"not null"`
	OnTime             bool
}

func (*MeetingAttendance) BeforeCreate

func (ma *MeetingAttendance) BeforeCreate(tx *gorm.DB) error

type MeetingAttendanceListResponse

type MeetingAttendanceListResponse struct {
	ID                 uint
	MeetingID          uint
	AttendanceMarkedAt time.Time
	OnTime             bool
	User               User
	MeetingName        string
	TeamName           string
}

type PasswordAuth

type PasswordAuth struct {
	gorm.Model
	Email    string `gorm:"size:255;not null;unique;"`
	Password string `gorm:"size:255;not null;"`
	UserID   uint   `gorm:"unique;"`
}

func (*PasswordAuth) HashPassword

func (pa *PasswordAuth) HashPassword() error

type Team

type Team struct {
	gorm.Model
	Name         string `gorm:"not null;unique"`
	Description  string
	SuperAdminID uint // Foreign key to the user who is the super admin of this team
	// Meetings    []Meeting
	Protected bool   `gorm:"default:false"`   // If true, then users will need to be approved by the super admin to join this team
	Invite    string `gorm:"unique;not null"` // Invite code for this team, length 10
}

func (*Team) BeforeCreate

func (t *Team) BeforeCreate(tx *gorm.DB) error

gorm on create hook to generate invite code if not provided

type TeamEntryRequest

type TeamEntryRequest struct {
	gorm.Model
	TeamID uint   `gorm:"not null"`
	UserID uint   `gorm:"not null"`
	Status string `gorm:"not null;default:'pending'"` // 'pending', 'approved', 'rejected'
}

type TeamMember

type TeamMember struct {
	gorm.Model
	TeamID uint `gorm:"primaryKey"`
	UserID uint `gorm:"primaryKey"`
	Role   string
}

type User

type User struct {
	gorm.Model
	Email        string `gorm:"size:255;not null;unique;"`
	Name         string `gorm:"size:255;not null;"`
	ProfileImage string `gorm:"size:255;"`
	Verified     bool   `gorm:"default:false"`
}

type UserUpcomingMeetingsListResponse

type UserUpcomingMeetingsListResponse struct {
	Meeting Meeting
	Team    Team
}

type VerificationEntry

type VerificationEntry struct {
	gorm.Model
	Email string `gorm:"unique"`
	OTP   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳