{% extends "base.html" %}
{% block title %}Paste Settings{% endblock %}
{% block content %}
<div class="container mt-4">
    <h3>Paste Settings: paste_{{ paste.id }}.{{ paste.get_extension() }}</h3>

    <!-- Información del paste en solo lectura -->
    <table class="table table-bordered table-sm">
        <tr><th>ID</th><td>{{ paste.id }}</td></tr>
        <tr><th>Filename</th><td>{{ paste.filename }}</td></tr>
        <tr><th>Content Type</th><td>{{ paste.content_type }}</td></tr>
        <tr><th>Size (bytes)</th><td>{{ paste.size }}</td></tr>
        <tr><th>Created At</th><td>{{ paste.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</td></tr>
        <tr><th>Last Edited At</th><td>{{ paste.last_edited_at.strftime('%Y-%m-%d %H:%M:%S') if paste.last_edited_at else 'Never' }}</td></tr>
        <tr><th>Owner ID</th><td>{{ paste.owner_id }}</td></tr>
        <tr><th>User ID</th><td>{{ paste.user_id }}</td></tr>
        <tr><th>Private</th><td>{{ 'Yes' if paste.private else 'No' }}</td></tr>
        <tr><th>Is Favorite?</th><td>{{ 'Yes' if current_user in paste.favorites else 'No' }}</td></tr>
        <tr>
            <th>Shared With</th>
            <td>
                {% if paste.shared_with %}
                    {{ paste.shared_with | map(attribute='username') | join(', ') }}
                {% else %}
                    Nobody
                {% endif %}
            </td>
        </tr>
    </table>

    <form method="POST">
        {% if paste.content_type.startswith('text/') %}
        <div class="mb-3">
            <label for="language" class="form-label">Language (Optional)</label>
            <select class="form-select" id="language" name="language">
                <option value="">Select a Language, leave it blank to auto detect</option>
                {% for value, label in pygments_languages %}
                    <option value="{{ value }}" {% if paste.language == value %}selected{% endif %}>
                        {{ label }}
                    </option>
                {% endfor %}
            </select>
        </div>
        {% endif %}

        <div class="form-check mb-2">
            <input class="form-check-input" type="checkbox" id="private" name="private" {% if paste.private %}checked{% endif %}>
            <label class="form-check-label" for="private">Private</label>
        </div>

        <div class="mb-3">
            <label for="expires_at" class="form-label">Expires At</label>
            <input type="date" id="expires_at" name="expires_at" class="form-control"
                   value="{{ paste.expires_at.strftime('%Y-%m-%d') if paste.expires_at else '' }}">
        </div>

        <button type="submit" class="btn btn-primary">Save Changes</button>
        <a href="{{ url_for('user_dashboard') }}" class="btn btn-secondary">Back</a>
    </form>
</div>
{% endblock %}



