Added Deutsche Post as a shipping carrier, including new models, admin, serializers, and API client integration. Updated Carrier and SiteConfiguration models to support Deutsche Post, including shipping price and API credentials. Added requirements for the Deutsche Post API client and dependencies.
60 lines
3.3 KiB
Python
60 lines
3.3 KiB
Python
from django.db import models
|
|
|
|
# Create your models here.
|
|
|
|
class SiteConfiguration(models.Model):
|
|
name = models.CharField(max_length=100, default="Shop name", unique=True)
|
|
|
|
logo = models.ImageField(upload_to='shop_logos/', blank=True, null=True)
|
|
favicon = models.ImageField(upload_to='shop_favicons/', blank=True, null=True)
|
|
|
|
contact_email = models.EmailField(max_length=254, blank=True, null=True)
|
|
contact_phone = models.CharField(max_length=20, blank=True, null=True)
|
|
contact_address = models.TextField(blank=True, null=True)
|
|
opening_hours = models.JSONField(blank=True, null=True) #FIXME: vytvoř JSON tvar pro otvírací dobu, přes validátory
|
|
|
|
#Social
|
|
facebook_url = models.URLField(max_length=200, blank=True, null=True)
|
|
instagram_url = models.URLField(max_length=200, blank=True, null=True)
|
|
youtube_url = models.URLField(max_length=200, blank=True, null=True)
|
|
tiktok_url = models.URLField(max_length=200, blank=True, null=True)
|
|
whatsapp_number = models.CharField(max_length=20, blank=True, null=True)
|
|
|
|
#zasilkovna settings
|
|
zasilkovna_shipping_price = models.DecimalField(max_digits=10, decimal_places=2, default=50)
|
|
#FIXME: není implementováno ↓↓↓
|
|
zasilkovna_api_key = models.CharField(max_length=255, blank=True, null=True, help_text="API klíč pro přístup k Zásilkovna API (zatím není využito)")
|
|
#FIXME: není implementováno ↓↓↓
|
|
zasilkovna_api_password = models.CharField(max_length=255, blank=True, null=True, help_text="API heslo pro přístup k Zásilkovna API (zatím není využito)")
|
|
#FIXME: není implementováno ↓↓↓
|
|
free_shipping_over = models.DecimalField(max_digits=10, decimal_places=2, default=2000)
|
|
|
|
# Deutsche Post settings
|
|
deutschepost_api_url = models.URLField(max_length=255, default="https://gw.sandbox.deutschepost.com", help_text="Deutsche Post API URL (sandbox/production)")
|
|
deutschepost_client_id = models.CharField(max_length=255, blank=True, null=True, help_text="Deutsche Post OAuth Client ID")
|
|
deutschepost_client_secret = models.CharField(max_length=255, blank=True, null=True, help_text="Deutsche Post OAuth Client Secret")
|
|
deutschepost_customer_ekp = models.CharField(max_length=20, blank=True, null=True, help_text="Deutsche Post Customer EKP number")
|
|
deutschepost_shipping_price = models.DecimalField(max_digits=10, decimal_places=2, default=150, help_text="Default Deutsche Post shipping price")
|
|
|
|
#coupon settings
|
|
multiplying_coupons = models.BooleanField(default=True, help_text="Násobení kupónů v objednávce (ano/ne), pokud ne tak se použije pouze nejvyšší slevový kupón")
|
|
addition_of_coupons_amount = models.BooleanField(default=False, help_text="Sčítání slevových kupónů v objednávce (ano/ne), pokud ne tak se použije pouze nejvyšší slevový kupón")
|
|
|
|
class CURRENCY(models.TextChoices):
|
|
CZK = "CZK", "cz#Czech Koruna"
|
|
EUR = "EUR", "cz#Euro"
|
|
currency = models.CharField(max_length=10, default=CURRENCY.CZK, choices=CURRENCY.choices)
|
|
|
|
class Meta:
|
|
verbose_name = "Shop Configuration"
|
|
verbose_name_plural = "Shop Configuration"
|
|
|
|
def save(self, *args, **kwargs):
|
|
# zajištění singletonu
|
|
self.pk = 1
|
|
super().save(*args, **kwargs)
|
|
|
|
@classmethod
|
|
def get_solo(cls):
|
|
obj, _ = cls.objects.get_or_create(pk=1)
|
|
return obj |