Skip to content

Commit

Permalink
umbrella events (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
dheidemann committed Aug 8, 2024
1 parent 23e7d2b commit accfc17
Show file tree
Hide file tree
Showing 18 changed files with 2,759 additions and 2,115 deletions.
519 changes: 188 additions & 331 deletions server/README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions server/db/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func Init(ctx context.Context, tracer *trace.TracerProvider) (*bun.DB, *sql.DB,
))

relations := []interface{}{
(*models.EventToTutor)(nil),
(*models.TutorToEvent)(nil),
(*models.StudentToEvent)(nil),
(*models.RoomToEvent)(nil)}
(*models.EventToUserAssignment)(nil),
(*models.UserToEventAvailability)(nil),
(*models.UserToEventRegistration)(nil),
(*models.RoomToEventAvailability)(nil)}

tables := []interface{}{
(*models.Label)(nil),
Expand Down
45 changes: 29 additions & 16 deletions server/db/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ package db

import (
"context"
"fmt"
"log"
"strconv"
"time"

"github.com/FachschaftMathPhysInfo/pepp/server/models"
"github.com/uptrace/bun"
)

func seedData(ctx context.Context, db *bun.DB) error {
tutors := []*models.Tutor{
{User: models.User{Mail: "[email protected]", Fn: "Tutorin", Sn: "One", Confirmed: true}},
{User: models.User{Mail: "[email protected]", Fn: "Tutor", Sn: "Two", Confirmed: true}},
users := []*models.User{
{Mail: "[email protected]", Fn: "Tutorin", Sn: "One", Confirmed: true},
{Mail: "[email protected]", Fn: "Tutor", Sn: "Two", Confirmed: true},
}
if err := insertData(ctx, db, (*models.Tutor)(nil), tutors, "Tutors"); err != nil {
if err := insertData(ctx, db, (*models.User)(nil), users, "Users"); err != nil {
return err
}

Expand Down Expand Up @@ -50,15 +52,24 @@ func seedData(ctx context.Context, db *bun.DB) error {
return err
}

events := []*models.Event{{
Title: "Lineare Algebra",
Description: "Lorem Ipsum dolor sit amed",
TopicName: "Mathe",
TypeName: "Tutorium",
NeedsTutors: true,
From: time.Now().Add(4 * time.Hour),
To: time.Now().Add(5 * time.Hour),
}}
umbrellaID := int32(1)
events := []*models.Event{
{
Title: fmt.Sprintf("Vorkurs %s", strconv.Itoa(time.Now().Year())),
Description: "Lorem Ipsum",
From: time.Now(),
To: time.Now().Add(3 * (time.Hour * 24)),
},
{
Title: "Lineare Algebra",
Description: "Lorem Ipsum dolor sit amed",
TopicName: "Mathe",
TypeName: "Tutorium",
NeedsTutors: true,
From: time.Now().Add(4 * time.Hour),
To: time.Now().Add(5 * time.Hour),
UmbrellaID: &umbrellaID,
}}
if err := insertData(ctx, db, (*models.Event)(nil), events, "Events"); err != nil {
return err
}
Expand All @@ -72,10 +83,12 @@ func seedData(ctx context.Context, db *bun.DB) error {
{Key: "email-signature", Value: "Dein", Type: "STRING"},
{Key: "email-name", Value: "Pepp - Die Vorkursverwaltung", Type: "STRING"},
{Key: "email-confirm-subject", Value: "Bitte bestätige deine E-Mail Adresse", Type: "STRING"},
{Key: "email-confirm-intro", Value: "danke für deine Registrierung als Vorkurstutor/-in!", Type: "STRING"},
{Key: "email-confirm-button-instruction", Value: "Bitte klicke hier, um deine E-Mail Adresse und die Verfügbarkeiten zu bestätigen:", Type: "STRING"},
{Key: "email-confirm-intro", Value: "danke für deine Registrierung!", Type: "STRING"},
{Key: "email-confirm-button-instruction", Value: "Bitte klicke hier, um deine E-Mail Adresse zu bestätigen:", Type: "STRING"},
{Key: "email-confirm-button-text", Value: "Bestätigen", Type: "STRING"},
{Key: "email-confirm-outro", Value: "Wir melden uns bei dir.", Type: "STRING"},
{Key: "email-availability-subject", Value: "Deine Verfügbarkeiten", Type: "STRING"},
{Key: "email-availability-intro", Value: "du hast dich zu folgenden Veranstaltungen als verfügbar eingetragen:", Type: "STRING"},
{Key: "email-availability-outro", Value: "Danke! Wir melden uns bei dir.", Type: "STRING"},
{Key: "email-assignment-subject", Value: "Deine Veranstaltung", Type: "STRING"},
{Key: "email-assignment-event-title", Value: "Veranstaltung", Type: "STRING"},
{Key: "email-assignment-kind-title", Value: "Art", Type: "STRING"},
Expand Down
13 changes: 9 additions & 4 deletions server/email/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {

Confirmation Email
Assignment Email
Availability Email
}

func (c *Config) ApplySettings(s map[string]string) {
Expand All @@ -32,15 +33,19 @@ func (c *Config) ApplySettings(s map[string]string) {
Text: s["email-confirm-button-text"],
},
}}
c.Confirmation.Table = hermes.Table{

c.Assignment.Intros = []string{s["email-assignment-intro"]}
c.Assignment.Outros = []string{s["email-assignment-outro"]}

c.Availability.Subject = s["email-availability-subject"]
c.Availability.Intros = []string{s["email-availability-intro"]}
c.Availability.Outros = []string{s["email-availability-outro"]}
c.Availability.Table = hermes.Table{
Columns: hermes.Columns{
CustomWidth: map[string]string{
s["email-assignment-date-title"]: "20%",
s["email-assignment-kind-title"]: "30%",
},
},
}

c.Assignment.Intros = []string{s["email-assignment-intro"]}
c.Assignment.Outros = []string{s["email-assignment-outro"]}
}
26 changes: 3 additions & 23 deletions server/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ omit_getters: true
# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
# - "github.com/FachschaftMathPhysInfo/pepp/server/graph/model"
- github.com/FachschaftMathPhysInfo/pepp/server/models

# This section declares type mapping between the GraphQL and go type systems
#
Expand All @@ -87,35 +87,15 @@ models:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Building:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Building
NewBuilding:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Building
Event:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Event
NewUser:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.User
NewEvent:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Event
Tutor:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Tutor
NewTutor:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Tutor
Student:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Student
NewStudent:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Student
Label:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Label
NewLabel:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Label
Room:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Room
NewRoom:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Room
NewRoomToEventLink:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.RoomToEvent
NewEventToTutorLink:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.EventToTutor
Setting:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Setting
NewSetting:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Setting
Loading

0 comments on commit accfc17

Please sign in to comment.