update shop

sync_v2
Raz 8 months ago
parent b8a708ff44
commit 7574087bf8
  1. 20
      shop/admin.py
  2. 44
      shop/management/commands/create_initial_shop_data.py
  3. 22
      shop/migrations/0023_alter_color_options_color_ordering.py
  4. 4
      shop/models.py
  5. BIN
      shop/static/shop/images/products/PC002/blanc/PS_K473-B_WHITE.png.avif
  6. BIN
      shop/static/shop/images/products/PC002/blanc/PS_K473-S_WHITE.png.avif
  7. 0
      shop/static/shop/images/products/PC002/blanc/PS_K473_WHITE.png.avif
  8. BIN
      shop/static/shop/images/products/PC002/bleu-sport/PS_K473-B_NAVY.png.avif
  9. BIN
      shop/static/shop/images/products/PC002/bleu-sport/PS_K473-S_NAVY.png.avif
  10. BIN
      shop/static/shop/images/products/PC002/bleu-sport/PS_K473_NAVY.png.avif
  11. BIN
      shop/static/shop/images/products/PC002/fuchsia/PS_K473-B_FUCHSIA.png.avif
  12. BIN
      shop/static/shop/images/products/PC002/fuchsia/PS_K473-S_FUCHSIA.png.avif
  13. BIN
      shop/static/shop/images/products/PC002/fuchsia/PS_K473_FUCHSIA.png.avif
  14. BIN
      shop/static/shop/images/products/PC002/noir/PS_K473-B_BLACK.png.avif
  15. BIN
      shop/static/shop/images/products/PC002/noir/PS_K473-S_BLACK.png.avif
  16. BIN
      shop/static/shop/images/products/PC002/noir/PS_K473_BLACK.png.avif
  17. BIN
      shop/static/shop/images/products/PC003/blanc/PS_K476-B_WHITE.png.avif
  18. BIN
      shop/static/shop/images/products/PC003/blanc/PS_K476-S_WHITE.png.avif
  19. 0
      shop/static/shop/images/products/PC003/blanc/PS_K476_WHITE.png.avif
  20. BIN
      shop/static/shop/images/products/PC003/bleu-sport/PS_K476-B_NAVY.png.avif
  21. BIN
      shop/static/shop/images/products/PC003/bleu-sport/PS_K476-S_NAVY.png.avif
  22. BIN
      shop/static/shop/images/products/PC003/bleu-sport/PS_K476_NAVY.png.avif
  23. BIN
      shop/static/shop/images/products/PC003/fuchsia/PS_K476-B_FUCHSIA.png.avif
  24. BIN
      shop/static/shop/images/products/PC003/fuchsia/PS_K476-S_FUCHSIA.png.avif
  25. BIN
      shop/static/shop/images/products/PC003/fuchsia/PS_K476_FUCHSIA.png.avif
  26. BIN
      shop/static/shop/images/products/PC003/noir/PS_K476-B_BLACK.png.avif
  27. BIN
      shop/static/shop/images/products/PC003/noir/PS_K476-S_BLACK.png.avif
  28. BIN
      shop/static/shop/images/products/PC003/noir/PS_K476_BLACK.png.avif
  29. BIN
      shop/static/shop/images/products/PC004/blanc-bleu-sport/PS_PA4031-B_WHITE-SPORTYNAVY.png.avif
  30. BIN
      shop/static/shop/images/products/PC004/blanc-bleu-sport/PS_PA4031-S_WHITE-SPORTYNAVY.png.avif
  31. 0
      shop/static/shop/images/products/PC004/blanc-bleu-sport/PS_PA4031_WHITE-SPORTYNAVY.png.avif
  32. BIN
      shop/static/shop/images/products/PC004/noir-corail/PS_PA4031-B_BLACK-CORAL.png.avif
  33. BIN
      shop/static/shop/images/products/PC004/noir-corail/PS_PA4031-S_BLACK-CORAL.png.avif
  34. BIN
      shop/static/shop/images/products/PC004/noir-corail/PS_PA4031_BLACK-CORAL.png.avif
  35. BIN
      shop/static/shop/images/products/PC004/noir-gris-fonce-chine/PS_PA4031-B_BLACK-MARLDARKGREY.png.avif
  36. BIN
      shop/static/shop/images/products/PC004/noir-gris-fonce-chine/PS_PA4031-S_BLACK-MARLDARKGREY.png.avif
  37. BIN
      shop/static/shop/images/products/PC004/noir-gris-fonce-chine/PS_PA4031_BLACK-MARLDARKGREY.png.avif
  38. BIN
      shop/static/shop/images/products/PC005/blanc-bleu-sport/PS_PA1031-B_WHITE-SPORTYNAVY.png.avif
  39. BIN
      shop/static/shop/images/products/PC005/blanc-bleu-sport/PS_PA1031-S_WHITE-SPORTYNAVY.png.avif
  40. 0
      shop/static/shop/images/products/PC005/blanc-bleu-sport/PS_PA1031_WHITE-SPORTYNAVY.png.avif
  41. BIN
      shop/static/shop/images/products/PC005/bleu-sport-blanc/PS_PA1031-B_SPORTYNAVY-WHITE.png.avif
  42. BIN
      shop/static/shop/images/products/PC005/bleu-sport-blanc/PS_PA1031-S_SPORTYNAVY-WHITE.png.avif
  43. BIN
      shop/static/shop/images/products/PC005/bleu-sport-blanc/PS_PA1031_SPORTYNAVY-WHITE.png.avif
  44. BIN
      shop/static/shop/images/products/PC005/corail-noir/PS_PA1031-B_CORAL-BLACK.png.avif
  45. BIN
      shop/static/shop/images/products/PC005/corail-noir/PS_PA1031-S_CORAL-BLACK.png.avif
  46. BIN
      shop/static/shop/images/products/PC005/corail-noir/PS_PA1031_CORAL-BLACK.png.avif
  47. BIN
      shop/static/shop/images/products/PC005/noir-gris-fonce-chine/PS_PA1031-B_BLACK-MARLDARKGREY.png.avif
  48. BIN
      shop/static/shop/images/products/PC005/noir-gris-fonce-chine/PS_PA1031-S_BLACK-MARLDARKGREY.png.avif
  49. BIN
      shop/static/shop/images/products/PC005/noir-gris-fonce-chine/PS_PA1031_BLACK-MARLDARKGREY.png.avif
  50. BIN
      shop/static/shop/images/products/PC006/blanc-gris-clair/PS_PA4030-B_WHITE-FINEGREY.png.avif
  51. BIN
      shop/static/shop/images/products/PC006/blanc-gris-clair/PS_PA4030-S_WHITE-FINEGREY.png.avif
  52. BIN
      shop/static/shop/images/products/PC006/blanc-gris-clair/PS_PA4030_WHITE-FINEGREY.png.avif
  53. BIN
      shop/static/shop/images/products/PC006/bleu-sport-blanc/PS_PA4030-B_SPORTYNAVY-WHITE.png.avif
  54. BIN
      shop/static/shop/images/products/PC006/bleu-sport-blanc/PS_PA4030-S_SPORTYNAVY-WHITE.png.avif
  55. 0
      shop/static/shop/images/products/PC006/bleu-sport-blanc/PS_PA4030_SPORTYNAVY-WHITE.png.avif
  56. BIN
      shop/static/shop/images/products/PC006/bleu-sport-bleu-sport-chine/PS_PA4030-B_SPORTYNAVY-MARLSPORTYNAVY.png.avif
  57. BIN
      shop/static/shop/images/products/PC006/bleu-sport-bleu-sport-chine/PS_PA4030-S_SPORTYNAVY-MARLSPORTYNAVY.png.avif
  58. BIN
      shop/static/shop/images/products/PC006/bleu-sport-bleu-sport-chine/PS_PA4030_SPORTYNAVY-MARLSPORTYNAVY.png.avif
  59. BIN
      shop/static/shop/images/products/PC006/noir-gris-fonce-chine/PS_PA4030-B_BLACK-MARLDARKGREY.png.avif
  60. BIN
      shop/static/shop/images/products/PC006/noir-gris-fonce-chine/PS_PA4030-S_BLACK-MARLDARKGREY.png.avif
  61. BIN
      shop/static/shop/images/products/PC006/noir-gris-fonce-chine/PS_PA4030_BLACK-MARLDARKGREY.png.avif
  62. BIN
      shop/static/shop/images/products/PC006/noir/PS_PA4030-B_BLACK.png.avif
  63. BIN
      shop/static/shop/images/products/PC006/noir/PS_PA4030-S_BLACK.png.avif
  64. BIN
      shop/static/shop/images/products/PC006/noir/PS_PA4030_BLACK.png.avif
  65. BIN
      shop/static/shop/images/products/PC007/blanc-bleu-sport/PS_PA1030-B_WHITE-SPORTYNAVY.png.avif
  66. BIN
      shop/static/shop/images/products/PC007/blanc-bleu-sport/PS_PA1030-S_WHITE-SPORTYNAVY.png.avif
  67. 0
      shop/static/shop/images/products/PC007/blanc-bleu-sport/PS_PA1030_WHITE-SPORTYNAVY.png.avif
  68. BIN
      shop/static/shop/images/products/PC007/blanc-gris-clair/PS_PA1030-B_WHITE-FINEGREY.png.avif
  69. BIN
      shop/static/shop/images/products/PC007/blanc-gris-clair/PS_PA1030-S_WHITE-FINEGREY.png.avif
  70. BIN
      shop/static/shop/images/products/PC007/blanc-gris-clair/PS_PA1030_WHITE-FINEGREY.png.avif
  71. BIN
      shop/static/shop/images/products/PC007/gris-fonce-chine-noir/PS_PA1030-B_MARLDARKGREY-BLACK.png.avif
  72. BIN
      shop/static/shop/images/products/PC007/gris-fonce-chine-noir/PS_PA1030-S_MARLDARKGREY-BLACK.png.avif
  73. BIN
      shop/static/shop/images/products/PC007/gris-fonce-chine-noir/PS_PA1030_MARLDARKGREY-BLACK.png.avif
  74. BIN
      shop/static/shop/images/products/PC007/noir/PS_PA1030-B_BLACK.png.avif
  75. BIN
      shop/static/shop/images/products/PC007/noir/PS_PA1030-S_BLACK.png.avif
  76. BIN
      shop/static/shop/images/products/PC007/noir/PS_PA1030_BLACK.png.avif
  77. BIN
      shop/static/shop/images/products/hat.jpg
  78. BIN
      shop/static/shop/images/products/noir_hat.png.avif
  79. BIN
      shop/static/shop/images/products/tshirt_h.png

@ -1,5 +1,6 @@
from django.contrib import admin
from .models import Product, Color, Size, Order, OrderItem, GuestUser
from django.utils.html import format_html
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
@ -7,7 +8,24 @@ class ProductAdmin(admin.ModelAdmin):
@admin.register(Color)
class ColorAdmin(admin.ModelAdmin):
list_display = ("name",)
list_display = ("color_preview", "name", "ordering", "colorHex", "secondary_hex_color")
list_editable = ("ordering",)
ordering = ["ordering"]
search_fields = ["name"]
list_per_page = 20
def color_preview(self, obj):
if obj.secondary_hex_color:
return format_html(
'<div style="background-image: linear-gradient(to right, {} 50%, {} 50%); '
'width: 60px; height: 30px; border-radius: 15px; border: 1px solid #ddd;"></div>',
obj.colorHex, obj.secondary_hex_color
)
return format_html(
'<div style="background-color: {}; width: 60px; height: 30px; '
'border-radius: 15px; border: 1px solid #ddd;"></div>',
obj.colorHex
)
@admin.register(Size)
class SizeAdmin(admin.ModelAdmin):

@ -9,16 +9,18 @@ class Command(BaseCommand):
# Create colors
self.stdout.write('Creating colors...')
colors = [
{'name': 'Noir', 'hex': '#333333', 'secondary_hex': None},
{'name': 'Noir / Gris Foncé Chiné', 'hex': '#000000', 'secondary_hex': '#4D4D4D'},
{'name': 'Bleu Sport', 'hex': '#112B44', 'secondary_hex': None},
{'name': 'Bleu Sport / Bleu Sport Chiné', 'hex': '#112B44', 'secondary_hex': '#16395A'},
{'name': 'Bleu Sport / Blanc', 'hex': '#112B44', 'secondary_hex': '#FFFFFF'},
{'name': 'Blanc / Gris Clair', 'hex': '#FFFFFF', 'secondary_hex': '#D3D3D3'},
{'name': 'Fuchsia', 'hex': '#C1366B', 'secondary_hex': None},
{'name': 'Corail / Noir', 'hex': '#FF7F50', 'secondary_hex': '#000000'},
{'name': 'Blanc / Bleu Sport', 'hex': '#FFFFFF', 'secondary_hex': '#112B44'},
{'name': 'Blanc', 'hex': '#FFFFFF', 'secondary_hex': None},
{'name': 'Blanc', 'hex': '#FFFFFF', 'secondary_hex': None, 'ordering': 10},
{'name': 'Blanc / Bleu Sport', 'hex': '#FFFFFF', 'secondary_hex': '#112B44', 'ordering': 11},
{'name': 'Blanc / Gris Clair', 'hex': '#FFFFFF', 'secondary_hex': '#D3D3D3', 'ordering': 12},
{'name': 'Bleu Sport', 'hex': '#112B44', 'secondary_hex': None, 'ordering': 20},
{'name': 'Bleu Sport / Blanc', 'hex': '#112B44', 'secondary_hex': '#FFFFFF', 'ordering': 21},
{'name': 'Bleu Sport / Bleu Sport Chiné', 'hex': '#112B44', 'secondary_hex': '#16395A', 'ordering': 22},
{'name': 'Fuchsia', 'hex': '#C1366B', 'secondary_hex': None, 'ordering': 30},
{'name': 'Corail / Noir', 'hex': '#FF7F50', 'secondary_hex': '#000000', 'ordering': 40},
{'name': 'Gris Foncé Chiné / Noir', 'hex': '#4D4D4D', 'secondary_hex': '#000000', 'ordering': 50},
{'name': 'Noir', 'hex': '#333333', 'secondary_hex': None, 'ordering': 60},
{'name': 'Noir / Corail', 'hex': '#000000', 'secondary_hex': '#FF7F50', 'ordering': 61},
{'name': 'Noir / Gris Foncé Chiné', 'hex': '#000000', 'secondary_hex': '#4D4D4D', 'ordering': 62},
]
color_objects = {}
@ -27,21 +29,19 @@ class Command(BaseCommand):
name=color_data['name'],
defaults={
'colorHex': color_data['hex'],
'secondary_hex_color': color_data['secondary_hex']
'secondary_hex_color': color_data['secondary_hex'],
'ordering': color_data['ordering']
}
)
color_objects[color_data['name']] = color
if created:
self.stdout.write(f'Created color: {color_data["name"]}')
else:
# Update existing colors with secondary color if needed
if color.colorHex != color_data['hex'] or color.secondary_hex_color != color_data['secondary_hex']:
color.colorHex = color_data['hex']
color.secondary_hex_color = color_data['secondary_hex']
color.save()
self.stdout.write(f'Updated color: {color_data["name"]}')
else:
self.stdout.write(f'Color already exists: {color_data["name"]}')
color.colorHex = color_data['hex']
color.secondary_hex_color = color_data['secondary_hex']
color.ordering = color_data['ordering']
color.save()
self.stdout.write(f'Updated color: {color_data["name"]}')
# Create sizes
self.stdout.write('Creating sizes...')
@ -99,7 +99,7 @@ class Command(BaseCommand):
'price': 25.00,
'ordering_value': 20,
'cut': 1, # Women
'colors': ['Blanc / Bleu Sport', 'Noir', 'Noir / Gris Foncé Chiné'],
'colors': ['Blanc / Bleu Sport', 'Noir / Corail', 'Noir / Gris Foncé Chiné'],
'sizes': ['XS', 'S', 'M', 'L', 'XL'],
'image_filename': 'PS_PA4031_WHITE-SPORTYNAVY.png.avif'
},
@ -121,7 +121,7 @@ class Command(BaseCommand):
'price': 25.00,
'ordering_value': 40,
'cut': 2, # Men
'colors': ['Blanc / Bleu Sport', 'Noir', 'Noir / Gris Foncé Chiné'],
'colors': ['Blanc / Gris Clair', 'Bleu Sport / Blanc', 'Bleu Sport / Bleu Sport Chine', 'Noir', 'Noir / Gris Foncé Chiné'],
'sizes': ['S', 'M', 'L', 'XL', 'XXL', '3XL'],
'image_filename': 'tshirt_h.png'
},
@ -132,7 +132,7 @@ class Command(BaseCommand):
'price': 30.00,
'ordering_value': 50,
'cut': 2, # Men
'colors': ['Blanc / Bleu Sport', 'Noir', 'Noir / Gris Foncé Chiné'],
'colors': ['Blanc / Bleu Sport', 'Blanc / Gris Clair', 'Noir', 'Gris Foncé Chiné / Noir'],
'sizes': ['S', 'M', 'L', 'XL', 'XXL', '3XL'],
'image_filename': 'PS_PA1030_WHITE-SPORTYNAVY.png.avif'
},

@ -0,0 +1,22 @@
# Generated by Django 5.1 on 2025-03-27 11:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0022_alter_cartitem_options_alter_orderitem_options'),
]
operations = [
migrations.AlterModelOptions(
name='color',
options={'ordering': ['ordering']},
),
migrations.AddField(
model_name='color',
name='ordering',
field=models.IntegerField(default=0),
),
]

@ -18,6 +18,10 @@ class Color(models.Model):
colorHex = models.CharField(max_length=7, default="#FFFFFF", help_text="Color in hex format (e.g. #FF0000)")
secondary_hex_color = models.CharField(max_length=7, null=True, blank=True,
help_text="Secondary color in hex format for split color display")
ordering = models.IntegerField(default=0)
class Meta:
ordering = ['ordering'] # This will make queries respect the ordering by default
def __str__(self):
return self.name

Binary file not shown.

Before

Width:  |  Height:  |  Size: 909 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Loading…
Cancel
Save