#NEWLINE# def model( self ) : #NEWLINE# #INDENT# T = current . T #NEWLINE# db = current . db #NEWLINE# auth = current . auth #NEWLINE# s3 = current . response . s3 #NEWLINE# settings = current . deployment_settings #NEWLINE# organisation_id = self . org_organisation_id #NEWLINE# ADMIN = current . session . s3 . system_roles . ADMIN #NEWLINE# is_admin = auth . s3_has_role ( ADMIN ) #NEWLINE# add_components = self . add_components #NEWLINE# configure = self . configure #NEWLINE# crud_strings = s3 . crud_strings #NEWLINE# define_table = self . define_table #NEWLINE# root_org = auth . root_org ( ) #NEWLINE# if is_admin : #NEWLINE# #INDENT# filter_opts = ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if root_org : #NEWLINE# #INDENT# filter_opts = ( root_org , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# filter_opts = ( None , ) #NEWLINE# #UNINDENT# #UNINDENT# types = settings . get_member_membership_types ( ) #NEWLINE# tablename = 'member_membership_type' #NEWLINE# define_table ( tablename , Field ( 'name' , notnull = True , length = 64 , label = T ( 'Name' ) , requires = IS_NOT_EMPTY ( ) ) , organisation_id ( default = root_org , readable = is_admin , writable = is_admin ) , s3_comments ( label = T ( 'Description' ) , comment = None ) , * s3_meta_fields ( ) ) #NEWLINE# ADD_MEMBERSHIP_TYPE = T ( 'Create Membership Type' ) #NEWLINE# crud_strings [ tablename ] = Storage ( label_create = ADD_MEMBERSHIP_TYPE , title_display = T ( 'Membership Type Details' ) , title_list = T ( 'Membership Types' ) , title_update = T ( 'Edit Membership Type' ) , title_upload = T ( 'Import Membership Types' ) , label_list_button = T ( 'List Membership Types' ) , label_delete_button = T ( 'Delete Membership Type' ) , msg_record_created = T ( 'Membership Type added' ) , msg_record_modified = T ( 'Membership Type updated' ) , msg_record_deleted = T ( 'Membership Type deleted' ) , msg_list_empty = T ( 'No membership types currently registered' ) ) #NEWLINE# represent = S3Represent ( lookup = tablename , translate = True ) #NEWLINE# membership_type_id = S3ReusableField ( 'membership_type_id' , ( 'reference %s' % tablename ) , label = T ( 'Type' ) , ondelete = 'SET NULL' , readable = types , represent = represent , requires = IS_EMPTY_OR ( IS_ONE_OF ( db , 'member_membership_type.id' , represent , filterby = 'organisation_id' , filter_opts = filter_opts ) ) , sortby = 'name' , writable = types , comment = S3PopupLink ( f = 'membership_type' , label = ADD_MEMBERSHIP_TYPE , title = ADD_MEMBERSHIP_TYPE , tooltip = T ( 'Add a new membership type to the catalog.' ) ) ) #NEWLINE# configure ( tablename , deduplicate = S3Duplicate ( primary = ( 'name' , 'organisation_id' ) , ignore_deleted = True ) ) #NEWLINE# tablename = 'member_membership' #NEWLINE# define_table ( tablename , organisation_id ( empty = False , requires = self . org_organisation_requires ( updateable = True ) ) , Field ( 'code' , label = T ( 'Member ID' ) ) , self . pr_person_id ( comment = None , requires = IS_ADD_PERSON_WIDGET2 ( ) , widget = S3AddPersonWidget2 ( controller = 'member' ) ) , membership_type_id ( ) , s3_date ( 'start_date' , label = T ( 'Date Joined' ) , set_min = '#member_membership_end_date' ) , s3_date ( 'end_date' , label = T ( 'Date Resigned' ) , set_max = '#member_membership_start_date' , start_field = 'member_membership_start_date' , default_interval = 12 ) , Field ( 'leaving_reason' , label = T ( 'Reason for Leaving' ) , readable = False , writable = False ) , s3_date ( 'restart_date' , label = T ( 'Date Rejoined' ) , readable = False , set_max = '#member_membership_end_date' , writable = False ) , Field ( 'membership_fee' , 'double' , label = T ( 'Membership Fee' ) ) , s3_date ( 'membership_paid' , label = T ( 'Membership Paid' ) ) , Field ( 'fee_exemption' , 'boolean' , label = T ( 'Exempted from Membership Fee' ) , default = False , readable = False , writable = False ) , s3_comments ( ) , self . gis_location_id ( readable = False , writable = False ) , Field . Method ( 'paid' , self . member_membership_paid ) , * s3_meta_fields ( ) ) #NEWLINE# crud_strings [ tablename ] = Storage ( label_create = T ( 'Create Member' ) , title_display = T ( 'Member Details' ) , title_list = T ( 'Members' ) , title_update = T ( 'Edit Member' ) , title_upload = T ( 'Import Members' ) , label_list_button = T ( 'List Members' ) , label_delete_button = T ( 'Delete Member' ) , msg_record_created = T ( 'Member added' ) , msg_record_modified = T ( 'Member updated' ) , msg_record_deleted = T ( 'Member deleted' ) , msg_list_empty = T ( 'No Members currently registered' ) ) #NEWLINE# levels = current . gis . get_relevant_hierarchy_levels ( ) #NEWLINE# list_fields = [ 'person_id' , 'organisation_id' ] #NEWLINE# if types : #NEWLINE# #INDENT# list_fields . append ( 'membership_type_id' ) #NEWLINE# #UNINDENT# list_fields += [ 'start_date' , ( T ( 'Paid' ) , 'paid' ) , ( T ( 'Email' ) , 'email.value' ) , ( T ( 'Phone' ) , 'phone.value' ) ] #NEWLINE# report_fields = [ 'person_id' ] #NEWLINE# if types : #NEWLINE# #INDENT# report_fields . append ( 'membership_type_id' ) #NEWLINE# default_row = 'membership.membership_type_id' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# default_row = 'membership.paid' #NEWLINE# #UNINDENT# report_fields += [ ( T ( 'Paid' ) , 'paid' ) , 'organisation_id' ] #NEWLINE# text_fields = [ 'organisation_id$name' , 'organisation_id$acronym' , 'person_id$first_name' , 'person_id$middle_name' , 'person_id$last_name' ] #NEWLINE# if types : #NEWLINE# #INDENT# text_fields . append ( 'membership_type_id' ) #NEWLINE# #UNINDENT# for level in levels : #NEWLINE# #INDENT# lfield = ( 'location_id$%s' % level ) #NEWLINE# list_fields . append ( lfield ) #NEWLINE# report_fields . append ( lfield ) #NEWLINE# text_fields . append ( lfield ) #NEWLINE# #UNINDENT# if settings . get_org_branches ( ) : #NEWLINE# #INDENT# org_filter = S3HierarchyFilter ( 'organisation_id' , hidden = True , leafonly = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# org_filter = S3OptionsFilter ( 'organisation_id' , filter = True , header = '' , hidden = True ) #NEWLINE# #UNINDENT# filter_widgets = [ S3TextFilter ( text_fields , label = T ( 'Search' ) ) , org_filter ] #NEWLINE# if types : #NEWLINE# #INDENT# filter_widgets . append ( S3OptionsFilter ( 'membership_type_id' , cols = 3 , hidden = True ) ) #NEWLINE# #UNINDENT# filter_widgets += [ S3OptionsFilter ( 'paid' , cols = 3 , label = T ( 'Paid' ) , options = { #NEWLINE# #INDENT# T ( 'paid' ) : T ( 'paid' ) , #NEWLINE# T ( 'overdue' ) : T ( 'overdue' ) , #NEWLINE# T ( 'expired' ) : T ( 'expired' ) , #NEWLINE# #UNINDENT# } , hidden = True ) , S3LocationFilter ( 'location_id' , label = T ( 'Location' ) , levels = levels , hidden = True ) ] #NEWLINE# report_options = Storage ( rows = report_fields , cols = report_fields , facts = report_fields , defaults = Storage ( cols = 'membership.organisation_id' , rows = default_row , fact = 'count(membership.person_id)' , totals = True ) ) #NEWLINE# configure ( tablename , create_next = URL ( f = 'person' , args = 'address' , vars = { #NEWLINE# #INDENT# 'membership.id' : '[id]' , #NEWLINE# #UNINDENT# } ) , deduplicate = S3Duplicate ( primary = ( 'person_id' , 'organisation_id' ) , ignore_deleted = True ) , extra_fields = ( 'start_date' , 'membership_paid' , 'fee_exemption' ) , filter_widgets = filter_widgets , list_fields = list_fields , onaccept = self . member_onaccept , report_options = report_options , summary = [ { #NEWLINE# #INDENT# 'name' : 'addform' , #NEWLINE# 'common' : True , #NEWLINE# 'widgets' : [ { #NEWLINE# #INDENT# 'method' : 'create' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'table' , #NEWLINE# 'label' : 'Table' , #NEWLINE# 'widgets' : [ { #NEWLINE# #INDENT# 'method' : 'datatable' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'report' , #NEWLINE# 'label' : 'Report' , #NEWLINE# 'widgets' : [ { #NEWLINE# #INDENT# 'method' : 'report' , #NEWLINE# 'ajax_init' : True , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'map' , #NEWLINE# 'label' : 'Map' , #NEWLINE# 'widgets' : [ { #NEWLINE# #INDENT# 'method' : 'map' , #NEWLINE# 'ajax_init' : True , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } ] , update_realm = True ) #NEWLINE# self . add_components ( tablename , pr_contact = ( { #NEWLINE# #INDENT# 'name' : 'email' , #NEWLINE# 'link' : 'pr_person' , #NEWLINE# 'joinby' : 'id' , #NEWLINE# 'key' : 'pe_id' , #NEWLINE# 'fkey' : 'pe_id' , #NEWLINE# 'pkey' : 'person_id' , #NEWLINE# 'filterby' : 'contact_method' , #NEWLINE# 'filterfor' : ( 'EMAIL' , ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'phone' , #NEWLINE# 'link' : 'pr_person' , #NEWLINE# 'joinby' : 'id' , #NEWLINE# 'key' : 'pe_id' , #NEWLINE# 'fkey' : 'pe_id' , #NEWLINE# 'pkey' : 'person_id' , #NEWLINE# 'filterby' : 'contact_method' , #NEWLINE# 'filterfor' : ( 'SMS' , 'HOME_PHONE' , 'WORK_PHONE' ) , #NEWLINE# #UNINDENT# } ) , hrm_programme = { #NEWLINE# #INDENT# 'link' : 'member_membership_programme' , #NEWLINE# 'joinby' : 'membership_id' , #NEWLINE# 'key' : 'programme_id' , #NEWLINE# #UNINDENT# } ) #NEWLINE# represent = S3Represent ( lookup = tablename , fields = [ 'code' ] ) #NEWLINE# membership_id = S3ReusableField ( 'membership_id' , ( 'reference %s' % tablename ) , label = T ( 'Member' ) , ondelete = 'CASCADE' , represent = represent , requires = IS_ONE_OF ( db , 'member_membership.id' , represent ) ) #NEWLINE# return dict ( member_membership_id = membership_id )