Initialize fork and rebrand app to event_manager
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("events", "doctype", "offline_payment_method")
|
||||
|
||||
# Skip if the old columns don't exist (fresh install or already migrated)
|
||||
if not frappe.db.has_column("Pohodex Event Manager Event", "enable_offline_payments"):
|
||||
return
|
||||
|
||||
events_with_offline = frappe.get_all(
|
||||
"Pohodex Event Manager Event",
|
||||
filters={"enable_offline_payments": 1},
|
||||
fields=["name", "offline_payment_label", "offline_payment_details", "collect_payment_proof"],
|
||||
)
|
||||
|
||||
for event in events_with_offline:
|
||||
title = event.offline_payment_label or "Offline Payment"
|
||||
|
||||
method = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Offline Payment Method",
|
||||
"title": title,
|
||||
"event": event.name,
|
||||
"enabled": 1,
|
||||
"collect_payment_proof": event.collect_payment_proof,
|
||||
"description": event.offline_payment_details,
|
||||
}
|
||||
)
|
||||
method.insert(ignore_permissions=True)
|
||||
|
||||
# Link any existing Pohodex Event Manager Custom Fields scoped to "Offline Payment Form" for this event
|
||||
custom_fields = frappe.get_all(
|
||||
"Pohodex Event Manager Custom Field",
|
||||
filters={"event": event.name, "applied_to": "Offline Payment Form"},
|
||||
pluck="name",
|
||||
)
|
||||
for cf_name in custom_fields:
|
||||
frappe.db.set_value("Pohodex Event Manager Custom Field", cf_name, "offline_payment_method", method.name)
|
||||
|
||||
frappe.reload_doc("events", "doctype", "buzz_event")
|
||||
@@ -0,0 +1,20 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
events = frappe.get_all(
|
||||
"Pohodex Event Manager Event", filters={"payment_gateway": ("is", "set")}, fields=["name", "payment_gateway"]
|
||||
)
|
||||
|
||||
frappe.reload_doc("Events", "doctype", "buzz_event")
|
||||
frappe.reload_doc("Events", "doctype", "event_payment_gateway")
|
||||
|
||||
for event in events:
|
||||
doc = frappe.get_cached_doc("Pohodex Event Manager Event", event.name)
|
||||
doc.append(
|
||||
"payment_gateways",
|
||||
{
|
||||
"payment_gateway": event.payment_gateway,
|
||||
},
|
||||
)
|
||||
doc.save()
|
||||
@@ -0,0 +1,9 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
categories = frappe.db.get_all("Event Category", pluck="name")
|
||||
for category in categories:
|
||||
doc = frappe.get_cached_doc("Event Category", category)
|
||||
doc.set_slug()
|
||||
doc.save()
|
||||
@@ -0,0 +1,29 @@
|
||||
import frappe
|
||||
|
||||
doctypes = {
|
||||
"Event Management Settings": "Pohodex Event Manager Settings",
|
||||
"FE Event": "Pohodex Event Manager Event",
|
||||
}
|
||||
|
||||
|
||||
def execute():
|
||||
rename_doctypes()
|
||||
create_sequences()
|
||||
|
||||
|
||||
def rename_doctypes():
|
||||
for old in doctypes:
|
||||
new = doctypes[old]
|
||||
if not frappe.db.exists("DocType", new):
|
||||
print(f"Renaming {old} to {new}")
|
||||
frappe.rename_doc("DocType", old, new, force=True, ignore_if_exists=True)
|
||||
|
||||
|
||||
def create_sequences():
|
||||
doctype = "Pohodex Event Manager Event"
|
||||
sequence_name = frappe.scrub(doctype + "_id_seq")
|
||||
frappe.db.sql_ddl(f"drop sequence if exists {sequence_name}")
|
||||
last_name = frappe.db.get_all(doctype, fields=["max(name) as last"])[0].last
|
||||
start_value = (last_name or 0) + 1
|
||||
print(f"Creating sequence for {doctype} starting at {start_value}")
|
||||
frappe.db.create_sequence(doctype, start_value=start_value, check_not_exists=True)
|
||||
@@ -0,0 +1,35 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
BuzzCouponCode = frappe.qb.DocType("Pohodex Event Manager Coupon Code")
|
||||
|
||||
# 1. Set applies_to = "Event" for all Free Tickets coupons
|
||||
(
|
||||
frappe.qb.update(BuzzCouponCode)
|
||||
.set(BuzzCouponCode.applies_to, "Event")
|
||||
.where(BuzzCouponCode.coupon_type == "Free Tickets")
|
||||
.where((BuzzCouponCode.applies_to.isnull()) | (BuzzCouponCode.applies_to == ""))
|
||||
).run()
|
||||
|
||||
# 2. Set applies_to = "Event" for Discount coupons that have event set
|
||||
(
|
||||
frappe.qb.update(BuzzCouponCode)
|
||||
.set(BuzzCouponCode.applies_to, "Event")
|
||||
.where(BuzzCouponCode.coupon_type == "Discount")
|
||||
.where(BuzzCouponCode.event.isnotnull())
|
||||
.where(BuzzCouponCode.event != "")
|
||||
.where((BuzzCouponCode.applies_to.isnull()) | (BuzzCouponCode.applies_to == ""))
|
||||
).run()
|
||||
|
||||
# 3. Set applies_to = "Event Category" for Discount coupons that have event_category set
|
||||
(
|
||||
frappe.qb.update(BuzzCouponCode)
|
||||
.set(BuzzCouponCode.applies_to, "Event Category")
|
||||
.where(BuzzCouponCode.coupon_type == "Discount")
|
||||
.where(BuzzCouponCode.event_category.isnotnull())
|
||||
.where(BuzzCouponCode.event_category != "")
|
||||
.where((BuzzCouponCode.applies_to.isnull()) | (BuzzCouponCode.applies_to == ""))
|
||||
).run()
|
||||
|
||||
# Coupons with neither event nor event_category remain as global (applies_to = '')
|
||||
@@ -0,0 +1,13 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
EventBooking = frappe.qb.DocType("Event Booking")
|
||||
|
||||
# Set payment_status to "Paid" and status to "Confirmed" for all submitted bookings
|
||||
(
|
||||
frappe.qb.update(EventBooking)
|
||||
.set(EventBooking.payment_status, "Paid")
|
||||
.set(EventBooking.status, "Confirmed")
|
||||
.where(EventBooking.docstatus == 1)
|
||||
).run()
|
||||
Reference in New Issue
Block a user