Klubbadmin - ka module

KA class

A simple class to interface KA

  • Login done with PassBuy

  • Access the KA webpages programatically

  • Read and write support

class nif_tools.ka.KA(username, password, realm='ka', email_recepients=[])[source]

Bases: object

approve_application(application)[source]

Approve an application

Sanitizes, approves and invoices

approve_application_ended(inboxline, refund=True)[source]

Approve the cancellation - 1 application a time, or?

Will it refund invoices? :parameter dict inboxline: one item from get_applications_ended :parameter boolean refund: if to refund invoices or not, default True :returns boolean result: result of approval

approve_deceased()[source]

Approve and refund invoices for deceased member

can_invoice() → bool[source]
check_person_activities_org(org_id, activities)[source]

Returns true if acitivity org in application org

get(url=None, params=None, remove_keys=[])[source]

Gets json from a resource

Parameters
  • url (str) – the relative url to the resource

  • params (dict) – a dictionary for the parameters

  • remove_keys (list) – keys to remove

Returns int, dictionary requests.status_code, result

get_age(person_id)[source]

Get person from ka, calculate age by calendar year

Parameters

person_id (int) – Person Id

Returns int age

Person age by calendar year

get_applications()[source]

Get membership applications

These are the applications by the members themselves

Returns int

http status code

Returns list

list of inbox items = applications

get_applications_deceased()[source]

Get and process dead people

get_clubs()[source]

Get clubs in search filter

get_headers()[source]
get_inbox()[source]

alias for get_applications :return:

get_inbox_ended()[source]

Get inbox items for applications for ending membership

Returns list

inbox list of current applications to cancel membership(s)

get_invoices()[source]

Get list of invoices

Returns list invoices

list of invoices from search

get_members(member_from=None, member_to=None, unntak=None)[source]
get_members_in_org(org_id) -> (<class 'int'>, <class 'list'>)[source]
get_person(person_id, remove=True)[source]

Get person from ka

Parameters

person_id (int) – Person Id

Returns int status

http code

Returns dict person

person

get_person_activities(person_id)[source]
get_person_competence(person_id)[source]
get_person_details(person_id)[source]
get_person_id()[source]
get_person_licenses(person_id)[source]
get_person_orgs(person_id)[source]

Return orgs

p[‘MembershipOrgSelectionViewModel’][‘FederationClubSelectionViewModel’].keys() dict_keys([‘ClubList’, ‘ExistingClubs’, ‘PassiveClubs’, ‘NewClubOrgId’, ‘ExistingFederationFunctionFromDate’, ‘ReturnToIndex’, ‘ReturnUrl’])

get_person_products(person_id)[source]
get_person_reskonto(person_id)[source]
get_person_reskonto_year(person_id, year=2019)[source]
get_realm()[source]
get_url()[source]
get_username()[source]
magazines(products)[source]

Legacy @TODO Remove

post(url=None, params=None, remove_keys=[])[source]

Posts json to a resource-ish

Parameters
  • url (str) – the relative url to the resource

  • params (dict) – a dictionary for the parameters

  • remove_keys (list) – keys to remove

Returns int, dictionary requests.status_code, result

remove_keys(d, keys)[source]

Remove keys from dict

Parameters
  • d (dict) – dictionary object

  • keys (list) – keys to remove

Returns dict d

Dictionary with removed keys

req(r)[source]

Just parse the request object

Parameters

r (requests) – requests response object

Returns int, dict status_code, requests.json

requests_html(url, params, key1, key2=None, remove_keys=[], pre_pad='', post_pad='')[source]

Gets html page and returns json from jquery

sanitize_person_products(person_id, products, org_id=None, tandem=False)[source]

Sanitizes products by checking correct according to organization and if is tandem

Parameters
  • person_id (int) – Person Id

  • products (dict) – Products from get_person_products (and sanitized?)

  • org_id (int) – OrgId, only when this is given can Unntak be set

  • tandem (boolean) – If this is a tandem person, True else False

Returns dict products

Sanitized products

save_person_activities(org_id, selected_activities)[source]

We process the selected in select_person_activities

save_person_orgs()[source]
save_person_products(products)[source]

Save persons products

Parameters

products (dict) – products from get_person_products, should be sanitized in sanitize_products

Returns int status

Returns dict result

select_person_activities(person_id, org_id, activities)[source]

Select the club/org_id to get activities which we then can save later

Parameters
  • person_id (int) – Person Id

  • org_id (int) – Org Id for organization (club)

  • activities (dict) – Activities got in get_person_activities

Returns int, dict status_code, activities

?

send_invoices(person_ids, notify=False) -> (<class 'int'>, <class 'dict'>)[source]

This actually sends the invoice

touch_person(person_id)[source]

Just generate a change message