MASSIVE UPDATE:
bounty board feature buyers to see bounty boards seller profile page (like have theme chooser) Have the game and set name be filters. Add cards to vault manually update card inventory add to have the autocomplete for the card - store analytics, clicks, views, link to store (url/QR code) bulk item inventory creation -- Make the banner feature flag driven so I can have a beta site setup like the primary site don't use primary key values in urls - update to use uuid4 values site analytics. tianji is being sent item potent on the mtg and lorcana populate scripts Card item images for specific listings check that when you buy a card it is in the vault Buys should be able to search on store inventories More pie charts for the seller! post bounty board is slow to load seller reviews/ratings - show a historgram - need a way for someone to rate Report a seller feature for buyer to report Make sure the stlying is consistent based on the theme choosen smart minimum order quantity and shipping amounts (defined by the store itself) put virtual packs behind a feature flag like bounty board proxy service feature flag Terms of Service new description for TCGKof store SSN, ITIN, and EIN optomize for SEO
This commit is contained in:
110
store/forms.py
Normal file
110
store/forms.py
Normal file
@@ -0,0 +1,110 @@
|
||||
from django import forms
|
||||
from .models import Seller, CardListing, PackListing, Game, Bounty, BountyOffer
|
||||
from users.models import Profile
|
||||
|
||||
class SellerThemeForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Profile
|
||||
fields = ['theme_preference']
|
||||
widgets = {
|
||||
'theme_preference': forms.Select(attrs={'class': 'form-select'})
|
||||
}
|
||||
|
||||
class SellerRegistrationForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Seller
|
||||
fields = ['store_name', 'description', 'contact_email', 'contact_phone', 'business_address']
|
||||
widgets = {
|
||||
'description': forms.Textarea(attrs={'rows': 4}),
|
||||
'business_address': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
class SellerEditForm(forms.ModelForm):
|
||||
tax_id = forms.CharField(required=False, widget=forms.TextInput(attrs={'type': 'password'}), help_text="SSN, ITIN, or EIN (Stored securely)")
|
||||
payout_details = forms.CharField(required=False, widget=forms.Textarea(attrs={'rows': 3}), help_text="Bank account or other payout details (Stored securely)")
|
||||
|
||||
class Meta:
|
||||
model = Seller
|
||||
fields = ['store_name', 'description', 'contact_email', 'contact_phone', 'business_address', 'store_image', 'hero_image', 'minimum_order_amount', 'shipping_cost', 'tax_id', 'payout_details']
|
||||
widgets = {
|
||||
'description': forms.Textarea(attrs={'rows': 4}),
|
||||
'business_address': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if self.instance and self.instance.pk:
|
||||
self.fields['tax_id'].initial = self.instance.tax_id
|
||||
self.fields['payout_details'].initial = self.instance.payout_details
|
||||
|
||||
def save(self, commit=True):
|
||||
seller = super().save(commit=False)
|
||||
seller.tax_id = self.cleaned_data.get('tax_id')
|
||||
seller.payout_details = self.cleaned_data.get('payout_details')
|
||||
if commit:
|
||||
seller.save()
|
||||
return seller
|
||||
|
||||
class CardListingForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = CardListing
|
||||
fields = ['condition', 'price', 'quantity', 'status', 'image']
|
||||
# TODO: Add search widget for card selection or filter by game/set
|
||||
|
||||
class PackListingForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = PackListing
|
||||
fields = ['game', 'name', 'listing_type', 'price', 'quantity', 'image_url']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Helper to indicate quantity logic
|
||||
self.fields['quantity'].help_text = "For Virtual packs, this is automatically updated based on inventory."
|
||||
|
||||
class AddCardListingForm(forms.Form):
|
||||
card_name = forms.CharField(max_length=200, label="Card Name", help_text="Enter the card name.")
|
||||
game = forms.ModelChoiceField(queryset=Game.objects.all(), empty_label="Select Game")
|
||||
set_name = forms.CharField(max_length=200, label="Set Name", help_text="Enter the set name (e.g., 'Alpha', 'Base Set').")
|
||||
collector_number = forms.CharField(max_length=20, required=False, label="Card Number", help_text="The number on the bottom of the card (e.g. '197'). Useful for variants.")
|
||||
condition = forms.ChoiceField(choices=CardListing.CONDITION_CHOICES)
|
||||
price = forms.DecimalField(max_digits=10, decimal_places=2)
|
||||
quantity = forms.IntegerField(min_value=1, initial=1)
|
||||
image = forms.ImageField(required=False, label="Card Image")
|
||||
|
||||
class BountyForm(forms.ModelForm):
|
||||
card_name = forms.CharField(max_length=200, label="Card Name", help_text="Search for a card...", required=False)
|
||||
card_id = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||
|
||||
class Meta:
|
||||
model = Bounty
|
||||
fields = ['title', 'description', 'target_price', 'quantity_wanted']
|
||||
widgets = {
|
||||
'description': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
card_id = cleaned_data.get('card_id')
|
||||
title = cleaned_data.get('title')
|
||||
card_name = cleaned_data.get('card_name')
|
||||
|
||||
if not card_id and not title and not card_name:
|
||||
raise forms.ValidationError("You must either select a Card or provide a Title.")
|
||||
|
||||
return cleaned_data
|
||||
|
||||
class BountyOfferForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = BountyOffer
|
||||
fields = ['price', 'description']
|
||||
widgets = {
|
||||
'description': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
class MultipleFileInput(forms.ClearableFileInput):
|
||||
allow_multiple_selected = True
|
||||
|
||||
class BulkListingForm(forms.Form):
|
||||
csv_file = forms.FileField(label="Upload CSV", help_text="Upload the filled-out template CSV.")
|
||||
images = forms.FileField(widget=MultipleFileInput(attrs={'multiple': True}), required=False, label="Upload Images", help_text="Select all images referenced in your CSV.")
|
||||
|
||||
Reference in New Issue
Block a user