</footer>
-{% if object.forum_topics.all.count %}
-<h2>Na forum</h2>
-<ul>
-{% for forum_topic in object.forum_topics.all %}
- <li><a href="{{forum_topic.pybb_topic.get_absolute_url}}">{{forum_topic.pybb_topic.name}}</a></li>
-{% endfor %}
-</ul>
+{% if request.user.is_authenticated and object.forum_topics.all.count %}
+ <h2>Na forum</h2>
+ <ul>
+ {% for forum_topic in object.forum_topics.all %}
+ <li><a href="{{forum_topic.pybb_topic.get_absolute_url}}">{{forum_topic.pybb_topic.name}}</a></li>
+ {% endfor %}
+ </ul>
{% endif %}
</div>
'django.middleware.cache.FetchFromCacheMiddleware',
'fnpdjango.middleware.SetRemoteAddrFromXRealIP',
'pybb.middleware.PybbMiddleware',
+ 'forum.middleware.ForumMiddleware'
) if x is not None)
<li><a href="{{ package_student_url }}">Pobierz wszystkie lekcje w wersji dla ucznia</a></li>
<li><a href="{% url 'catalogue_lesson' 'slowniczek' %}">Słowniczek</a></li>
<li><a href="{% url 'catalogue_lesson' 'metody' %}">Metody edukacyjne</a></li>
- <li><a href="{% url 'pybb:index' %}">Forum</a></li>
+ {% if request.user.is_authenticated %}<li><a href="{% url 'pybb:index' %}">Forum</a></li>{% endif %}
<li><a href="http://nowoczesnapolska.org.pl/prywatnosc/">Polityka prywatności i ciasteczka</a></li>
</ul>
</section>
--- /dev/null
+from urllib import urlencode
+
+from django.contrib.auth import REDIRECT_FIELD_NAME
+from django.http import HttpResponseRedirect
+from django.core.urlresolvers import reverse
+from django_cas.views import login as cas_login
+
+
+class ForumMiddleware:
+ def process_request(self, request):
+ if request.path.startswith(reverse('pybb:index')) \
+ and (not hasattr(request, 'user') or not request.user.is_authenticated()):
+ params = urlencode({REDIRECT_FIELD_NAME: request.get_full_path()})
+ return HttpResponseRedirect(reverse(cas_login) + '?' + params)