{
    "user": {
        "username": "{{ user.username | escapejs }}",
        "first_name": "{{ user.first_name | escapejs }}",
        "last_name": "{{ user.last_name | escapejs }}",
        "password": "{{ user.password }}",
        "id": "{{ user.id }}",
        "email":  "{{ user.email }}",
        "business":  "{{ user.business }}",
        "dr":  "{{ user.dr }}",

        "groups":  [
            {% for group in user.mgroups.all %}
                {% if forloop.last %}
                    "{{ group.name }}"
                {% else %}
                    "{{ group.name }}",
                {% endif %}
            {% endfor %}
        ],

        {% if user.photo %}
            "photo": "{{ user.photo.id }}",
        {% else %}
            "photo": null,
        {% endif %}

        "photos":  [
        {% for photo in user.photos.all %}
        {
            "id": "{{ photo.id }}",
            "hash": "{{ photo.hash }}",
            "img": "{{ photo.img.url }}"
        }{% if not forloop.last %},{% endif %}
        {% endfor %}
        ],

        "notes": [
        {% for note in notes %}
            {
                "id": "{{ note.id }}",
                "x": "{{ note.coord_x|safe }}",
                "y": "{{ note.coord_y|safe }}",
                "h": "{{ note.height|safe }}",
                "w": "{{ note.weight|safe }}",
                "id_doc": {% if note.document %}"{{ note.document.id }}"{% else %}"-1"{% endif %},
                "page": "{{ note.page }}",
                "text": "{{ note.text|escapejs }}",
                "type": "{{ note.note_type }}"
            }{% if not forloop.last %},{% endif %}
        {% endfor %}
        ]
    }
}
