Commit 881afd9e authored by Skia's avatar Skia

Improve SAS main view, and make some translations

parent 3f6199f6
Pipeline #703 passed with stage
in 3 minutes and 15 seconds
This diff is collapsed.
......@@ -4,32 +4,44 @@
{% trans %}SAS{% endtrans %}
{% endblock %}
{% macro display_album(a) %}
{% if a.is_moderated %}
<a href="{{ url("sas:album", album_id=a.id) }}">
<div class="album">
<div>
{% if a.file %}
<img src="{{ a.as_picture.get_download_url() }}" alt="{% trans %}preview{% endtrans %}">
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
<img src="{{ a.children.filter(is_folder=False).first().as_picture.get_download_thumb_url() }}" alt="{% trans %}preview{% endtrans %}">
{% else %}
<img src="{{ static('core/img/sas.jpg') }}" alt="{% trans %}preview{% endtrans %}">
{% endif %}
</div>
{{ a.name }}
</div>
</a>
{% elif user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
<div style="display: inline-block; border: solid 1px red; text-align: center">
<p><a href="{{ url('core:file_moderate', file_id=a.id) }}?next={{ url('sas:moderation') }}">Moderate</a> or <a href="">Delete</a></p>
<a href="{{ url("sas:album", album_id=a.id) }}">{{ a.name }}</a>
</div>
{% endif %}
{% endmacro %}
{% block content %}
<h3>{% trans %}SAS{% endtrans %}</h3>
<hr>
<h4>{% trans %}Latest albums{% endtrans %}</h4>
<div>
{% for a in latest %}
{{ display_album(a) }}
{% endfor %}
</div>
<hr>
<h4>{% trans %}All categories{% endtrans %}</h4>
<div>
{% for a in root_file.children.filter(is_folder=True).order_by('date') %}
{% if a.is_moderated %}
<a href="{{ url("sas:album", album_id=a.id) }}">
<div class="album">
<div>
{% if a.file %}
<img src="{{ a.as_picture.get_download_url() }}" alt="{% trans %}preview{% endtrans %}">
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
<img src="{{ a.children.filter(is_folder=False).first().as_picture.get_download_thumb_url() }}" alt="{% trans %}preview{% endtrans %}">
{% else %}
<img src="{{ static('core/img/sas.jpg') }}" alt="{% trans %}preview{% endtrans %}">
{% endif %}
</div>
{{ a.name }}
</div>
</a>
{% elif user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
<div style="display: inline-block; border: solid 1px red; text-align: center">
<p><a href="{{ url('core:file_moderate', file_id=a.id) }}?next={{ url('sas:moderation') }}">Moderate</a> or <a href="">Delete</a></p>
<a href="{{ url("sas:album", album_id=a.id) }}">{{ a.name }}</a>
</div>
{% endif %}
{{ display_album(a) }}
{% endfor %}
</div>
{% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
......
......@@ -85,6 +85,7 @@ class SASMainView(FormView):
def get_context_data(self, **kwargs):
kwargs = super(SASMainView, self).get_context_data(**kwargs)
kwargs['root_file'] = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first()
kwargs['latest'] = SithFile.objects.filter(is_in_sas=True, is_folder=True, is_moderated=True).order_by('-id')[:5]
return kwargs
class PictureView(CanViewMixin, DetailView, FormMixin):
......
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