adding sale_type to item creation

pull/3/head
lalanza808 5 years ago
parent b80110ce47
commit 4bdd75e678

@ -5,15 +5,16 @@ from items.models import Item, address_is_valid_monero
class CreateItemForm(forms.ModelForm): class CreateItemForm(forms.ModelForm):
class Meta: class Meta:
model = Item model = Item
fields = ['name', 'description', 'whereabouts', 'ask_price_xmr', 'payout_address'] fields = ['sale_type', 'name', 'description', 'whereabouts', 'ask_price_xmr', 'payout_address']
labels = { labels = {
'ask_price_xmr': 'Asking Price (XMR)', 'ask_price_xmr': 'Asking Price (XMR)',
'payout_address': 'Payout Wallet Address' 'payout_address': 'Payout Wallet Address',
'sale_type': 'Method of Delivery'
} }
help_texts = { help_texts = {
'name': 'Use a succinct name for your item. Don\'t be spammy or obscene.', 'name': 'Use a succinct name for your item. Don\'t be spammy or obscene.',
'description': 'Describe the condition of the item and any important information. Try to refrain from sharing personally identifiable information like phone numbers or social media links.', 'description': 'Describe the condition of the item and any important information. Try to refrain from sharing personally identifiable information like phone numbers or social media links.',
'whereabouts': 'A simple pointer to your general region - a nearby capital city and your state would be perfect.', 'whereabouts': 'Your general location - a nearby capital city and your state would be great for most cases so shipping costs can be accounted for. Use randomized text to remain anonymous.',
'ask_price_xmr': 'How many moneroj do you want for your item?', 'ask_price_xmr': 'How many moneroj do you want for your item?',
'payout_address': 'A Monero wallet address where funds will be sent after sale is confirmed.', 'payout_address': 'A Monero wallet address where funds will be sent after sale is confirmed.',
} }
@ -27,4 +28,3 @@ class SearchItemForm(forms.Form):
attrs={'placeholder':'Search whereabouts, item name, or description'} attrs={'placeholder':'Search whereabouts, item name, or description'}
) )
) )

@ -0,0 +1,18 @@
# Generated by Django 2.2.10 on 2020-04-06 06:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('items', '0002_item_whereabouts'),
]
operations = [
migrations.AddField(
model_name='item',
name='sale_type',
field=models.CharField(choices=[('SHIPPING', 'Ship the item to a provided address.'), ('MEETING', 'Deliver the item to an agreed upon public location.')], default='ship', max_length=20),
),
]

@ -11,6 +11,11 @@ from core.monero import AuctionDaemon
from core.validators import address_is_valid_monero from core.validators import address_is_valid_monero
ItemSaleTypes = (
('SHIPPING', 'Ship the item to a provided address.'),
('MEETING', 'Deliver the item to an agreed upon public location.')
)
class Item(ExportModelOperationsMixin('item'), models.Model): class Item(ExportModelOperationsMixin('item'), models.Model):
owner = models.ForeignKey(User, related_name='owner', on_delete=models.CASCADE) owner = models.ForeignKey(User, related_name='owner', on_delete=models.CASCADE)
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
@ -21,6 +26,7 @@ class Item(ExportModelOperationsMixin('item'), models.Model):
available = models.BooleanField(default=True) available = models.BooleanField(default=True)
payout_address = models.CharField(max_length=100, validators=[address_is_valid_monero]) payout_address = models.CharField(max_length=100, validators=[address_is_valid_monero])
whereabouts = models.CharField(max_length=100) whereabouts = models.CharField(max_length=100)
sale_type = models.CharField(max_length=20, choices=ItemSaleTypes, default='SHIPPING')
def __str__(self): def __str__(self):
return f"{self.id} - {self.owner} - {self.name}" return f"{self.id} - {self.owner} - {self.name}"

@ -11,6 +11,7 @@
</header> </header>
<section> <section>
{% if not item.available %}<p>This item is currently pending sale. Bidding is temporarily closed.</p>{% endif %} {% if not item.available %}<p>This item is currently pending sale. Bidding is temporarily closed.</p>{% endif %}
<p class="sale-info"><strong>Method of Delivery</strong>: {{ item.sale_type }}</p>
<p class="sale-info"><strong>Whereabouts</strong>: <a href="https://duckduckgo.com/?q={{ item.whereabouts }}" target="_blank">{{ item.whereabouts }}</a></p> <p class="sale-info"><strong>Whereabouts</strong>: <a href="https://duckduckgo.com/?q={{ item.whereabouts }}" target="_blank">{{ item.whereabouts }}</a></p>
<p class="sale-info"><strong>Creation</strong>: {{ item.list_date | date:"d M Y H:i:s e" }}</p> <p class="sale-info"><strong>Creation</strong>: {{ item.list_date | date:"d M Y H:i:s e" }}</p>
<p class="sale-info"><strong>Last Updated</strong>: {{ item.last_updated | date:"d M Y H:i:s e" }}</p> <p class="sale-info"><strong>Last Updated</strong>: {{ item.last_updated | date:"d M Y H:i:s e" }}</p>