picture.jinja 4.95 KB
Newer Older
Skia's avatar
Skia committed
1
2
{% extends "core/base.jinja" %}

3
4
5
6
7
8
{% block head %}
{{ super() }}
<style>
#prev, #next {
    display: inline-block;
    width: 42%;
Skia's avatar
Skia committed
9
    height: 100px;
10
11
    margin: 0.5%;
    border: solid 1px grey;
Skia's avatar
Skia committed
12
13
14
    overflow: hidden;
    background: #aaa;
    text-align: center;
15
16
17
18
}
#prev img, #next img {
    display: block;
    margin: auto;
Skia's avatar
Skia committed
19
    max-height: 80%;
20
21
22
23
24
    max-width: 100%;
}
</style>
{% endblock %}

Skia's avatar
Skia committed
25
26
27
28
{% block title %}
{% trans %}SAS{% endtrans %}
{% endblock %}

29
{% macro print_path(file) %}
Skia's avatar
Skia committed
30
{% if file and file.parent %}
31
32
33
34
35
{{ print_path(file.parent) }}
<a href="{{ url('sas:album', album_id=file.id) }}">{{ file.get_display_name() }}</a> >
{% endif %}
{% endmacro %}

Skia's avatar
Skia committed
36
{% block content %}
Skia's avatar
Skia committed
37
<a href="{{ url('sas:main') }}">SAS</a> > {{ print_path(picture.parent) }} {{ picture.get_display_name() }}
Skia's avatar
Skia committed
38
39
({{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }})
<h3> {{ picture.get_display_name() }}</h3>
Skia's avatar
Skia committed
40
<div style="display: inline-block; width: 19%; vertical-align: top; overflow: hidden; float: right">
41
42
43
44
    <div>
        <div id="prev">
        {% if picture.get_previous() %}
        <a href="{{ url("sas:picture", picture_id=picture.get_previous().id) }}#pict">
Skia's avatar
Skia committed
45
            &larr;
Skia's avatar
Skia committed
46
            <img src="{{ picture.get_previous().as_picture.get_download_thumb_url() }}" alt="{{ picture.get_previous().get_display_name() }}" />
47
48
49
50
51
52
        </a>
        {% endif %}
        </div>
        <div id="next">
        {% if picture.get_next() %}
        <a href="{{ url("sas:picture", picture_id=picture.get_next().id) }}#pict">
Skia's avatar
Skia committed
53
            &rarr;
Skia's avatar
Skia committed
54
            <img src="{{ picture.get_next().as_picture.get_download_thumb_url() }}" alt="{{ picture.get_next().get_display_name() }}" />
55
56
57
58
59
        </a>
        {% endif %}
        </div>
    </div>
    <div>
Skia's avatar
Skia committed
60
        <h5>{% trans %}People{% endtrans %}</h5>
61
62
63
        <ul>
            {% for r in picture.people.all() %}
            <li>
Skia's avatar
Skia committed
64
                <a href="{{ r.user.get_absolute_url() }}">{{ r.user.get_short_name() }}</a>
Skia's avatar
Skia committed
65
                {% if user == r.user or user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
66
67
68
69
70
                <a href="?remove_user={{ r.user.id }}">{% trans %}Delete{% endtrans %}</a>
                {% endif %}
            </li>
            {% endfor %}
        </ul>
Skia's avatar
Skia committed
71
        <form action="" method="post" enctype="multipart/form-data" style="margin: 0px;">
72
73
74
75
76
            {% csrf_token %}
            {{ form.as_p() }}
            <p><input type="submit" value="{% trans %}Go{% endtrans %}" /></p>
        </form>
    </div>
Skia's avatar
Skia committed
77
78
79
    <div>
        <h5>{% trans %}Infos{% endtrans %}</h5>
        <p>{% trans %}Date: {% endtrans %}{{ picture.date|date(DATETIME_FORMAT) }}</p>
Skia's avatar
Skia committed
80
81
        <p>{% trans %}Owner: {% endtrans %}<a href="{{ picture.owner.get_absolute_url() }}">{{ picture.owner.get_short_name() }}</a></p>
        <p>{% trans %}Moderator: {% endtrans %}<a href="{{ picture.moderator.get_absolute_url() }}">{{ picture.moderator.get_short_name() }}</a></p>
Skia's avatar
Skia committed
82
83
        <p>{{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}</p>
    </div>
Skia's avatar
Skia committed
84
85
86
87
88
89
    <div>
        <h5>{% trans %}Tools{% endtrans %}</h5>
        <p>
            <a href="{{ picture.get_download_url() }}">{% trans %}HD version{% endtrans %}</a>
        </p>
        <p style="font-size: smaller;">
Skia's avatar
Skia committed
90
            <a href="{{ url('sas:picture_edit', picture_id=picture.id) }}">{% trans %}Edit{% endtrans %}</a><br>
Skia's avatar
Skia committed
91
92
93
94
95
96
            <a href="?rotate_left">{% trans %}Rotate left{% endtrans %}</a><br>
            <a href="?rotate_right">{% trans %}Rotate right{% endtrans %}</a><br>
            <a href="?ask_removal">{% trans %}Ask for removal{% endtrans %}</a><br>
        </p>
    </div>
</div>
97
98
99
{% if picture.is_moderated %}
<div id="pict">
{% else %}
Skia's avatar
Skia committed
100
<div id="pict" style="border: solid #f00 2px; box-shadow: red 0px 0px 5px">
101
102
103
104
105
106
107
108
109
110
111
112
113
{% set next = picture.get_next() %}
{% if not next %}
    {% set next = url('sas:moderation') %}
{% else %}
    {% set next = next.get_absolute_url() + "#pict" %}
{% endif %}
<div style="background: lightgrey; padding: 2px;">
    <a href="{{ url('core:file_moderate', file_id=picture.id) }}?next={{ next }}">
        {% trans %}Moderate{% endtrans %}</a> |
    <a href="{{ url('core:file_delete', file_id=picture.id) }}?next={{ next }}">
        {% trans %}Delete{% endtrans %}</a>
</div>
{% endif %}
Skia's avatar
Skia committed
114
115
116
117
118
    {% if picture.is_vertical %}
    <img src="{{ picture.get_download_compressed_url() }}" alt="{{ picture.get_display_name() }}" style="width: 60%; display: block; margin: auto"/>
    {% else %}
    <img src="{{ picture.get_download_compressed_url() }}" alt="{{ picture.get_display_name() }}" style="width: 100%; display: block; margin: auto"/>
    {% endif %}
Skia's avatar
Skia committed
119
120
121
</div>
{% endblock %}

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{% 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 %}