controller

package
v0.0.0-...-0ad18f3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2017 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package controller holds all handlers and handler functions as well as necessary infrastructure for session management and security

work.go implements all controller actions and their helper functions for the parent work.html template. This also comprises the search functionality. All user work is done on tabs that are dynamically loaded into the work template. These have their own controller files.

Index

Constants

View Source
const S_APPLICANT = "GOSTIP_APPLICANT"
View Source
const S_DKFAI = "DKFAI-App-Session"

keys for the session store

View Source
const S_USER = "GOSTIP_USER"

Variables

This section is empty.

Functions

func AuthAny

func AuthAny(h http.Handler) http.Handler

authorize for anyone who is logged in

func AuthEnrol

func AuthEnrol(h http.Handler) http.Handler

authorize for deans office staff for enrolling

func AuthMasterAdmin

func AuthMasterAdmin(h http.Handler) http.Handler

authorize for master administrator

func AuthProjectOffice

func AuthProjectOffice(h http.Handler) http.Handler

authorize for project office staff

func AuthUserAdmin

func AuthUserAdmin(h http.Handler) http.Handler

authorize for user administrator

func FindApplicant

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

handler function that executes a database search for applicants and returns an html fragment for a select box.

func GetChecklistCsv

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

controller function to prepare a csv file with applicant enrol data for download

func GetResultsCsv

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

controller function to prepare a csv file with applicant data for download

func HandleIndex

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

func HandleLogin

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

func HandleLogin handles requests to login. For GET requests, the login form gets displayed. POST requests are checked for a valid username/password. If check succeeds, a user session is initiated and username and user information are stored in the session store.

func HandleLogout

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

func HandleLogout serves requests to /logout. It cancels the current user session and redirects to login page.

func HandleWork

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

load the "work" template. Tabs are included depending on role of current user.

func MergeDiff

func MergeDiff(mineOld, mineNew, otherNew interface{}, automerge bool, tag ...string) (diffs map[string]MergeInfo, err error)

function MergeDiff runs a three way diff between the old and new versions of my struct and a different changed version of the same struct, similar to git merge. Differences are flagged in return parameter diffs using type MergeDiffType.If automerge is true, mineNew fields get updated to updated fields of otherNew and only changed fields are flagged in diffs. mineOld, mineNew, otherNew must be pointers to same struct types. If tag is not empty, only fields are compared that are tagged with the given tag and the tag value will be used as key in the diffs map.

func MergeScaleResults

func MergeScaleResults(diffs map[string]MergeInfo, key string)

function MergeScale scales integral values by factor for all map keys that contain string key

func RedirectHTTP

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

RedirectHTTP is an HTTP handler (suitable for use with http.HandleFunc) that responds to all requests by redirecting to the same URL served over HTTPS. It should only be invoked for requests received over HTTP.

func RequestLogger

func RequestLogger(h http.Handler) http.Handler

RequestLogger uses logRequest function to log request info to log output

func SessionChecker

func SessionChecker(h http.Handler) http.Handler

SessionChecker filter checks if there is a valid session, i.e if someone is logged in

func SessionStore

func SessionStore() sessions.Store

accessor for the gorilla session store

func SetRouting

func SetRouting() *mux.Router

func ShowCancellation

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

ShowCancellation is handler to show the selected applicant from the search select element for cancellation tab. It returns an html page fragment that is inserted into the respective tab area.

func ShowEnrol

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

ShowEnrol is handler to show the selected applicant from the search select element for enrol and edit tabs. It returns an html page fragment that is inserted into the respective tab area.

func ShowRegistration

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

ShowRegistration is handler for registration form get requests: On GET, show an empty registration form, on POST save data into db and show a confirmation message.

func ShowResults

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

controller function to show applicant data for results editing

func SubmitApplicantDelete

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

SubmitApplicantDelete is handler that accepts form submissions from the edit tab. Only http POST method is accepted.

func SubmitApplicantEdit

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

SubmitEdit is handler that accepts form submissions from the edit tab. Only http POST method is accepted.

func SubmitCancelation

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

SubmitCancellation is handler that accepts form submissions from the cancellation tab. Only http POST method is accepted.

func SubmitEnrol

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

SubmitEnrol is handler that accepts form submissions from the enrol tab. Only http POST method is accepted.

func SubmitRegistration

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

SubmitRegistration is handler for registration form post requests: On POST save data into db and show a confirmation message.

func SubmitResults

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

submit results into ApplicantData struct

Types

type HandlerSwitch

type HandlerSwitch struct {
	Mux          http.Handler
	Redirect     http.Handler
	AllowedHosts []string
}

interne Aufrufe vom gleichen lokalen Netz mit Mux annehmen, sonst redirect auf HTTPS

func (*HandlerSwitch) ServeHTTP

func (h *HandlerSwitch) ServeHTTP(w http.ResponseWriter, r *http.Request)

Handler function, die Internetzugriffe auf den Redirect Handler umleitet. Lokale Zugriffe werden direkt von MUX geroutet

type MergeDiffType

type MergeDiffType int
const (
	NONE   MergeDiffType = iota // no changes at all
	MINE                        // only my value changed
	THEIRS                      // only their value changed
	BOTH                        // both values changed and are different
	SAME                        // both values changed but are equal
)

type MergeInfo

type MergeInfo struct {
	Mine     interface{}
	Other    interface{}
	Conflict MergeDiffType
}

type to record value changes for web forms

Jump to

Keyboard shortcuts

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