Move profile and settings into the new unified dashboard, showing user info in one place

This commit is contained in:
badblocks 2025-03-31 22:20:59 -07:00
parent 2d826734a0
commit 7edefe23c3
37 changed files with 726 additions and 500 deletions

View file

@ -1,4 +1,4 @@
{% load trade_offer_tags %}
{% load trade_offer_tags pagination_tags %}
{% comment %}
This snippet renders a grid of trade offer cards (or acceptance cards) along with pagination controls.
For a TradeOffer, we use {% render_trade_offer %}; for a TradeAcceptance, {% render_trade_acceptance %}.
@ -17,4 +17,5 @@
{% empty %}
<div>No trade offers available.</div>
{% endfor %}
</div>
</div>
{% render_pagination offers %}

View file

@ -1,38 +0,0 @@
{% include "trades/_trade_offer_list.html" %}
{% if offers.has_other_pages %}
<nav aria-label="Trade offers pagination" class="mt-6">
<ul class="flex justify-center space-x-2">
{% if offers.has_previous %}
<li>
<a class="btn btn-outline ajax-page-link" data-page="{{ offers.previous_page_number }}" href="#">
Previous
</a>
</li>
{% else %}
<li>
<span class="btn btn-outline btn-disabled">Previous</span>
</li>
{% endif %}
{% for num in offers.paginator.page_range %}
<li>
<a class="btn btn-outline ajax-page-link {% if offers.number == num %}btn-active{% endif %}" data-page="{{ num }}" href="#">
{{ num }}
</a>
</li>
{% endfor %}
{% if offers.has_next %}
<li>
<a class="btn btn-outline ajax-page-link" data-page="{{ offers.next_page_number }}" href="#">
Next
</a>
</li>
{% else %}
<li>
<span class="btn btn-outline btn-disabled">Next</span>
</li>
{% endif %}
</ul>
</nav>
{% endif %}

View file

@ -0,0 +1,16 @@
Hello {{ recipient_user }},
Great news! {{ acting_user }} ({{ acting_user_friend_code }}) has accepted your trade offer.
Trade Details:
- #{{ hash }}
- They are offering: {{ want_card }}
- They want: {{ has_card }}
What's next? You can now mark the trade as "Sent" once you've offered the card to them in the app, or reject the trade if needed.
Visit your dashboard to manage this trade:
{% url 'dashboard' %}
Happy trading!
PKMN Trade Club

View file

@ -0,0 +1,16 @@
Hello {{ recipient_user }},
{{ acting_user }} ({{ acting_user_friend_code }}) has marked your trade as "Received".
Trade Details:
- #{{ hash }}
- Card you sent: {{ has_card }}
- Card they offered: {{ want_card }}
What's next? Send a thank you to this user to increase their reputation!
Visit your dashboard to send thanks:
{% url 'dashboard' %}
Happy trading!
PKMN Trade Club

View file

@ -0,0 +1,16 @@
Hello {{ recipient_user }},
We're sorry to inform you that {{ acting_user }} ({{ acting_user_friend_code }}) has canceled their trade acceptance.
Trade Details:
- #{{ hash }}
- Card you were going to send: {{ has_card }}
- Card they were offering: {{ want_card }}
Your trade offer is still active and available for other users to accept.
Visit your dashboard to manage your trade offers:
{% url 'dashboard' %}
Happy trading!
PKMN Trade Club

View file

@ -0,0 +1,16 @@
Hello {{ recipient_user }},
We're sorry to inform you that {{ acting_user }} ({{ acting_user_friend_code }}) has rejected the trade.
Trade Details:
- #{{ hash }}
- Card you were going to receive: {{ has_card }}
- Card you were offering: {{ want_card }}
Don't worry - there are plenty of other trade opportunities available! You can browse our marketplace for similar trades.
Visit the marketplace:
https://pkmntrade.club{% url 'trade_offer_list' %}
Better luck with your next trade!
PKMN Trade Club

View file

@ -0,0 +1,16 @@
Hello {{ recipient_user }},
{{ acting_user }} ({{ acting_user_friend_code }}) has marked your trade as "Sent".
Trade Details:
- #{{ hash }}
- Card being sent to you: {{ has_card }}
- Card you're offering: {{ want_card }}
What's next? Once you respond to the trade in the app, please mark the trade as "Received" in your dashboard.
Visit your dashboard to manage this trade:
{% url 'dashboard' %}
Happy trading!
PKMN Trade Club

View file

@ -0,0 +1,16 @@
Hello {{ recipient_user }},
{{ acting_user }} ({{ acting_user_friend_code }}) has sent their thanks for the successful trade!
Trade Details:
- #{{ hash }}
- Card you sent: {{ has_card }}
- Card they offered: {{ want_card }}
What's next? Send a thank you to this user to increase their reputation!
Visit your dashboard to send thanks:
{% url 'dashboard' %}
Happy trading!
PKMN Trade Club

View file

@ -0,0 +1,15 @@
Hello {{ recipient_user }},
{{ acting_user }} ({{ acting_user_friend_code }}) has sent their thanks for the successful trade!
Trade Details:
- #{{ hash }}
- Card {% if is_initiator %}you{% else %}they{% endif %} sent: {{ has_card }}
- Card {% if is_initiator %}they{% else %}you{% endif %} offered: {{ want_card }}
This trade is now completed; no further actions can be made.
Thank you for using PKMN Trade Club.
Happy trading!
PKMN Trade Club

View file

@ -0,0 +1,16 @@
Hello {{ recipient_user }},
{{ acting_user }} ({{ acting_user_friend_code }}) has sent their thanks for the successful trade!
Trade Details:
- #{{ hash }}
- Card they sent: {{ has_card }}
- Card you offered: {{ want_card }}
What's next? Send a thank you to this user to increase their reputation!
Visit your dashboard to send thanks:
{% url 'dashboard' %}
Happy trading!
PKMN Trade Club

View file

@ -1,13 +1,13 @@
{% extends 'base.html' %}
{% load static %}
{% load static pagination_tags %}
{% block title %}All Trade Offers{% endblock title %}
{% block title %}Trade Offers{% endblock title %}
{% block content %}
<div class="container mx-auto max-w-4xl mt-6" x-data="{ allExpanded: false }">
<!-- Header-->
<div class="flex justify-between items-center mb-4">
<h1 class="text-2xl font-bold">All Trade Offers</h1>
<h1 class="text-2xl font-bold">Trade Offers</h1>
<div>
<form method="get" class="flex items-center gap-4" x-data>
<label class="cursor-pointer flex items-center gap-2">
@ -27,47 +27,23 @@
<div class="flex justify-end mb-4">
<a href="{% url 'trade_offer_create' %}" class="btn btn-success">Create New Offer</a>
</div>
<div
id="all-trade-offers"
x-data="tradeOffersPagination('{% url 'trade_offer_list' %}?')"
x-init="init()"
>
{% include "trades/_trade_offer_list_paginated.html" with offers=all_trade_offers_paginated %}
<div id="all-trade-offers"
x-data="{
page: {{ all_trade_offers_paginated.number|default:1 }},
loadOffers() {
let url = new URL('{% url 'trade_offer_list' %}', window.location.origin);
let params = new URLSearchParams(window.location.search);
params.set('page', this.page);
url.search = params.toString();
fetch(url, { headers: { 'X-Requested-With': 'XMLHttpRequest' }})
.then(response => response.text())
.then(html => { this.$el.innerHTML = html; });
}
}"
x-init="loadOffers()"
x-on:change-page.window="page = $event.detail.page; loadOffers()">
{% include "trades/_trade_offer_list.html" with offers=all_trade_offers_paginated %}
</div>
</section>
</div>
<script>
function tradeOffersPagination(baseUrl) {
return {
baseUrl: baseUrl,
loadPage(page) {
let url = new URL(this.baseUrl, window.location.origin);
url.searchParams.set("page", page);
this.$el.innerHTML = '<div class="flex justify-center items-center w-full mt-10"><span class="loading loading-dots loading-xl"></span></div>';
fetch(url, {
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.text())
.then(html => {
this.$el.innerHTML = html;
// Reinitialize the click events after injecting the new fragment.
this.init();
});
},
init() {
// Bind click events for AJAX pagination links within this component.
this.$el.querySelectorAll("a.ajax-page-link").forEach(link => {
link.addEventListener("click", (event) => {
event.preventDefault();
const page = link.getAttribute("data-page");
this.loadPage(page);
});
});
}
}
}
</script>
{% endblock content %}

View file

@ -1,98 +0,0 @@
{% extends 'base.html' %}
{% load static %}
{% block title %}My Trades{% endblock title %}
{% block content %}
<div class="container mx-auto max-w-4xl mt-6" x-data="{ allExpanded: false }">
<!-- Header -->
<div class="flex justify-between items-start mb-4">
<a href="{% url 'trade_offer_create' %}" class="btn btn-success">Create New Offer</a>
<div>
<form method="get" class="flex flex-wrap justify-end space-x-4 gap-2" x-data>
<label class="cursor-pointer flex items-center space-x-2 h-10">
<span x-text="allExpanded ? 'Collapse All' : 'Expand All'"></span>
<input type="checkbox" name="all_expanded" value="true" class="toggle toggle-primary" @click="allExpanded = !allExpanded; $dispatch('toggle-all', { expanded: allExpanded })">
</label>
<label class="cursor-pointer flex items-center space-x-2 h-10">
<span class="font-medium">Only Closed</span>
<input type="checkbox" name="show_closed" value="true" class="toggle toggle-primary" @change="$el.form.submit()" {% if show_closed %}checked{% endif %}>
</label>
{% include "trades/_friend_code_select.html" with friend_codes=friend_codes selected_friend_code=selected_friend_code field_name="friend_code" label="" %}
<button type="submit" class="btn btn-primary" x-show="false">Apply</button>
</form>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-8">
<!-- Section: Waiting for Your Response -->
<section class="mb-12">
<h2 class="text-2xl font-bold mb-4">Waiting for Your Response</h2>
<div
id="waiting-acceptances"
x-data="tradeOffersPagination('{% url 'trade_offer_my_list' %}?ajax_section=waiting_acceptances')"
x-init="init()"
>
{% include "trades/_trade_offer_list_paginated.html" with offers=trade_acceptances_waiting_paginated %}
</div>
</section>
<!-- Section: Waiting for Their Response -->
<section class="mb-12">
<h2 class="text-2xl font-bold mb-4">Waiting for Their Response</h2>
<div
id="other-acceptances"
x-data="tradeOffersPagination('{% url 'trade_offer_my_list' %}?ajax_section=other_party_acceptances')"
x-init="init()"
>
{% include "trades/_trade_offer_list_paginated.html" with offers=other_party_trade_acceptances_paginated %}
</div>
</section>
</div>
<!-- Section: My Trade Offers -->
<section class="mb-12">
<h2 class="text-2xl font-bold mb-4">My Trade Offers</h2>
<div
id="my-trade-offers"
x-data="tradeOffersPagination('{% url 'trade_offer_my_list' %}?ajax_section=my_trade_offers')"
x-init="init()">
{% include "trades/_trade_offer_list_paginated.html" with offers=my_trade_offers_paginated %}
</div>
</section>
</div>
<script>
function tradeOffersPagination(baseUrl) {
return {
baseUrl: baseUrl,
loadPage(page) {
let url = new URL(this.baseUrl, window.location.origin);
url.searchParams.set("page", page);
fetch(url, {
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.text())
.then(html => {
this.$el.innerHTML = html;
// Reinitialize click events after content update.
this.init();
});
},
init() {
// Bind click events on pagination links within the component.
this.$el.querySelectorAll("a.ajax-page-link").forEach(link => {
link.addEventListener("click", (event) => {
event.preventDefault();
let page = link.getAttribute("data-page");
this.loadPage(page);
});
});
}
}
}
</script>
{% endblock content %}