Initial working version with minor bugs

This commit is contained in:
badblocks 2025-02-26 00:06:42 -08:00
parent f946e4933a
commit 71b3993326
83 changed files with 34485 additions and 173 deletions

View file

@ -0,0 +1,41 @@
{% extends '_base.html' %}
{% load static %}
{% load card_multiselect %}
{% block title %}Create Trade Offer{% endblock title %}
{% block content %}
<h2>Create a Trade Offer</h2>
<form method="post" novalidate>
{% csrf_token %}
{# Render the nonSelect2 field normally (e.g. initiated_by) #}
<div class="mb-3">
<label for="initiated_by" class="form-label">Initiated by</label>
{{ form.initiated_by }}
</div>
<div class="mb-3">
{% card_multiselect "have_cards" "Have:" available_cards "Select one or more cards..." form.have_cards.value %}
</div>
<div class="mb-3">
{% card_multiselect "want_cards" "Want:" available_cards "Select one or more cards..." form.want_cards.value %}
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% if form.errors %}
<div class="alert alert-danger">
<strong>Please correct the errors below:</strong>
<ul>
{% for field in form %}
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endblock content %}

View file

@ -0,0 +1,14 @@
{% extends '_base.html' %}
{% load static %}
{% block title %}Delete Trade Offer{% endblock title %}
{% block content %}
<h2>Delete Trade Offer</h2>
<p>Are you sure you want to delete this trade offer?</p>
<form method="post">
{% csrf_token %}
<button type="submit" class="btn btn-danger">Confirm Delete</button>
<a href="{% url 'trade_offer_list' %}" class="btn btn-secondary">Cancel</a>
</form>
{% endblock content %}

View file

@ -0,0 +1,62 @@
{% extends '_base.html' %}
{% load static %}
{% load el_pagination_tags %}
{% block title %}Trade Offer List{% endblock title %}
{% block content %}
<div class="d-flex justify-content-end mb-3">
<form method="get" class="d-flex align-items-center">
<div class="form-check me-3">
<input class="form-check-input" type="checkbox" name="show_completed" id="show_completed" value="true" {% if show_completed %}checked{% endif %}>
<label class="form-check-label" for="show_completed">
Only Completed
</label>
</div>
<button type="submit" class="btn btn-primary">Apply</button>
</form>
</div>
<h2>Trade Offers</h2>
<table class="table">
<thead>
<tr>
<th>Offer</th>
<th>State</th>
<th>Updated At</th>
</tr>
</thead>
<tbody>
{% paginate 10 object_list as paginated_offers %}
{% for offer in paginated_offers %}
<tr>
<td>
<a href="{% url 'trade_offer_update' offer.id %}" class="d-flex align-items-center text-decoration-none">
<div class="flex-grow-1 text-start">
FT: {% for card in offer.cards_ft.all %}
{{ card.name }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</div>
<div class="px-2 text-center" style="min-width: 50px;">&#x27F6;</div>
<div class="flex-grow-1 text-end">
LF: {% for card in offer.cards_lf.all %}
{{ card.name }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</div>
</a>
</td>
<td>{{ offer.get_state_display }}</td>
<td>{{ offer.updated_at }}</td>
</tr>
{% empty %}
<tr>
<td colspan="3">No trade offers available.</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="pagination">
{% show_pages %}
</div>
<a href="{% url 'trade_offer_create' %}" class="btn btn-success">Create New Offer</a>
{% endblock content %}

View file

@ -0,0 +1,100 @@
{% extends '_base.html' %}
{% load static %}
{% block title %}Trade Offer Details & Update{% endblock title %}
{% block content %}
<div class="container my-4">
<h2 class="mb-4">Trade Offer Details</h2>
<!-- Offer Details Card -->
<div class="card mb-4">
<div class="card-header">
Offer Information
</div>
<div class="card-body">
<p>
<strong>Created At:</strong> {{ object.created_at|date:"M d, Y H:i" }}<br>
<strong>Updated At:</strong> {{ object.updated_at|date:"M d, Y H:i" }}<br>
{% comment %}
Only display these fields if the current user is associated with the initiating friend code
or (if available) with the accepted friend code.
{% endcomment %}
{% if object.initiated_by.user == request.user or object.accepted_by and object.accepted_by.user == request.user %}
<strong>Initiated By:</strong> {{ object.initiated_by }}<br>
<strong>Accepted By:</strong>
{% if object.accepted_by %}
{{ object.accepted_by }}
{% else %}
Not yet accepted
{% endif %}<br>
{% endif %}
<strong>Cards You Have:</strong>
{% for card in object.have_cards.all %}
{{ card.name }}{% if not forloop.last %}, {% endif %}
{% endfor %}<br>
<strong>Cards You Want:</strong>
{% for card in object.want_cards.all %}
{{ card.name }}{% if not forloop.last %}, {% endif %}
{% endfor %}<br>
<strong>Current State:</strong> {{ object.get_state_display }}
</p>
</div>
</div>
{% if form.fields %}
<!-- Form Card -->
<div class="card mb-4">
<div class="card-header">
{% if action == "accept" %}
Accept Trade Offer
{% else %}
Update Trade Offer
{% endif %}
</div>
<div class="card-body">
<form method="post" novalidate>
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn {% if action == 'accept' %}btn-success{% else %}btn-primary{% endif %}">
{% if action == "accept" %}
Accept Trade Offer
{% else %}
Submit
{% endif %}
</button>
</form>
</div>
</div>
{% else %}
<div class="alert alert-info">
You are not authorized to perform any status changes on this trade offer.
</div>
{% endif %}
{% if form and form.errors %}
<div class="alert alert-danger mt-3">
<strong>Please correct the errors below:</strong>
<ul class="mb-0">
{% for field in form %}
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="mt-3">
<a href="{% url 'trade_offer_list' %}" class="btn btn-secondary">Back to Trade Offers</a>
{% if can_delete %}
<a href="{% url 'trade_offer_delete' object.pk %}" class="btn btn-danger ms-2">Delete Trade Offer</a>
{% endif %}
</div>
</div>
{% endblock content %}