Compare commits

..

No commits in common. "main" and "v1.3.2" have entirely different histories.
main ... v1.3.2

17 changed files with 12 additions and 203 deletions

View file

@ -99,10 +99,6 @@ 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,10 +4,8 @@ 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"
) )
@ -139,37 +137,6 @@ 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; {
@ -180,8 +147,5 @@ 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,7 +16,6 @@ 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,12 +42,3 @@ 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,56 +300,6 @@ 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,8 +15,6 @@
{{ 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,7 +1,6 @@
{{ 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">
@ -11,16 +10,16 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{range $attendie := .Attendies }} {{range $suiter := .Attendies }}
{{if not $attendie.OnWaitingList }} {{if not $suiter.OnWaitingList }}
<tr> <tr>
<td>{{ $attendie.Nickname }}</td> <td>{{ $suiter.Nickname }}</td>
{{ if $attendie.AttendsRestaurant }} {{ if $suiter.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 $attendie.AttendsBar }} {{ if $suiter.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>
@ -30,22 +29,4 @@
{{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

@ -1,34 +0,0 @@
{{ 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,7 +1,6 @@
{{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">
@ -64,6 +63,5 @@
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
</div>
{{end}} {{end}}
{{end}} {{end}}

View file

@ -1,7 +1,6 @@
{{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">
@ -81,6 +80,5 @@
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
</div>
{{ end }} {{ end }}
{{end}} {{end}}

View file

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"github.com/glebarez/sqlite" "gorm.io/driver/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,9 +94,4 @@ var defaultMessages = []i18n.Message{
One: "AfterParty", One: "AfterParty",
Other: "AfterParties", Other: "AfterParties",
}, },
{
ID: "Event",
One: "Event",
Other: "Events",
},
} }

View file

@ -29,7 +29,6 @@ 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,7 +14,6 @@ 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,8 +1,6 @@
module ulmer-furs.de/pretix-proxy/v2 module ulmer-furs.de/pretix-proxy/v2
go 1.21 go 1.19
toolchain go1.22.4
require ( require (
github.com/go-playground/validator/v10 v10.15.4 github.com/go-playground/validator/v10 v10.15.4
@ -15,30 +13,16 @@ 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.7 gorm.io/gorm v1.25.4
) )
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 (
@ -47,7 +31,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.6.0 // indirect github.com/google/uuid v1.4.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
@ -60,6 +44,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-20231108232855-2478ac86f678 golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/sys v0.19.0 // indirect golang.org/x/sys v0.14.0 // indirect
) )

View file

@ -9,11 +9,6 @@
"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,10 +7,6 @@
"one": "Attendie", "one": "Attendie",
"other": "Attendies" "other": "Attendies"
}, },
"Event": {
"one": "Event",
"other": "Events"
},
"Guest": { "Guest": {
"one": "Guest", "one": "Guest",
"other": "Guets" "other": "Guets"