diff --git a/shop/admin.py b/shop/admin.py index 290d6ef..d39d098 100644 --- a/shop/admin.py +++ b/shop/admin.py @@ -29,10 +29,10 @@ class KeySetAdmin(admin.ModelAdmin): @admin.register(Product) class ProductAdmin(admin.ModelAdmin): - list_display = ('product_name', 'seller', 'get_rating', 'price', 'stock', 'physical', 'approved') - list_filter = ('approved', 'physical','worldwide_shipping','free_shipping') + list_display = ('product_name', 'seller', 'get_rating', 'price', 'stock', 'physical', 'approved', 'removed') + list_filter = ('approved', 'physical','worldwide_shipping','free_shipping', 'removed') fieldsets = ( - ('Product info', {'fields': ('product_name', 'product_description', ('price', 'price_currency', 'cached_rate'), 'seller')}), + ('Product info', {'fields': ('product_name', 'product_description', ('price', 'price_currency', 'cached_rate'), 'seller', ('removed', 'delete_on_over'))}), ('Moderation', {'fields': ('approved',)}), ('Shipping/Delivery', {'fields': (('stock', 'physical'), ('ships_from', 'worldwide_shipping'), ('local_price', 'outside_price', 'free_shipping'))}), ('Digital', {'fields': ('redeeming_instructions',('unlimited_stock','can_purchase_multiple'))}) @@ -104,4 +104,4 @@ class ReviewAdmin(admin.ModelAdmin): inlines = [ReviewVoteInline] admin.site.register(UserShop) -admin.site.register(ShippingUpdate) \ No newline at end of file +admin.site.register(ShippingUpdate) diff --git a/shop/migrations/0003_auto_20170521_1334.py b/shop/migrations/0003_auto_20170521_1334.py new file mode 100644 index 0000000..0f85713 --- /dev/null +++ b/shop/migrations/0003_auto_20170521_1334.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-05-21 13:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0002_auto_20170520_1307'), + ] + + operations = [ + migrations.AddField( + model_name='product', + name='delete_on_over', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='product', + name='removed', + field=models.BooleanField(default=False), + ), + ] diff --git a/shop/models.py b/shop/models.py index 3a9e8be..e95ab10 100644 --- a/shop/models.py +++ b/shop/models.py @@ -73,6 +73,8 @@ class Product(models.Model): unlimited_stock = models.BooleanField(default=False) can_purchase_multiple = models.BooleanField(default=True) + delete_on_over = models.BooleanField(default=False) + removed = models.BooleanField(default=False) def __str__(self): return self.product_name @@ -128,7 +130,7 @@ def buy(self, address, wallet, ammount, gift=False): us = UserShop(user=self.seller, pay_to_address=a) us.save() if (self.stock >= ammount or self.unlimited_stock) and \ - self.ships_to(address): + self.ships_to(address) and not self.removed: if getattr(settings, 'FEE_ADDRESS', '') != '': wallet.send_to( getattr(settings, 'FEE_ADDRESS', ''), @@ -147,6 +149,8 @@ def buy(self, address, wallet, ammount, gift=False): fee = 1 if not self.unlimited_stock: self.stock -= ammount + if self.delete_on_over and self.stock == 0: + self.removed = True self.save() send_mail("Someone bought one of your items!", """Hello %s, diff --git a/shop/static/shop/main.css b/shop/static/shop/main.css index f4010ad..9c355a8 100644 --- a/shop/static/shop/main.css +++ b/shop/static/shop/main.css @@ -262,5 +262,5 @@ html { } body { - margin-bottom: 60px; + margin-bottom: 100px; } diff --git a/shop/templates/shop/newproduct.html b/shop/templates/shop/newproduct.html index 9a56463..ac8a4b1 100644 --- a/shop/templates/shop/newproduct.html +++ b/shop/templates/shop/newproduct.html @@ -38,6 +38,11 @@