Commit 5bcaa09d authored by Jitka Novotna's avatar Jitka Novotna

user subscriptions without languages

parent d215152c
...@@ -63,16 +63,19 @@ $("#views-menu li a").click(function(){ ...@@ -63,16 +63,19 @@ $("#views-menu li a").click(function(){
<div class="tab-content"> <div class="tab-content">
{% if user.is_authenticated %} {% if user.is_authenticated %}
<div class="tab-pane active" id="your-subscriptions"> <div class="tab-pane active" id="your-subscriptions">
{% if usersubscriptions %} {% if subscribed_projects %}
{% with usersubscriptions as translations and 2 as show_language and user.profile.hide_completed as hide_completed %} {% if usersubscriptions %}
{% include "list-translations.html" %} {% with usersubscriptions as translations and 2 as show_language and user.profile.hide_completed as hide_completed %}
{% endwith %} {% include "list-translations.html" %}
{% endwith %}
{% else %}
{% with subscribed_projects as projects %}
{% include "list-projects.html" %}
{% endwith %}
{% endif %}
{% else %} {% else %}
{% with usersubscriptions as projects %} <p class="help-block">{% trans "Choose your languages in preferences and you will get an overview here of available translations for those languages in your subscribed projects." %}</p>
{% include "list-projects.html" %} {% endif %}
{% endwith %}
<p class="help-block">{% trans "Choose your languages in preferences and you will get an overview here of available translations for those languages in your subscribed projects." %}</p>
{% endif %} {# usersubscriptions #}
<p> <p>
<a class="btn btn-default" href="{% url 'profile' %}#languages">{% trans "Manage your languages" %}</a> <a class="btn btn-default" href="{% url 'profile' %}#languages">{% trans "Manage your languages" %}</a>
<a class="btn btn-default" href="{% url 'profile' %}#subscriptions">{% trans "Manage your subscriptions" %}</a> <a class="btn btn-default" href="{% url 'profile' %}#subscriptions">{% trans "Manage your subscriptions" %}</a>
......
...@@ -44,13 +44,16 @@ def weblate_context(request): ...@@ -44,13 +44,16 @@ def weblate_context(request):
componentlists = ComponentList.objects.all() componentlists = ComponentList.objects.all()
# Load user translations if user is authenticated # Load user translations if user is authenticated
subscribed_projects = None
usersubscriptions = None usersubscriptions = None
userlanguages = None userlanguages = None
if request.user.is_authenticated(): if request.user.is_authenticated():
subscribed_projects = request.user.profile.subscriptions.all()
usersubscriptions = Translation.objects.filter( usersubscriptions = Translation.objects.filter(
language__in=request.user.profile.languages.all(), language__in=request.user.profile.languages.all(),
subproject__project__in=request.user.profile.subscriptions.all() subproject__project__in=subscribed_projects
).order_by( ).order_by(
'subproject__project__name', 'subproject__name' 'subproject__project__name', 'subproject__name'
).select_related() ).select_related()
...@@ -91,6 +94,7 @@ def weblate_context(request): ...@@ -91,6 +94,7 @@ def weblate_context(request):
'registration_open': appsettings.REGISTRATION_OPEN, 'registration_open': appsettings.REGISTRATION_OPEN,
'acl_projects': projects, 'acl_projects': projects,
'subscribed_projects': subscribed_projects,
'usersubscriptions': usersubscriptions, 'usersubscriptions': usersubscriptions,
'userlanguages': userlanguages, 'userlanguages': userlanguages,
'componentlists': componentlists, 'componentlists': componentlists,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment