Accreditations - Seluj78/IntraPy GitHub Wiki

To use the Accreditation Handler, you must import it first:

from IntraPy.accreditation_handler import accreditations

Once imported, Theses functions will be available to you:

get_accreditations

    def get_accreditations(self, **options):
# Where options are the options you want to pass to get_accredidations

Here's a list of all the parameters this function can take:

  • page_number (An int, defining which page you want to get your accreditations from)
  • page_size (An int, defining the number of accreditations you want to get)
  • pretty (A boolean, False by default. Set to True if you want the output to be formatted (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it))
  • from_page (An int, The page you want to start your loop from)
  • to_page (An int, The page you want to end your loop to)
Please note that page_number variable has priority over from_page and to_page

The list of accreditations will be returned in a list like so by default, if you print it:

[{'id': XXX, 'name': "XXX", 'user_id': XXX, 'cursus_id': XXX, 'validated': XXX}, {'id': 2, 'name': "XXX", 'user_id': XXX, 'cursus_id': XXX, 'validated': XXX}, {'id': 3, 'name': "XXX", 'user_id': XXX, 'cursus_id': XXX, 'validated': XXX},...]

Or, with pretty=True:

[
   {
      'id':X,
      'name':"XXX",
      'user_id':XXX,
      'cursus_id':XXX,
      'validated':XXX
   },
   {
      'id':X,
      'name':"XXX",
      'user_id':XXX,
      'cursus_id':XXX,
      'validated':XXX
   },
   {
      'id':X,
      'name':"XXX",
      'user_id':XXX,
      'cursus_id':XXX,
      'validated':XXX
   },
   ...
]

Here are a few examples to get you started:

from IntraPy.accreditation_handler import accreditations

accreditations = accreditations.Accreditations()
print(accreditations.get_accreditations()) # This will print all the accreditations availables
from IntraPy.accreditation_handler import accreditations

accreditations = accreditations.Accreditations()
print(accreditations.get_accreditations(pretty=True)) # This will print all the accreditations availables, in a formatted form (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.accreditation_handler import accreditations

accreditations = accreditations.Accreditations()
print(accreditations.get_accreditations(page_number=2, page_size=5, pretty=True)) # This will return 5 accreditations from page 2 in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.accreditation_handler import accreditations

accreditations = accreditations.Accreditations()
print(accreditations.get_accreditations(from_page=2, to_page=5, pretty=True)) # This will all the accreditations from page 2 to page 5 (with a default page size of 30) in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)

get_accreditation_by_id()

    def get_accreditations_by_id(self, accreditation_id: int):
# Where accredidation_id is the id of the accredidation you want to get more info on.

This function will return the info on a peculiar id you asked for. The info will be returned on a json form:

{
   'id':ID,
   'name':'NAME',
   'user_id':USER_ID,
   'cursus_id':CURSUS_ID,
   'validated':XXX
}

Of course here the list is formatted but if you execute this:

from IntraPy.accreditation_handler import accreditations

accreditations = accreditations.Accreditations()
print(accreditations.get_accreditation_by_id(1))

you'll get something like this:

{'id': ID, 'name': 'NAME', 'user_id': USER_ID, 'cursus_id': CURSUS_ID, 'validated': XXX}