chg: revamped fistures !minor

This commit is contained in:
cătălin 2021-01-25 14:59:23 +01:00
commit 66b8c1bc53
8 changed files with 185 additions and 56 deletions

View file

@ -25,7 +25,13 @@ EMAIL_HOST_PASSWORD = "somepassword"
EMAIL_USE_TLS = True
```
- this will send an email when calling `/api/orders/{order}/sent` which will render `bernini/templates/order_sold.html` as body
#### fixtures
```bash
./wrapper.sh m loaddata users
./wrapper.sh m loaddata products
./wrapper.sh m loaddata product
./wrapper.sh m loaddata lines
```
### api
- based on [Django REST framework](https://www.django-rest-framework.org/)
- auth system using and extending django's `contrib.auth`

42
order/fixtures/lines.json Normal file
View file

@ -0,0 +1,42 @@
[
{
"model": "order.saleorderline",
"pk": 1,
"fields": {
"name": "sol 1",
"product": 1,
"order": 1,
"quantity": 5
}
},
{
"model": "order.saleorderline",
"pk": 2,
"fields": {
"name": "sol 2",
"product": 2,
"order": 1,
"quantity": 1
}
},
{
"model": "order.saleorderline",
"pk": 3,
"fields": {
"name": "sol 3",
"product": 3,
"order": 2,
"quantity": 3
}
},
{
"model": "order.saleorderline",
"pk": 4,
"fields": {
"name": "sol 4",
"product": 4,
"order": 2,
"quantity": 25
}
}
]

View file

@ -1,54 +0,0 @@
[
{
"model": "django.contrib.auth.models.User",
"pk": 100,
"fields": {
"username": "alovelace",
"first_name": "Ada",
"last_name": "Lovelace",
"email": "alovelace@berni.ni",
"password": "alovelace"
}
},
{
"model": "django.contrib.auth.models.User",
"pk": 200,
"fields": {
"username": "ltorvalds",
"first_name": "Linus",
"last_name": "Torvalds",
"email": "ltorvalds@berni.ni",
"password": "ltorvalds"
}
},
{
"model": "django.contrib.auth.models.User",
"pk": 300,
"fields": {
"username": "dritchie",
"first_name": "Dennis",
"last_name": "Ritchie",
"email": "dritchie@berni.ni",
"password": "dritchie"
}
},
{
"model": "django.contrib.auth.models.User",
"pk": 400,
"fields": {
"username": "kthompson",
"first_name": "Ken",
"last_name": "Thompson",
"email": "kthompson@berni.ni",
"password": "kthompson"
}
},
{
"model": "SaleOrder",
"pk": 1,
"fields": {
"name": "Ken's first sale order",
"user": 400
}
}
]

View file

@ -0,0 +1,22 @@
[
{
"model": "order.saleorder",
"pk": 1,
"fields": {
"name": "Laurentius' first quote",
"sold_to": 5,
"total": 2749.94,
"sold_at": "2021-01-25T00:47:01Z"
}
},
{
"model": "order.saleorder",
"pk": 2,
"fields": {
"name": "Laurentius' second quote",
"sold_to": 5,
"total": 6499.72,
"sold_at": "2021-01-25T13:49:02Z"
}
}
]

View file

@ -0,0 +1,34 @@
[
{
"model": "order.product",
"pk": 1,
"fields": {
"name": "Boots of the Explorer",
"unit_price": 499.99
}
},
{
"model": "order.product",
"pk": 2,
"fields": {
"name": "Lord's Blade Waistcloth",
"unit_price": 249.99
}
},
{
"model": "order.product",
"pk": 3,
"fields": {
"name": "Leggings of Favor",
"unit_price": 499.99
}
},
{
"model": "order.product",
"pk": 4,
"fields": {
"name": "Brigand Trousers",
"unit_price": 199.99
}
}
]

View file

@ -0,0 +1,23 @@
# Generated by Django 3.1.5 on 2021-01-25 13:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('order', '0002_auto_20210124_2304'),
]
operations = [
migrations.AlterField(
model_name='product',
name='unit_price',
field=models.FloatField(default=0),
),
migrations.AlterField(
model_name='saleorderline',
name='quantity',
field=models.IntegerField(default=1),
),
]

View file

@ -50,7 +50,7 @@ class SaleOrder(BaseModel):
class Product(models.Model):
name = models.CharField(max_length=200)
unit_price = models.IntegerField(default=0)
unit_price = models.FloatField(default=0)
class SaleOrderLine(models.Model):

56
users/fixtures/users.json Normal file
View file

@ -0,0 +1,56 @@
[
{
"model": "auth.user",
"pk": 1,
"fields": {
"password": "pbkdf2_sha256$216000$XUCdRSZgidku$tsan8mpxMengfd7rL5THvqofYTyZk9ko90hd+/OrV6A=",
"last_login": "2021-01-25T13:44:36Z",
"is_superuser": true,
"username": "admin",
"first_name": "Admin",
"last_name": "",
"email": "admin@berni.ni",
"is_staff": true,
"is_active": true,
"date_joined": "2021-01-19T21:47:24Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 4,
"fields": {
"password": "pbkdf2_sha256$216000$qLORqdXRy45f$8JXtnVZbhvIFJh3rWpBiJko4PBVrUsGh4R3dAYOA7kg=",
"last_login": null,
"is_superuser": false,
"username": "solaire@berni.ni",
"first_name": "Solaire",
"last_name": "of Astora",
"email": "solaire@berni.ni",
"is_staff": true,
"is_active": true,
"date_joined": "2021-01-25T13:43:07Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 5,
"fields": {
"password": "pbkdf2_sha256$216000$KzsdPkNXwOlk$CgXZPR6B+If9V1YoudPEreQYtxxNB8a0zIyikiOH5Tw=",
"last_login": null,
"is_superuser": false,
"username": "laurentius@berni.ni",
"first_name": "Laurentius",
"last_name": "of the Great Swamp",
"email": "laurentius@berni.ni",
"is_staff": true,
"is_active": true,
"date_joined": "2021-01-25T13:43:46Z",
"groups": [],
"user_permissions": []
}
}
]