Browse Source

k4ever django project - db online!

seba 11 years ago
parent
commit
5acc7b8d29

+ 0
- 0
k4ever/__init__.py View File


+ 0
- 0
k4ever/buyable/__init__.py View File


+ 7
- 0
k4ever/buyable/admin.py View File

@@ -0,0 +1,7 @@
1
+from models import Buyable, BuyableType, Purchase
2
+from django.contrib import admin
3
+
4
+admin.site.register(Buyable)
5
+admin.site.register(BuyableType)
6
+admin.site.register(Purchase)
7
+

+ 31
- 0
k4ever/buyable/models.py View File

@@ -0,0 +1,31 @@
1
+from django.db import models
2
+from django.contrib.auth.models import User
3
+
4
+# Create your models here.
5
+class BuyableType(models.Model):
6
+	name = models.CharField(max_length=100)
7
+	
8
+	def __unicode__(self):
9
+		return self.name
10
+
11
+
12
+class Buyable(models.Model):
13
+	name = models.CharField(max_length=100)
14
+	price = models.FloatField()
15
+	image = models.ImageField(upload_to='img/buyable/')
16
+	deposit = models.FloatField()
17
+	description = models.TextField()
18
+	buyableType = models.ManyToManyField(BuyableType)
19
+	
20
+	def __unicode__(self):
21
+		return "%s (%s EUR/%s Pfand)" % (self.name, self.price, self.deposit)
22
+
23
+class Purchase(models.Model):
24
+	user = models.ForeignKey(User)
25
+	dateTime = models.DateTimeField()
26
+	price = models.FloatField()
27
+	isDeposit = models.BooleanField()
28
+	buyable = models.ForeignKey(Buyable)
29
+	
30
+	def __unicode__(self):
31
+		return "%s%s, %s by %s" % (self.buyable.name, self.isDeposit and " (deposit)" or "", self.price, self.user)

+ 23
- 0
k4ever/buyable/tests.py View File

@@ -0,0 +1,23 @@
1
+"""
2
+This file demonstrates two different styles of tests (one doctest and one
3
+unittest). These will both pass when you run "manage.py test".
4
+
5
+Replace these with more appropriate tests for your application.
6
+"""
7
+
8
+from django.test import TestCase
9
+
10
+class SimpleTest(TestCase):
11
+    def test_basic_addition(self):
12
+        """
13
+        Tests that 1 + 1 always equals 2.
14
+        """
15
+        self.failUnlessEqual(1 + 1, 2)
16
+
17
+__test__ = {"doctest": """
18
+Another way to test that 1 + 1 is equal to 2.
19
+
20
+>>> 1 + 1 == 2
21
+True
22
+"""}
23
+

+ 1
- 0
k4ever/buyable/views.py View File

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

BIN
k4ever/k4ever.db View File


+ 0
- 0
k4ever/main/__init__.py View File


+ 6
- 0
k4ever/main/models.py View File

@@ -0,0 +1,6 @@
1
+from django.db import models
2
+from django.contrib.auth.models import User
3
+
4
+class UserProfile(models.Model):
5
+	user = models.ForeignKey(User, unique=True)
6
+	balance = models.FloatField()

+ 23
- 0
k4ever/main/tests.py View File

@@ -0,0 +1,23 @@
1
+"""
2
+This file demonstrates two different styles of tests (one doctest and one
3
+unittest). These will both pass when you run "manage.py test".
4
+
5
+Replace these with more appropriate tests for your application.
6
+"""
7
+
8
+from django.test import TestCase
9
+
10
+class SimpleTest(TestCase):
11
+    def test_basic_addition(self):
12
+        """
13
+        Tests that 1 + 1 always equals 2.
14
+        """
15
+        self.failUnlessEqual(1 + 1, 2)
16
+
17
+__test__ = {"doctest": """
18
+Another way to test that 1 + 1 is equal to 2.
19
+
20
+>>> 1 + 1 == 2
21
+True
22
+"""}
23
+

+ 1
- 0
k4ever/main/views.py View File

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

+ 11
- 0
k4ever/manage.py View File

@@ -0,0 +1,11 @@
1
+#!/usr/bin/env python
2
+from django.core.management import execute_manager
3
+try:
4
+    import settings # Assumed to be in the same directory.
5
+except ImportError:
6
+    import sys
7
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
8
+    sys.exit(1)
9
+
10
+if __name__ == "__main__":
11
+    execute_manager(settings)

+ 0
- 0
k4ever/media/css/style.css View File


+ 0
- 0
k4ever/media/img/buyable/.dummy View File


+ 0
- 0
k4ever/media/js/.dummy View File


+ 101
- 0
k4ever/settings.py View File

@@ -0,0 +1,101 @@
1
+# Django settings for k4ever project.
2
+
3
+DEBUG = True
4
+TEMPLATE_DEBUG = DEBUG
5
+
6
+ADMINS = (
7
+    # ('Your Name', 'your_email@domain.com'),
8
+)
9
+
10
+MANAGERS = ADMINS
11
+
12
+DATABASES = {
13
+    'default': {
14
+        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
15
+        'NAME': 'k4ever.db',                      # Or path to database file if using sqlite3.
16
+        'USER': '',                      # Not used with sqlite3.
17
+        'PASSWORD': '',                  # Not used with sqlite3.
18
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
19
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
20
+    }
21
+}
22
+
23
+# Local time zone for this installation. Choices can be found here:
24
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
25
+# although not all choices may be available on all operating systems.
26
+# On Unix systems, a value of None will cause Django to use the same
27
+# timezone as the operating system.
28
+# If running in a Windows environment this must be set to the same as your
29
+# system time zone.
30
+TIME_ZONE = 'Germany/Berlin'
31
+
32
+# Language code for this installation. All choices can be found here:
33
+# http://www.i18nguy.com/unicode/language-identifiers.html
34
+LANGUAGE_CODE = 'de-de'
35
+
36
+SITE_ID = 1
37
+
38
+# If you set this to False, Django will make some optimizations so as not
39
+# to load the internationalization machinery.
40
+USE_I18N = True
41
+
42
+# If you set this to False, Django will not format dates, numbers and
43
+# calendars according to the current locale
44
+USE_L10N = True
45
+
46
+# Absolute path to the directory that holds media.
47
+# Example: "/home/media/media.lawrence.com/"
48
+MEDIA_ROOT = 'media/'
49
+
50
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
51
+# trailing slash if there is a path component (optional in other cases).
52
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
53
+MEDIA_URL = 'media/'
54
+
55
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
56
+# trailing slash.
57
+# Examples: "http://foo.com/media/", "/media/".
58
+ADMIN_MEDIA_PREFIX = '/media/admin/'
59
+
60
+# Make this unique, and don't share it with anybody.
61
+SECRET_KEY = 'l(f*a$l)_n_n_5#lh@rvhv(na^!lj1u#bow=c!*90(1w$5%b^j'
62
+
63
+# User Profile
64
+AUTH_PROFILE_MODULE = 'main.models.UserProfile'
65
+
66
+# List of callables that know how to import templates from various sources.
67
+TEMPLATE_LOADERS = (
68
+    'django.template.loaders.filesystem.Loader',
69
+    'django.template.loaders.app_directories.Loader',
70
+	'django.template.loaders.app_directories.load_template_source',
71
+#     'django.template.loaders.eggs.Loader',
72
+)
73
+
74
+MIDDLEWARE_CLASSES = (
75
+    'django.middleware.common.CommonMiddleware',
76
+    'django.contrib.sessions.middleware.SessionMiddleware',
77
+    'django.middleware.csrf.CsrfViewMiddleware',
78
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
79
+    'django.contrib.messages.middleware.MessageMiddleware',
80
+)
81
+
82
+ROOT_URLCONF = 'k4ever.urls'
83
+
84
+TEMPLATE_DIRS = (
85
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
86
+    # Always use forward slashes, even on Windows.
87
+    # Don't forget to use absolute paths, not relative paths.
88
+)
89
+
90
+INSTALLED_APPS = (
91
+    'django.contrib.auth',
92
+    'django.contrib.contenttypes',
93
+    'django.contrib.sessions',
94
+    'django.contrib.sites',
95
+    'django.contrib.messages',
96
+	'buyable',
97
+	'transaction',
98
+	'main',
99
+    # Uncomment the next line to enable the admin:
100
+    'django.contrib.admin',
101
+)

+ 0
- 0
k4ever/transaction/__init__.py View File


+ 5
- 0
k4ever/transaction/admin.py View File

@@ -0,0 +1,5 @@
1
+from models import Transaction, TransactionType
2
+from django.contrib import admin
3
+
4
+admin.site.register(Transaction)
5
+admin.site.register(TransactionType)

+ 23
- 0
k4ever/transaction/models.py View File

@@ -0,0 +1,23 @@
1
+from django.db import models
2
+from django.contrib.auth.models import User
3
+
4
+
5
+class TransactionType(models.Model):
6
+	name = models.CharField(max_length=100)
7
+	needsCheck = models.BooleanField(default=True)
8
+	
9
+	def __unicode__(self):
10
+		return self.name + (self.needsCheck and  " (needs Check)" or "")
11
+
12
+class Transaction(models.Model):
13
+	user = models.ForeignKey(User, unique=True)
14
+	transactionType = models.ForeignKey(TransactionType)
15
+	dateTime = models.DateTimeField()
16
+	amount = models.FloatField()
17
+	checked = models.BooleanField(default=False)
18
+	
19
+	def __unicode__(self):
20
+		return "%s for user %s (%s), %schecked" % (self.amount, self.user, self.transactionType, (self.checked and "" or "not "))
21
+
22
+
23
+

+ 23
- 0
k4ever/transaction/tests.py View File

@@ -0,0 +1,23 @@
1
+"""
2
+This file demonstrates two different styles of tests (one doctest and one
3
+unittest). These will both pass when you run "manage.py test".
4
+
5
+Replace these with more appropriate tests for your application.
6
+"""
7
+
8
+from django.test import TestCase
9
+
10
+class SimpleTest(TestCase):
11
+    def test_basic_addition(self):
12
+        """
13
+        Tests that 1 + 1 always equals 2.
14
+        """
15
+        self.failUnlessEqual(1 + 1, 2)
16
+
17
+__test__ = {"doctest": """
18
+Another way to test that 1 + 1 is equal to 2.
19
+
20
+>>> 1 + 1 == 2
21
+True
22
+"""}
23
+

+ 1
- 0
k4ever/transaction/views.py View File

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

+ 17
- 0
k4ever/urls.py View File

@@ -0,0 +1,17 @@
1
+from django.conf.urls.defaults import *
2
+
3
+# Uncomment the next two lines to enable the admin:
4
+from django.contrib import admin
5
+admin.autodiscover()
6
+
7
+urlpatterns = patterns('',
8
+    # Example:
9
+    # (r'^k4ever/', include('k4ever.foo.urls')),
10
+
11
+    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
12
+    # to INSTALLED_APPS to enable admin documentation:
13
+    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
14
+
15
+    # Uncomment the next line to enable the admin:
16
+    (r'^admin/', include(admin.site.urls)),
17
+)

Loading…
Cancel
Save