club_sessions.views package

Contents

club_sessions.views package#

Submodules#

club_sessions.views.admin module#

club_sessions.views.admin.add_club_session(club, session_name, master_session_type='DP')[source]#

Add a new session to a club

club_sessions.views.admin.add_club_session_defaults(club: Organisation)[source]#

When we add a club we set up some sensible defaults

club_sessions.views.admin.add_payment_method_session_type_combos(club)[source]#

Add the required instances of SessionTypePaymentMethod and SessionTypePaymentMethodMembership if they do not already exist

club_sessions.views.admin.turn_off_payment_type(club)[source]#

Handle a payment type being disabled for a club. We need to remove this payment from the session tables

club_sessions.views.core module#

club_sessions.views.core.add_table(session)[source]#

Add a table to a session

club_sessions.views.core.augment_session_entries(session_entries, mixed_dict, membership_type_dict, session_fees, club)[source]#

Sub of tab_session_htmx. Adds extra values to the session_entries for display by the template

Players can be:

Users UnregisteredUsers Nothing

If Nothing, they can have a valid ABF number, an invalid ABF number or no ABF number

Their relationship with the club can be:

Member Non-member

club_sessions.views.core.augment_session_entries_process_entry(session_entry, mixed_dict, membership_type_dict, extras_dict, valid_payment_methods)[source]#

sub of augment_session_entries to handle a single session entry

club_sessions.views.core.back_out_top_up(session_misc_payment: SessionMiscPayment, club: Organisation, player: User, director: User)[source]#

Reverse a top up

club_sessions.views.core.bridge_credits_for_club(club)[source]#

return the bridge credits payment method for a club

club_sessions.views.core.calculate_payment_method_and_balance(session_entries, session_fees, club)[source]#

work out who can pay by bridge credits and if they have enough money

club_sessions.views.core.change_user_on_session_entry(club: Organisation, session: Session, session_entry: SessionEntry, source, system_number, sitout, playing_director, non_abf_visitor, member_last_name_search, member_first_name_search, director)[source]#

Handle changing the player on a session entry

We could get:

source and system number for a User or UnregisteredUser sitout - change to a sitout playing_director - change to a playing director non_abf_visitor - someone who isn’t registered with the ABF, also get the first and last name

If Bridge Credits or IOUs are in place, we reject the change

club_sessions.views.core.change_user_on_session_entry_non_player(player_type, session_entry, club, message)[source]#

sub of change_user_on_session_entry

club_sessions.views.core.change_user_on_session_entry_player(system_number, session_entry, club, message)[source]#

sub of change_user_on_session_entry

club_sessions.views.core.delete_table(session, table_number)[source]#

delete a table

club_sessions.views.core.edit_session_entry_handle_bridge_credits(club, session, session_entry, director, is_user, old_payment_method, new_payment_method, old_fee, new_fee, old_is_paid, new_is_paid)[source]#

Handle a director making any changes to an entry that involve bridge credits.

Returns:

message to return to user, can be empty session_entry(SessionEntry) new_is_paid(Boolean): possibly modified value for new_is_paid flag (used to indicate error)

Return type:

message(str)

club_sessions.views.core.edit_session_entry_handle_ious(club, session_entry, administrator, old_payment_method, new_payment_method, old_fee, new_fee, old_is_paid, new_is_paid, message='')[source]#

handle the director changing anything on a session entry that relates to IOUs

club_sessions.views.core.edit_session_entry_handle_other(club, session_entry, director, is_user, old_payment_method, new_payment_method, old_fee, new_fee, old_is_paid, new_is_paid)[source]#

Handle a director making any changes to an entry that don’t involve bridge credits or IOUs.

Returns:

message to return to user, can be empty session_entry(SessionEntry)

Return type:

message(str)

club_sessions.views.core.get_allowed_payment_methods(session_entries, session, payment_methods)[source]#

logic is too complicated for a template, so build the payment_methods here for each session_entry

Only allow IOU for properly registered users Only allow Bridge Credits for properly registered users Don’t allow changes to bridge credits if already paid for Don’t show bridge credits as an option if we have already processed them

club_sessions.views.core.get_extras_as_total_for_session_entries(session, paid_only=False, unpaid_only=False, payment_method_string=None)[source]#

get the total amount of extras for each session entry as a dictionary

paid_only - only included total for extras that have been paid for unpaid_only - only included total for extras that have not been paid for payment_method_string - filter to include only matching payment methods e.g. “Cash”

club_sessions.views.core.get_extras_for_session_entries(session_entries)[source]#

get the extras associated with a queryset of SessionEntries

club_sessions.views.core.get_session_fee_for_player(session_entry: SessionEntry, club: Organisation)[source]#

return correct fee for a player

club_sessions.views.core.get_session_fees_for_session(session)[source]#

return session fees as a dictionary. We use the name of the membership as the key, not the number

e.g. session_fees = {“Standard”: {“EFTPOS”: 5, “Cash”: 12}}

club_sessions.views.core.get_summary_table_data(session, session_entries, mixed_dict, membership_type_dict)[source]#

Summarise session_entries for the summary view.

Returns a dictionary like:
‘Bridge Credits’:

‘fee’: 150 ‘amount_paid’: 90 ‘outstanding’: 60 ‘player_count’: 5 ‘players’: [User, session_entry, membership]

‘Cash’: …

Note: Users may pay for extras using a different payment method

We use the fact that SessionEntry and SessionMiscPayment are quite similar.

club_sessions.views.core.get_summary_table_data_sub(payment_summary, items, mixed_dict, membership_type_dict, extra_flag=False)[source]#

sub for get_summary_table_data

club_sessions.views.core.get_table_view_data(session, session_entries)[source]#

handle formatting for the table view

club_sessions.views.core.handle_bridge_credit_changes_refund(club, session_entry, director, old_fee, new_fee, new_payment_method, new_is_paid)[source]#

Handle situation where a refund is required for a session entry

club_sessions.views.core.handle_change_additional_session_fee(old_fee, new_fee, session, club, old_reason)[source]#

Handle the settings being changed for additional fees

club_sessions.views.core.handle_change_additional_session_fee_reason(old_reason, new_reason, session, club)[source]#

Handle the settings being changed for additional fees - change the reason

club_sessions.views.core.handle_change_secondary_payment_method(old_method, new_method, session, club, administrator)[source]#

make changes when the secondary payment method is updated

club_sessions.views.core.handle_change_session_type(session, administrator)[source]#

Called when the settings for the session change and the session type is modified

club_sessions.views.core.handle_iou_changes_for_misc_off(club, session_entry, session_misc_payment)[source]#

Turn off using an IOU for a misc payment

club_sessions.views.core.handle_iou_changes_for_misc_on(club, session_entry, session_misc_payment, administrator)[source]#

Handle turning on an IOU for a misc payment

club_sessions.views.core.handle_iou_changes_off(club, session_entry)[source]#

Turn off using an IOU

club_sessions.views.core.handle_iou_changes_on(club, session_entry, administrator)[source]#

Handle turning on an IOU

club_sessions.views.core.iou_for_club(club)[source]#

return the IOU payment method for a club

club_sessions.views.core.load_session_entry_static(session, club)[source]#

Sub of tab_session_htmx. Load the data we need to be able to process the session tab

club_sessions.views.core.pay_bridge_credit_for_extra(session_misc_payment: SessionMiscPayment, session: Session, club: Organisation, member: User)[source]#

Handle a director paying for an extra from the edit panel using bridge credits

Returns:

Success or Failure

Return type:

boolean

club_sessions.views.core.process_bridge_credits(session_entries, session, club, bridge_credits, extras)[source]#

sub of process_bridge_credits_htmx to handle looping through and making payments

club_sessions.views.core.recalculate_session_status(session: Session)[source]#

recalculate what state a session is in based upon the payment status of its session entries

club_sessions.views.core.refund_bridge_credit_for_extra(session_misc_payment: SessionMiscPayment, club: Organisation, player: User, director: User)[source]#

“ Handle an extra with paid bridge credits being changed

club_sessions.views.core.reset_values_on_session_entry(session_entry: SessionEntry, club: Organisation)[source]#

Reset common fields when a user is changed

club_sessions.views.core.session_health_check(club, session, club_bc_pm, user, send_emails=False)[source]#

Check for duplicate bridge credit payments in the session

Parameters:

Returns an error message if an issue detected Sends an email to the support contact if an issue is found (and send_emails set)

club_sessions.views.core.session_totals_calculations(session, session_entries, session_fees, membership_type_dict)[source]#

sub of session_totals_htmx to build dict of totals

club_sessions.views.decorators module#

Club sessions Decorators to simplify code

club_sessions.views.decorators.user_is_club_director(include_session_entry=False)[source]#

checks if user is a director for this club. Requires Request to have a club_id parameter

Call as:

from .decorators import user_is_club_director

@user_is_club_director() def my_func(request, club):

You don’t need @login_required as it does that for you as well

We add a parameter (club) to the actual call which is fine for calls from URLs but if we call this internally it will need to be called without the club parameter.

We also add session.

Optionally, specify include_session_entry to have that loaded and checked for validity

club_sessions.views.imports module#

club_sessions.views.imports.import_file_upload_htmx(request)[source]#

Upload player names for a session

Called from club admin to create a new session and fill it with players from the uploaded file

club_sessions.views.manage_session module#

club_sessions.views.manage_session.manage_session(request, session_id)[source]#

Main page to manage a club session after it has been created.

Not much happens in this function, mostly it just renders the page.

The different tabs look after themselves: tab_settings_htmx, tab_session_htmx live here and the reports run from their own file.

club_sessions.views.new_session module#

club_sessions.views.new_session.new_session(request, club_id)[source]#

Set up a new bridge session for a club. Normally we import a file, so this won’t be used much.

club_sessions.views.reports module#

club_sessions.views.reports.csv_download(request, session_id)[source]#

Download CSV of player details from a session

club_sessions.views.reports.payment_method_summary(session)[source]#

Summarise the payment methods and extras - used for both online and CSV reporting

We don’t use a database query to summarise the sessions as we need to manipulate the non-players for the report.

club_sessions.views.reports.payment_method_summary_sub(payment_methods, payment_status_field)[source]#

sub of payment_method_summary to format the data for sessions and extras with all values including zeros for unpaid or paid amounts.

The only difference between SessionEntry and SessionMiscPayment is the field name used to check if payment has been made. We accept this as a parameter.

club_sessions.views.reports.xlsx_download(request, session_id)[source]#

Download XLS File of player details from a session

Module contents#