Browse Source

cash app, including model

master
Frederic 11 years ago
parent
commit
4ea8f52923
  1. 0
      cash/__init__.py
  2. 8
      cash/admin.py
  3. 40
      cash/models.py
  4. 16
      cash/tests.py
  5. 1
      cash/views.py
  6. 3
      lugcash2/settings.py
  7. 6
      lugcash2/urls.py

0
cash/__init__.py

8
cash/admin.py

@ -0,0 +1,8 @@ @@ -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)

40
cash/models.py

@ -0,0 +1,40 @@ @@ -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)

16
cash/tests.py

@ -0,0 +1,16 @@ @@ -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)

1
cash/views.py

@ -0,0 +1 @@ @@ -0,0 +1 @@
# Create your views here.

3
lugcash2/settings.py

@ -123,6 +123,9 @@ INSTALLED_APPS = ( @@ -123,6 +123,9 @@ INSTALLED_APPS = (
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'django_evolution',
'cash'
)
# A sample logging configuration. The only tangible logging

6
lugcash2/urls.py

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
@ -13,5 +13,5 @@ urlpatterns = patterns('', @@ -13,5 +13,5 @@ urlpatterns = patterns('',
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', include(admin.site.urls)),
)

Loading…
Cancel
Save