Frederic
11 years ago
7 changed files with 71 additions and 3 deletions
@ -0,0 +1,8 @@ |
|||||||
|
from django.contrib import admin |
||||||
|
from cash.models import * |
||||||
|
|
||||||
|
admin.site.register(Account) |
||||||
|
admin.site.register(Product) |
||||||
|
admin.site.register(ProductBarcode) |
||||||
|
admin.site.register(ProductCategory) |
||||||
|
|
@ -0,0 +1,40 @@ |
|||||||
|
from django.db import models |
||||||
|
from django.contrib.auth.models import User |
||||||
|
|
||||||
|
class Account(models.Model): |
||||||
|
user = models.OneToOneField(User) |
||||||
|
card_number = models.CharField(max_length=32) |
||||||
|
pin = models.CharField(max_length=32) |
||||||
|
daily_digest = models.BooleanField() |
||||||
|
credit = models.IntegerField() |
||||||
|
|
||||||
|
class ProductCategory(models.Model): |
||||||
|
name = models.CharField(max_length=32) |
||||||
|
comment = models.CharField(max_length=128, blank=True) |
||||||
|
|
||||||
|
class Product(models.Model): |
||||||
|
name = models.CharField(max_length=32) |
||||||
|
price = models.IntegerField() |
||||||
|
deleted = models.BooleanField() |
||||||
|
category = models.ForeignKey(ProductCategory, blank=True, null=True) |
||||||
|
|
||||||
|
class ProductBarcode(models.Model): |
||||||
|
barcode = models.CharField(max_length=32) |
||||||
|
comment = models.CharField(max_length=128) |
||||||
|
product = models.ForeignKey(Product) |
||||||
|
|
||||||
|
class Transaction(models.Model): |
||||||
|
account = models.ForeignKey(Account) |
||||||
|
timestamp = models.DateTimeField(auto_now_add=True) |
||||||
|
subject = models.CharField(max_length=32) |
||||||
|
description = models.TextField() |
||||||
|
amount = models.IntegerField() |
||||||
|
|
||||||
|
class SalesLogEntry(models.Model): |
||||||
|
account = models.ForeignKey(Account) |
||||||
|
product = models.ForeignKey(Product) |
||||||
|
count = models.IntegerField() |
||||||
|
unit_price = models.IntegerField() |
||||||
|
timestamp = models.DateTimeField(auto_now_add=True) |
||||||
|
|
||||||
|
|
@ -0,0 +1,16 @@ |
|||||||
|
""" |
||||||
|
This file demonstrates writing tests using the unittest module. These will pass |
||||||
|
when you run "manage.py test". |
||||||
|
|
||||||
|
Replace this with more appropriate tests for your application. |
||||||
|
""" |
||||||
|
|
||||||
|
from django.test import TestCase |
||||||
|
|
||||||
|
|
||||||
|
class SimpleTest(TestCase): |
||||||
|
def test_basic_addition(self): |
||||||
|
""" |
||||||
|
Tests that 1 + 1 always equals 2. |
||||||
|
""" |
||||||
|
self.assertEqual(1 + 1, 2) |
Loading…
Reference in new issue