Example #1
0
    def test_is_admin(self):
        """ Test the is_admin function. """
        app = flask.Flask('fedocal')

        with app.test_request_context():
            flask.g.fas_user = None
            self.assertFalse(fedocal.is_admin())
            flask.g.fas_user = FakeUser(fedocal.APP.config['ADMIN_GROUP'])
            self.assertTrue(fedocal.is_admin())
Example #2
0
def api():
    """
API documentation
=================

Fedocal provides a small read-only API.


The API supports GET and POST requests with the same arguments.

A trailing slash is optional on all API endpoints. There is no
difference between using one and not using one.

Responses are always served as ``application/json`` (unless ``JSONP``
is explicitly requested, in which case fedocal returns the
appropriate ``application/javascript``).

    """
    auth_form = forms.LoginForm()
    admin = fedocal.is_admin()
    api_html = load_doc(api)
    meetings_api_html = load_doc(api_meetings)
    calendars_api_html = load_doc(api_calendars)
    return flask.render_template(
        'api.html',
        auth_form=auth_form,
        admin=admin,
        api_html=api_html,
        calendars_api_html=calendars_api_html,
        meetings_api_html=meetings_api_html)