Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cf-web-api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KS Pardubický kraj
cf-web-api
Commits
96263514
Verified
Commit
96263514
authored
2 years ago
by
Andrej Ramašeuski
Browse files
Options
Downloads
Patches
Plain Diff
Cistka konfigurace, zmena mapovani id produktu
parent
42a1897d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
cf2022.conf
+0
-11
0 additions, 11 deletions
cf2022.conf
lib/CF2022/Controller/Orders.pm
+18
-12
18 additions, 12 deletions
lib/CF2022/Controller/Orders.pm
lib/CF2022/Controller/Products.pm
+45
-9
45 additions, 9 deletions
lib/CF2022/Controller/Products.pm
with
64 additions
and
33 deletions
.gitlab-ci.yml
+
1
−
1
View file @
96263514
...
...
@@ -2,7 +2,7 @@ image: docker:20.10.9
variables
:
DOCKER_TLS_CERTDIR
:
"
/certs"
IMAGE_VER
:
0.1
3.4
IMAGE_VER
:
0.1
4.0
services
:
-
docker:20.10.9-dind
...
...
This diff is collapsed.
Click to expand it.
cf2022.conf
+
0
−
11
View file @
96263514
...
...
@@ -2,15 +2,4 @@
secrets
=> [
'14283e549647774b17d10e1d75bcf16c2969673e'
],
oauth_url
=>
'https://auth.pirati.cz/auth/realms/pirati'
,
groups_url
=>
'https://iapi.pirati.cz/v1/octopus/groups'
,
pretix_api
=>
'https://pretix.pir-test.eu/api/v1'
,
pretix_token
=>
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
,
pretix_testmode
=>
1
,
pretix_organizer
=>
'pirati'
,
pretix_event
=>
'cf2022'
,
pretix_qid_sso
=>
29
,
# identifikator otazky SSO UID
pretix_qid_region
=>
8
,
# identifikator otazky Kraj
pretix_qid_photo
=>
28
,
# identifikator otazky Foto
pretix_product_member
=>
1
,
# produkt pro cleny (NEMAPOVANY!)
pretix_product_regp
=>
2
,
# produkt pro regp (NEMAPOVANY!)
mail_domain
=>
'pirati.cz'
,
}
This diff is collapsed.
Click to expand it.
lib/CF2022/Controller/Orders.pm
+
18
−
12
View file @
96263514
...
...
@@ -4,11 +4,6 @@ use Mojo::UserAgent;
use
Mojo::Asset::
File
;
use
Image::PNG::
QRCode
'
qrpng
';
use
constant
MAIN_PRODUCTS
=>
qr/^(1|2|3)$/
;
# typy akreditace
use
constant
NONFREE_PRODUCTS
=>
qr/^(1)$/
;
# akreditace vyzadujici token
use
constant
SUBSIDY_PRODUCTS
=>
qr/^(58)$/
;
# prispevkove polozky
use
constant
FALLBACK_PRODUCT
=>
2
;
# fallback akreditace
use
constant
TPL_VS
=>
'
%d%07d
';
use
constant
TPL_PAYMENT
=>
'
SPD*1.0*ACC:%s*AM:%f*MSG:%s, %s*X-ID:%s*X-VS:%d*X-SS:%d*X-KS:%d
';
...
...
@@ -25,6 +20,15 @@ sub create ($c ) {
my
$accredited
=
0
;
my
$accreditation
=
0
;
# clasifikator typu
my
$pt
=
{};
CLASS:
foreach
my
$class
(
qw(main nonfree subsidy)
)
{
foreach
my
$id
(
split
/\D+/
,
$cfg
->
{"
products_
$class
"}
)
{
$pt
->
{
$class
}{
$id
}
=
1
;
}
}
my
$url
=
sprintf
('
%s/organizers/%s/events/%s/orders/
',
$c
->
config
->
{
pretix_api
},
$c
->
config
->
{
pretix_organizer
},
...
...
@@ -60,7 +64,7 @@ sub create ($c ) {
},
);
$accreditation
=
$c
->
config
->
{'
pretix_
product_
'
.
$group
->
{
role
}};
$accreditation
=
$c
->
config
->
{'
product
s
_
'
.
$group
->
{
role
}};
if
(
$group
->
{
role
}
eq
'
member
'
)
{
$args
->
{
email
}
=
$claims
->
{
preferred_username
}
...
...
@@ -90,16 +94,18 @@ sub create ($c ) {
PRODUCT:
foreach
my
$product
(
@
{
$args
->
{
products
}
}
)
{
next
PRODUCT
if
$product
->
{
id
}
=~
SUBSIDY_PRODUCTS
&&
!
$product
->
{
price
};
$product
->
{
id
}
=
$c
->
mapped_product_id
(
$product
->
{
id
});
next
PRODUCT
if
$pt
->
{
subsidy
}{
$product
->
{
id
}}
&&
!
$product
->
{
price
};
if
(
$p
roduct
->
{
id
}
=~
MAIN_PRODUCTS
)
{
if
(
$p
t
->
{
main
}{
$product
->
{
id
}
}
)
{
next
PRODUCT
if
$accredited
++
;
# neumoznit dvoji akreditace
if
(
$accreditation
)
{
$product
->
{
id
}
=
$accreditation
;
}
elsif
(
$product
->
{
id
}
=~
NONFREE_PRODUCTS
)
{
$product
->
{
id
}
=
FALLBACK_PRODUCT
;
elsif
(
$pt
->
{
nonfree
}{
$product
->
{
id
}
}
)
{
$product
->
{
id
}
=
$cfg
->
{
products_fallback
}
;
}
}
...
...
@@ -108,7 +114,7 @@ sub create ($c ) {
}
# fallback akreditace
@products
=
(
{
id
=>
FALLBACK_PRODUCT
},
@products
)
if
!
$accredited
;
@products
=
(
{
id
=>
$cfg
->
{
products_fallback
}
},
@products
)
if
!
$accredited
;
my
$order
=
{
email
=>
$args
->
{
email
},
...
...
@@ -136,7 +142,7 @@ sub create ($c ) {
foreach
my
$product
(
@products
)
{
my
$item
=
{
item
=>
$c
->
mapped_product_id
(
$product
->
{
id
}
)
,
item
=>
$product
->
{
id
},
variation
=>
$c
->
mapped_variation_id
(
$product
->
{
variation
}),
attendee_name
=>
$args
->
{
name
},
price
=>
$product
->
{
price
},
...
...
This diff is collapsed.
Click to expand it.
lib/CF2022/Controller/Products.pm
+
45
−
9
View file @
96263514
...
...
@@ -5,22 +5,56 @@ use Mojo::UserAgent;
sub
list
{
my
$c
=
shift
->
openapi
->
valid_input
or
return
;
my
$url
=
sprintf
('
%s/organizers/%s/events/%s/items/
',
my
$ua
=
Mojo::
UserAgent
->
new
;
my
$products
=
$ua
->
get
(
sprintf
('
%s/organizers/%s/events/%s/items/
',
$c
->
config
->
{
pretix_api
},
$c
->
config
->
{
pretix_organizer
},
$c
->
config
->
{
pretix_event
},
)
;
my
$ua
=
Mojo::
UserAgent
->
new
;
)
,
{
Authorization
=>
'
Token
'
.
$c
->
config
->
{
pretix_token
}
}
)
->
result
->
json
;
my
$records
=
$ua
->
get
(
$url
,
{
my
$quotas
=
$ua
->
get
(
sprintf
('
%s/organizers/%s/events/%s/quotas/
',
$c
->
config
->
{
pretix_api
},
$c
->
config
->
{
pretix_organizer
},
$c
->
config
->
{
pretix_event
},
),
{
Authorization
=>
'
Token
'
.
$c
->
config
->
{
pretix_token
}
}
)
->
result
->
json
;
my
$q
=
{};
QUOTE:
foreach
my
$record
(
@
{
$quotas
->
{
results
}
}
)
{
next
if
!
$record
->
{
size
};
my
$quota
=
$ua
->
get
(
sprintf
('
%s/organizers/%s/events/%s/quotas/%d/availability/
',
$c
->
config
->
{
pretix_api
},
$c
->
config
->
{
pretix_organizer
},
$c
->
config
->
{
pretix_event
},
$record
->
{
id
},
),
{
Authorization
=>
'
Token
'
.
$c
->
config
->
{
pretix_token
}
}
)
->
result
->
json
;
ITEM:
foreach
my
$item_id
(
@
{
$record
->
{
items
}
}
)
{
$q
->
{
$item_id
}{
total
}
+=
$quota
->
{
total_size
};
$q
->
{
$item_id
}{
available
}
+=
$quota
->
{
available_number
};
foreach
my
$variation_id
(
@
{
$record
->
{
variations
}
}
)
{
$q
->
{
$item_id
}{
$variation_id
}{
total
}
+=
$quota
->
{
total_size
};
$q
->
{
$item_id
}{
$variation_id
}{
available
}
+=
$quota
->
{
available_number
};
}
}
}
$c
->
trace
(
$q
);
my
@options
=
();
RECORD:
foreach
my
$record
(
@
{
$
record
s
->
{
results
}
}
)
{
foreach
my
$record
(
@
{
$
product
s
->
{
results
}
}
)
{
next
RECORD
if
!
$record
->
{
active
};
push
@options
,
{
...
...
@@ -29,11 +63,13 @@ sub list {
price
=>
$record
->
{
default_price
}
+
0
,
free_price
=>
$record
->
{
free_price
},
category_id
=>
$record
->
{
category
},
quotes
=>
$q
->
{
$record
->
{
id
}},
variations
=>
[
map
{{
id
=>
$_
->
{
id
},
value
=>
$_
->
{
value
}{
en
},
price
=>
$_
->
{
price
}
+
0
id
=>
$_
->
{
id
},
value
=>
$_
->
{
value
}{
en
},
price
=>
$_
->
{
price
}
+
0
,
quotes
=>
$q
->
{
$record
->
{
id
}}{
$_
->
{
id
}
},
}}
@
{
$record
->
{
variations
}
}
],
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment