Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
5faef9defc | |||
c983a1b19c | |||
615691e3c5 | |||
dc9a1b60f1 | |||
a8bff45a8e | |||
95e64b8ded | |||
1d20377ee6 |
17 changed files with 203 additions and 12 deletions
|
@ -99,6 +99,10 @@ func GetAttendiesByEventPublicTable(c *fiber.Ctx) error {
|
|||
MessageID: "AfterParty",
|
||||
PluralCount: 1,
|
||||
}),
|
||||
"Event": localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: "Event",
|
||||
PluralCount: 1,
|
||||
}),
|
||||
}
|
||||
return c.Render("app/views/index", fiber.Map{
|
||||
"EventName": *(event).Name,
|
||||
|
|
|
@ -4,8 +4,10 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/yassinebenaid/godump"
|
||||
"ulmer-furs.de/pretix-proxy/v2/app/service"
|
||||
"ulmer-furs.de/pretix-proxy/v2/app/util"
|
||||
"ulmer-furs.de/pretix-proxy/v2/config"
|
||||
"ulmer-furs.de/pretix-proxy/v2/entities"
|
||||
)
|
||||
|
||||
|
@ -137,6 +139,37 @@ func PostPretixSpecialEventWithRoles(c *fiber.Ctx) error {
|
|||
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) {
|
||||
pretixOrders, err := util.GetPretixOrders(organizer, event)
|
||||
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...)
|
||||
link = next_page.Next
|
||||
}
|
||||
if config.Env.Debug {
|
||||
godump.Dump(pretixOrders)
|
||||
}
|
||||
return pretixOrders, err
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ func PublicRoutes(app *fiber.App) {
|
|||
webhooks.Post("/pretix/role_product", controller.PostPretixRoleProduct)
|
||||
webhooks.Post("/pretix/subproduct", controller.PostPretixRegularsTable)
|
||||
webhooks.Post("/pretix/speicalEventRoles", controller.PostPretixSpecialEventWithRoles)
|
||||
webhooks.Post("/pretix/specialEventWithoutMain", controller.PostPretixEventWithoutMainProduct)
|
||||
apiv1.Post("/login", controller.LoginUser)
|
||||
apiv1.Get("/event", controller.ReturnAllEventsPublic)
|
||||
apiv1.Get("/ping", controller.Ping)
|
||||
|
|
|
@ -41,4 +41,13 @@ tbody>tr:nth-child(odd) {
|
|||
|
||||
.tdred {
|
||||
background-color: #ff6e6e;
|
||||
}
|
||||
|
||||
.tableWrapper {
|
||||
overflow-x: auto;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.tableWrapper table {
|
||||
transform: rotate(180deg);
|
||||
}
|
|
@ -6,10 +6,10 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
"ulmer-furs.de/pretix-proxy/v2/app/service"
|
||||
"ulmer-furs.de/pretix-proxy/v2/config"
|
||||
"ulmer-furs.de/pretix-proxy/v2/entities"
|
||||
|
@ -300,6 +300,56 @@ func GetAttendiesFromPretixJsonWithRoleQuestionNoSubproducts(pretixEvent *entiti
|
|||
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) {
|
||||
roleAnswer := order.Positions[*indexParticipation].Answers[*indexRole].OptionIdentifiers
|
||||
if slices.Contains(roleAnswer, *event.OptionIdSuiter) {
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
{{ template "regularstable" .}}
|
||||
{{ else if eq .EventType "SpecialEventRoles" }}
|
||||
{{ template "specialEventRoles" . }}
|
||||
{{ else if eq .EventType "SpecialEvent" }}
|
||||
{{ template "specialEvent" . }}
|
||||
{{ end }}
|
||||
</main>
|
||||
</body>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{{ define "regularstable" }}
|
||||
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
|
||||
<h2 class="textWhite">{{ .Locals.Registered }}</h2>
|
||||
<div class="tableWrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="tableHeading">
|
||||
|
@ -10,16 +11,16 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $suiter := .Attendies }}
|
||||
{{if not $suiter.OnWaitingList }}
|
||||
{{range $attendie := .Attendies }}
|
||||
{{if not $attendie.OnWaitingList }}
|
||||
<tr>
|
||||
<td>{{ $suiter.Nickname }}</td>
|
||||
{{ if $suiter.AttendsRestaurant }}
|
||||
<td>{{ $attendie.Nickname }}</td>
|
||||
{{ if $attendie.AttendsRestaurant }}
|
||||
<td class="tdgreen">✓ {{ $.Locals.Yes }}</td>
|
||||
{{ else }}
|
||||
<td class="tdred">❌ {{ $.Locals.No }}</td>
|
||||
{{ end }}
|
||||
{{ if $suiter.AttendsBar }}
|
||||
{{ if $attendie.AttendsBar }}
|
||||
<td class="tdgreen">✓ {{ $.Locals.Yes }}</td>
|
||||
{{ else }}
|
||||
<td class="tdred">❌ {{ $.Locals.No }}</td>
|
||||
|
@ -29,4 +30,22 @@
|
|||
{{end}}
|
||||
</tbody>
|
||||
</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}}
|
34
src/app/views/specialEvent.html
Normal file
34
src/app/views/specialEvent.html
Normal 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}}
|
|
@ -1,6 +1,7 @@
|
|||
{{define "specialEventRoles"}}
|
||||
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
|
||||
<h2 class="textWhite">{{ .Locals.Registered }}</h2>
|
||||
<div class="tableWrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="tableHeading">
|
||||
|
@ -63,5 +64,6 @@
|
|||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
|
@ -1,6 +1,7 @@
|
|||
{{define "suitwalk"}}
|
||||
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
|
||||
<h2 class="textWhite">{{ .Locals.Registered }}</h2>
|
||||
<div class="tableWrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="tableHeading">
|
||||
|
@ -80,5 +81,6 @@
|
|||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{end}}
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"gorm.io/driver/sqlite"
|
||||
"github.com/glebarez/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"ulmer-furs.de/pretix-proxy/v2/entities"
|
||||
"ulmer-furs.de/pretix-proxy/v2/seeder"
|
||||
|
|
|
@ -94,4 +94,9 @@ var defaultMessages = []i18n.Message{
|
|||
One: "AfterParty",
|
||||
Other: "AfterParties",
|
||||
},
|
||||
{
|
||||
ID: "Event",
|
||||
One: "Event",
|
||||
Other: "Events",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ type Db_Attendies struct {
|
|||
Role *Role
|
||||
AttendsRestaurant bool `gorm:"column: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"`
|
||||
RegistrationTime time.Time `gorm:"column:registration_time;not null;default:CURRENT_TIMESTAMP"`
|
||||
OnWaitingList bool `gorm:"column:on_wating_list;not null;default:false"`
|
||||
|
|
|
@ -14,6 +14,7 @@ type Db_Event struct {
|
|||
ItemIdBar *int `gorm:"column:item_id_bar"`
|
||||
ItemIdParticipation *int `gorm:"column:item_id_participation"`
|
||||
ItemIdRole *int `gorm:"column:item_id_role"`
|
||||
ItemIdEvent *int `gorm:"column:item_id_event"`
|
||||
QuestionIdRole *string `gorm:"column:question_id_role"`
|
||||
QuestionIdName *string `gorm:"column:question_id_name"`
|
||||
QuestionIdPrivacy *string `gorm:"column:question_id_is_private"`
|
||||
|
|
26
src/go.mod
26
src/go.mod
|
@ -1,6 +1,8 @@
|
|||
module ulmer-furs.de/pretix-proxy/v2
|
||||
|
||||
go 1.19
|
||||
go 1.21
|
||||
|
||||
toolchain go1.22.4
|
||||
|
||||
require (
|
||||
github.com/go-playground/validator/v10 v10.15.4
|
||||
|
@ -13,16 +15,30 @@ require (
|
|||
golang.org/x/crypto v0.15.0
|
||||
golang.org/x/text v0.14.0
|
||||
gorm.io/driver/sqlite v1.5.3
|
||||
gorm.io/gorm v1.25.4
|
||||
gorm.io/gorm v1.25.7
|
||||
)
|
||||
|
||||
require (
|
||||
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/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/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/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
|
||||
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 (
|
||||
|
@ -31,7 +47,7 @@ require (
|
|||
github.com/gofiber/template v1.8.2 // indirect
|
||||
github.com/gofiber/template/html/v2 v2.0.5
|
||||
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/now v1.1.5 // 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/fasthttp v1.50.0 // indirect
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20231108232855-2478ac86f678
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
)
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
"one": "Teilnehmer*in",
|
||||
"other": "Teilnehmende"
|
||||
},
|
||||
"Event": {
|
||||
"hash": "sha1-c5497bca58468ae64aed6c0fd921109217988db3",
|
||||
"one": "Event",
|
||||
"other": "Events"
|
||||
},
|
||||
"Guest": {
|
||||
"hash": "sha1-7b7f214bbd4af36f25668b0ddade965422d342fd",
|
||||
"one": "Gast",
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
"one": "Attendie",
|
||||
"other": "Attendies"
|
||||
},
|
||||
"Event": {
|
||||
"one": "Event",
|
||||
"other": "Events"
|
||||
},
|
||||
"Guest": {
|
||||
"one": "Guest",
|
||||
"other": "Guets"
|
||||
|
|
Loading…
Reference in a new issue