Add picture-people relation and ask for removal thing

This commit is contained in:
Skia
2016-11-19 17:19:00 +01:00
parent b619619b85
commit 22ab21e4e1
9 changed files with 221 additions and 18 deletions

View File

@ -6,11 +6,6 @@
{% block content %}
<h3>{{ album.get_display_name() }}</h3>
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p() }}
<p><input type="submit" value="{% trans %}Upload{% endtrans %}" /></p>
</form>
<div>
{% for a in album.children.filter(is_folder=True, is_moderated=True).all() %}
<div style="display: inline-block; border: solid 1px black;">
@ -22,13 +17,18 @@
{# for a in album.children.filter(mime_type__in=['image/jpeg', 'image/png']).all() #}
{% for p in album.children.filter(is_folder=False, is_moderated=True).all() %}
{% if p.as_picture.can_be_viewed_by(user) %}
<div style="display: inline-block; border: solid 1px black;">
<a href="{{ url("sas:picture", picture_id=p.id) }}">
<img src="{{ p.as_picture.get_download_url() }}" alt="{{ p.get_display_name() }}" style="width: 50px"/>
<div style="display: inline-block; border: solid 1px black; width: 9%; margin: 0.1%">
<a href="{{ url("sas:picture", picture_id=p.id) }}#pict">
<img src="{{ p.as_picture.get_download_url() }}" alt="{{ p.get_display_name() }}" style="max-width: 100%"/>
</a>
</div>
{% endif %}
{% endfor %}
</div>
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p() }}
<p><input type="submit" value="{% trans %}Upload{% endtrans %}" /></p>
</form>
{% endblock %}

View File

@ -23,6 +23,9 @@
{% trans %}Owner: {% endtrans %}{{ p.owner.get_display_name() }}<br/>
{% trans %}Date: {% endtrans %}{{ p.date|date(DATE_FORMAT) }} {{ p.date|time(TIME_FORMAT) }}<br/>
</p>
{% if p.asked_for_removal %}
<p class="important">{% trans %}Asked for removal{% endtrans %}</p>
{% endif %}
<p>
<input type="radio" name="action_{{ p.id }}" id="m_{{ p.id }}" value="moderate"/>
<a href="{{ url('core:file_moderate', file_id=p.id) }}?next={{ url('sas:moderation') }}">{% trans %}Moderate{% endtrans %}</a>

View File

@ -1,16 +1,97 @@
{% extends "core/base.jinja" %}
{% block head %}
{{ super() }}
<style>
#prev, #next {
display: inline-block;
width: 42%;
margin: 0.5%;
border: solid 1px grey;
overflow: auto;
background: #333;
}
#prev img, #next img {
display: block;
margin: auto;
max-width: 100%;
max-height: 100%;
}
</style>
{% endblock %}
{% block title %}
{% trans %}SAS{% endtrans %}
{% endblock %}
{% macro print_path(file) %}
{% if file %}
{{ print_path(file.parent) }}
<a href="{{ url('sas:album', album_id=file.id) }}">{{ file.get_display_name() }}</a> >
{% endif %}
{% endmacro %}
{% block content %}
{{ print_path(picture.parent) }} {{ picture.get_display_name() }}
<h3>{{ picture.get_display_name() }}</h3>
<div style="float: right">
PREV / NEXT
<div style="display: inline-block; width: 89%; background: #333;" id="pict">
<img src="{{ picture.get_download_url() }}" alt="{{ picture.get_display_name() }}" style="width: 90%; display: block; margin: auto"/>
</div>
<div>
<img src="{{ picture.get_download_url() }}" alt="{{ picture.get_display_name() }}" style="width: 90%"/>
<div style="display: inline-block; width: 10%; vertical-align: top;">
<div>
<div id="prev">
{% if picture.get_previous() %}
<a href="{{ url("sas:picture", picture_id=picture.get_previous().id) }}#pict">
<img src="{{ picture.get_previous().as_picture.get_download_url() }}" alt="{{ picture.get_previous().get_display_name() }}" />
</a>
{% endif %}
</div>
<div id="next">
{% if picture.get_next() %}
<a href="{{ url("sas:picture", picture_id=picture.get_next().id) }}#pict">
<img src="{{ picture.get_next().as_picture.get_download_url() }}" alt="{{ picture.get_next().get_display_name() }}" />
</a>
{% endif %}
</div>
</div>
<div>
<ul>
{% for r in picture.people.all() %}
<li>
<a href="{{ r.user.get_absolute_url() }}">{{ r.user.get_display_name() }}</a>
{% if user == r.user or user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID) %}
<a href="?remove_user={{ r.user.id }}">{% trans %}Delete{% endtrans %}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
<div>
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p() }}
<p><input type="submit" value="{% trans %}Go{% endtrans %}" /></p>
</form>
</div>
<p style="font-size: smaller;">
<a href="?ask_removal">{% trans %}Ask for removal{% endtrans %}</a>
</p>
</div>
{% endblock %}
{% block script %}
{{ super() }}
<script>
$( function() {
$(document).keydown(function (e) {
if (e.keyCode == 37) {
console.log("prev");
$('#prev a')[0].click();
} else if (e.keyCode == 39) {
console.log("next");
$('#next a')[0].click();
}
});
} );
</script>
{% endblock %}