Add social sharing #35
@ -54,6 +54,7 @@ INSTALLED_APPS = [
|
|||||||
"rest_framework",
|
"rest_framework",
|
||||||
"rest_framework_simplejwt",
|
"rest_framework_simplejwt",
|
||||||
"django_extensions",
|
"django_extensions",
|
||||||
|
"django_social_share",
|
||||||
|
|
||||||
"users",
|
"users",
|
||||||
"trials",
|
"trials",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load social_share %}
|
||||||
|
|
||||||
{% block title %}Test result{% endblock %}
|
{% block title %}Test result{% endblock %}
|
||||||
|
|
||||||
@ -26,11 +27,13 @@
|
|||||||
<h5 class="resultText">Maksymalny wynik: {{ max }}</h5>
|
<h5 class="resultText">Maksymalny wynik: {{ max }}</h5>
|
||||||
<h5 class="resultText">Wynik procentowy: {{ percentage }}%</h5>
|
<h5 class="resultText">Wynik procentowy: {{ percentage }}%</h5>
|
||||||
<button class="defaultButton"><a href="{% url 'home' %}">Strona główna</a></button>
|
<button class="defaultButton"><a href="{% url 'home' %}">Strona główna</a></button>
|
||||||
{# <p class="resultText">Correct answers: 3</p>#}
|
{% if password == "" %}
|
||||||
{# <p class="resultText">Incorrect answers: 2</p>#}
|
Udostępnij:
|
||||||
{# <p class="resultText">Total questions: 5</p>#}
|
{% post_to_facebook object_or_url "Post to Facebook!" %}
|
||||||
|
{% post_to_linkedin object_or_url %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -341,7 +341,8 @@ class TestTemplateView(TemplateView):
|
|||||||
"points": score,
|
"points": score,
|
||||||
"max": max,
|
"max": max,
|
||||||
"passing": test.passing_score,
|
"passing": test.passing_score,
|
||||||
"percentage": int(score / max * 100)
|
"percentage": int(score / max * 100),
|
||||||
|
"password": test.password
|
||||||
}
|
}
|
||||||
SolvedTest.objects.create(
|
SolvedTest.objects.create(
|
||||||
score=score,
|
score=score,
|
||||||
@ -352,12 +353,14 @@ class TestTemplateView(TemplateView):
|
|||||||
)
|
)
|
||||||
template_name = "result.html"
|
template_name = "result.html"
|
||||||
template = get_template(template_name)
|
template = get_template(template_name)
|
||||||
return HttpResponse(template.render(context))
|
return HttpResponse(template.render(context, request))
|
||||||
|
|
||||||
|
|
||||||
def TestPasswordTemplateView(request, test_id):
|
def TestPasswordTemplateView(request, test_id):
|
||||||
|
test = Test.objects.get(id=test_id)
|
||||||
|
if test.password == "":
|
||||||
|
return redirect(f'/tests/{test_id}/show')
|
||||||
if request.POST:
|
if request.POST:
|
||||||
test = Test.objects.get(id=test_id)
|
|
||||||
if request.POST["password"] == test.password:
|
if request.POST["password"] == test.password:
|
||||||
return redirect(f'/tests/{test_id}/show')
|
return redirect(f'/tests/{test_id}/show')
|
||||||
return render(request, 'testPassword.html')
|
return render(request, 'testPassword.html')
|
||||||
|
Loading…
Reference in New Issue
Block a user