Missing context data (max_photos). Fixes #66

Signed-off-by: Oliver Falk's avatarOliver Falk <oliver@linux-kernel.at>
parent feab5f61
Pipeline #1980 passed with stage
in 10 minutes and 7 seconds
......@@ -155,10 +155,13 @@ outline: inherit;
{% endif %}
{% if not max_photos %}
<p>
<a href="{% url 'upload_photo' %}" class="button">{% trans 'Upload a new photo' %}</a>&nbsp;
<a href="{% url 'import_photo' %}" class="button">{% trans 'Import photo from other services' %}</a>
</p>
<p>
<a href="{% url 'upload_photo' %}" class="button">{% trans 'Upload a new photo' %}</a>&nbsp;
<a href="{% url 'import_photo' %}" class="button">{% trans 'Import photo from other services' %}</a>
</p>
{% else %}
{% trans "You've reached the maximum number of allowed images!" %}<br/>
{% trans "No further images can be uploaded." %}
{% endif %}
<div style="height:40px"></div>
{% endblock content %}
......@@ -898,6 +898,18 @@ class ProfileView(TemplateView):
self._confirm_claimed_openid()
return super().get(self, request, args, kwargs)
def get_context_data(self, **kwargs):
'''
Provide additional context data, like if max_photos is reached
already or not.
'''
context = super().get_context_data(**kwargs)
context['max_photos'] = False
if self.request.user:
if self.request.user.photo_set.all().count() >= MAX_NUM_PHOTOS:
context['max_photos'] = True
return context
def _confirm_claimed_openid(self):
openids = self.request.user.useropenid_set.all()
# If there is only one OpenID, we eventually need to add it to the user account
......
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