user_detail.jinja 9.22 KB
Newer Older
1
{% extends "core/base.jinja" %}
2
{% from "core/macros.jinja" import show_slots, show_tokens, user_subscription %}
Skia's avatar
Skia committed
3 4

{% block title %}
Skia's avatar
Skia committed
5
{% trans user_name=profile.get_display_name() %}{{ user_name }}'s profile{% endtrans %}
Skia's avatar
Skia committed
6 7
{% endblock %}

8
{% block content %}
Skia's avatar
Skia committed
9
<div id="user_profile_page">
10
    <div id="user_profile">
Skia's avatar
Skia committed
11 12
        <!-- Profile -->
        <div id="user_profile_infos">
Skia's avatar
Skia committed
13 14
            <h4>{{ profile.get_full_name() }}</h4>
            {% if profile.nick_name %}
Skia's avatar
Skia committed
15
                <div id="user_profile_infos_nick">&laquo; {{ profile.nick_name }} &raquo;</div>
Skia's avatar
Skia committed
16
            {% endif %}
Skia's avatar
Skia committed
17 18 19 20 21

            {% if profile.quote %}
                <div id="user_profile_infos_quote">
                    {{ profile.quote }}
                </div>
Sli's avatar
Sli committed
22
            {% endif %}
Skia's avatar
Skia committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

            <div id="user_profile_infos_items">
                {% if profile.date_of_birth %}
                    <div>
                        <span class="user_profile_infos_item">{% trans %}Born: {% endtrans %}</span>
                        <span class="user_profile_infos_item_value">{{ profile.date_of_birth|date("d/m/Y") }}</span>
                    </div>
                {% endif %}

                {% if profile.department != "NA" %}
                    <div>
                        <span class="user_profile_infos_item">{% trans %}Department: {% endtrans %}</span>
                        <span class="user_profile_infos_item_value">{{ profile.department }}{{ profile.semester }}</span>
                    </div>
                {% endif %}

                {% if profile.dpt_option %}
                    <div>
                        <span class="user_profile_infos_item">{% trans %}Option: {% endtrans %}</span>
                        <span class="user_profile_infos_item_value">{{ profile.dpt_option }}</span>
                    </div>
                {% endif %}

                {% if profile.phone %}
                    <div>
                        <span class="user_profile_infos_item">{% trans %}Phone: {% endtrans %}</span>
                        <span class="user_profile_infos_item_value">{{ profile.phone }}</span>
                    </div>
                {% endif %}

                {% if profile.address %}
                    <div>
                        <span class="user_profile_infos_item">{% trans %}Address: {% endtrans %}</span>
                        <span class="user_profile_infos_item_value">{{ profile.address }}</span>
                    </div>
                {% endif %}

                {% if profile.parent_address %}
                    <div>
                        <span class="user_profile_infos_item">{% trans %}Parents address: {% endtrans %}</span>
                        <span class="user_profile_infos_item_value">{{ profile.parent_address }}</span>
                    </div>
                {% endif %}
            </div>

Skia's avatar
Skia committed
68
            {% if profile.promo %}
Skia's avatar
Skia committed
69 70 71 72
                <div id="user_profile_infos_promo">
                    <img src="{{ static('core/img/promo_%02d.png' % profile.promo) }}" alt="Promo {{ profile.promo }}" />
                    {% trans %}Promo: {% endtrans %}{{ profile.promo }}
                </div>
73 74
            {% endif %}
        </div>
Skia's avatar
Skia committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
        <!-- Pictures -->
        <div id="user_profile_pictures">
            <div id="user_profile_pictures_bigone">
                {% if profile.profile_pict %}
                    <img src="{{ profile.profile_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}"
                        title="{% trans %}Profile{% endtrans %}" />
                {% else %}
                    <img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Profile{% endtrans %}"
                        title="{% trans %}Profile{% endtrans %}" />
                {% endif %}
            </div>
            <div id="user_profile_pictures_thumbnails">
                {% if profile.profile_pict %}
                    <img src="{{ profile.profile_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}"
                        title="{% trans %}Profile{% endtrans %}" />
                {% else %}
                    <img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Profile{% endtrans %}"
                        title="{% trans %}Profile{% endtrans %}" />
                {% endif %}

                {% if profile.avatar_pict %}
                    <img src="{{ profile.avatar_pict.get_download_url() }}" alt="{% trans %}Avatar{% endtrans %}"
                        title="{% trans %}Avatar{% endtrans %}" />
                {% else %}
                    <img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Avatar{% endtrans %}"
                        title="{% trans %}Avatar{% endtrans %}" />
                {% endif %}

                {% if profile.scrub_pict %}
                    <img src="{{ profile.scrub_pict.get_download_url() }}" alt="{% trans %}Scrub{% endtrans %}"
                        title="{% trans %}Scrub{% endtrans %}" />
                {% else %}
                    <img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Scrub{% endtrans %}"
                        title="{% trans %}Scrub{% endtrans %}" />
                {% endif %}
            </div>
        </div>
112
    </div>
Skia's avatar
Skia committed
113

114
    {% if user.memberships.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user == profile or user.is_in_group(settings.SITH_BAR_MANAGER_BOARD_GROUP) %}
Skia's avatar
Skia committed
115 116 117 118 119 120 121
    {# if the user is member of a club, he can view the subscription state #}
    <hr>
    {% if profile.is_subscribed %}
        {% if user == profile or user.is_root or user.is_board_member %}
        <div>
            {{ user_subscription(profile) }}
        </div>
Sli's avatar
Sli committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
        <br>
        <div id="drop_subscriptions">
            <h5>{% trans %}Subscription history{% endtrans %}</h5>
            <table>
                <tr>
                    <th>{% trans %}Subscription start{% endtrans %}</th>
                    <th>{% trans %}Subscription end{% endtrans %}</th>
                    <th>{% trans %}Subscription type{% endtrans %}</th>
                    <th>{% trans %}Payment method{% endtrans %}</th>
                </tr>
            {% for sub in profile.subscriptions.all() %}
                <tr>
                    <td>{{ sub.subscription_start }}</td>
                    <td>{{ sub.subscription_end }}</td>
                    <td>{{ sub.subscription_type }}</td>
                    <td>{{ sub.get_payment_method_display() }}</td>
                </tr>
            {% endfor %}
            </table>
        </div>
Sli's avatar
Sli committed
142
        {% endif %}
Skia's avatar
Skia committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
        {% if user == profile or user.is_root or user.is_board_member or user.is_launderette_manager %}
        <div>
            {# Shows tokens bought by the user #}
            {{ show_tokens(profile) }}
            {# Shows slots took by the user #}
            {{ show_slots(profile) }}
        </div>
        {% endif %}
    {% else %}
        <div>
        {% trans %}Not subscribed{% endtrans %}
        {% if user.is_board_member %}
            <a href="{{ url('subscription:subscription') }}?member={{ profile.id }}">{% trans %}New subscription{% endtrans %}</a>
            {% endif %}
        {% endif %}
        </div>
Sli's avatar
Sli committed
159
    {% endif %}
Skia's avatar
Skia committed
160

Skia's avatar
Skia committed
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
    {% if user.is_root or user.is_board_member %}
    <div>
        <hr>
        <form style="margin-left: 0px;" action="{{ url('core:user_gift_create', user_id=profile.id) }}" method="post">
            {% csrf_token %}
            {{ gift_form.label }}
            {{ gift_form.user }}
            <input type="submit" value="{% trans %}Give gift{% endtrans %}">
        </form>
        {% if profile.gifts.exists() %}
        <br>
            <div id="drop_gifts">
                <h5>{% trans %}Last given gift :{% endtrans %} {{ profile.gifts.order_by('-date').first() }}</h5>
                <div>
                    <ul>
                    {% for gift in profile.gifts.all().order_by('-date') %}
                        <li>{{ gift }} <a href="{{ url('core:user_gift_delete', user_id=profile.id, gift_id=gift.id) }}">{% trans %}Delete{% endtrans %}</a></li>
                    {% endfor %}
                    </ul>
                </div>
Sli's avatar
Sli committed
181
            </div>
Skia's avatar
Skia committed
182 183 184 185
        {% else %}
            {% trans %}No gift given yet{% endtrans %}
        {% endif %}
    </div>
Sli's avatar
Sli committed
186
    {% endif %}
Skia's avatar
Skia committed
187
</div>
Sli's avatar
Sli committed
188 189


Skia's avatar
Skia committed
190 191
{% endblock %}

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
{% block script %}
{{ super() }}
<script>
$( function() {
    var keys = [];
    var pattern = "71,85,89,71,85,89";
    $(document).keydown(function (e) {
        keys.push(e.keyCode);
        if (keys.toString()==pattern) {
                keys = [];
                $("#right_column img").attr("src", "{{ static('core/img/yug.jpg') }}");
        }
        if (keys.length==6) {
            keys.shift();
        }
    });
} );
Skia's avatar
Skia committed
209 210 211 212 213 214 215
$(function(){
    $("#user_profile_pictures_thumbnails img").click(function () {
        $("#user_profile_pictures_bigone img").attr("src", $(this)[0].src);
        $("#user_profile_pictures_bigone img").attr("alt", $(this)[0].alt);
        $("#user_profile_pictures_bigone img").attr("title", $(this)[0].title);
    })
});
Sli's avatar
Sli committed
216 217 218 219 220 221 222
$(function(){
    $("#drop_gifts").accordion({
        heightStyle: "content",
        collapsible: true,
        active: false
    });
});
Sli's avatar
Sli committed
223 224 225 226 227 228 229
$(function(){
    $("#drop_subscriptions").accordion({
        heightStyle: "content",
        collapsible: true,
        active: false
    });
});
230 231
</script>
{% endblock %}
Skia's avatar
Skia committed
232