models

package
v0.0.0-...-253fa15 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package models contains all database tables as structs and their validation functions. It also contains additional structs representing front end data, such as the user login credentials.

Index

Constants

View Source
const (
	//BoolTrue ...
	BoolTrue = "true"

	//TableFAQCategory DB table name
	TableFAQCategory = "faq_category"
	//TableNewsFeedCategory DB table name
	TableNewsFeedCategory = "news_feed_category"

	//EventTypeNormal allows users to enroll in normal events
	EventTypeNormal = "normal"
	//EventTypeCalendar allows users to enroll in calender slots
	EventTypeCalendar = "calendar"

	//TableAllowlists DB table name
	TableAllowlists = "allowlists"
	//TableBlocklists DB table name
	TableBlocklists = "blocklists"
	//TableInstructors DB table name
	TableInstructors = "instructors"
	//TableEditors DB table name
	TableEditors = "editors"

	//ColTitle DB column name
	ColTitle = "title"
	//ColAnnotation DB column name
	ColAnnotation = "annotation"
	//ColHasComments DB column name
	ColHasComments = "has_comments"
	//ColHasWaitlist DB column name
	ColHasWaitlist = "has_waitlist"
	//ColEnrollmentStart DB column name
	ColEnrollmentStart = "enrollment_start"
	//ColEnrollmentEnd DB column name
	ColEnrollmentEnd = "enrollment_end"
	//ColExpirationDate DB column name
	ColExpirationDate = "expiration_date"
	//ColUnsubscribeEnd DB column name
	ColUnsubscribeEnd = "unsubscribe_end"
	//ColVisible DB column name
	ColVisible = "visible"
	//ColOnlyLDAP DB column name
	ColOnlyLDAP = "only_ldap"
	//ColFee DB column name
	ColFee = "fee"
	//ColSubtitle DB column name
	ColSubtitle = "subtitle"
	//ColDescription DB column name
	ColDescription = "description"
	//ColSpeaker DB column name
	ColSpeaker = "speaker"
	//ColCustomEMail DB column name
	ColCustomEMail = "custom_email"
)

Variables

View Source
var FeePattern = regexp.MustCompile("^([0-9]{1,6}([,|.][0-9]{0,2})?)?")

FeePattern is the regular expression of accepted course fees

Functions

func BelongsToElement

func BelongsToElement(table, column1, column2 string, ID1, ID2 int) (belongs bool, err error)

BelongsToElement returns whether e.g. an event belongs to a course.

func GetEMailSubjectBody

func GetEMailSubjectBody(data *EMailData, language *string, subjectKey string,
	filename string, email *app.EMail, c *revel.Controller) (err error)

GetEMailSubjectBody assigns the template content to the e-mail body and sets the e-mail subject.

func ValidateLength

func ValidateLength(str *string, msgKey string, min, max int, v *revel.Validation)

ValidateLength of a not null string.

func ValidateLengthAndValid

func ValidateLengthAndValid(str *sql.NullString, msgKey string, min, max int, v *revel.Validation)

ValidateLengthAndValid sets valid to true if the string is not empty and also validates its length (if non-empty).

Types

type Affiliations

type Affiliations []string

Affiliations contains all affiliations of a user.

type CalendarEvent

type CalendarEvent struct {
	ID         int            `db:"id"`
	CourseID   int            `db:"course_id"`
	Title      string         `db:"title"`
	Annotation sql.NullString `db:"annotation"`

	//loaded week
	Monday time.Time
	Week   int
	Year   int

	//day templates for this week [0...6]
	Days Days

	//all upcoming exceptions
	Exceptions Exceptions

	//exeptions of this week
	ExceptionsOfWeek ExceptionsOfWeek
	//transformed schedule for easy front end usage
	ScheduleWeek []Schedule

	//used for enrollment
	NoEnroll      bool
	NoUnsubscribe bool
	EnrollMsg     string
}

CalendarEvent is a special calendar-based event of a course.

func (*CalendarEvent) Delete

func (event *CalendarEvent) Delete(v *revel.Validation) (users []EMailData, err error)

Delete a calendar event.

func (*CalendarEvent) Duplicate

func (event *CalendarEvent) Duplicate(tx *sqlx.Tx) (err error)

Duplicate an calendar event.

func (*CalendarEvent) Get

func (event *CalendarEvent) Get(tx *sqlx.Tx, courseID *int, monday time.Time, userID int) (err error)

Get a calendar event by its ID and a monday.

func (*CalendarEvent) GetColumnValue

func (event *CalendarEvent) GetColumnValue(tx *sqlx.Tx, column string) (err error)

GetColumnValue returns the value of a specific column.

func (*CalendarEvent) Insert

func (event *CalendarEvent) Insert(tx *sqlx.Tx, courseID int) (err error)

Insert a calendar event into a given Course_ID

func (*CalendarEvent) NewBlank

func (event *CalendarEvent) NewBlank() (err error)

NewBlank creates a new blank calendar event.

func (*CalendarEvent) Update

func (event *CalendarEvent) Update(column string, value interface{}) (err error)

Update the specific column in the calendar event.

type CalendarEvents

type CalendarEvents []CalendarEvent

CalendarEvents holds all calendar events of a course.

func (*CalendarEvents) Duplicate

func (events *CalendarEvents) Duplicate(tx *sqlx.Tx, courseIDNew, courseIDOld *int) (err error)

Duplicate all calendar events of a course.

func (*CalendarEvents) Get

func (events *CalendarEvents) Get(tx *sqlx.Tx, courseID *int, monday time.Time,
	userID int) (err error)

Get all calendar events by the provided monday.

func (*CalendarEvents) Insert

func (events *CalendarEvents) Insert(tx *sqlx.Tx, courseID *int) (err error)

Insert all calendar events.

type Categories

type Categories []Category

Categories holds all categories of either the FAQs or the news feed.

func (*Categories) Select

func (categories *Categories) Select(table string) (err error)

Select all categories and their respective entries from either the FAQs or the NewsFeed table.

type Category

type Category struct {
	ID         int           `db:"id, primarykey, autoincrement"`
	Name       string        `db:"name"`
	LastEditor sql.NullInt32 `db:"last_editor"`
	LastEdited string        `db:"last_edited"`

	Entries HelpPageEntries ``
}

Category is a model of the category table. Categories are used for grouping the entries of the FAQs (faq_category) and the news feed (news_feed_category).

func (*Category) Delete

func (category *Category) Delete(table *string) (err error)

Delete a category from either faq_category or news_feed_category.

func (*Category) Insert

func (category *Category) Insert(table *string, userID *int) (err error)

Insert a new category into either faq_category or news_feed_category.

func (*Category) Update

func (category *Category) Update(table *string, userID *int) (err error)

Update a category in either faq_category or news_feed_category.

func (*Category) Validate

func (category *Category) Validate(v *revel.Validation)

Validate Category fields.

type ChildHasCourseLimit

type ChildHasCourseLimit struct{}

ChildHasCourseLimit implements whether any child group has a course limit or not.

func (ChildHasCourseLimit) DefaultMessage

func (courseLimit ChildHasCourseLimit) DefaultMessage() string

DefaultMessage returns the default message of ChildHasCourseLimit.

func (ChildHasCourseLimit) IsSatisfied

func (courseLimit ChildHasCourseLimit) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of ChildHasCourseLimit.

type Course

type Course struct {
	ID                int             `db:"id, primarykey, autoincrement"`
	Title             string          `db:"title"`
	Creator           sql.NullInt32   `db:"creator"`
	Subtitle          sql.NullString  `db:"subtitle"`
	Visible           bool            `db:"visible"`
	Active            bool            `db:"active"`
	OnlyLDAP          bool            `db:"only_ldap"`
	CreationDate      time.Time       `db:"creation_date"`
	Description       sql.NullString  `db:"description"`
	Speaker           sql.NullString  `db:"speaker"`
	Fee               sql.NullFloat64 `db:"fee"`
	CustomEMail       sql.NullString  `db:"custom_email"`
	EnrollLimitEvents sql.NullInt32   `db:"enroll_limit_events"`
	EnrollmentStart   time.Time       `db:"enrollment_start"`
	EnrollmentEnd     time.Time       `db:"enrollment_end"`
	UnsubscribeEnd    sql.NullTime    `db:"unsubscribe_end"`
	ExpirationDate    time.Time       `db:"expiration_date"`
	ParentID          sql.NullInt32   `db:"parent_id"`

	//course data of different tables
	Events         Events         ``
	CalendarEvents CalendarEvents ``
	Editors        UserList       ``
	Instructors    UserList       ``
	Blocklist      UserList       ``
	Allowlist      UserList       ``
	Restrictions   Restrictions   ``

	//additional information required when displaying the course
	CreatorData User ``

	//path to the course entry in the groups tree
	Path Groups ``

	//used for correct template rendering
	CreatorID string
	Expired   bool

	//used to add/edit course restrictions
	CoursesOfStudies CoursesOfStudies
	Degrees          Degrees

	//used for enrollment
	CourseStatus CourseStatus
	Manage       bool

	//used to render buttons for redirect
	CanEdit               bool `db:"can_edit"`
	CanManageParticipants bool `db:"can_manage_participants"`
	IsCreator             bool

	//used for pretty timestamp rendering
	CreationDateStr    string         `db:"creation_date_str"`
	EnrollmentStartStr string         `db:"enrollment_start_str"`
	EnrollmentEndStr   string         `db:"enrollment_end_str"`
	UnsubscribeEndStr  sql.NullString `db:"unsubscribe_end_str"`
	ExpirationDateStr  string         `db:"expiration_date_str"`
}

Course is a model of the course table.

func (*Course) Activate

func (course *Course) Activate(v *revel.Validation) (invalid bool,
	users EMailsData, err error)

Activate a course.

func (*Course) Delete

func (course *Course) Delete() (valid bool, err error)

Delete a course. Courses must be inactive or expired to be deleted.

func (*Course) Duplicate

func (course *Course) Duplicate() (err error)

Duplicate a course.

func (*Course) Get

func (course *Course) Get(tx *sqlx.Tx, manage bool, userID int) (err error)

Get all course data. If manage is false, only get publicly available course data. Also, if it is false, get enrollment information for this user for each event.

func (*Course) GetColumnValue

func (course *Course) GetColumnValue(tx *sqlx.Tx, column string) (err error)

GetColumnValue returns the value of a specific column.

func (*Course) GetForEnrollment

func (course *Course) GetForEnrollment(tx *sqlx.Tx, userID, eventID *int) (err error)

GetForEnrollment returns only the information required for enrollment.

func (*Course) GetForValidation

func (course *Course) GetForValidation(tx *sqlx.Tx) (err error)

GetForValidation only returns the course data required for validation.

func (*Course) GetVisible

func (course *Course) GetVisible(elem string) (err error)

GetVisible of a course.

func (*Course) InsertFromDraft

func (course *Course) InsertFromDraft(v *revel.Validation) (err error)

InsertFromDraft inserts a new course by duplicating an existing course.

func (*Course) InsertUploadedCourse

func (course *Course) InsertUploadedCourse() (err error)

InsertUploadedCourse a new course from a provided course struct. The course struct is extracted from an uploaded JSON file.

func (*Course) Load

func (course *Course) Load(version int, data *[]byte) (success bool, err error)

Load a course from a JSON file. The JSON can have the struct of the old Turm2.

func (*Course) NewBlank

func (course *Course) NewBlank() (err error)

NewBlank creates a new blank course.

func (*Course) Update

func (course *Course) Update(tx *sqlx.Tx, column string, value interface{},
	conf *EditEMailConfig) (err error)

Update the specified column in the course table.

func (*Course) UpdateTimestamp

func (course *Course) UpdateTimestamp(v *revel.Validation, conf *EditEMailConfig,
	fieldID string, t time.Time, valid bool) (err error)

UpdateTimestamp of a course. Also ensures validitiy, if the course is already active.

func (*Course) Validate

func (course *Course) Validate(v *revel.Validation)

Validate all course fields.

type CourseList

type CourseList []CourseListInfo

CourseList holds the most essential information about a list of courses.

func (*CourseList) Get

func (list *CourseList) Get(active, expired bool, userID int, role string) (
	editor, instructor CourseList, err error)

Get the course lists for the specified users.

func (*CourseList) GetByUserID

func (list *CourseList) GetByUserID(tx *sqlx.Tx, userID int, userType string, active,
	expired bool) (err error)

GetByUserID returns all courses according to the user type.

func (*CourseList) Search

func (list *CourseList) Search(value string) (err error)

Search all courses.

func (*CourseList) SearchForDrafts

func (list *CourseList) SearchForDrafts(value string, userID int, role string) (err error)

SearchForDrafts returns all courses that can be duplicated by a creator.

type CourseListInfo

type CourseListInfo struct {
	ID              int       `db:"id, primarykey, autoincrement"`
	Title           string    `db:"title"`
	CreationDate    time.Time `db:"creation_date"`
	CreationDateStr string    `db:"creation_date_str"`
	EMail           string    `db:"email"` //e-mail address of either the creator or the editor
}

CourseListInfo holds only the most essential information about courses.

type CourseOfStudies

type CourseOfStudies struct {
	ID   int    `db:"id, primarykey, autoincrement"`
	Name string `db:"name"`
}

CourseOfStudies of a student.

type CourseStatus

type CourseStatus struct {
	AtBlocklist             bool
	AtAllowlist             bool
	UnsubscribeOver         bool `db:"unsubscribe_over"`
	NoEnrollmentPeriod      bool `db:"no_enrollment_period"`
	NotSatisfyRestrictions  bool
	NotLDAP                 bool
	MaxEnrollCoursesReached bool
	MaxEnrollCourses        int `db:"limit"`
}

CourseStatus validates the enrollment status of an user for a course.

type Courses

type Courses []Course

Courses holds different courses.

type CoursesOfStudies

type CoursesOfStudies []CourseOfStudies

CoursesOfStudies holds all existing courses of studies.

func (*CoursesOfStudies) Get

func (courses *CoursesOfStudies) Get(tx *sqlx.Tx) (err error)

Get all courses of studies.

type Credentials

type Credentials struct {
	Username     string
	EMail        string
	Password     string
	StayLoggedIn bool
}

Credentials entered at the login page.

func (*Credentials) Validate

func (credentials *Credentials) Validate(v *revel.Validation)

Validate the credentials.

type CustomEMailData

type CustomEMailData struct {
	Salutation    Salutation     `db:"salutation"`
	Title         sql.NullString `db:"title"`
	NameAffix     sql.NullString `db:"name_affix"`
	AcademicTitle sql.NullString `db:"academic_title"`
	LastName      string         `db:"last_name"`
	FirstName     string         `db:"first_name"`
	CourseID      int            `db:"course_id"`
	CourseTitle   string         `db:"course_title"`
	EventTitle    string         `db:"event_title"`
	MeetingCount  int            `db:"meeting_count"`
	EMailCreator  string         `db:"email_creator"`
	Start         string         `db:"start"`
	End           string         `db:"end"`
	URL           string
}

CustomEMailData contains all fields that can be used in the custom e-mail.

type CustomTime

type CustomTime struct {
	Value string
	Hour  int
	Min   int
}

CustomTime is used to compare times.

func (*CustomTime) After

func (t1 *CustomTime) After(t2 *CustomTime) (after bool)

After checks if t1 is after (>) t2.

func (*CustomTime) Before

func (t1 *CustomTime) Before(t2 *CustomTime) (before bool)

Before checks if t1 is before or equal (<=) t2.

func (*CustomTime) Equals

func (t1 *CustomTime) Equals(t2 *CustomTime) (equals bool)

Equals checks if t1 equals t2.

func (*CustomTime) SetTime

func (t1 *CustomTime) SetTime(value string) (success bool)

SetTime uses a time string of format '12:50'. If value is a valid time it sets hour and min.

func (*CustomTime) String

func (t1 *CustomTime) String()

String sets the value field of the CustomTime struct.

func (*CustomTime) Sub

func (t1 *CustomTime) Sub(t2 *CustomTime) (min int)

Sub returns the time interval between two times.

type Day

type Day struct {
	Date     string
	DayTmpls DayTmpls
}

Day contains all day templates of a specific week day.

type DayTmpl

type DayTmpl struct {
	ID              int    `db:"id"`
	CalendarEventID int    `db:"calendar_event_id"`
	StartTime       string `db:"start_time"`
	EndTime         string `db:"end_time"`
	Interval        int    `db:"interval"`
	DayOfWeek       int    `db:"day_of_week"` //must be an integer between [0, 6]

	Slots Slots
}

DayTmpl is a section of a week day (Monday - Sunday).

func (*DayTmpl) Delete

func (tmpl *DayTmpl) Delete() (users EMailsData, err error)

Delete a day template if it has no slots.

func (*DayTmpl) Insert

func (tmpl *DayTmpl) Insert(tx *sqlx.Tx, v *revel.Validation) (err error)

Insert a day template.

func (*DayTmpl) Update

func (tmpl *DayTmpl) Update(v *revel.Validation) (users []EMailData, err error)

Update a day tmpl.

type DayTmpls

type DayTmpls []DayTmpl

DayTmpls holds all day templates of a specific week day.

func (*DayTmpls) Duplicate

func (tmpls *DayTmpls) Duplicate(tx *sqlx.Tx, eventIDNew, eventIDOld *int) (err error)

Duplicate all day templates of a calendar event.

type Days

type Days []Day

Days of a week.

func (*Days) Get

func (days *Days) Get(tx *sqlx.Tx, calendarEventID *int, monday time.Time,
	participants bool, viewMatrNr bool, userID int) (err error)

Get all days of a calendar event for a specific week.

type Degree

type Degree struct {
	ID   int    `db:"id, primarykey, autoincrement"`
	Name string `db:"name"`
}

Degree pursued by a student.

type Degrees

type Degrees []Degree

Degrees holds all existing degrees.

func (*Degrees) Get

func (degrees *Degrees) Get(tx *sqlx.Tx) (err error)

Get all degrees.

type EMailData

type EMailData struct {

	//used for salutation, user specific changes (new pw, role, activation, ...)
	User User

	//used for linking to the page
	URL string

	//used for enrollment
	CourseTitle string         `db:"course_title"`
	EventTitle  string         `db:"event_title"`
	CourseID    int            `db:"course_id"`
	CustomEMail sql.NullString `db:"custom_email"`

	//used for changing the enrollment status
	Status EnrollmentStatus

	//new course role type
	CourseRole string
	ViewMatrNr bool

	//used for slot enrollments
	Start  string `db:"start"`
	End    string `db:"end"`
	UserID int    `db:"user_id"`

	//used for notifying users about edits
	Field string

	//used for the custom enrollment e-mail
	CustomEMailData CustomEMailData
}

EMailData holds all data that is rendered in the different e-mail templates.

type EMailsData

type EMailsData []EMailData

EMailsData holds the data for multiple e-mails.

type EditEMailConfig

type EditEMailConfig struct {
	OptionUsers     int
	OptionEditors   int
	ID              int
	IsEvent         bool
	IsCalendarEvent bool

	Users              Users
	EditorsInstructors Users

	CourseTitle string `db:"course_title"`
	EventTitle  string `db:"event_title"`
	CourseID    int    `db:"course_id"`

	Field string
}

EditEMailConfig provides all information for sending edit notification e-mails.

func (*EditEMailConfig) Get

func (conf *EditEMailConfig) Get(tx *sqlx.Tx) (err error)

Get all information for sending edit notification e-mails.

type EnrollOption

type EnrollOption int

EnrollOption is a type for encoding different enrollment options.

const (
	//ENROLL is for normally enrolling in an event
	ENROLL EnrollOption = iota
	//UNSUBSCRIBE is for normally unsubscribing from an event
	UNSUBSCRIBE
	//NOENROLL disables the enrollment button
	NOENROLL
	//NOUNSUBSCRIBE disables the unsubscribe button
	NOUNSUBSCRIBE
	//ENROLLTOWAITLIST is for enrolling to the wait list
	ENROLLTOWAITLIST
	//UNSUBSCRIBEFROMWAITLIST is for unsubscribing from the wait list
	UNSUBSCRIBEFROMWAITLIST
)

func (EnrollOption) String

func (s EnrollOption) String() string

type Enrolled

type Enrolled struct {
	UserID           int              `db:"user_id, primarykey"`
	EventID          int              `db:"event_id, primarykey"`
	Status           EnrollmentStatus `db:"status"`
	TimeOfEnrollment time.Time        `db:"time_of_enrollment"`
	Comment          sql.NullString   `db:"comment"`

	//used for pretty timestamp rendering
	TimeOfEnrollmentStr string `db:"time_of_enrollment_str"`

	//used for profile page
	CourseID    int    `db:"course_id"`
	CourseTitle string `db:"course_title"`
	EventTitle  string `db:"event_title"`

	Start string `db:"start"`
	End   string `db:"end"`
}

Enrolled is a model of the enrolled table.

func (*Enrolled) ChangeStatus

func (enrolled *Enrolled) ChangeStatus(courseID *int, v *revel.Validation) (data EMailData,
	err error)

ChangeStatus updates the enrollment status of a user.

func (*Enrolled) Enroll

func (enrolled *Enrolled) Enroll(courseID *int, v *revel.Validation) (data EMailData, err error)

Enroll a user via participants management.

func (*Enrolled) EnrollOrUnsubscribe

func (enrolled *Enrolled) EnrollOrUnsubscribe(action EnrollOption, key string) (data EMailData,
	waitList bool, users Users, msg string, err error)

EnrollOrUnsubscribe a user in/from an event.

func (*Enrolled) Unsubscribe

func (enrolled *Enrolled) Unsubscribe(courseID *int, v *revel.Validation) (data EMailData,
	users Users, err error)

Unsubscribe a user via participants management.

func (*Enrolled) Waitlist

func (enrolled *Enrolled) Waitlist(courseID *int, v *revel.Validation) (data EMailData,
	users Users, err error)

Waitlist enrolls a user to a wait list via participants management.

type EnrollmentStatus

type EnrollmentStatus int

EnrollmentStatus is a type for encoding the enrollment status.

const (
	//ENROLLED users enrolled in an event
	ENROLLED EnrollmentStatus = iota
	//ONWAITLIST users are at the waitlist of an event
	ONWAITLIST
	//AWAITINGPAYMENT users enrolled in an event but did not yet pay the fee of the course
	AWAITINGPAYMENT
	PAID
	//FREED users enrolled in an event and do not have to pay the fee of the course
	FREED
	//UNSUBSCRIBED users unsubscribed from an event
	UNSUBSCRIBED
)

func (EnrollmentStatus) String

func (status EnrollmentStatus) String() string

type Enrollments

type Enrollments []Enrolled

Enrollments of a user.

func (*Enrollments) SelectByCourse

func (enrollments *Enrollments) SelectByCourse(tx *sqlx.Tx, userID, courseID *int) (err error)

SelectByCourse selects all enrollments of a user for a specific course.

func (*Enrollments) SelectByUser

func (enrollments *Enrollments) SelectByUser(tx *sqlx.Tx, userID *int, expired bool) (err error)

SelectByUser returns all enrollments of a user.

func (*Enrollments) SelectSlotsByUser

func (enrollments *Enrollments) SelectSlotsByUser(tx *sqlx.Tx, userID *int, expired bool) (err error)

SelectSlotsByUser returns all slot enrollments of a user.

type Entries

type Entries []Entry

Entries of all users on either the participants list, the wait list or the unsubscribed list.

func (*Entries) Get

func (entries *Entries) Get(tx *sqlx.Tx, listType string, eventID *int, viewMatrNr bool) (err error)

Get all entries on a specific list.

func (*Entries) Search

func (entries *Entries) Search(ID, eventID, userID *int, value *string) (hasWaitlist bool, err error)

Search all entries.

type Entry

type Entry struct {
	User
	Enrolled
}

Entry of a user on either the participants list, the wait list or the unsubscribed list.

type Event

type Event struct {
	ID            int            `db:"id, primarykey, autoincrement"`
	CourseID      int            `db:"course_id"`
	Capacity      int            `db:"capacity"`
	HasWaitlist   bool           `db:"has_waitlist"`
	HasComments   bool           `db:"has_comments"`
	Title         string         `db:"title"`
	Annotation    sql.NullString `db:"annotation"`
	EnrollmentKey sql.NullString `db:"enrollment_key"`
	Meetings      Meetings       ``

	//Fullness is the number of users that enrolled in this event
	Fullness int ``
	//Percentage is (Fullness * 100) / Capacity
	Percentage int ``

	//comments of enrolled users (if enabled)
	Comments []sql.NullString

	//used for enrollment
	EventStatus  EventStatus
	EnrollOption EnrollOption
	EnrollMsg    string
}

Event is a model of the event table.

func (*Event) Delete

func (event *Event) Delete(v *revel.Validation) (err error)

Delete an event.

func (*Event) Duplicate

func (event *Event) Duplicate(tx *sqlx.Tx) (err error)

Duplicate an event.

func (*Event) Get

func (event *Event) Get(tx *sqlx.Tx) (err error)

Get returns all data of one event.

func (*Event) GetColumnValue

func (event *Event) GetColumnValue(tx *sqlx.Tx, column string) (err error)

GetColumnValue returns the value of a specific column.

func (*Event) NewBlank

func (event *Event) NewBlank(conf *EditEMailConfig) (err error)

NewBlank creates a new blank event.

func (*Event) Update

func (event *Event) Update(tx *sqlx.Tx, column string, value interface{},
	conf *EditEMailConfig) (users EMailsData, err error)

Update the specified column in the event table.

func (*Event) UpdateComments

func (event *Event) UpdateComments(option bool, v *revel.Validation) (err error)

UpdateComments of an event.

func (*Event) UpdateKey

func (event *Event) UpdateKey() (err error)

UpdateKey updates the enrollment key of an event.

func (*Event) UpdateWaitlist

func (event *Event) UpdateWaitlist(option bool, v *revel.Validation) (err error)

UpdateWaitlist of an event.

type EventStatus

type EventStatus struct {
	Enrolled           bool
	Full               bool
	EnrollLimitReached bool //important to evaluate EnrollLimitEvents
	OnWaitlist         bool
	InOtherEvent       bool
}

EventStatus validates the enrollment status of an user for a event.

type Events

type Events []Event

Events holds all events of a course.

func (*Events) Duplicate

func (events *Events) Duplicate(tx *sqlx.Tx, courseIDNew, courseIDOld *int) (err error)

Duplicate all events of a course.

func (*Events) Get

func (events *Events) Get(tx *sqlx.Tx, userID, courseID *int, manage bool,
	limit *sql.NullInt32) (err error)

Get all events of a course.

func (*Events) GetForValidation

func (events *Events) GetForValidation(tx *sqlx.Tx, courseID *int) (err error)

GetForValidation only returns event data required for course validation.

func (*Events) Insert

func (events *Events) Insert(tx *sqlx.Tx, courseID *int) (err error)

Insert all events of a course struct.

type Exception

type Exception struct {
	ID               int            `db:"id"`
	CalendarEventID  int            `db:"calendar_event_id"`
	ExceptionStartDB time.Time      `db:"exception_start"`
	ExceptionEndDB   time.Time      `db:"exception_end"`
	Annotation       sql.NullString `db:"annotation"`

	//used to get the front end values
	ExceptionStart     string `db:"exception_start_str"`
	ExceptionEnd       string `db:"exception_end_str"`
	ExceptionStartTime string ``
	ExceptionEndTime   string ``
}

Exception can lock a timespan on a specific date.

func (*Exception) Delete

func (except *Exception) Delete(tx *sqlx.Tx) (err error)

Delete an exception.

func (*Exception) Insert

func (except *Exception) Insert(tx *sqlx.Tx, v *revel.Validation) (users EMailsData, err error)

Insert an exception.

func (*Exception) Update

func (except *Exception) Update(v *revel.Validation) (users EMailsData, err error)

Update an exception.

type Exceptions

type Exceptions []Exception

Exceptions is a slice of exceptions.

func (*Exceptions) Duplicate

func (excepts *Exceptions) Duplicate(tx *sqlx.Tx, eventIDNew, eventIDOld *int) (err error)

Duplicate all exceptions of a calendar event.

func (*Exceptions) Get

func (excepts *Exceptions) Get(tx *sqlx.Tx, eventID *int) (err error)

Get all current or upcoming exceptions.

type ExceptionsOfWeek

type ExceptionsOfWeek []Exception

ExceptionsOfWeek holds all exeptions of a week [0....6].

func (*ExceptionsOfWeek) Get

func (excepts *ExceptionsOfWeek) Get(tx *sqlx.Tx, eventID *int, monday time.Time) (err error)

Get all exceptions of a week. Monday specifies the week for which all exceptions must be loaded.

type Group

type Group struct {
	ID          int           `db:"id, primarykey, autoincrement"`
	ParentID    sql.NullInt32 `db:"parent_id"`
	Name        string        `db:"name"`
	CourseLimit sql.NullInt32 `db:"course_limit"`
	LastEditor  sql.NullInt32 `db:"last_editor"`
	LastEdited  string        `db:"last_edited"`
	Groups      []Group       `` //not a field in the respective table

	//used to ensure unique IDs if more than one group tree is present at a page
	IDPrefix string ``
	//identifies whether any parent/child has a course limit
	InheritsLimits bool ``
	ChildHasLimits bool ``
	//used to open courses
	CourseID int `db:"course_id"`
}

Group is a model of the groups table. Groups are used to specify sections and subsections of an institution in which courses are placed.

func (*Group) Delete

func (group *Group) Delete() (err error)

Delete a group from the groups table.

func (*Group) Get

func (group *Group) Get(tx *sqlx.Tx) (err error)

Get a group by its ID.

func (*Group) Insert

func (group *Group) Insert(userID *int) (err error)

Insert a new group into the groups table.

func (*Group) Update

func (group *Group) Update(userID *int) (err error)

Update a group in the groups table.

func (*Group) Validate

func (group *Group) Validate(v *revel.Validation)

Validate Group fields.

type Groups

type Groups []Group

Groups holds all groups in which courses can be placed. The struct is filled recursively by traversing the children of each group.

func (*Groups) Select

func (groups *Groups) Select(prefix *string) (err error)

Select all groups.

func (*Groups) SelectByUser

func (groups *Groups) SelectByUser(userID *int, tx *sqlx.Tx) (err error)

SelectByUser selects all groups created by a user.

func (*Groups) SelectPath

func (groups *Groups) SelectPath(courseID *int, tx *sqlx.Tx) (err error)

SelectPath selects the path of a course in the groups tree.

type HelpPageEntries

type HelpPageEntries []HelpPageEntry

HelpPageEntries holds all entries of a specified help page.

type HelpPageEntry

type HelpPageEntry struct {
	ID         int           `db:"id, primarykey, autoincrement"`
	CategoryID int           `db:"category_id"`
	LastEditor sql.NullInt32 `db:"last_editor"`
	LastEdited string        `db:"last_edited"`

	//determine the entry type
	IsFAQ bool

	//NewsFeed value
	Content string `db:"content"`

	//FAQ values
	Question string `db:"question"`
	Answer   string `db:"answer"`
}

HelpPageEntry is a model for either a FAQ or a news feed entry.

func (*HelpPageEntry) Delete

func (entry *HelpPageEntry) Delete(table *string) (err error)

Delete an entry from either faq or news_feed.

func (*HelpPageEntry) Insert

func (entry *HelpPageEntry) Insert(userID *int) (err error)

Insert a help page entry into either the faq or the news_feed table.

func (*HelpPageEntry) Update

func (entry *HelpPageEntry) Update(userID *int) (err error)

Update a help page entry in either the faq or the news_feed table.

func (*HelpPageEntry) Validate

func (entry *HelpPageEntry) Validate(v *revel.Validation)

Validate either FAQ or NewsFeed entry fields.

type IsTimestamp

type IsTimestamp struct{}

IsTimestamp validates if a value can be parsed to a timestamp.

func (IsTimestamp) DefaultMessage

func (v IsTimestamp) DefaultMessage() string

DefaultMessage returns the default message of IsTimestamp.

func (IsTimestamp) IsSatisfied

func (v IsTimestamp) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of IsTimestamp.

type LanguageValidator

type LanguageValidator struct{}

LanguageValidator implements the validation of the selected language.

func (LanguageValidator) DefaultMessage

func (v LanguageValidator) DefaultMessage() string

DefaultMessage returns the default message of LanguageValidator.

func (LanguageValidator) IsSatisfied

func (v LanguageValidator) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of LanguageValidator.

type ListConf

type ListConf struct {

	//specify which users are downloaded/e-mailed
	AllEvents    bool
	EventIDs     []int
	Participants bool
	WaitList     bool
	Unsubscribed bool

	//used for downloading the participants list
	UseComma bool
	Filename string

	//used for sending an e-mail
	Subject string
	Content string

	//used to specify a time interval for calendar events
	Start     string
	End       string
	StartTime string
	EndTime   string
}

ListConf determines to whom an e-mail is send or which users are at the downloaded participants list.

type LogEntries

type LogEntries []LogEntry

LogEntries contains all relevant log entries.

func (*LogEntries) Insert

func (entries *LogEntries) Insert() (err error)

Insert opens the log file and inserts all new log entries.

func (*LogEntries) Select

func (entries *LogEntries) Select() (err error)

Select all log entries.

type LogEntry

type LogEntry struct {
	ID             int       `db:"id, primarykey, autoincrement"`
	TimeOfCreation time.Time `db:"time_of_creation"`
	JSON           string    `db:"json"`
	Solved         bool      `db:"solved"`

	TimeOfCreationStr string `db:"time_of_creation_str"`
}

LogEntry represents a line of the error log.

func (*LogEntry) Solve

func (entry *LogEntry) Solve() (err error)

Solve a log entry.

type Meeting

type Meeting struct {
	ID              int             `db:"id, primarykey, autoincrement"`
	EventID         int             `db:"event_id"`
	MeetingInterval MeetingInterval `db:"meeting_interval"`
	WeekDay         sql.NullInt32   `db:"weekday"`
	Place           sql.NullString  `db:"place"`
	Annotation      sql.NullString  `db:"annotation"`
	MeetingStart    time.Time       `db:"meeting_start"`
	MeetingEnd      time.Time       `db:"meeting_end"`

	//used to get the front end values
	MeetingStartTime string ``
	MeetingEndTime   string ``

	//used for pretty timestamp rendering
	MeetingStartStr string `db:"meeting_start_str"`
	MeetingEndStr   string `db:"meeting_end_str"`
}

Meeting is a model of the meeting table.

func (*Meeting) Delete

func (meeting *Meeting) Delete(conf *EditEMailConfig) (err error)

Delete a meeting.

func (*Meeting) Duplicate

func (meeting *Meeting) Duplicate(conf *EditEMailConfig) (err error)

Duplicate a meeting.

func (*Meeting) NewBlank

func (meeting *Meeting) NewBlank(conf *EditEMailConfig) (err error)

NewBlank creates a new blank meeting.

func (*Meeting) Update

func (meeting *Meeting) Update(conf *EditEMailConfig) (err error)

Update a meeting.

func (*Meeting) Validate

func (meeting *Meeting) Validate(v *revel.Validation)

Validate meeting fields.

type MeetingInterval

type MeetingInterval int

MeetingInterval is a type for encoding different types of meetings.

const (
	//SINGLE meetings happen once
	SINGLE MeetingInterval = iota
	//WEEKLY meetings happen every week
	WEEKLY
	//EVEN meetings happen in even weeks
	EVEN
	//ODD meetings happen in odd weeks
	ODD
)

func (MeetingInterval) String

func (interval MeetingInterval) String() string

type Meetings

type Meetings []Meeting

Meetings holds all meetings of an event.

func (*Meetings) Duplicate

func (meetings *Meetings) Duplicate(tx *sqlx.Tx, eventIDNew, eventIDOld *int) (err error)

Duplicate all meetings of an event.

func (*Meetings) Get

func (meetings *Meetings) Get(tx *sqlx.Tx, eventID *int) (err error)

Get all meetings of an event.

func (*Meetings) Insert

func (meetings *Meetings) Insert(tx *sqlx.Tx, eventID *int) (err error)

Insert all meetings of an event.

type NewCourseParam

type NewCourseParam struct {
	Title    string
	Option   Option
	CourseID int
	JSON     []byte
}

NewCourseParam holds all information about the different options to create a new course.

func (*NewCourseParam) Validate

func (param *NewCourseParam) Validate(v *revel.Validation, course *Course)

Validate NewCourseParam fields.

type NoActiveChildren

type NoActiveChildren struct{}

NoActiveChildren implements whether a group contains any subgroups or active courses.

func (NoActiveChildren) DefaultMessage

func (noneActive NoActiveChildren) DefaultMessage() string

DefaultMessage returns the default message of NoActiveChildren.

func (NoActiveChildren) IsSatisfied

func (noneActive NoActiveChildren) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of NoActiveChildren.

type NotRequired

type NotRequired struct{}

NotRequired implements the validation of fields that must not be set.

func (NotRequired) DefaultMessage

func (v NotRequired) DefaultMessage() string

DefaultMessage returns the default message of NotRequired.

func (NotRequired) IsSatisfied

func (v NotRequired) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of NotRequired.

type NotUnique

type NotUnique struct{}

NotUnique implements the validation of fields that must not be set.

func (NotUnique) DefaultMessage

func (v NotUnique) DefaultMessage() string

DefaultMessage returns the default message of NotUnique.

func (NotUnique) IsSatisfied

func (v NotUnique) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of NotUnique.

type NullAffiliations

type NullAffiliations struct {
	Affiliations Affiliations
	Valid        bool //Valid is true if Affiliations is not NULL
}

NullAffiliations represents affiliations that may be null.

func (*NullAffiliations) Scan

func (affiliations *NullAffiliations) Scan(value interface{}) error

Scan constructs NullAffiliations from a SQL Value.

func (NullAffiliations) Value

func (affiliations NullAffiliations) Value() (driver.Value, error)

Value constructs a SQL Value from NullAffiliations.

type Option

type Option int

Option encodes the different options to create a new course.

const (
	//BLANK is for empty courses
	BLANK Option = iota
	//DRAFT is for using existing courses
	DRAFT
	//UPLOAD is for uploading courses
	UPLOAD
)

func (Option) String

func (op Option) String() string

type ParentHasCourseLimit

type ParentHasCourseLimit struct{}

ParentHasCourseLimit implements whether any parent group has a course limit or not.

func (ParentHasCourseLimit) DefaultMessage

func (courseLimit ParentHasCourseLimit) DefaultMessage() string

DefaultMessage returns the default message of ParentHasCourseLimit.

func (ParentHasCourseLimit) IsSatisfied

func (courseLimit ParentHasCourseLimit) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of ParentHasCourseLimit.

type ParticipantList

type ParticipantList struct {

	//general event information
	Event

	//all participant lists of the event
	Participants Entries
	Waitlist     Entries
	Unsubscribed Entries

	//additional calendar event information
	IsCalendarEvent bool `db:"is_calendar_event"`
	Monday          time.Time
	Week            int
	Year            int
	//day templates for this week [0...6]
	Days Days

	//all slots of a calendar event
	Slots Slots
}

ParticipantList of an event.

type ParticipantLists

type ParticipantLists []ParticipantList

ParticipantLists of a course.

func (*ParticipantLists) Get

func (lists *ParticipantLists) Get(tx *sqlx.Tx, courseID *int, viewMatrNr bool,
	allSlots bool) (err error)

Get all participant lists of a course.

type Participants

type Participants struct {
	ID                 int            `db:"id, primarykey, autoincrement"`
	Title              string         `db:"title"`
	Active             bool           `db:"active"`
	EnrollmentStartStr string         `db:"enrollment_start_str"`
	EnrollmentEndStr   string         `db:"enrollment_end_str"`
	UnsubscribeEndStr  sql.NullString `db:"unsubscribe_end_str"`
	ExpirationDateStr  string         `db:"expiration_date_str"`
	ViewMatrNr         bool           `db:"view_matr_nr"`
	UserEMail          string         `db:"user_email"`

	Expired bool
	Lists   ParticipantLists
}

Participants of a course.

func (*Participants) Get

func (parts *Participants) Get(userID int, allSlots bool) (err error)

Get all participants of a course.

type Restriction

type Restriction struct {
	ID                int           `db:"id, primarykey, autoincrement"`
	CourseID          int           `db:"course_id"`
	MinimumSemester   sql.NullInt64 `db:"minimum_semester"`
	DegreeID          sql.NullInt64 `db:"degree_id"`
	CourseOfStudiesID sql.NullInt64 `db:"courses_of_studies_id"`

	//for usability
	DegreeName  sql.NullString `db:"degree_name"`
	StudiesName sql.NullString `db:"studies_name"`
}

Restriction is a model of the restriction table.

func (*Restriction) Delete

func (rest *Restriction) Delete() (err error)

Delete a restriction.

func (*Restriction) Exists

func (rest *Restriction) Exists(tx *sqlx.Tx) (exists bool, err error)

Exists returns if a restriction exists in the DB.

func (*Restriction) Insert

func (rest *Restriction) Insert(tx *sqlx.Tx, courseID int) (err error)

Insert restriction.

func (*Restriction) Update

func (rest *Restriction) Update() (err error)

Update restriction.

func (*Restriction) Validate

func (rest *Restriction) Validate(v *revel.Validation)

Validate Restriction fields.

type Restrictions

type Restrictions []Restriction

Restrictions of a course.

func (*Restrictions) Duplicate

func (rests *Restrictions) Duplicate(tx *sqlx.Tx, courseID, courseIDOld *int) (err error)

Duplicate all restrictions of a course.

func (*Restrictions) Get

func (rests *Restrictions) Get(tx *sqlx.Tx, courseID *int) (err error)

Get all restrictions of a course.

func (*Restrictions) InsertUploaded

func (rests *Restrictions) InsertUploaded(tx *sqlx.Tx, courseID int) (err error)

InsertUploaded restrictions of a course.

type Role

type Role int

Role is a type for encoding different user roles.

const (
	//USER is the default role without any extra privileges
	USER Role = iota
	//CREATOR allows the creation of courses
	CREATOR
	//ADMIN grants all privileges
	ADMIN
)

func (Role) String

func (u Role) String() string

type Salutation

type Salutation int

Salutation is a type for encoding different forms of address.

const (
	//NONE is for no form of address
	NONE Salutation = iota
	//MR is for Mr.
	MR
	//MS is for Ms.
	MS
)

func (Salutation) String

func (s Salutation) String() string

type Schedule

type Schedule struct {
	Date    string
	Entries []ScheduleEntry
	InPast  bool
	Today   bool
}

Schedule is a helper struct to display a day template at the front end.

type ScheduleEntry

type ScheduleEntry struct {
	StartTime string
	EndTime   string //should be the same as the subsequent start time
	Interval  int
	Type      ScheduleEntryType

	UserID string
	SlotID int
}

ScheduleEntry containing all information to print a section of a day template.

type ScheduleEntryType

type ScheduleEntryType int

ScheduleEntryType is a type for encoding different schedule entries.

const (
	//FREE is for no entry
	FREE ScheduleEntryType = iota
	//SLOT is for slots
	SLOT
	//EXCEPTION is for exceptions
	EXCEPTION
	//BLOCKED is for Timeslots between
	BLOCKED
)

func (ScheduleEntryType) String

func (s ScheduleEntryType) String() string

type Slot

type Slot struct {
	ID        int `db:"id"`
	DayTmplID int `db:"day_tmpl_id"`
	UserID    int `db:"user_id"`

	//date + time
	Start time.Time `db:"start_time"`
	End   time.Time `db:"end_time"`

	//used for participants management
	User     User
	StartStr string `db:"start_str"`
	EndStr   string `db:"end_str"`
}

Slot is a booked timespan on an specific date.

func (*Slot) BelongsToEvent

func (slot *Slot) BelongsToEvent(eventID int) (belongs bool, err error)

BelongsToEvent checks if a slot belongs to an event

func (*Slot) Delete

func (slot *Slot) Delete(v *revel.Validation) (data EMailData, err error)

Delete a slot if it it is more than an hour away.

func (*Slot) DeleteManual

func (slot *Slot) DeleteManual() (data EMailData, err error)

DeleteManual manually deletes a slot.

func (*Slot) Get

func (slot *Slot) Get(tx *sqlx.Tx) (err error)

Get all data of a slot.

func (*Slot) Insert

func (slot *Slot) Insert(v *revel.Validation, calendarEventID int,
	manual bool) (data EMailData, err error)

Insert a new slot.

type Slots

type Slots []Slot

Slots booked at a specific day within StartTime and EndTime of a day template.

func (*Slots) Get

func (slots *Slots) Get(tx *sqlx.Tx, dayTmplID int, monday time.Time,
	weekday int) (err error)

Get all slots of a day template. Monday specifies the week for which all slots must be loaded and weekday specifies the day.

func (*Slots) GetAllCalendarEvent

func (slots *Slots) GetAllCalendarEvent(tx *sqlx.Tx, calendarEventID int) (err error)

GetAllCalendarEvent returns all slots of a calendar event.

func (*Slots) GetAllDayTmpl

func (slots *Slots) GetAllDayTmpl(tx *sqlx.Tx, dayTmplID int) (err error)

GetAllDayTmpl returns all slots of a day template.

type Studies

type Studies []Study

Studies holds all courses of study of an user.

func (*Studies) Select

func (studies *Studies) Select(tx *sqlx.Tx, userID *int) (err error)

Select all courses of studies of a user.

type Study

type Study struct {
	UserID            int    `db:"user_id, primarykey"`
	Semester          int    `db:"semester"`
	DegreeID          int    `db:"degree_id, primarykey"`
	CourseOfStudiesID int    `db:"course_of_studies_id, primarykey"`
	Degree            string `db:"degree"`            //not a field in the studies table
	CourseOfStudies   string `db:"course_of_studies"` //not a field in the studies table
}

Study is a model of the studies table.

type Unique

type Unique struct{}

Unique implements the validation of the uniqueness of a column value in a provided table.

func (Unique) DefaultMessage

func (uniqueV Unique) DefaultMessage() string

DefaultMessage returns the default message of Unique.

func (Unique) IsSatisfied

func (uniqueV Unique) IsSatisfied(i interface{}) bool

IsSatisfied implements the validation result of Unique.

type Unsubscribed

type Unsubscribed struct {
	UserID  int `db:"user_id, primarykey"`
	EventID int `db:"event_id, primarykey"`
}

Unsubscribed is a model of the unsubscribed table.

type User

type User struct {
	ID         int            `db:"id, primarykey, autoincrement"`
	LastName   string         `db:"last_name"`
	FirstName  string         `db:"first_name"`
	EMail      string         `db:"email, unique"`
	Salutation Salutation     `db:"salutation"`
	Role       Role           `db:"role"`
	LastLogin  string         `db:"last_login"`
	FirstLogin string         `db:"first_login"`
	Language   sql.NullString `db:"language"`

	//ldap user fields
	MatrNr        sql.NullInt32    `db:"matr_nr, unique"`
	AcademicTitle sql.NullString   `db:"academic_title"`
	Title         sql.NullString   `db:"title"`
	NameAffix     sql.NullString   `db:"name_affix"`
	Affiliations  NullAffiliations `db:"affiliations"`
	Studies       Studies          ``

	//external user fields
	Password       sql.NullString `db:"password"`
	PasswordRepeat string         `` //not a field in the respective table
	ActivationCode sql.NullString `db:"activation_code"`

	//not a field in the resprective table
	IsEditor     bool
	IsInstructor bool

	//used for event enrollment
	IsLDAP bool `db:"is_ldap"`

	//used for profile page
	ActiveEnrollments  Enrollments
	ExpiredEnrollments Enrollments
	ActiveSlots        Enrollments
	ExpiredSlots       Enrollments
}

User is a model of the users table.

func (*User) AuthorizedToEdit

func (user *User) AuthorizedToEdit(table *string, ID *int) (authorized, expired bool, err error)

AuthorizedToEdit returns whether a user is authorized to edit a course or not.

func (*User) ChangeRole

func (user *User) ChangeRole() (err error)

ChangeRole of an user.

func (*User) ChangeUserData

func (user *User) ChangeUserData(v *revel.Validation) (err error)

ChangeUserData updates the salutation, first name, last name and e-mail of an user.

func (*User) GenerateNewPassword

func (user *User) GenerateNewPassword(v *revel.Validation) (err error)

GenerateNewPassword for an user.

func (*User) Get

func (user *User) Get(tx *sqlx.Tx) (err error)

Get all data of an user.

func (*User) GetBasicData

func (user *User) GetBasicData(tx *sqlx.Tx) (err error)

GetBasicData returns basic information of an user.

func (*User) GetNavigationData

func (user *User) GetNavigationData() (err error)

GetNavigationData returns all information used for the navigation bar.

func (*User) GetProfileData

func (user *User) GetProfileData() (err error)

GetProfileData returns all profile information of the user.

func (*User) HasElevatedRights

func (user *User) HasElevatedRights(ID *int, table string) (authorized, expired bool, err error)

HasElevatedRights returns whether a user is an instructor, editor, creator or admin (of a course).

func (*User) IsEditorInstructor

func (user *User) IsEditorInstructor(tx *sqlx.Tx) (bool, bool, error)

IsEditorInstructor returns whether a user is an editor or instructor or not.

func (*User) Login

func (user *User) Login() (err error)

Login inserts or updates a user. It provides all session values of that user.

func (*User) NewActivationCode

func (user *User) NewActivationCode() (err error)

NewActivationCode creates a new activation code for an user.

func (*User) NewPassword

func (user *User) NewPassword(newPw1, newPw2 string, v *revel.Validation) (err error)

NewPassword sets a new password for an user.

func (*User) Register

func (user *User) Register(v *revel.Validation) (err error)

Register inserts an external user. It provides all session values of that user.

func (*User) SetPrefLanguage

func (user *User) SetPrefLanguage() (err error)

SetPrefLanguage sets the preferred language of an user.

func (*User) Validate

func (user *User) Validate(tx *sqlx.Tx, v *revel.Validation)

Validate User fields when changing user data.

func (*User) ValidateRegister

func (user *User) ValidateRegister(tx *sqlx.Tx, v *revel.Validation)

ValidateRegister User fields of newly registered users.

func (*User) VerifyActivationCode

func (user *User) VerifyActivationCode() (success bool, err error)

VerifyActivationCode verifies an activation code.

type UserDetails

type UserDetails struct {
	User User

	//all groups created by this user
	Groups Groups

	//all (former) enrollments of the user
	Enrollments       []Enrolled
	FormerEnrollments []Unsubscribed

	//all courses in which the user was directly involved
	CreatedCourses []Course
	EditorOf       []Course
	InstructorOf   []Course

	//all courses of which the user was on the allowlist/blocklist
	OnAllowlist []Course
	OnBlocklist []Course

	//all categories, faqs and news created by this user
	Categories []Category
	FAQs       []HelpPageEntries
	News       []HelpPageEntries
}

UserDetails holds detailed data related to a user.

func (*UserDetails) Get

func (user *UserDetails) Get() (err error)

Get all user details.

type UserList

type UserList []UserListEntry

UserList holds users enlisted on one (or more) of the user lists.

func (*UserList) Duplicate

func (users *UserList) Duplicate(tx *sqlx.Tx, courseIDNew, courseIDOld *int, table string) (err error)

Duplicate the user list of a course.

func (*UserList) Get

func (users *UserList) Get(tx *sqlx.Tx, courseID *int, table string) (err error)

Get all users at a user list of a course.

func (*UserList) GetEditorsInstructors

func (users *UserList) GetEditorsInstructors(courseID *int) (instructors UserList, err error)

GetEditorsInstructors returns editors and instructors.

func (*UserList) InsertUploaded

func (users *UserList) InsertUploaded(tx *sqlx.Tx, courseID *int, table string) (err error)

InsertUploaded inserts all entries in a user list into a course. Skips all users with an invalid user ID.

func (*UserList) Search

func (users *UserList) Search(value, listType *string, searchInactive *bool, courseID *int) (err error)

Search for a user and identify whether that user is already on a user list.

type UserListEntry

type UserListEntry struct {
	UserID     int  `db:"user_id, primarykey"`
	CourseID   int  `db:"course_id, primarykey"`
	ViewMatrNr bool `db:"view_matr_nr"` //only a field in the tables editor and instructor

	//identifies whether a user is already on a user list
	OnList bool `db:"on_list"`

	//used for showing users at user searches
	EMail string `db:"email, unique"`

	//used for showing users properly
	AcademicTitle  sql.NullString `db:"academic_title"`
	Title          sql.NullString `db:"title"`
	NameAffix      sql.NullString `db:"name_affix"`
	LastName       string         `db:"last_name"`
	FirstName      string         `db:"first_name"`
	Salutation     Salutation     `db:"salutation"`
	ActivationCode sql.NullString `db:"activation_code"`
}

UserListEntry is a model of the user list tables, which are: editors, instructors, blocklist, allowlist. It is also used to render users for the different user searches at the course management page.

func (*UserListEntry) Delete

func (user *UserListEntry) Delete(table string) (active bool, data EMailData, err error)

Delete the provided user list entry of a course.

func (*UserListEntry) Exists

func (user *UserListEntry) Exists(tx *sqlx.Tx) (exists bool, err error)

Exists returns if a user exists in the DB.

func (*UserListEntry) Insert

func (user *UserListEntry) Insert(table string) (active bool, data EMailData, err error)

Insert the provided user list entry of a course.

func (*UserListEntry) Update

func (user *UserListEntry) Update(table string) (active bool, data EMailData, err error)

Update updates the ViewMatrNr field of a list entry of a course.

type Users

type Users []User

Users holds specific users, such as only admins, creators, ...

func (*Users) AutoEnrollFromWaitList

func (users *Users) AutoEnrollFromWaitList(tx *sqlx.Tx, eventID *int,
	status EnrollmentStatus) (err error)

AutoEnrollFromWaitList is a function that is triggered in many different situations: - A user unsubscribes from an event and now there is a free slot. - When increasing the course capacity. - When manually unsubscribing an user from an event.

func (*Users) Get

func (users *Users) Get(creators *Users) (err error)

Get specific users.

func (*Users) Search

func (users *Users) Search(value *string, searchInactive *bool) (err error)

Search for users.

type ValidateUniqueData

type ValidateUniqueData struct {
	Column string
	Table  string
	Value  string
	Tx     *sqlx.Tx
}

ValidateUniqueData contains all data to validate the uniqueness of a column value in a table.

type Version2Course

type Version2Course struct {
	CourseName             string
	Subtitle               string
	CourseLeader           []Version2UserList
	Limitation             []Version2Limitations
	EnrollmentStartDate    string
	EnrollmentEndDate      string
	EnrollmentStartTime    string
	EnrollmentEndTime      string
	DisenrollmentStartDate string
	DisenrollmentStartTime string
	ExpirationDate         string
	ExpirationTime         string
	Public                 string
	PaymentAmount          string
	Description            string
	Event                  []Version2Event
	Blacklist              []Version2UserList
	Whitelist              []Version2UserList
	Parent                 string
	Prioid                 int
	EnrollLimitEvents      int
	WelcomeMail            string
}

Version2Course is the version 2 struct of a course.

func (*Version2Course) Transform

func (version2Course *Version2Course) Transform(course *Course) (err error)

Transform a version 2 course struct to the current course struct.

type Version2Event

type Version2Event struct {
	WaitingList         string
	Description         string
	MaximumParticipants string
	EnrollmentKey1      string
	EnrollmentKey2      string
	InitEnrollmentKey   string
	Meeting             []Version2Meeting
}

Version2Event is the version 2 struct of an event.

func (*Version2Event) Transform

func (version2Event *Version2Event) Transform(event *Event, i int) (err error)

Transform a version 2 event struct to the current event struct.

type Version2Limitations

type Version2Limitations struct {
	OnlyLDAP        string
	Degree          string
	CourseOfStudies string
	Semester        string
}

Version2Limitations is the version 2 struct used for course restrictions.

type Version2Meeting

type Version2Meeting struct {
	MeetingRegularity string
	Day               string
	WeeklyInterval    string
	MeetingDate       string
	MeetingStartTime  string
	MeetingEndTime    string
	Location          string
	Annotation        string
}

Version2Meeting is the version 2 struct of a meeting.

func (*Version2Meeting) Transform

func (version2Meeting *Version2Meeting) Transform(meeting *Meeting) (err error)

Transform a version 2 meeting struct to the current meeting struct.

type Version2UserList

type Version2UserList struct {
	Uid       int
	Firstname string
	Lastname  string
	Email     string
}

Version2UserList is the version 2 struct used for user lists.

type Version3Course

type Version3Course struct {
	Course
	Blacklist UserList ``
	Whitelist UserList ``
}

Version3Course contains the Blacklist and Whitelist field for backwards compatibility.

func (*Version3Course) Transform

func (version3Course *Version3Course) Transform(course *Course)

Transform a version 3 course struct to the current course struct.

Jump to

Keyboard shortcuts

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