From 4bdd75e678c9445a38d4a7d9b043c191f8467e07 Mon Sep 17 00:00:00 2001 From: lalanza808 Date: Sun, 5 Apr 2020 23:29:44 -0700 Subject: [PATCH] adding sale_type to item creation --- items/forms.py | 8 ++++---- items/migrations/0003_item_sale_type.py | 18 ++++++++++++++++++ items/models.py | 6 ++++++ web/templates/items/get_item.html | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 items/migrations/0003_item_sale_type.py diff --git a/items/forms.py b/items/forms.py index 57dded2..4b515dc 100644 --- a/items/forms.py +++ b/items/forms.py @@ -5,15 +5,16 @@ from items.models import Item, address_is_valid_monero class CreateItemForm(forms.ModelForm): class Meta: model = Item - fields = ['name', 'description', 'whereabouts', 'ask_price_xmr', 'payout_address'] + fields = ['sale_type', 'name', 'description', 'whereabouts', 'ask_price_xmr', 'payout_address'] labels = { 'ask_price_xmr': 'Asking Price (XMR)', - 'payout_address': 'Payout Wallet Address' + 'payout_address': 'Payout Wallet Address', + 'sale_type': 'Method of Delivery' } help_texts = { '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.', - '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?', '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'} ) ) - diff --git a/items/migrations/0003_item_sale_type.py b/items/migrations/0003_item_sale_type.py new file mode 100644 index 0000000..9f7217f --- /dev/null +++ b/items/migrations/0003_item_sale_type.py @@ -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), + ), + ] diff --git a/items/models.py b/items/models.py index e9cbcc7..4d10bef 100644 --- a/items/models.py +++ b/items/models.py @@ -11,6 +11,11 @@ from core.monero import AuctionDaemon 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): owner = models.ForeignKey(User, related_name='owner', on_delete=models.CASCADE) name = models.CharField(max_length=100) @@ -21,6 +26,7 @@ class Item(ExportModelOperationsMixin('item'), models.Model): available = models.BooleanField(default=True) payout_address = models.CharField(max_length=100, validators=[address_is_valid_monero]) whereabouts = models.CharField(max_length=100) + sale_type = models.CharField(max_length=20, choices=ItemSaleTypes, default='SHIPPING') def __str__(self): return f"{self.id} - {self.owner} - {self.name}" diff --git a/web/templates/items/get_item.html b/web/templates/items/get_item.html index a0bb251..240e9a0 100644 --- a/web/templates/items/get_item.html +++ b/web/templates/items/get_item.html @@ -11,6 +11,7 @@
{% if not item.available %}

This item is currently pending sale. Bidding is temporarily closed.

{% endif %} +

Method of Delivery: {{ item.sale_type }}

Whereabouts: {{ item.whereabouts }}

Creation: {{ item.list_date | date:"d M Y H:i:s e" }}

Last Updated: {{ item.last_updated | date:"d M Y H:i:s e" }}