|
3 | 3 | from abc import abstractmethod |
4 | 4 | from collections import Counter |
5 | 5 | from email.utils import parseaddr |
| 6 | +from datetime import datetime |
6 | 7 |
|
7 | 8 | from django.contrib.admin.models import LogEntry, ADDITION, CHANGE |
8 | 9 | from django.contrib.auth.models import User |
@@ -44,16 +45,17 @@ class NoMoreInventoryError(Exception): |
44 | 45 | pass |
45 | 46 |
|
46 | 47 |
|
47 | | - |
48 | 48 | # Create your models here. |
49 | 49 |
|
| 50 | + |
50 | 51 | class BaseModel(models.Model): |
51 | 52 | created_at = models.DateTimeField(auto_now_add=True) |
52 | 53 | updated_at = models.DateTimeField(auto_now=True) |
53 | 54 |
|
54 | 55 | class Meta: |
55 | 56 | abstract = True |
56 | 57 |
|
| 58 | + |
57 | 59 | # So we have two "basic" operations to do with money |
58 | 60 | # we can take money from a user and we can give them money |
59 | 61 | # the class names here are written from the perspective of |
@@ -99,7 +101,8 @@ def __init__(self, product, order, count): |
99 | 101 |
|
100 | 102 | def price(self): |
101 | 103 | return self.product.price * self.count |
102 | | - |
| 104 | + |
| 105 | + |
103 | 106 | class Order(object): |
104 | 107 | def __init__(self, member, room, items=None): |
105 | 108 | self.member = member |
@@ -688,6 +691,7 @@ class Sale(BaseModel): |
688 | 691 | room = models.ForeignKey(Room, on_delete=models.CASCADE, null=True) |
689 | 692 | timestamp = models.DateTimeField(auto_now_add=True) |
690 | 693 | price = models.IntegerField() |
| 694 | + |
691 | 695 | class Meta(BaseModel.Meta): |
692 | 696 | index_together = [ |
693 | 697 | ["product", "timestamp"], |
|
0 commit comments