mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-16 09:38:49 +02:00
461 lines
9.9 KiB
Go
461 lines
9.9 KiB
Go
//Calendar implementation for the HTWK Leipzig timetable. Evaluation and display of the individual dates in iCal format.
|
|
//Copyright (C) 2024 HTWKalender support@htwkalender.de
|
|
|
|
//This program is free software: you can redistribute it and/or modify
|
|
//it under the terms of the GNU Affero General Public License as published by
|
|
//the Free Software Foundation, either version 3 of the License, or
|
|
//(at your option) any later version.
|
|
|
|
//This program is distributed in the hope that it will be useful,
|
|
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
//GNU Affero General Public License for more details.
|
|
|
|
//You should have received a copy of the GNU Affero General Public License
|
|
//along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
package migrations
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/pocketbase/dbx"
|
|
"github.com/pocketbase/pocketbase/daos"
|
|
m "github.com/pocketbase/pocketbase/migrations"
|
|
"github.com/pocketbase/pocketbase/models"
|
|
)
|
|
|
|
func init() {
|
|
m.Register(func(db dbx.Builder) error {
|
|
jsonData := `[
|
|
{
|
|
"id": "cfq9mqlmd97v8z5",
|
|
"created": "2023-09-19 17:31:15.957Z",
|
|
"updated": "2023-11-01 21:17:43.567Z",
|
|
"name": "groups",
|
|
"type": "base",
|
|
"system": false,
|
|
"schema": [
|
|
{
|
|
"system": false,
|
|
"id": "85msl21p",
|
|
"name": "university",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "2sii4dtp",
|
|
"name": "shortcut",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "uiwgo28f",
|
|
"name": "groupId",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "y0l1lrzs",
|
|
"name": "course",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "kr62mhbz",
|
|
"name": "faculty",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "ya6znpez",
|
|
"name": "facultyId",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
}
|
|
],
|
|
"indexes": [
|
|
"CREATE UNIQUE INDEX ` + "`" + `idx_rcaN2Oq` + "`" + ` ON ` + "`" + `groups` + "`" + ` (` + "`" + `course` + "`" + `)"
|
|
],
|
|
"listRule": null,
|
|
"viewRule": null,
|
|
"createRule": null,
|
|
"updateRule": null,
|
|
"deleteRule": null,
|
|
"options": {}
|
|
},
|
|
{
|
|
"id": "d65h4wh7zk13gxp",
|
|
"created": "2023-09-19 17:31:15.957Z",
|
|
"updated": "2023-11-20 20:38:58.258Z",
|
|
"name": "feeds",
|
|
"type": "base",
|
|
"system": false,
|
|
"schema": [
|
|
{
|
|
"system": false,
|
|
"id": "cowxjfmc",
|
|
"name": "modules",
|
|
"type": "json",
|
|
"required": true,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "wmmney8x",
|
|
"name": "retrieved",
|
|
"type": "date",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": "",
|
|
"max": ""
|
|
}
|
|
}
|
|
],
|
|
"indexes": [],
|
|
"listRule": null,
|
|
"viewRule": "",
|
|
"createRule": null,
|
|
"updateRule": "",
|
|
"deleteRule": null,
|
|
"options": {}
|
|
},
|
|
{
|
|
"id": "7her4515qsmrxe8",
|
|
"created": "2023-09-19 17:31:15.958Z",
|
|
"updated": "2023-11-01 21:17:43.567Z",
|
|
"name": "events",
|
|
"type": "base",
|
|
"system": false,
|
|
"schema": [
|
|
{
|
|
"system": false,
|
|
"id": "m8ne8e3m",
|
|
"name": "Day",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "xnsxqp7j",
|
|
"name": "Week",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "aeuskrjo",
|
|
"name": "Name",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "klrzqyw0",
|
|
"name": "EventType",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "5zltexoy",
|
|
"name": "Prof",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "gy3nvfmx",
|
|
"name": "Rooms",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "hn7b8dfy",
|
|
"name": "Notes",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "axskpwm8",
|
|
"name": "BookedAt",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "vyyefxp7",
|
|
"name": "course",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "vlbpm9fz",
|
|
"name": "semester",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "0kahthzr",
|
|
"name": "uuid",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "6hkjwgb4",
|
|
"name": "start",
|
|
"type": "date",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": "",
|
|
"max": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "szbefpjf",
|
|
"name": "end",
|
|
"type": "date",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": "",
|
|
"max": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "nlnnxu7x",
|
|
"name": "Compulsory",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
}
|
|
],
|
|
"indexes": [
|
|
"CREATE INDEX ` + "`" + `idx_4vOTAiC` + "`" + ` ON ` + "`" + `events` + "`" + ` (\n ` + "`" + `Name` + "`" + `,\n ` + "`" + `course` + "`" + `,\n ` + "`" + `start` + "`" + `,\n ` + "`" + `end` + "`" + `,\n ` + "`" + `semester` + "`" + `,\n ` + "`" + `EventType` + "`" + `,\n ` + "`" + `Compulsory` + "`" + `\n)"
|
|
],
|
|
"listRule": null,
|
|
"viewRule": null,
|
|
"createRule": null,
|
|
"updateRule": null,
|
|
"deleteRule": null,
|
|
"options": {}
|
|
},
|
|
{
|
|
"id": "_pb_users_auth_",
|
|
"created": "2023-11-01 21:17:43.390Z",
|
|
"updated": "2023-11-01 21:17:43.567Z",
|
|
"name": "users",
|
|
"type": "auth",
|
|
"system": false,
|
|
"schema": [
|
|
{
|
|
"system": false,
|
|
"id": "users_name",
|
|
"name": "name",
|
|
"type": "text",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"min": null,
|
|
"max": null,
|
|
"pattern": ""
|
|
}
|
|
},
|
|
{
|
|
"system": false,
|
|
"id": "users_avatar",
|
|
"name": "avatar",
|
|
"type": "file",
|
|
"required": false,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"maxSelect": 1,
|
|
"maxSize": 5242880,
|
|
"mimeTypes": [
|
|
"image/jpeg",
|
|
"image/png",
|
|
"image/svg+xml",
|
|
"image/gif",
|
|
"image/webp"
|
|
],
|
|
"thumbs": null,
|
|
"protected": false
|
|
}
|
|
}
|
|
],
|
|
"indexes": [],
|
|
"listRule": "id = @request.auth.id",
|
|
"viewRule": "id = @request.auth.id",
|
|
"createRule": "",
|
|
"updateRule": "id = @request.auth.id",
|
|
"deleteRule": "id = @request.auth.id",
|
|
"options": {
|
|
"allowEmailAuth": true,
|
|
"allowOAuth2Auth": true,
|
|
"allowUsernameAuth": true,
|
|
"exceptEmailDomains": null,
|
|
"manageRule": null,
|
|
"minPasswordLength": 8,
|
|
"onlyEmailDomains": null,
|
|
"requireEmail": false
|
|
}
|
|
}
|
|
]`
|
|
|
|
collections := []*models.Collection{}
|
|
if err := json.Unmarshal([]byte(jsonData), &collections); err != nil {
|
|
return err
|
|
}
|
|
|
|
return daos.New(db).ImportCollections(collections, true, nil)
|
|
}, func(db dbx.Builder) error {
|
|
return nil
|
|
})
|
|
}
|