{% extends "base.html" %} {% block content %}

User Loans

Relationship: One user can loan multiple tablets (one-to-many). This page demonstrates the many-to-many relationship between users and tablets via the loans table.

{% for user_data in users_with_loans %} {% set user = user_data.user %} {% set loans = user_data.loans %}

{{ user.name }} ({{ user.identification }})

{{ loans|length }} tablet{{ 's' if loans|length != 1 else '' }} loaned
{% if loans %} {% for loan in loans %} {% endfor %}
Tablet Serial Number Loan Date Return Date Status
{{ loan.brand }} {{ loan.model }} {{ loan.serial_number }} {{ loan.loan_date }} {{ loan.return_date or '-' }} {{ loan.status }}
{% else %}

No loans recorded for this user.

{% endif %}
{% endfor %} {% if users_with_loans|length == 0 %}

No users found. Add users and loan tablets to see data here.

{% endif %}
{% endblock %}