Skip to content

Commit

Permalink
Add notice before posting to external service
Browse files Browse the repository at this point in the history
  • Loading branch information
teemulehtinen committed Jan 30, 2016
1 parent 9194dc8 commit eece804
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 23 deletions.
2 changes: 1 addition & 1 deletion exercise/templates/exercise/exercise_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% load exercise %}
{% load apps %}

{% block title %}{{ block.super }}: {% trans "Exercise" %} {{ module.order }}.{{ exercise.order }}{% endblock %}
{% block title %}{{ block.super }}: {{ exercise }}{% endblock %}

{% block siblings %}
{% include "course/_siblings.html" with next=exercise.next previous=exercise.previous %}
Expand Down
69 changes: 54 additions & 15 deletions external_services/templates/external_services/lti_form.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,55 @@
{% extends "course/course_base.html" %}
{% load i18n %}
<html>
<head>
<meta charset="UTF-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>$(function() { $("form")[0].submit(); });</script>
</head>
<body>
<form id="lti_login_form" method="POST" action="{{ url }}">
{% for entry in parameters %}
<input type="hidden" name="{{ entry.0 }}" value="{{ entry.1 }}" />
{% endfor %}
<input type="submit" value="{% trans 'Continue to service...' %}" />
</form>
</body>
</html>

{% block title %}{{ block.super }}: {{ service.menu_label }}{% endblock %}

{% block breadcrumblist %}
{{ block.super }}
<li class="active">{{ service.menu_label }}</li>
{% endblock %}

{% block coursecontent %}
<div class="alert alert-warning">
<p>
{% blocktrans with name=service.menu_label %}
You are about to use an external service, {{ name }}, for the first time.
To use the service, your name and email address will be transferred
to the provider of this service.
{% endblocktrans %}
</p>
<p>
<a href="{{ site }}" target="_new">{{ site }}</a>
</p>
<p>
<br>
<form id="lti_login_form" method="POST" action="{{ service.url }}">
{% for entry in parameters %}
<input type="hidden" name="{{ entry.0 }}" value="{{ entry.1 }}" />
{% endfor %}
<input type="submit" value="{% blocktrans with name=service.menu_label %}Accept and continue to {{ name }}{% endblocktrans %}" class="btn btn-primary" />
</form>
</p>
</div>
{% endblock %}

{% block scripts %}
{{ block.super }}
<script>
$(function() {
var cookieName = "aplusexse{{ service.id }}";
var regex = new RegExp("(?:(?:^|.*;\s*)" + cookieName + "\s*\=\s*([^;]*).*$)|^.*$");
var val = document.cookie.replace(regex, "$1");
if (val == "1") {
$("form")[0].submit();
}
$("form").on("submit", function() {
var expire = new Date();
expire.setFullYear(expire.getFullYear() + 1);
var path = document.location.href.split("/");
document.cookie = cookieName + "=1"
+ ";path=/" + path[3] + "/" + path[4] + "/"
+ ";expires=" + expire.toGMTString();
});
});
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions external_services/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ def get_common_objects(self):
self.request.get_host(),
self.menu_item.label,
)
self.url = self.service.url
self.parameters = lti.sign_post_parameters()
self.note("url", "parameters")
self.site = '/'.join(self.service.url.split('/')[:3])
self.note("service", "parameters", "site")
Binary file modified locale/fi/LC_MESSAGES/django.mo
Binary file not shown.
26 changes: 21 additions & 5 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-30 17:19+0200\n"
"POT-Creation-Date: 2016-01-30 18:04+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -445,7 +445,6 @@ msgstr ""

#: deviations/templates/deviations/list_dl.html:28
#: edit_course/templates/edit_course/edit_content.html:137
#: exercise/templates/exercise/exercise_base.html:7
msgid "Exercise"
msgstr "Tehtävä"

Expand Down Expand Up @@ -1716,9 +1715,23 @@ msgstr ""
msgid "Heavier menu entries are placed after lighter ones."
msgstr ""

#: external_services/templates/external_services/lti_form.html:13
msgid "Continue to service..."
msgstr "Jatka ulkoiseen palveluun..."
#: external_services/templates/external_services/lti_form.html:14
#, python-format
msgid ""
"\n"
"\t\tYou are about to use an external service, %(name)s, for the first time.\n"
"\t\tTo use the service, your name and email address will be transferred\n"
"\t\tto the provider of this service.\n"
"\t\t"
msgstr ""
"\nOlet siirtymässä ensimmäistä kertaa ulkoiseen palveluun, %(name)s. "
"Palvelun käyttämiseksi nimesi ja sähköpostiosoitteesi lähetetään "
"tämän palvelun ylläpitäjälle."

#: external_services/templates/external_services/lti_form.html:29
#, python-format
msgid "Accept and continue to %(name)s"
msgstr "Hyväksy ja jatka palveluun, %(name)s"

#: lib/fields.py:27
msgid "The number must be between 0.0 and 1.0"
Expand Down Expand Up @@ -1878,3 +1891,6 @@ msgstr ""
"\n"
"Olet kirjautunut onnistuneesti ulos palvelusta. Jos käytät julkista "
"tietokonetta, sulje selain poistaaksesi istunnon tiedot."

#~ msgid "Continue to service..."
#~ msgstr "Jatka ulkoiseen palveluun..."

0 comments on commit eece804

Please sign in to comment.