masterpoints package#
Submodules#
masterpoints.admin module#
Generated by utils/cgit/cgit_util_generate_admin_file on 2025-10-30 13:19:56.883818
- class masterpoints.admin.ClubMembershipHistoryAdmin(model, admin_site)[source]#
Bases:
ModelAdminAdmin class for model ClubMembershipHistory
- autocomplete_fields = ['club']#
- property media#
- class masterpoints.admin.MPBatchAdmin(model, admin_site)[source]#
Bases:
ModelAdminAdmin class for model MPBatch
- list_filter = ('source', 'is_approved', 'is_charged')#
- property media#
- search_fields = ['=old_mpc_id']#
- class masterpoints.admin.MPTranAdmin(model, admin_site)[source]#
Bases:
ModelAdminAdmin class for model MPTran
- autocomplete_fields = ['mp_batch', 'user']#
- property media#
- class masterpoints.admin.MasterpointEventAdmin(model, admin_site)[source]#
Bases:
ModelAdminAdmin class for model MasterpointEvent
- autocomplete_fields = ['billing_organisation', 'added_by']#
- property media#
- class masterpoints.admin.PeriodAdmin(model, admin_site)[source]#
Bases:
ModelAdminAdmin class for model Period
- property media#
- search_fields = ['old_mpc_id']#
masterpoints.apps module#
masterpoints.factories module#
- class masterpoints.factories.MasterpointDB[source]#
Bases:
MasterpointFactoryConcrete implementation of a masterpoint factory using a database to get the data
- get_masterpoints(system_number)[source]#
Retrieves the total masterpoints and rank for a given system number.
Looks up the masterpoints database for the provided system number and returns a dictionary containing the total points and the rank name. If the system number is not found, returns ‘Not found’ for both fields.
- Parameters:
system_number – The unique identifier for the user in the masterpoints system.
- Returns:
A dictionary with keys ‘points’ and ‘rank’ representing the user’s masterpoints and rank.
- Return type:
dict
- masterpoint_search(request, system_number, last_name, first_name)[source]#
Called by the masterpoints page on the side menu to show masterpoints for a searched user or the logged in user
- process_transactions(details, month, year)[source]#
Separate process and provisional details add formatting to the matchpoint numbers
- class masterpoints.factories.MasterpointDjango[source]#
Bases:
MasterpointFactoryConcrete implementation of a masterpoint factory using local tables in Django to get the data
- get_masterpoints(system_number)[source]#
Retrieves the total masterpoints and rank for a given system number.
Does this using local tables.
- Parameters:
system_number – The unique identifier for the user in the masterpoints system.
- Returns:
A dictionary with keys ‘points’ and ‘rank’ representing the user’s masterpoints and rank.
- Return type:
dict
- masterpoint_search(request, system_number, last_name, first_name)[source]#
Called by the masterpoints page on the side menu to show masterpoints for a searched user or the logged in user
- system_number_lookup(system_number)[source]#
Used for registering new users through the web sign up form
- system_number_valid(system_number)[source]#
Checks if this is valid, returns boolean. To be valid this must exist in the MPC with IsActive True and not already be a user in the system
- user_summary(system_number)[source]#
Basic Masterpoint related information about a user
- Returns e.g.:
{ ‘ABFNumber’: ‘620246’, ‘Surname’: ‘Guthrie’, ‘GivenNames’: ‘Mark’, ‘IsActive’: True, ‘TotalMPs’: 1028.22, ‘TotalGold’: 451.25, ‘ TotalRed’: 483.01, ‘ TotalGreen’: 93.96, ‘RankName’: ‘Grand’, ‘home_club’: ‘North Shore Bridge Club Inc’ }
- class masterpoints.factories.MasterpointFactory[source]#
Bases:
objectAbstract class for accessing masterpoint data
- class masterpoints.factories.MasterpointFile[source]#
Bases:
MasterpointFactoryConcrete implementation of a masterpoint factory using a file to get the data
- masterpoints.factories.masterpoint_query_list(query)[source]#
Generic function to talk to the masterpoints SQL Server and return data as a list
masterpoints.models module#
- class masterpoints.models.ChargeType(*args, **kwargs)[source]#
Bases:
ModelDifferent types of charges for Masterpoints
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- fee_including_gst#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- invoice_words#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_gst_taxable#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mps_or_player#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_id#
This is only needed while we still use the MPC as the source of truth. Delete later
- price_list_sequence#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- show_on_invoice#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- show_on_price_list#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- type_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class masterpoints.models.ClubMembershipHistory(*args, **kwargs)[source]#
Bases:
Modelhistoric view of memberships
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- billing_month#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- billing_year#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- club#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- club_id#
- home_members#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_club_id#
only needed temporarily
- old_mpc_id#
only needed temporarily
- class masterpoints.models.GreenPointAchievementBand(*args, **kwargs)[source]#
Bases:
ModelRequirements for green point levels
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- high_points#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- low_points#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_id#
temporary link with MPC
- class masterpoints.models.MPBatch(*args, **kwargs)[source]#
Bases:
ModelBasic unit of uploaded data with masterpoints
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- admin_comments#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- authorisation_number#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- check_flag#
temporary. Used while we sync with the MPC. Can be removed later
- club#
We link to either an Event (in Masterpoints terminology) or a club
- club_id#
- event_month#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_posted_date(*, field=<django.db.models.fields.DateTimeField: posted_date>, is_next=True, **kwargs)#
- get_previous_by_posted_date(*, field=<django.db.models.fields.DateTimeField: posted_date>, is_next=False, **kwargs)#
- get_source_display(*, field=<django.db.models.fields.CharField: source>)#
- how_submitted#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_approved#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_charged#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_mccutcheon_eligible#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- masterpoint_event#
We link to either an Event (in Masterpoints terminology) or a club
- masterpoint_event_id#
- mps_submitted_gold#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mps_submitted_green#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mps_submitted_red#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mptran_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_event_or_club_id#
Can be removed when we no longer sync from the MPC
- old_mpc_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- old_mpc_posted_by_user_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- posted_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- posting_month#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- posting_year#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- source#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- uploaded_comments#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- uploaded_filename#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class masterpoints.models.MPColours(*values)[source]#
Bases:
TextChoices- GOLD = 'Y'#
- GREEN = 'G'#
- RED = 'R'#
- class masterpoints.models.MPTran(*args, **kwargs)[source]#
Bases:
Model[{“ORDINAL_POSITION”:1,”COLUMN_NAME”:”TranID”,”DATA_TYPE”:”int”,”CHARACTER_MAXIMUM_LENGTH”:null,”IS_NULLABLE”:”NO”}, {“ORDINAL_POSITION”:2,”COLUMN_NAME”:”PlayerID”,”DATA_TYPE”:”int”,”CHARACTER_MAXIMUM_LENGTH”:null,”IS_NULLABLE”:”YES”}, {“ORDINAL_POSITION”:3,”COLUMN_NAME”:”MPColour”,”DATA_TYPE”:”char”,”CHARACTER_MAXIMUM_LENGTH”:1,”IS_NULLABLE”:”YES”}, {“ORDINAL_POSITION”:4,”COLUMN_NAME”:”MPs”,”DATA_TYPE”:”money”,”CHARACTER_MAXIMUM_LENGTH”:null,”IS_NULLABLE”:”YES”}, {“ORDINAL_POSITION”:5,”COLUMN_NAME”:”Source”,”DATA_TYPE”:”char”,”CHARACTER_MAXIMUM_LENGTH”:1,”IS_NULLABLE”:”YES”}, {“ORDINAL_POSITION”:6,”COLUMN_NAME”:”MPBatchID”,”DATA_TYPE”:”int”,”CHARACTER_MAXIMUM_LENGTH”:null,”IS_NULLABLE”:”YES”}, {“ORDINAL_POSITION”:7,”COLUMN_NAME”:”IsApproved”,”DATA_TYPE”:”char”,”CHARACTER_MAXIMUM_LENGTH”:1,”IS_NULLABLE”:”YES”}]
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- get_mp_colour_display(*, field=<django.db.models.fields.CharField: mp_colour>)#
- get_source_display(*, field=<django.db.models.fields.CharField: source>)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_approved#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mp_amount#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mp_batch#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- mp_batch_id#
- mp_colour#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- old_mp_batch_id#
temporary - here for any debugging
- old_mpc_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- old_mpc_player_id#
temporary - here for any debugging
- source#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id#
- class masterpoints.models.MasterpointEvent(*args, **kwargs)[source]#
Bases:
ModelThese represent the acceptable events for awarding masterpoints
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- added_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- added_by_id#
- billing_club_id#
Should only be needed for old MPC - billing_organisation is the real link
- billing_organisation#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- billing_organisation_id#
- comments#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- event_code#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- event_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)#
- get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)#
- gold_point_event_tier#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- grade#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_closed#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mp_colour#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- mpbatch_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_id#
This is only needed while we still use the MPC as the source of truth. Delete later
- t_grade#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class masterpoints.models.Period(*args, **kwargs)[source]#
Bases:
ModelNot sure yet if we need this
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- get_next_by_period_end(*, field=<django.db.models.fields.DateTimeField: period_end>, is_next=True, **kwargs)#
- get_previous_by_period_end(*, field=<django.db.models.fields.DateTimeField: period_end>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_current#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- period_end#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- period_month#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- period_year#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- promotion_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class masterpoints.models.Promotion(*args, **kwargs)[source]#
Bases:
Modelrecord of when players where promoted
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- get_next_by_record_date(*, field=<django.db.models.fields.DateTimeField: record_date>, is_next=True, **kwargs)#
- get_previous_by_record_date(*, field=<django.db.models.fields.DateTimeField: record_date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- period#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- period_id#
- rank#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- rank_id#
- record_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- system_number#
ideally this would be a foreign key but we can’t link to both User and UnregisteredUser
- class masterpoints.models.Rank(*args, **kwargs)[source]#
Bases:
ModelDifferent levels within Masterpoint ranking
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- gold_needed#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- old_mpc_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- promotion_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- rank_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- rank_old_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- rank_sequence#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- red_gold_needed#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- total_needed#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
masterpoints.tests module#
masterpoints.urls module#
masterpoints.views module#
- masterpoints.views.abf_checksum_is_valid(abf_number: int) bool[source]#
Takes an ABF number and confirms the number has a valid checksum. Doesn’t check with the MPC to see if this is a valid number (not inactive, actually registered etc).
- masterpoints.views.abf_registration_card(request)[source]#
Logged out search for user to print a registration card
- masterpoints.views.abf_registration_card_htmx(request)[source]#
Perform the user search and return the list
- masterpoints.views.download_abf_card_pdf(request)[source]#
Downloads a PDF with basic information about this registered user
- masterpoints.views.get_abf_checksum(abf_raw: int) int[source]#
Calculate the checksum for an ABF number given the raw number without the checksum
Formula is:
convert to 6 digit with leading 0, e.g. 62024 becomes 062024 total is 0th place x 7, 1st place x 6, 2nd place x 5 etc result = total mod 11 if result = 0 checksum = 0 else checksum = 11 - (result mod 11)
- masterpoints.views.masterpoint_query_local(query)[source]#
Generic function to talk to the masterpoints server and return data
THIS IS A DUPLICATE OF THE FUNCTION IN UTILS/UTIL_VIEWS/MASTERPOINTS due to circular dependency problems.
Takes in a SQLServer query e.g. “select count(*) from table”
Returns an iterable, either an empty list or the response from the server.
In case there is a problem connecting to the server, this will do everything it can to fail silently.
- masterpoints.views.masterpoints_search(request)[source]#
Called from the masterpoints page to search fo other users
- masterpoints.views.process_transactions(details, month, year)[source]#
Separate process and provisional details add formatting to the matchpoint numbers
- masterpoints.views.search_mpc_users_by_name(first_name_search, last_name_search)[source]#
search the masterpoint centre for users by first and last name
- masterpoints.views.system_number_available(system_number)[source]#
Called from the registration page. Takes in a system number and returns True if number is valid and available