From afaa392b2fff9da07446d12ff87966e2f57ce92d Mon Sep 17 00:00:00 2001 From: badbl0cks <4161747+badbl0cks@users.noreply.github.com> Date: Tue, 15 Apr 2025 00:15:08 -0700 Subject: [PATCH] use tags for card_badge and trade_offer clickable areas (except for main card_badge row on trade_offers, still uses @click for now because the a tag can't wrap that content for some reason). closes #14 --- accounts/migrations/0001_initial.py | 2 +- accounts/models.py | 2 +- cards/migrations/0001_initial.py | 2 +- home/views.py | 10 +- theme/static_src/src/styles.css | 4 +- theme/static_src/tailwind.config.js | 120 +++++------ theme/templates/account/dashboard.html | 4 +- theme/templates/base.html | 8 +- theme/templates/cards/card_detail.html | 4 +- theme/templates/cards/card_list.html | 4 +- .../friend_codes/edit_friend_code.html | 2 - .../templates/trades/trade_offer_detail.html | 22 +- .../templates/trades/trade_offer_search.html | 4 +- theme/templatetags/card_badge.html | 6 +- theme/templatetags/trade_acceptance.html | 32 +-- theme/templatetags/trade_offer.html | 16 +- theme/templatetags/trade_offer_png.html | 189 ++++++++++-------- trades/forms.py | 16 +- trades/migrations/0001_initial.py | 2 +- trades/models.py | 8 +- trades/signals.py | 7 +- trades/views.py | 10 +- 22 files changed, 247 insertions(+), 227 deletions(-) diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py index 9d87ecd..ccf2e37 100644 --- a/accounts/migrations/0001_initial.py +++ b/accounts/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.2 on 2025-04-14 04:07 +# Generated by Django 5.1.2 on 2025-04-14 20:58 import accounts.models import django.contrib.auth.models diff --git a/accounts/models.py b/accounts/models.py index eb8cbaa..65610e7 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -20,7 +20,7 @@ class CustomUser(AbstractUser): enable_email_notifications = models.BooleanField( default=True, verbose_name="Enable Email Notifications", - help_text="Receive new trade notifications via email." + help_text="Receive trade notifications via email." ) reputation_score = models.IntegerField(default=0) diff --git a/cards/migrations/0001_initial.py b/cards/migrations/0001_initial.py index 3761385..9312fa8 100644 --- a/cards/migrations/0001_initial.py +++ b/cards/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.2 on 2025-04-14 04:07 +# Generated by Django 5.1.2 on 2025-04-14 20:58 import django.db.models.deletion from django.db import migrations, models diff --git a/home/views.py b/home/views.py index b26e523..2010bdc 100644 --- a/home/views.py +++ b/home/views.py @@ -22,8 +22,8 @@ class HomePageView(TemplateView): context = super().get_context_data(**kwargs) try: - # Get all cards ordered by name - context["cards"] = Card.objects.all().order_by("name") + # Get all cards ordered by name, exclude cards with rarity level > 5 + context["cards"] = Card.objects.filter(rarity_level__lte=5).order_by("name", "rarity_level") # Reuse base trade offer queryset for market stats base_offer_qs = TradeOffer.objects.filter(is_closed=False) @@ -39,7 +39,7 @@ class HomePageView(TemplateView): # Most Offered Cards try: context["most_offered_cards"] = ( - Card.objects.filter(tradeofferhavecard__isnull=False) + Card.objects.filter(tradeofferhavecard__isnull=False).filter(rarity_level__lte=5) .annotate(offer_count=Sum("tradeofferhavecard__quantity")) .order_by("-offer_count")[:6] ) @@ -50,7 +50,7 @@ class HomePageView(TemplateView): # Most Wanted Cards try: context["most_wanted_cards"] = ( - Card.objects.filter(tradeofferwantcard__isnull=False) + Card.objects.filter(tradeofferwantcard__isnull=False).filter(rarity_level__lte=5) .annotate(offer_count=Sum("tradeofferwantcard__quantity")) .order_by("-offer_count")[:6] ) @@ -61,7 +61,7 @@ class HomePageView(TemplateView): # Least Offered Cards try: context["least_offered_cards"] = ( - Card.objects.annotate( + Card.objects.filter(rarity_level__lte=5).annotate( offer_count=Coalesce(Sum("tradeofferhavecard__quantity"), 0) ) .order_by("offer_count")[:6] diff --git a/theme/static_src/src/styles.css b/theme/static_src/src/styles.css index efeaa50..5b06b59 100644 --- a/theme/static_src/src/styles.css +++ b/theme/static_src/src/styles.css @@ -23,7 +23,9 @@ * */ -@theme {} +@theme { + --breakpoint-xs: 24rem; +} /* diff --git a/theme/static_src/tailwind.config.js b/theme/static_src/tailwind.config.js index 4dc3e18..f873516 100644 --- a/theme/static_src/tailwind.config.js +++ b/theme/static_src/tailwind.config.js @@ -6,68 +6,68 @@ */ module.exports = { - content: [ - /** - * HTML. Paths to Django template files that will contain Tailwind CSS classes. - */ + content: [ + /** + * HTML. Paths to Django template files that will contain Tailwind CSS classes. + */ - /* Templates within theme app (/templates), e.g. base.html. */ - '../templates/**/*.html', + /* Templates within theme app (/templates), e.g. base.html. */ + "../templates/**/*.html", - /* - * Main templates directory of the project (BASE_DIR/templates). - * Adjust the following line to match your project structure. - */ - '../../templates/**/*.html', + /* + * Main templates directory of the project (BASE_DIR/templates). + * Adjust the following line to match your project structure. + */ + "../../templates/**/*.html", - /* - * Templates in other django apps (BASE_DIR//templates). - * Adjust the following line to match your project structure. - */ - '../../**/templates/**/*.html', + /* + * Templates in other django apps (BASE_DIR//templates). + * Adjust the following line to match your project structure. + */ + "../../**/templates/**/*.html", - /** - * JS: If you use Tailwind CSS in JavaScript, uncomment the following lines and make sure - * patterns match your project structure. - */ - /* JS 1: Ignore any JavaScript in node_modules folder. */ - // '!../../**/node_modules', - /* JS 2: Process all JavaScript files in the project. */ - // '../../**/*.js', + /** + * JS: If you use Tailwind CSS in JavaScript, uncomment the following lines and make sure + * patterns match your project structure. + */ + /* JS 1: Ignore any JavaScript in node_modules folder. */ + // '!../../**/node_modules', + /* JS 2: Process all JavaScript files in the project. */ + // '../../**/*.js', - /** - * Python: If you use Tailwind CSS classes in Python, uncomment the following line - * and make sure the pattern below matches your project structure. - */ - // '../../**/*.py' - ], - safelist: [ - 'alert-info', - 'alert-success', - 'alert-warning', - 'alert-error', - 'btn-info', - 'btn-success', - 'btn-warning', - 'btn-error', - 'bg-info', - 'bg-success', - 'bg-warning', - 'bg-error', - 'text-gray-700' - ], - theme: { - extend: {}, - }, - plugins: [ - /** - * '@tailwindcss/forms' is the forms plugin that provides a minimal styling - * for forms. If you don't like it or have own styling for forms, - * comment the line below to disable '@tailwindcss/forms'. - */ - require('@tailwindcss/forms'), - require('@tailwindcss/typography'), - require('@tailwindcss/aspect-ratio'), - ], - darkMode: 'class', -} + /** + * Python: If you use Tailwind CSS classes in Python, uncomment the following line + * and make sure the pattern below matches your project structure. + */ + // '../../**/*.py' + ], + safelist: [ + "alert-info", + "alert-success", + "alert-warning", + "alert-error", + "btn-info", + "btn-success", + "btn-warning", + "btn-error", + "bg-info", + "bg-success", + "bg-warning", + "bg-error", + "text-gray-700", + ], + theme: { + extend: {}, + }, + plugins: [ + /** + * '@tailwindcss/forms' is the forms plugin that provides a minimal styling + * for forms. If you don't like it or have own styling for forms, + * comment the line below to disable '@tailwindcss/forms'. + */ + require("@tailwindcss/forms"), + require("@tailwindcss/typography"), + require("@tailwindcss/aspect-ratio"), + ], + darkMode: "class", +}; diff --git a/theme/templates/account/dashboard.html b/theme/templates/account/dashboard.html index 17841c9..2e1eb29 100644 --- a/theme/templates/account/dashboard.html +++ b/theme/templates/account/dashboard.html @@ -106,8 +106,8 @@ {% with gravatar_profile=request.user.email|gravatar_profile_data %}
-
-
+
+
{{ request.user.email|gravatar:128 }}
diff --git a/theme/templates/base.html b/theme/templates/base.html index 3b117e6..3f3dac8 100644 --- a/theme/templates/base.html +++ b/theme/templates/base.html @@ -79,13 +79,13 @@ {% if user.is_authenticated %}
diff --git a/theme/templates/cards/card_detail.html b/theme/templates/cards/card_detail.html index 625e05a..020743d 100644 --- a/theme/templates/cards/card_detail.html +++ b/theme/templates/cards/card_detail.html @@ -38,7 +38,7 @@
-
-
-