Add gift function

This commit is contained in:
2017-11-06 00:22:25 +01:00
parent 9ab7cb98dc
commit e3fd3b81ab
7 changed files with 141 additions and 5 deletions

View File

@ -66,13 +66,39 @@
{% endif %}
{% else %}
{% trans %}Not subscribed{% endtrans %}
{% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %}
{% if user.is_board_member %}
<a href="{{ url('subscription:subscription') }}?member={{ profile.id }}">{% trans %}New subscription{% endtrans %}</a>
{% endif %}
{% endif %}
</p>
{% endif %}
{% if user.is_root or user.is_board_member %}
<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>
</div>
{% else %}
{% trans %}No gift given yet{% endtrans %}
{% endif %}
{% endif %}
{% endblock %}
{% block script %}
@ -92,6 +118,13 @@ $( function() {
}
});
} );
$(function(){
$("#drop_gifts").accordion({
heightStyle: "content",
collapsible: true,
active: false
});
});
</script>
{% endblock %}