API for interacting with the Tahrir database
Go to file
mscherer 5916c25c05
Merge pull request #51 from frenzymadness/patch-1
Switch tox-github-action from master to main branch
2023-04-12 16:41:25 +02:00
.github/workflows Switch tox-github-action from master to main branch 2023-04-12 14:11:42 +02:00
alembic Format the codebase using `black` 2019-02-01 01:31:31 +05:30
tahrir_api Replace deprecated ZopeTransactionExtension with ZopeTransactionEvents 2019-10-25 20:59:54 -03:00
tests Avoid configuring Session since it already is scoped and will have no effect 2019-08-12 21:55:35 +02:00
.cico.pipeline Add a .cico.pipeline file. 2019-01-21 16:18:32 +01:00
.gitignore Add a few step to start hack on the project in development section README 2019-08-12 21:55:35 +02:00
.travis.yml Added a .travis.yml file for great CI justice 2013-03-20 17:20:11 -04:00
CHANGELOG.rst 0.8.1 2016-11-01 15:04:56 +05:30
LICENSE Relicense to GPLv3+. Fixes #7. 2013-04-24 12:34:03 -04:00
MANIFEST.in Add requirements file 2019-08-12 21:55:35 +02:00
README.rst Add a few step to start hack on the project in development section README 2019-08-12 21:55:35 +02:00
alembic.ini Add a few step to start hack on the project in development section README 2019-08-12 21:55:35 +02:00
requirements.txt Add requirements file 2019-08-12 21:55:35 +02:00
setup.py Add requirements file 2019-08-12 21:55:35 +02:00
tox.ini Migrate tahrir-api from Python2 to Python3 2019-02-01 01:31:31 +05:30

README.rst

Tahrir-API
==========

API for interacting with the Tahrir database.  Based on the `Tahrir
<https://github.com/fedora-infra/tahrir>`_ database model written by `Ralph
Bean <https://github.com/ralphbean>`_. 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)


Development
===========

Set-up your env
---------------
Install helper

.. code-block:: bash

    $ sudo dnf install -y python3-virtualenvwrapper  # RedHat-based OS

Build your virtual env

.. code-block:: bash

    $ export WORKON_HOME=$HOME/.virtualenvs
    $ mkvirtualenv tahrir-api

Connect w/ your virutal env

.. code-block:: bash

    $ workon tahrir-api
    (tahrir-api)$

Install
-------
Requirements

.. code-block:: bash

    (tahrir-api)$ pip install -r requirements.txt

Project installation

.. code-block:: bash

    (tahrir-api)$ python setup.py develop

Happy hacking!

Run the tests
-------------

You can run the tests with ``tox``

.. code-block:: bash

    (tahrir-api)$ pip install tox
    (tahrir-api)$ tox