Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chaotikum
website
Commits
eb74c6a7
Commit
eb74c6a7
authored
2 years ago
by
Lukas Ruge
Browse files
Options
Downloads
Patches
Plain Diff
add media ticket generator
parent
78809c1d
No related branches found
No related tags found
No related merge requests found
Pipeline
#7308
passed
2 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
media_ticket_generator.py
+77
-0
77 additions, 0 deletions
media_ticket_generator.py
with
77 additions
and
0 deletions
media_ticket_generator.py
0 → 100644
+
77
−
0
View file @
eb74c6a7
# requires requests==2.28.2
# requires xmltodict=0.13.0
# requires python-frontmatter==1.0.0
import
requests
import
xmltodict
import
frontmatter
import
glob
import
os
import
sys
api_key
=
os
.
environ
.
get
(
'
REDMINE_API_KEY
'
)
known_uids
=
[]
url
=
'
https://chaotikum.org/conferences/all/frab.xml
'
response
=
requests
.
get
(
url
)
data
=
xmltodict
.
parse
(
response
.
content
)
for
day
in
data
[
'
schedule
'
][
'
day
'
]:
if
'
event
'
in
day
[
'
room
'
]:
if
'
@guid
'
in
day
[
'
room
'
][
'
event
'
]:
known_uids
.
append
(
day
[
'
room
'
][
'
event
'
][
'
@guid
'
])
else
:
for
event
in
day
[
'
room
'
][
'
event
'
]:
known_uids
.
append
(
event
[
'
@guid
'
])
else
:
for
room
in
day
[
'
room
'
]:
if
'
@guid
'
in
room
[
'
event
'
]:
known_uids
.
append
(
room
[
'
event
'
][
'
@guid
'
])
else
:
for
event
in
room
[
'
event
'
]:
known_uids
.
append
(
event
[
'
@guid
'
])
files
=
glob
.
glob
(
'
_media/*.md
'
)
for
file
in
files
:
post
=
frontmatter
.
load
(
file
)
if
'
uid
'
in
post
.
keys
():
uid
=
post
[
'
uid
'
]
if
uid
not
in
known_uids
:
if
api_key
is
None
:
print
(
"
No environment variable REDMINE_API_KEY present.
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
else
:
print
(
'
new uid, create ticket in redmine
'
)
title
=
post
[
'
title
'
]
content
=
post
.
content
print
(
'
Title:
'
+
title
)
print
(
'
uid:
'
+
uid
)
print
(
content
)
# https://www.redmine.org/projects/redmine/wiki/rest_issues
# https://www.redmine.org/projects/redmine/wiki/rest_api
# https://www.redmine.org/issues/31186
url
=
f
"
https://redmine.chaotikum.org/issues.json?key=
{
api_key
}
"
post_content
=
{}
post_content
[
'
issue
'
]
=
{};
post_content
[
'
issue
'
][
"
project_id
"
]
=
38
post_content
[
'
issue
'
][
"
subject
"
]
=
title
post_content
[
'
issue
'
][
"
description
"
]
=
content
post_content
[
'
issue
'
][
"
custom_fields
"
]
=
[]
uuid_field
=
{}
uuid_field
[
'
id
'
]
=
11
uuid_field
[
'
value
'
]
=
uid
uuid_field
[
'
name
'
]
=
"
Video-UUID
"
post_content
[
'
issue
'
][
"
custom_fields
"
].
append
(
uuid_field
)
speaker_field
=
{}
speaker_field
[
'
id
'
]
=
8
speaker_field
[
'
value
'
]
=
"
Speaker
"
speaker_field
[
'
name
'
]
=
"
Sprecher
"
post_content
[
'
issue
'
][
"
custom_fields
"
].
append
(
speaker_field
)
r
=
requests
.
post
(
url
=
url
,
json
=
post_content
)
print
(
r
.
json
())
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