adding karma 'app'

This commit is contained in:
Mike Bloy 2011-01-09 12:51:12 -06:00
parent da313800b9
commit 154eb9753f
6 changed files with 64 additions and 3 deletions

0
botweb/karma/__init__.py Normal file
View File

33
botweb/karma/models.py Normal file
View File

@ -0,0 +1,33 @@
from django.db import models
class LogEntry(models.Model):
id = models.IntegerField(primary_key=True)
key = models.CharField(max_length=255)
delta = models.IntegerField(choices=((1, u'++'), (-1, u'--')))
who = models.CharField(max_length=30)
userhost = models.CharField(max_length=512)
timestamp = models.DateTimeField(db_column='karmatime')
class Meta:
db_table = 'karma_log'
ordering = ['timestamp']
managed = False
class User(models.Model):
who = models.CharField(max_length=30, primary_key=True)
pos = models.IntegerField()
neg = models.IntegerField()
class Meta:
db_table = 'karma_users'
ordering = ['who']
managed = False
class Value(models.Model):
key = models.CharField(max_length=255, primary_key=True)
value = models.IntegerField()
class Meta:
db_table = 'karma_values'
ordering = ['value']
managed = False

23
botweb/karma/tests.py Normal file
View File

@ -0,0 +1,23 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these 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.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

1
botweb/karma/views.py Normal file
View File

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

View File

@ -6,7 +6,7 @@ DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
('Mike Bloy', 'mike@bloy.org'),
)
MANAGERS = ADMINS

View File

@ -4,7 +4,11 @@ from django.conf.urls.defaults import *
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
urlpatterns = patterns(
'',
(r'^karma/$', 'karma.views.index'),
(r'^karma/givers/$', 'karma.views.givers'),
(r'^karma/stats/$', 'karma.views.stats'),
# Example:
# (r'^botweb/', include('botweb.foo.urls')),