public

package
v0.0.0-...-01500c1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*
		Permission Bit mask
	*/
	USER_PERMISSION_NORMAL = 0
	USER_PERMISSION_REVIEW = 1
	USER_PERMISSION_RECOMM = 2

	/*Admin Permission*/
	USER_PERMISSION_GM = 4
)
View Source
const (
	MAIN_STORAGE_BUCKET = "nthu-a-plus-storage"

	USER_AUTH_SESSION           = "user-auth"
	USER_ID_SESSION_KEY         = "user_id"
	USER_PERMISSION_SESSION_KEY = "user_perm"
	REVIEWER_AUTH_SESSION       = "reviewer-auth"
	REVIEWER_ID_SESSION_KEY     = "reviewer_id"
	GM_AUTH_SESSION             = "gm-auth"
	GM_ID_SESSION_KEY           = "gm_id"

	APPLICATION_DB_FORM_COLLECTION   = "forms"
	APPLICATION_DB_RECOMM_COLLECTION = "recomms"
)
View Source
const (
	GM_PERMITTED_HEADER_KEY = "GM-AUTHORIZE-DATA"
)

Variables

View Source
var (
	CONFIG_FILE_NAME string = "config"
	Config           *viper.Viper

	DB_ADDRESS string = "127.0.0.1"

	//Loggers
	LogV *log.Logger
	LogD *log.Logger
	LogE *log.Logger
	LogW *log.Logger

	//Session
	SessionStorage *sessions.CookieStore

	//Cloud Storage Signed URL
	StoragePrivateKey          []byte
	StorageServiceAccountEmail string

	RecommLetterSubject string
	RecommLetterTmpl    *template.Template
)

Functions

func AuthGMVerifierWrapper

func AuthGMVerifierWrapper(handler http.HandlerFunc) http.HandlerFunc

func AuthReviewerVerifyWrapper

func AuthReviewerVerifyWrapper(handler http.HandlerFunc) http.HandlerFunc

func AuthUserVerifierWrapper

func AuthUserVerifierWrapper(handler http.HandlerFunc) http.HandlerFunc

func ConvertName

func ConvertName(rawString string) string

func EmailFilter

func EmailFilter(orig string) string

func FormalIdVerifier

func FormalIdVerifier(str string) bool

func GetGMSessionValue

func GetGMSessionValue(req *http.Request, key interface{}) (interface{}, error)

func GetNewApplicationDatabase

func GetNewApplicationDatabase() *mgo.Database

func GetNewMiscDatabase

func GetNewMiscDatabase() *mgo.Database

func GetNewReviewerDatabase

func GetNewReviewerDatabase() *mgo.Database

func GetNewStagingDatabase

func GetNewStagingDatabase() *mgo.Database

func GetNewUserDatabase

func GetNewUserDatabase() *mgo.Database

func GetReviewerSessionValue

func GetReviewerSessionValue(req *http.Request, key interface{}) (interface{}, error)

func GetSessionGMId

func GetSessionGMId(req *http.Request) (bson.ObjectId, error)

func GetSessionReviewerId

func GetSessionReviewerId(req *http.Request) (bson.ObjectId, error)

func GetSessionUserId

func GetSessionUserId(req *http.Request) (bson.ObjectId, error)

func GetUserSessionValue

func GetUserSessionValue(req *http.Request, key interface{}) (interface{}, error)

func NewHashString

func NewHashString() string

func NewSecureHashString

func NewSecureHashString() string

func RequestMethodGuard

func RequestMethodGuard(handler http.HandlerFunc, methods ...string) http.HandlerFunc

func ResponseOkAsJson

func ResponseOkAsJson(resp http.ResponseWriter, value interface{}) (int, error)

func ResponseStatusAsJson

func ResponseStatusAsJson(resp http.ResponseWriter, status int, value interface{}) (int, error)

func SendMail

func SendMail(to string, applier BasicUser, url string) error

func SetGMSessionValue

func SetGMSessionValue(req *http.Request, resp http.ResponseWriter, key, value interface{}) error

func SetReviewerSessionValue

func SetReviewerSessionValue(req *http.Request, resp http.ResponseWriter, key, value interface{}) error

func SetUserSessionValue

func SetUserSessionValue(req *http.Request, resp http.ResponseWriter, key, value interface{}) error

func StringJoin

func StringJoin(sep string, elements ...string) string

Types

type BasicUser

type BasicUser struct {
	Name  string
	Email string
}

type FileStoragePath

type FileStoragePath string

type RecommResult

type RecommResult struct {
	Recommender BasicUser
	ApplyUser   BasicUser
	Done        bool
	Hash        string "" //Only for reviewers and GMs
}

type RecommView

type RecommView struct {
	Hash string

	Recommender BasicUser
	ApplyUser   BasicUser
	Topic       string

	LastModified time.Time
	Content      string
	Attachment   string
}

type ReviewResponse

type ReviewResponse struct {
	ResearchArea int `json:"researchArea"`
	Classes      int `json:"classes"`
	Skills       int `json:"skills"`
	Grade        int `json:"grade"`
	Language     int `json:"language"`
	ResearchPlan int `json:"researchPlan"`
	Recomm       int `json:"recomm"`
	Other        int `json:"other"`
	Overall      int `json:"overall"`
}

type ReviewScore

type ReviewScore uint

type ReviewerProfile

type ReviewerProfile struct {
	Email     string
	Username  string
	FormalId  string
	Thumbnail string ""

	Topics      []TopicId
	Permissions []string
}

type SimpleResult

type SimpleResult struct {
	Message     string ""
	Description string ""
}

type TopicId

type TopicId uint

type UserPermission

type UserPermission uint64

func GetSessionUserPermission

func GetSessionUserPermission(req *http.Request) (UserPermission, error)

func (UserPermission) ContainsPermission

func (this UserPermission) ContainsPermission(perm_bit uint64) bool

type UserProfile

type UserProfile struct {
	Email     string
	Username  string
	FormalId  string
	Thumbnail string ""
}

Jump to

Keyboard shortcuts

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