Skip to content
Snippets Groups Projects
Commit 6b65f555 authored by Christian Dresen's avatar Christian Dresen
Browse files

[WarpPay] Added Position to Category and to Products

parent 24efef4c
No related branches found
No related tags found
No related merge requests found
...@@ -6,21 +6,23 @@ from warpauth.models import LdapUser ...@@ -6,21 +6,23 @@ from warpauth.models import LdapUser
class ProductCategory(models.Model): class ProductCategory(models.Model):
name = models.CharField(max_length=100, unique=True) name = models.CharField(max_length=100, unique=True)
position = models.FloatField(null=True, blank=True, default=0)
def __str__(self): def __str__(self):
return self.name return self.name
class ProductCategorySerializer(serializers.ModelSerializer): class ProductCategorySerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = ProductCategory model = ProductCategory
fields = ['id', 'name'] fields = ['id', 'name','position']
class Product(models.Model): class Product(models.Model):
name = models.CharField(max_length=100, null=True) name = models.CharField(max_length=100, null=True)
price_ek = models.FloatField() price_ek = models.FloatField()
price_vk = models.FloatField() price_vk = models.FloatField()
category = models.ForeignKey(ProductCategory, on_delete=models.CASCADE, null=True) category = models.ForeignKey(ProductCategory, on_delete=models.CASCADE, null=True)
stock_count = models.IntegerField() stock_count = models.IntegerField(null=True, blank=True, default=0)
barcode = models.CharField(max_length=100, null=True) barcode = models.CharField(max_length=100, null=True, blank=True)
position = models.FloatField(null=True, blank=True, default=0)
def __str__(self): def __str__(self):
return self.name return self.name
...@@ -30,7 +32,7 @@ class ProductSerializer(serializers.ModelSerializer): ...@@ -30,7 +32,7 @@ class ProductSerializer(serializers.ModelSerializer):
category = serializers.StringRelatedField() category = serializers.StringRelatedField()
class Meta: class Meta:
model = Product model = Product
fields = ['id', 'name', 'price_vk', 'category', 'barcode','stock_count'] fields = ['id', 'name', 'price_vk', 'category', 'barcode','stock_count','position']
class Transaction(models.Model): class Transaction(models.Model):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment