def __init__(self, type_raw, update_show_suboptions=False, update_form=None, create_form=None): self.update_show_suboptions = update_show_suboptions self.create_form = option_form_factory( Option, ('name', 'description', 'required', 'depends_on', 'price', 'notify_on_selection'), ('name', 'type', 'description', 'required', 'depends_on', 'price', 'notify_on_selection'), type_raw ) if create_form is None else create_form self.update_form = option_form_factory( Option, ('name', 'description', 'required', 'depends_on', 'price', 'notify_on_selection'), ('name', 'type', 'description', 'required', 'depends_on', 'price', 'notify_on_selection'), type_raw ) if update_form is None else update_form
'choices': SBaseTypeManager( 'choices', update_show_suboptions=True ), 'autoselect': SBaseTypeManager('autoselect'), 'autoselectchoice': SBaseTypeManager( 'autoselectchoice', update_show_suboptions=True, update_form=UpdateAutoSelectChoiceOptionForm, create_form=CreateAutoSelectChoiceOptionForm ), 'discount': SDiscountTypeManager( 'discount', update_show_suboptions=True, create_form=CreateDiscountOptionForm, update_form=option_form_factory( Option, ('name', 'description', 'required', 'price', 'depends_on', 'notify_on_selection'), ('name', 'type', 'description', 'required' 'price', 'depends_on', 'notify_on_selection'), 'discount' ) ) } def stype_manager_factory(option_or_type): """ Returns a type manager based on the options type """ return _stype_manager_register[option_or_type.type if hasattr(option_or_type, 'type') else option_or_type]
@staticmethod def get_widget(scope, option): if scope == SCOPE.SADMIN: return MembershipChoiceNoPassWidget(scope, option) else: return MembershipChoiceNoPassWidget(scope, option, send_notifications=True) options.register_custom_type(MEMBERSHIP_OPTION_TYPE_ID, 'Kontingent', MembershipTypeManager) options.register_custom_type(MEMBERSHIP_NOPASS_OPTION_TYPE_ID, 'Kontingent (ingen fripas)', MembershipWithoutPassTypeManager) sadmin2.register_custom_stype(MEMBERSHIP_OPTION_TYPE_ID, SBaseTypeManager(MEMBERSHIP_OPTION_TYPE_ID, create_form=option_form_factory( Option, ('name', 'description', 'required', 'depends_on', 'notify_on_selection'), ('name', 'type', 'description', 'required', 'depends_on', 'notify_on_selection'), MEMBERSHIP_OPTION_TYPE_ID), update_form=option_form_factory( Option, ('name', 'description', 'required', 'depends_on', 'notify_on_selection'), ('name', 'type', 'description', 'required', 'depends_on', 'notify_on_selection'), MEMBERSHIP_OPTION_TYPE_ID))) sadmin2.register_custom_stype(MEMBERSHIP_NOPASS_OPTION_TYPE_ID, SBaseTypeManager(MEMBERSHIP_NOPASS_OPTION_TYPE_ID, create_form=option_form_factory( Option, ('name', 'description', 'required', 'depends_on', 'notify_on_selection'), ('name', 'type', 'description', 'required', 'depends_on', 'notify_on_selection'), MEMBERSHIP_NOPASS_OPTION_TYPE_ID),