admin

package module
v0.0.0-...-d47133a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DBStr          = os.Getenv("POSTGRES_STR")
	ADMIN_PASSWORD = os.Getenv("ADMIN_PASSWORD")
	DB             *gorm.DB
	//go:embed templates/*
	Templates embed.FS
)

Functions

func AdminDashboard

func AdminDashboard(w http.ResponseWriter, r *http.Request)

func AuthHandler

func AuthHandler(next http.Handler) http.Handler

func AutoMigrateDB

func AutoMigrateDB()

func GetLogin

func GetLogin(w http.ResponseWriter, r *http.Request)

func GetLogout

func GetLogout(w http.ResponseWriter, r *http.Request)

func GetRefreshCourses

func GetRefreshCourses(w http.ResponseWriter, r *http.Request)

func GetRefreshMajors

func GetRefreshMajors(w http.ResponseWriter, r *http.Request)

func InitDB

func InitDB()

func PostLogin

func PostLogin(w http.ResponseWriter, r *http.Request)

func PostRefreshCourses

func PostRefreshCourses(w http.ResponseWriter, r *http.Request)

func PostRefreshMajors

func PostRefreshMajors(w http.ResponseWriter, r *http.Request)

func ScrapeCoursesOfMajors

func ScrapeCoursesOfMajors(majors []Major)

func ScrapeMajors

func ScrapeMajors()

Types

type Course

type Course struct {
	CRN              string `gorm:"primarykey"`
	MajorCode        string `gorm:"not null"`
	Major            Major  `gorm:"foreignKey:MajorCode;constraint:OnDelete:CASCADE"`
	Code             string
	Catalogue        string
	Title            string
	TeachingMethod   string
	Instructor       string
	Lectures         []Lecture
	Capacity         int
	Enrolled         int
	Reservation      string
	MajorRestriction string
	Prerequisites    string
	ClassRestriction string
	CreatedAt        time.Time
	UpdatedAt        time.Time
	DeletedAt        gorm.DeletedAt `gorm:"index"`
}

type Lecture

type Lecture struct {
	gorm.Model
	CourseCRN string `gorm:"uniqueIndex:idx_lecture;not null"`
	Course    Course `gorm:"foreignKey:CourseCRN;constraint:OnDelete:CASCADE"`
	Building  string
	Day       string `gorm:"uniqueIndex:idx_lecture"`
	Time      string `gorm:"uniqueIndex:idx_lecture"`
	TimeStart int
	TimeEnd   int
	Room      string
}

type Major

type Major struct {
	Code        string `gorm:"primarykey"`
	Courses     []Course
	CreatedAt   time.Time
	RefreshedAt time.Time
}

type Post

type Post struct {
	gorm.Model
	Author  string        `json:"author"`
	Date    string        `json:"date"`
	Content template.HTML `json:"content"`
}

type Result

type Result struct {
	Major    Major
	Courses  []Course
	Lectures []Lecture
}

type Schedule

type Schedule struct {
	gorm.Model
	UserID     uint `gorm:"not null"`
	User       User `gorm:"constraint:OnDelete:CASCADE;"`
	IsSelected bool
	Courses    []Course `gorm:"many2many:schedule_courses_go;"`
}

func (Schedule) TableName

func (Schedule) TableName() string

type Session

type Session struct {
	Token     string `gorm:"primarykey"`
	UserID    uint   `gorm:"not null"`
	User      User   `gorm:"constraint:OnDelete:CASCADE"`
	ExpiresAt time.Time
	CreatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type User

type User struct {
	gorm.Model
	Username   string  `gorm:"unique" validate:"required"`
	Email      *string `gorm:"unique" validate:"required,email"`
	Password   *string `validate:"required"`
	IsAdmin    bool
	FacebookID *string `gorm:"unique"`
	TwitterID  *string `gorm:"unique"`
	MajorCode  *string
	Major      Major    `gorm:"foreignKey:MajorCode"`
	Courses    []Course `gorm:"many2many:user_courses_go;"`
	Schedules  []Schedule
	Sessions   []Session
}

Jump to

Keyboard shortcuts

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