Exemple #1
0
def test_invites_list_cache_clear(app, authed_client):
    """Sending an invite should clear the cache key for a user's list of invites."""
    app.config['REQUIRE_INVITE_CODE'] = True
    add_permissions(app, 'invites_send')
    Invite.from_inviter(1)  # Cache it

    authed_client.post(
        '/invites', data=json.dumps({'email': '*****@*****.**'})
    )
    sent_invites = Invite.from_inviter(1, include_dead=True)
    assert len(sent_invites) == 4
Exemple #2
0
def invites_view(user: User, used: bool, include_dead: bool) -> flask.Response:
    """
    View sent invites. If a user_id is specified, only invites sent by that user
    will be returned, otherwise only your invites are returned. If requester has
    the ``invites_view_others`` permission, they can view sent invites of another user.

    .. :quickref: Invite; View multiple invites.

    **Example response**:

    .. parsed-literal::

       {
         "status": "success",
         "response": [
            "<Invite>",
            "<Invite>"
         ]
       }

    :query boolean used: (Optional) Whether or not to only show used invites
        (overrides ``include_dead``)
    :query boolean include_dead: (Optional) Whether or not to include expired invites

    :>json list response: A list of invites

    :statuscode 200: View successful
    :statuscode 403: User does not have permission to view user's invites
    """
    invites = Invite.from_inviter(user.id,
                                  include_dead=include_dead,
                                  used=used)
    return flask.jsonify(invites)