Compare commits

..

7 commits
v1.3.2 ... main

Author SHA1 Message Date
5faef9defc
feat(style): mobile tweaks
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
Signed-off-by: Nikurasu <publicmail@nikurasu.gay>
2024-06-30 20:35:46 +02:00
c983a1b19c
feat(style): mobile tweaks
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
Signed-off-by: Nikurasu <publicmail@nikurasu.gay>
2024-06-29 18:50:20 +02:00
615691e3c5
feat(style): mobile tweaks
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
Signed-off-by: Nikurasu <publicmail@nikurasu.gay>
2024-06-29 18:36:38 +02:00
dc9a1b60f1
fix(i18n): add missing localization
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-06-17 21:14:37 +02:00
a8bff45a8e
feature(db): switch to cgo-less driver
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-06-16 21:26:50 +02:00
95e64b8ded
Add ui with new translations
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-06-14 01:27:45 +02:00
1d20377ee6
Add function for Erding Event
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-06-14 00:44:28 +02:00
17 changed files with 203 additions and 12 deletions

View file

@ -99,6 +99,10 @@ func GetAttendiesByEventPublicTable(c *fiber.Ctx) error {
MessageID: "AfterParty", MessageID: "AfterParty",
PluralCount: 1, PluralCount: 1,
}), }),
"Event": localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "Event",
PluralCount: 1,
}),
} }
return c.Render("app/views/index", fiber.Map{ return c.Render("app/views/index", fiber.Map{
"EventName": *(event).Name, "EventName": *(event).Name,

View file

@ -4,8 +4,10 @@ import (
"fmt" "fmt"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/yassinebenaid/godump"
"ulmer-furs.de/pretix-proxy/v2/app/service" "ulmer-furs.de/pretix-proxy/v2/app/service"
"ulmer-furs.de/pretix-proxy/v2/app/util" "ulmer-furs.de/pretix-proxy/v2/app/util"
"ulmer-furs.de/pretix-proxy/v2/config"
"ulmer-furs.de/pretix-proxy/v2/entities" "ulmer-furs.de/pretix-proxy/v2/entities"
) )
@ -137,6 +139,37 @@ func PostPretixSpecialEventWithRoles(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK) return c.SendStatus(fiber.StatusOK)
} }
func PostPretixEventWithoutMainProduct(c *fiber.Ctx) error {
data := new(entities.Pretix_Webhook)
if err := c.BodyParser(data); err != nil {
return c.Status(fiber.ErrBadRequest.Code).SendString(err.Error())
}
pretixOrders, err := getAllPretixOrders(&data.Organizer, &data.Event)
if err != nil {
return c.SendStatus(fiber.StatusInternalServerError)
}
event, err := service.Get_db_event_by_event(data.Event)
if err != nil {
return c.Status(fiber.StatusNotFound).SendString("Event not found")
}
attendies, err := util.GetAttendiesFromPretixJsonFindNameInProducts(pretixOrders, &event)
if err != nil {
fmt.Println(err)
return c.SendStatus(fiber.StatusInternalServerError)
}
if err := service.DeleteAttendiesByEvent(event); err != nil {
fmt.Println(err)
return c.SendStatus(fiber.StatusInternalServerError)
}
for _, attendie := range attendies {
if err := service.CreateNewAttendie(attendie); err != nil {
fmt.Print(err)
return c.SendStatus(fiber.StatusInternalServerError)
}
}
return c.SendStatus(fiber.StatusOK)
}
func getAllPretixOrders(organizer, event *string) (*entities.Pretix_Event, error) { func getAllPretixOrders(organizer, event *string) (*entities.Pretix_Event, error) {
pretixOrders, err := util.GetPretixOrders(organizer, event) pretixOrders, err := util.GetPretixOrders(organizer, event)
for link := pretixOrders.Next; link != nil; { for link := pretixOrders.Next; link != nil; {
@ -147,5 +180,8 @@ func getAllPretixOrders(organizer, event *string) (*entities.Pretix_Event, error
pretixOrders.Results = append(pretixOrders.Results, next_page.Results...) pretixOrders.Results = append(pretixOrders.Results, next_page.Results...)
link = next_page.Next link = next_page.Next
} }
if config.Env.Debug {
godump.Dump(pretixOrders)
}
return pretixOrders, err return pretixOrders, err
} }

View file

@ -16,6 +16,7 @@ func PublicRoutes(app *fiber.App) {
webhooks.Post("/pretix/role_product", controller.PostPretixRoleProduct) webhooks.Post("/pretix/role_product", controller.PostPretixRoleProduct)
webhooks.Post("/pretix/subproduct", controller.PostPretixRegularsTable) webhooks.Post("/pretix/subproduct", controller.PostPretixRegularsTable)
webhooks.Post("/pretix/speicalEventRoles", controller.PostPretixSpecialEventWithRoles) webhooks.Post("/pretix/speicalEventRoles", controller.PostPretixSpecialEventWithRoles)
webhooks.Post("/pretix/specialEventWithoutMain", controller.PostPretixEventWithoutMainProduct)
apiv1.Post("/login", controller.LoginUser) apiv1.Post("/login", controller.LoginUser)
apiv1.Get("/event", controller.ReturnAllEventsPublic) apiv1.Get("/event", controller.ReturnAllEventsPublic)
apiv1.Get("/ping", controller.Ping) apiv1.Get("/ping", controller.Ping)

View file

@ -42,3 +42,12 @@ tbody>tr:nth-child(odd) {
.tdred { .tdred {
background-color: #ff6e6e; background-color: #ff6e6e;
} }
.tableWrapper {
overflow-x: auto;
transform: rotate(180deg);
}
.tableWrapper table {
transform: rotate(180deg);
}

View file

@ -6,10 +6,10 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"slices"
"sort" "sort"
"strconv" "strconv"
"golang.org/x/exp/slices"
"ulmer-furs.de/pretix-proxy/v2/app/service" "ulmer-furs.de/pretix-proxy/v2/app/service"
"ulmer-furs.de/pretix-proxy/v2/config" "ulmer-furs.de/pretix-proxy/v2/config"
"ulmer-furs.de/pretix-proxy/v2/entities" "ulmer-furs.de/pretix-proxy/v2/entities"
@ -300,6 +300,56 @@ func GetAttendiesFromPretixJsonWithRoleQuestionNoSubproducts(pretixEvent *entiti
return attendies, nil return attendies, nil
} }
func GetAttendiesFromPretixJsonFindNameInProducts(pretixEvent *entities.Pretix_Event, event *entities.Db_Event) (entities.AttendiesList, error) {
var attendies entities.AttendiesList
for _, order := range pretixEvent.Results {
if checkCanceled(order) {
continue
}
var attendie entities.Db_Attendies
attendie.Event = event
if event.ItemIdEvent == nil {
return attendies, errors.New("event has no ItemIdEvent")
}
if event.ItemIdRestaurant == nil {
return attendies, errors.New("event has no ItemIdRestaurant")
}
indexEvent := slices.IndexFunc(order.Positions, func(p entities.Pretix_Position) bool { return p.Item == *event.ItemIdEvent })
indexRestaurant := slices.IndexFunc(order.Positions, func(p entities.Pretix_Position) bool { return p.Item == *event.ItemIdRestaurant })
var indexName int
var indexPrivacy int
if indexEvent != -1 {
indexName = slices.IndexFunc(order.Positions[indexEvent].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName })
indexPrivacy = slices.IndexFunc(order.Positions[indexEvent].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdPrivacy })
attendie.AttendsEvent = true
attendie.Nickname = getAttendieNickname(&order, &indexName, &indexEvent)
privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexEvent)
if err != nil {
return nil, err
}
attendie.Privacy = !privacy
}
if indexRestaurant != -1 {
indexName = slices.IndexFunc(order.Positions[indexRestaurant].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName })
indexPrivacy = slices.IndexFunc(order.Positions[indexRestaurant].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdPrivacy })
attendie.AttendsRestaurant = true
attendie.Nickname = getAttendieNickname(&order, &indexName, &indexRestaurant)
privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexRestaurant)
if err != nil {
return nil, err
}
attendie.Privacy = !privacy
}
attendie.RegistrationTime = order.Datetime
attendies = append(attendies, attendie)
}
return attendies, nil
}
func checkCanceled(pretixResult entities.Pretix_Result) bool {
return pretixResult.Status == "c" || pretixResult.Status == "e"
}
func getAttendieRole(order *entities.Pretix_Result, event *entities.Db_Event, indexRole, indexParticipation *int) (*entities.Role, error) { func getAttendieRole(order *entities.Pretix_Result, event *entities.Db_Event, indexRole, indexParticipation *int) (*entities.Role, error) {
roleAnswer := order.Positions[*indexParticipation].Answers[*indexRole].OptionIdentifiers roleAnswer := order.Positions[*indexParticipation].Answers[*indexRole].OptionIdentifiers
if slices.Contains(roleAnswer, *event.OptionIdSuiter) { if slices.Contains(roleAnswer, *event.OptionIdSuiter) {

View file

@ -15,6 +15,8 @@
{{ template "regularstable" .}} {{ template "regularstable" .}}
{{ else if eq .EventType "SpecialEventRoles" }} {{ else if eq .EventType "SpecialEventRoles" }}
{{ template "specialEventRoles" . }} {{ template "specialEventRoles" . }}
{{ else if eq .EventType "SpecialEvent" }}
{{ template "specialEvent" . }}
{{ end }} {{ end }}
</main> </main>
</body> </body>

View file

@ -1,6 +1,7 @@
{{ define "regularstable" }} {{ define "regularstable" }}
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1> <h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
<h2 class="textWhite">{{ .Locals.Registered }}</h2> <h2 class="textWhite">{{ .Locals.Registered }}</h2>
<div class="tableWrapper">
<table> <table>
<thead> <thead>
<tr class="tableHeading"> <tr class="tableHeading">
@ -10,16 +11,16 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{range $suiter := .Attendies }} {{range $attendie := .Attendies }}
{{if not $suiter.OnWaitingList }} {{if not $attendie.OnWaitingList }}
<tr> <tr>
<td>{{ $suiter.Nickname }}</td> <td>{{ $attendie.Nickname }}</td>
{{ if $suiter.AttendsRestaurant }} {{ if $attendie.AttendsRestaurant }}
<td class="tdgreen">✓ {{ $.Locals.Yes }}</td> <td class="tdgreen">✓ {{ $.Locals.Yes }}</td>
{{ else }} {{ else }}
<td class="tdred">❌ {{ $.Locals.No }}</td> <td class="tdred">❌ {{ $.Locals.No }}</td>
{{ end }} {{ end }}
{{ if $suiter.AttendsBar }} {{ if $attendie.AttendsBar }}
<td class="tdgreen">✓ {{ $.Locals.Yes }}</td> <td class="tdgreen">✓ {{ $.Locals.Yes }}</td>
{{ else }} {{ else }}
<td class="tdred">❌ {{ $.Locals.No }}</td> <td class="tdred">❌ {{ $.Locals.No }}</td>
@ -29,4 +30,22 @@
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
<h2 class="textWhite">{{ .Locals.SuiterWaitinglist }}</h2>
<table>
<thead>
<tr>
<th>{{ .Locals.Name }}</th>
</tr>
</thead>
<tbody>
{{range $attendie := .Attendies }}
{{if $attendie.OnWaitingList }}
<tr>
<td>{{ $attendie.Nickname }}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</div>
{{end}} {{end}}

View file

@ -0,0 +1,34 @@
{{ define "specialEvent" }}
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
<h2 class="textWhite">{{ .Locals.Registered }}</h2>
<div class="tableWrapper">
<table>
<thead>
<tr class="tableHeading">
<th>{{ .Locals.Name }}</th>
<th>{{ .Locals.Restaurant }}</th>
<th>{{ .Locals.Event }}</th>
</tr>
</thead>
<tbody>
{{range $attendie := .Attendies }}
{{if not $attendie.OnWaitingList }}
<tr>
<td>{{ $attendie.Nickname }}</td>
{{ if $attendie.AttendsRestaurant }}
<td class="tdgreen">✓ {{ $.Locals.Yes }}</td>
{{ else }}
<td class="tdred">❌ {{ $.Locals.No }}</td>
{{ end }}
{{ if $attendie.AttendsEvent }}
<td class="tdgreen">✓ {{ $.Locals.Yes }}</td>
{{ else }}
<td class="tdred">❌ {{ $.Locals.No }}</td>
{{ end }}
</tr>
{{end}}
{{end}}
</tbody>
</table>
</div>
{{end}}

View file

@ -1,6 +1,7 @@
{{define "specialEventRoles"}} {{define "specialEventRoles"}}
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1> <h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
<h2 class="textWhite">{{ .Locals.Registered }}</h2> <h2 class="textWhite">{{ .Locals.Registered }}</h2>
<div class="tableWrapper">
<table> <table>
<thead> <thead>
<tr class="tableHeading"> <tr class="tableHeading">
@ -63,5 +64,6 @@
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
</div>
{{end}} {{end}}
{{end}} {{end}}

View file

@ -1,6 +1,7 @@
{{define "suitwalk"}} {{define "suitwalk"}}
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1> <h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
<h2 class="textWhite">{{ .Locals.Registered }}</h2> <h2 class="textWhite">{{ .Locals.Registered }}</h2>
<div class="tableWrapper">
<table> <table>
<thead> <thead>
<tr class="tableHeading"> <tr class="tableHeading">
@ -80,5 +81,6 @@
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
</div>
{{ end }} {{ end }}
{{end}} {{end}}

View file

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"gorm.io/driver/sqlite" "github.com/glebarez/sqlite"
"gorm.io/gorm" "gorm.io/gorm"
"ulmer-furs.de/pretix-proxy/v2/entities" "ulmer-furs.de/pretix-proxy/v2/entities"
"ulmer-furs.de/pretix-proxy/v2/seeder" "ulmer-furs.de/pretix-proxy/v2/seeder"

View file

@ -94,4 +94,9 @@ var defaultMessages = []i18n.Message{
One: "AfterParty", One: "AfterParty",
Other: "AfterParties", Other: "AfterParties",
}, },
{
ID: "Event",
One: "Event",
Other: "Events",
},
} }

View file

@ -29,6 +29,7 @@ type Db_Attendies struct {
Role *Role Role *Role
AttendsRestaurant bool `gorm:"column:attends_restaurant;not null;default:false"` AttendsRestaurant bool `gorm:"column:attends_restaurant;not null;default:false"`
AttendsBar bool `gorm:"attends_restaurant;not null;default:false"` AttendsBar bool `gorm:"attends_restaurant;not null;default:false"`
AttendsEvent bool `gorm:"attends_event;not null;default:false"`
Privacy bool `gorm:"column:privacy;not null;default:false"` Privacy bool `gorm:"column:privacy;not null;default:false"`
RegistrationTime time.Time `gorm:"column:registration_time;not null;default:CURRENT_TIMESTAMP"` RegistrationTime time.Time `gorm:"column:registration_time;not null;default:CURRENT_TIMESTAMP"`
OnWaitingList bool `gorm:"column:on_wating_list;not null;default:false"` OnWaitingList bool `gorm:"column:on_wating_list;not null;default:false"`

View file

@ -14,6 +14,7 @@ type Db_Event struct {
ItemIdBar *int `gorm:"column:item_id_bar"` ItemIdBar *int `gorm:"column:item_id_bar"`
ItemIdParticipation *int `gorm:"column:item_id_participation"` ItemIdParticipation *int `gorm:"column:item_id_participation"`
ItemIdRole *int `gorm:"column:item_id_role"` ItemIdRole *int `gorm:"column:item_id_role"`
ItemIdEvent *int `gorm:"column:item_id_event"`
QuestionIdRole *string `gorm:"column:question_id_role"` QuestionIdRole *string `gorm:"column:question_id_role"`
QuestionIdName *string `gorm:"column:question_id_name"` QuestionIdName *string `gorm:"column:question_id_name"`
QuestionIdPrivacy *string `gorm:"column:question_id_is_private"` QuestionIdPrivacy *string `gorm:"column:question_id_is_private"`

View file

@ -1,6 +1,8 @@
module ulmer-furs.de/pretix-proxy/v2 module ulmer-furs.de/pretix-proxy/v2
go 1.19 go 1.21
toolchain go1.22.4
require ( require (
github.com/go-playground/validator/v10 v10.15.4 github.com/go-playground/validator/v10 v10.15.4
@ -13,16 +15,30 @@ require (
golang.org/x/crypto v0.15.0 golang.org/x/crypto v0.15.0
golang.org/x/text v0.14.0 golang.org/x/text v0.14.0
gorm.io/driver/sqlite v1.5.3 gorm.io/driver/sqlite v1.5.3
gorm.io/gorm v1.25.4 gorm.io/gorm v1.25.7
) )
require ( require (
github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/glebarez/sqlite v1.11.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/leodido/go-urn v1.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/yassinebenaid/godump v0.7.0 // indirect
golang.org/x/net v0.10.0 // indirect golang.org/x/net v0.10.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.52.1 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.30.1 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
) )
require ( require (
@ -31,7 +47,7 @@ require (
github.com/gofiber/template v1.8.2 // indirect github.com/gofiber/template v1.8.2 // indirect
github.com/gofiber/template/html/v2 v2.0.5 github.com/gofiber/template/html/v2 v2.0.5
github.com/gofiber/utils v1.1.0 // indirect github.com/gofiber/utils v1.1.0 // indirect
github.com/google/uuid v1.4.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/compress v1.16.7 // indirect
@ -44,6 +60,6 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.50.0 // indirect github.com/valyala/fasthttp v1.50.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 golang.org/x/exp v0.0.0-20231108232855-2478ac86f678
golang.org/x/sys v0.14.0 // indirect golang.org/x/sys v0.19.0 // indirect
) )

View file

@ -9,6 +9,11 @@
"one": "Teilnehmer*in", "one": "Teilnehmer*in",
"other": "Teilnehmende" "other": "Teilnehmende"
}, },
"Event": {
"hash": "sha1-c5497bca58468ae64aed6c0fd921109217988db3",
"one": "Event",
"other": "Events"
},
"Guest": { "Guest": {
"hash": "sha1-7b7f214bbd4af36f25668b0ddade965422d342fd", "hash": "sha1-7b7f214bbd4af36f25668b0ddade965422d342fd",
"one": "Gast", "one": "Gast",

View file

@ -7,6 +7,10 @@
"one": "Attendie", "one": "Attendie",
"other": "Attendies" "other": "Attendies"
}, },
"Event": {
"one": "Event",
"other": "Events"
},
"Guest": { "Guest": {
"one": "Guest", "one": "Guest",
"other": "Guets" "other": "Guets"