Skip to content

Commit

Permalink
Add ToolConfig usage example to README.rst (pylti#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steph Samson authored and ryanhiebert committed Dec 16, 2016
1 parent 2e8719a commit 5bcf45c
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Usage
The primary goal of this library is to provide classes
for building Python LTI tool providers (LTI apps).
To that end, the functionality that you're looking for
is probably in the ``ToolConfig`` and ``ToolProvider`` classes.
is probably in the ``ToolConfig`` and ``ToolProvider`` classes (``ToolConsumer``
is available too, if you want to consume LTI Providers).


Tool Config Example (Django)
Expand Down Expand Up @@ -112,6 +113,48 @@ Tool Provider OAuth Request Validation Example (Django)
# do stuff if ok / not ok
Tool Consumer Example (Django)
----------------------------

In your view:

.. code-block:: python
def index(request):
consumer = ToolConsumer(
consumer_key='my_key_given_from_provider',
consumer_secret='super_secret',
launch_url='provider_url',
params={
'lti_message_type': 'basic-lti-launch-request'
}
)
return render(
request,
'lti_consumer/index.html',
{
'launch_data': consumer.generate_launch_data(),
'launch_url': consumer.launch_url
}
)
At the template:

.. code-block:: html

<form action="{{ launch_url }}"
name="ltiLaunchForm"
id="ltiLaunchForm"
method="POST"
encType="application/x-www-form-urlencoded">
{% for key, value in launch_data.items %}
<input type="hidden" name="{{ key }}" value="{{ value }}"/>
{% endfor %}
<button type="submit">Launch the tool</button>
</form>


Testing
=======

Expand Down

0 comments on commit 5bcf45c

Please sign in to comment.