https://github.com/opennti/nti.tahrir-api
https://github.com/opennti/nti.tahrir-api
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/opennti/nti.tahrir-api
- Owner: OpenNTI
- License: gpl-3.0
- Created: 2017-10-16T21:34:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-24T18:06:03.000Z (about 3 years ago)
- Last Synced: 2025-03-11T02:51:36.070Z (over 1 year ago)
- Language: Python
- Size: 259 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
Tahrir-API
==========
API for interacting with the Tahrir database. Based on the `Tahrir
`_ database model written by `Ralph
Bean `_. There are two classes that can be used
in this module. The first is the ``TahrirDatabase`` class located in
``tahrir_api.dbapi`` and the second is the database model located in
``tahrir_api.model``. The ``TahrirDatabase`` class is a high level way to
interact with the database. The model is used for a slightly more low level way
of interacting with the database. It allows for custom interactions with the
database without having to use the ``TahrirDatabase`` class.
Creating a Badge
================
This is an example of creating a badge via Tahrir-API:
.. code-block:: python
from tahrir_api.dbapi import TahrirDatabase
db = TahrirDatabase('backend://badges:badgesareawesome@localhost/badges')
origin = 'http://foss.rit.edu/badges'
issuer_name = 'FOSS@RIT'
org = 'http://foss.rit.edu'
contact = 'foss@rit.edu'
issuer_id = db.add_issuer(origin, issuer_name, org, contact)
badge_name = 'fossbox'
image = 'http://foss.rit.edu/files/fossboxbadge.png'
desc = 'Welcome to the FOSSBox. A member is you!'
criteria = 'http://foss.rit.edu'
db.add_badge(badge_name, image, desc, criteria, issuer_id)
Awarding a Badge
================
This is an example of awarding a badge via Tahrir-API:
.. code-block:: python
from tahrir_api.dbapi import TahrirDatabase
db = TahrirDatabase('backend://badges:badgesareawesome@localhost/badges')
badge_id = 'fossbox'
person_email = 'person@email.com'
issued_on = None
db.add_person(person_email)
db.add_assertion(badge_id, person_email, issued_on)