2011-10-13 23:34:56 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2010-04-15 14:41:08 +02:00
|
|
|
import datetime
|
2011-10-13 23:34:56 +02:00
|
|
|
|
2010-03-27 16:54:31 +01:00
|
|
|
from django.db import models
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
2011-10-13 23:34:56 +02:00
|
|
|
|
2010-04-21 18:34:33 +02:00
|
|
|
def standalone_number(self):
|
|
|
|
return 1
|
|
|
|
|
2010-04-15 14:41:08 +02:00
|
|
|
class Numbers(object):
|
2010-04-21 18:34:33 +02:00
|
|
|
@staticmethod
|
|
|
|
def get_static_number(self):
|
|
|
|
return 2
|
2010-04-15 14:41:08 +02:00
|
|
|
|
|
|
|
@classmethod
|
2010-04-21 18:34:33 +02:00
|
|
|
def get_class_number(self):
|
|
|
|
return 3
|
|
|
|
|
|
|
|
def get_member_number(self):
|
|
|
|
return 4
|
|
|
|
|
|
|
|
nn = Numbers()
|
2010-04-15 14:41:08 +02:00
|
|
|
|
2010-03-27 16:54:31 +01:00
|
|
|
class Group(models.Model):
|
|
|
|
name = models.CharField(_('name'), max_length=100)
|
|
|
|
|
|
|
|
class Event(models.Model):
|
|
|
|
group = models.ForeignKey(Group)
|
2010-04-15 14:41:08 +02:00
|
|
|
|
|
|
|
class Happening(models.Model):
|
|
|
|
when = models.DateTimeField(blank=True, default=datetime.datetime.now)
|
|
|
|
name = models.CharField(blank=True, max_length=100, default=lambda:"test")
|
2010-04-21 18:34:33 +02:00
|
|
|
number1 = models.IntegerField(blank=True, default=standalone_number)
|
|
|
|
number2 = models.IntegerField(blank=True, default=Numbers.get_static_number)
|
|
|
|
number3 = models.IntegerField(blank=True, default=Numbers.get_class_number)
|
|
|
|
number4 = models.IntegerField(blank=True, default=nn.get_member_number)
|