mirror of
https://github.com/ae-utbm/sith3.git
synced 2024-09-20 01:48:09 +00:00
ef968f3673
* Better usage of cache for group retrieval * Cache clearing on object deletion or update * replace signals by save and delete override * add is_anonymous check in is_owned_by Add in many is_owned_by(self, user) methods that user is not anonymous. Since many of those functions do db queries, this should reduce a little bit the load of the db. * Stricter usage of User.is_in_group Constrain the parameters that can be passed to the function to make sure only a str or an int can be used. Also force to explicitly specify if the group id or the group name is used. * write test and correct bugs * remove forgotten populate commands * Correct test
111 lines
3.6 KiB
Django/Jinja
111 lines
3.6 KiB
Django/Jinja
{% extends "core/base.jinja" %}
|
|
|
|
{%- block additional_css -%}
|
|
<link rel="stylesheet" href="{{ scss('sas/album.scss') }}">
|
|
{%- endblock -%}
|
|
|
|
{% block title %}
|
|
{% trans %}SAS{% endtrans %}
|
|
{% endblock %}
|
|
|
|
{% set edit_mode = user.is_in_group(pk=settings.SITH_GROUP_SAS_ADMIN_ID) %}
|
|
|
|
{% macro display_album(a, checkbox) %}
|
|
<a href="{{ url('sas:album', album_id=a.id) }}">
|
|
{% if a.file %}
|
|
{% set img = a.get_download_url() %}
|
|
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
|
|
{% set img = a.children.filter(is_folder=False).first().as_picture.get_download_thumb_url() %}
|
|
{% else %}
|
|
{% set img = static('core/img/sas.jpg') %}
|
|
{% endif %}
|
|
|
|
<div
|
|
class="album"
|
|
style="background-image: url('{{ img }}');"
|
|
>
|
|
<div class="text">
|
|
{{ a.name }}
|
|
</div>
|
|
</div>
|
|
{# {% if edit_mode and checkbox %}
|
|
<input type="checkbox" name="file_list" value="{{ a.id }}">
|
|
{% endif %} #}
|
|
</a>
|
|
{% endmacro %}
|
|
|
|
{% block content %}
|
|
<main>
|
|
<h3>{% trans %}SAS{% endtrans %}</h3>
|
|
|
|
{% if not user.is_authenticated %}
|
|
<p>{% trans %}You must be logged in to see the SAS.{% endtrans %}</p>
|
|
{% else %}
|
|
<br>
|
|
<h4>{% trans %}Latest albums{% endtrans %}</h4>
|
|
|
|
<div class="albums">
|
|
{% for a in latest %}
|
|
{{ display_album(a) }}
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<br>
|
|
|
|
{% if edit_mode %}
|
|
<form action="" method="post" enctype="multipart/form-data">
|
|
{% csrf_token %}
|
|
|
|
<div class="navbar">
|
|
<h4>{% trans %}All categories{% endtrans %}</h4>
|
|
|
|
{# <div class="toolbar">
|
|
<input name="delete" type="submit" value="{% trans %}Delete{% endtrans %}">
|
|
</div> #}
|
|
</div>
|
|
|
|
{% if clipboard %}
|
|
<div class="clipboard">
|
|
{% trans %}Clipboard: {% endtrans %}
|
|
<ul>
|
|
{% for f in clipboard %}
|
|
<li>{{ f.get_full_path() }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
<input name="clear" type="submit" value="{% trans %}Clear clipboard{% endtrans %}">
|
|
</div>
|
|
{% endif %}
|
|
{% else %}
|
|
<h4>{% trans %}All categories{% endtrans %}</h4>
|
|
{% endif %}
|
|
|
|
<div class="albums">
|
|
{% for a in categories %}
|
|
{{ display_album(a, true) }}
|
|
{% endfor %}
|
|
</div>
|
|
|
|
{% if edit_mode %}
|
|
</form>
|
|
|
|
<br>
|
|
|
|
<form class="add-files" action="" method="post" enctype="multipart/form-data">
|
|
{% csrf_token %}
|
|
|
|
<div class="inputs">
|
|
<div>
|
|
<label for="{{ form.album_name.name }}">{{ form.album_name.label }}</label>
|
|
{{ form.album_name }}
|
|
</div>
|
|
<input type="submit" value="{% trans %}Create{% endtrans %}" />
|
|
</div>
|
|
|
|
{{ form.non_field_errors() }}
|
|
{{ form.album_name.errors }}
|
|
</form>
|
|
{% endif %}
|
|
{% endif %}
|
|
</main>
|
|
{% endblock %}
|