mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-07 04:09:15 +02:00
98 implement anonymized DTO events
This commit is contained in:
@@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
@@ -13,21 +14,30 @@ func (m Events) Contains(event Event) bool {
|
||||
return slices.Contains(m, event)
|
||||
}
|
||||
|
||||
type AnonymizedEventDTO struct {
|
||||
Day string `db:"Day" json:"day"`
|
||||
Week string `db:"Week" json:"week"`
|
||||
Start types.DateTime `db:"start" json:"start"`
|
||||
End types.DateTime `db:"end" json:"end"`
|
||||
Rooms string `db:"Rooms" json:"rooms"`
|
||||
Free bool `json:"free"`
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
UUID string `db:"uuid" json:"uuid"`
|
||||
Day string `db:"Day" json:"day"`
|
||||
Week string `db:"Week" json:"week"`
|
||||
Start types.DateTime `db:"start" json:"start"`
|
||||
End types.DateTime `db:"end" json:"end"`
|
||||
Name string `db:"Name" json:"name"`
|
||||
EventType string `db:"EventType" json:"eventType"`
|
||||
Compulsory string `db:"Compulsory" json:"compulsory"`
|
||||
Prof string `db:"Prof" json:"prof"`
|
||||
Rooms string `db:"Rooms" json:"rooms"`
|
||||
Notes string `db:"Notes" json:"notes"`
|
||||
BookedAt string `db:"BookedAt" json:"bookedAt"`
|
||||
Course string `db:"course" json:"course"`
|
||||
Semester string `db:"semester" json:"semester"`
|
||||
UUID string `db:"uuid" json:"uuid"`
|
||||
Day string `db:"Day" json:"day"`
|
||||
Week string `db:"Week" json:"week"`
|
||||
Start types.DateTime `db:"start" json:"start"`
|
||||
End types.DateTime `db:"end" json:"end"`
|
||||
Name string `db:"Name" json:"name"`
|
||||
EventType string `db:"EventType" json:"eventType"`
|
||||
Compulsory string `db:"Compulsory" json:"compulsory"`
|
||||
Prof string `db:"Prof" json:"prof"`
|
||||
Rooms string `db:"Rooms" json:"rooms"`
|
||||
Notes string `db:"Notes" json:"notes"`
|
||||
BookedAt string `db:"BookedAt" json:"bookedAt"`
|
||||
Course string `db:"course" json:"course"`
|
||||
Semester string `db:"semester" json:"semester"`
|
||||
models.BaseModel
|
||||
}
|
||||
|
||||
@@ -52,3 +62,15 @@ func (m *Event) SetCourse(course string) Event {
|
||||
m.Course = course
|
||||
return *m
|
||||
}
|
||||
|
||||
// Creates an AnonymizedEventDTO from an Event hiding all sensitive data
|
||||
func (m *Event) AnonymizeEvent() AnonymizedEventDTO {
|
||||
return AnonymizedEventDTO{
|
||||
Day: m.Day,
|
||||
Week: m.Week,
|
||||
Start: m.Start,
|
||||
End: m.End,
|
||||
Rooms: m.Rooms,
|
||||
Free: strings.Contains(strings.ToLower(m.Name), "zur freien verfügung"),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user