This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
"""Give existing bib allocations their edition, so bib numbers are checked per edition."""
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.sql(
|
||||
"""update `tabBib Allocation` b
|
||||
join `tabRegistration` r on r.name = b.registration
|
||||
set b.event_edition = r.event_edition
|
||||
where b.event_edition is null or b.event_edition = ''"""
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
"""Create the roles used by race-day staff. Runs before doctypes sync so permission rows can name them."""
|
||||
|
||||
import frappe
|
||||
|
||||
ROLES = ("Registration Desk", "Timing Officer", "Race Director")
|
||||
|
||||
|
||||
def execute():
|
||||
for name in ROLES:
|
||||
if not frappe.db.exists("Role", name):
|
||||
frappe.get_doc({"doctype": "Role", "role_name": name, "desk_access": 1}).insert(ignore_permissions=True)
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Fill in full names and tidy phone numbers, emails and nationalities on existing participants."""
|
||||
|
||||
import frappe
|
||||
|
||||
from lukenya_marathon.lukenya_marathon.participant_utils import (
|
||||
build_full_name,
|
||||
normalize_nationality,
|
||||
normalize_phone,
|
||||
)
|
||||
|
||||
|
||||
def execute():
|
||||
rows = frappe.db.sql(
|
||||
"""select name, first_name, last_name, full_name, nationality, phone, whatsapp,
|
||||
emergency_contact_phone, email, id_number from `tabParticipant`""",
|
||||
as_dict=True,
|
||||
)
|
||||
for row in rows:
|
||||
wanted = {
|
||||
"full_name": build_full_name(row.first_name, row.last_name),
|
||||
"nationality": normalize_nationality(row.nationality),
|
||||
"phone": normalize_phone(row.phone),
|
||||
"whatsapp": normalize_phone(row.whatsapp),
|
||||
"emergency_contact_phone": normalize_phone(row.emergency_contact_phone),
|
||||
"email": (row.email or "").strip().lower(),
|
||||
"id_number": (row.id_number or "").strip() or None,
|
||||
}
|
||||
changes = {key: value for key, value in wanted.items() if (row.get(key) or None) != (value or None)}
|
||||
if changes:
|
||||
frappe.db.set_value("Participant", row.name, changes, update_modified=False)
|
||||
@@ -0,0 +1,8 @@
|
||||
"""Fill Registration's bib, chip, race pack and check-in status from the records that own them.
|
||||
Only entries that already have such records are touched, so nothing typed by hand is wiped."""
|
||||
|
||||
from lukenya_marathon.lukenya_marathon.race_sync import resync_all
|
||||
|
||||
|
||||
def execute():
|
||||
resync_all()
|
||||
Reference in New Issue
Block a user