Skip to content

Commit

Permalink
feat(place/bookings): allow templated QR codes
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Feb 27, 2025
1 parent 853f61c commit 87ae84d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/place/bookings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,17 @@ class Place::Bookings < PlaceOS::Driver
self[:offline_image] = setting?(String, :offline_image)

self[:custom_qr_color] = setting?(String, :custom_qr_color)
self[:custom_qr_url] = setting?(String, :custom_qr_url).try(&.gsub("{system_id}", control_sys.id))
self[:custom_qr_url] = setting?(String, :custom_qr_url).try do |custom_url|
url = custom_url.gsub("{system_id}", control_sys.id)
if email = control_sys.email
url = url.gsub("{system_email}", email)
url = url.gsub("{system_email_prefix}", email.split('@', 2)[0])
end
url = url.gsub("{system_map_id}", control_sys.map_id.as(String)) if control_sys.map_id
url = url.gsub("{system_code}", control_sys.code.as(String)) if control_sys.code
url = url.gsub("{system_type}", control_sys.type.as(String)) if control_sys.type
url
end

hide_qr_code = setting?(Bool, :hide_qr_code) || false
show_qr_code = setting?(Bool, :show_qr_code)
Expand Down

0 comments on commit 87ae84d

Please sign in to comment.