diff --git a/src/accounts/models.py b/src/accounts/models.py
index 1647c59..bdda95d 100644
--- a/src/accounts/models.py
+++ b/src/accounts/models.py
@@ -19,10 +19,10 @@ class Address(models.Model):
def __str__(self):
return f"""
- {first_name} {last_name}
- {street_address_1}
- {street_address_2}
- {city}, {state}, {postal_code}
+ {self.first_name} {self.last_name}
+ {self.street_address_1}
+ {self.street_address_2}
+ {self.city}, {self.state}, {self.postal_code}
"""
diff --git a/src/core/migrations/0002_shippingrate_is_selectable_and_more.py b/src/core/migrations/0002_shippingrate_is_selectable_and_more.py
new file mode 100644
index 0000000..130ee1b
--- /dev/null
+++ b/src/core/migrations/0002_shippingrate_is_selectable_and_more.py
@@ -0,0 +1,24 @@
+# Generated by Django 4.0.2 on 2022-10-29 14:44
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='shippingrate',
+ name='is_selectable',
+ field=models.BooleanField(default=True),
+ ),
+ migrations.AddField(
+ model_name='sitesettings',
+ name='default_shipping_rate',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='core.shippingrate'),
+ ),
+ ]
diff --git a/src/core/models.py b/src/core/models.py
index d4de40b..3e290e7 100644
--- a/src/core/models.py
+++ b/src/core/models.py
@@ -56,17 +56,6 @@ class SingletonBase(models.Model):
abstract = True
-class SiteSettings(SingletonBase):
- usps_user_id = models.CharField(max_length=255)
-
- def __str__(self):
- return 'Site Settings'
-
- class Meta:
- verbose_name = 'Site Settings'
- verbose_name_plural = 'Site Settings'
-
-
class ProductCategory(models.Model):
name = models.CharField(max_length=255)
main_category = models.BooleanField(default=True)
@@ -271,6 +260,7 @@ class ShippingRate(models.Model):
blank=True,
null=True
)
+ is_selectable = models.BooleanField(default=True)
def get_absolute_url(self):
return reverse('dashboard:rate-detail', kwargs={'pk': self.pk})
@@ -366,6 +356,14 @@ class Order(models.Model):
objects = OrderManager()
+ def minus_stock(self):
+ for line in self.lines.all():
+ line.minus_stock()
+
+ def add_stock(self):
+ for line in self.lines.all():
+ line.add_stock()
+
def get_total_quantity(self):
return sum([line.quantity for line in self])
@@ -443,6 +441,16 @@ class OrderLine(models.Model):
def quantity_unfulfilled(self):
return self.quantity - self.quantity_fulfilled
+ def minus_stock(self):
+ if self.variant.track_inventory:
+ self.variant.stock -= self.quantity
+ self.variant.save()
+
+ def add_stock(self):
+ if self.variant.track_inventory:
+ self.variant.stock += self.quantity
+ self.variant.save()
+
class TrackingNumber(models.Model):
order = models.ForeignKey(
@@ -472,3 +480,21 @@ class Subscription(models.Model):
on_delete=models.SET_NULL,
null=True
)
+
+
+class SiteSettings(SingletonBase):
+ usps_user_id = models.CharField(max_length=255)
+ default_shipping_rate = models.ForeignKey(
+ ShippingRate,
+ blank=True,
+ null=True,
+ related_name='+',
+ on_delete=models.SET_NULL
+ )
+
+ def __str__(self):
+ return 'Site Settings'
+
+ class Meta:
+ verbose_name = 'Site Settings'
+ verbose_name_plural = 'Site Settings'
diff --git a/src/dashboard/templates/dashboard/customer_list.html b/src/dashboard/templates/dashboard/customer_list.html
index 5387de4..d7aac40 100644
--- a/src/dashboard/templates/dashboard/customer_list.html
+++ b/src/dashboard/templates/dashboard/customer_list.html
@@ -22,5 +22,24 @@
No customers
{% endfor %}
+
{% endblock content %}
diff --git a/src/dashboard/templates/dashboard/option_form.html b/src/dashboard/templates/dashboard/option_form.html
index e69de29..84f5538 100644
--- a/src/dashboard/templates/dashboard/option_form.html
+++ b/src/dashboard/templates/dashboard/option_form.html
@@ -0,0 +1,18 @@
+{% extends "dashboard.html" %}
+
+{% block content %}
+
+
+
+
+{% endblock %}
diff --git a/src/dashboard/templates/dashboard/order_detail.html b/src/dashboard/templates/dashboard/order_detail.html
index 0c325b8..c530b70 100644
--- a/src/dashboard/templates/dashboard/order_detail.html
+++ b/src/dashboard/templates/dashboard/order_detail.html
@@ -4,7 +4,10 @@
{% block content %}