2011-08-22 22:04:40 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
|
|
|
|
|
|
|
|
class Module(models.Model):
|
|
|
|
title = models.CharField(max_length=255)
|
|
|
|
slug = models.SlugField()
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
|
|
|
return "/m/" + self.slug
|
|
|
|
|
|
|
|
|
|
|
|
class ModuleTab(models.Model):
|
|
|
|
module = models.ForeignKey(Module)
|
|
|
|
title = models.CharField(max_length=64)
|
|
|
|
text = models.TextField()
|
2011-08-27 10:54:45 +00:00
|
|
|
model = models.ForeignKey("ModelExtra")
|
2011-08-22 22:04:40 +00:00
|
|
|
is_default = models.BooleanField(default=False)
|
|
|
|
order = models.IntegerField(default=1)
|
|
|
|
is_displayed = models.BooleanField(default=True)
|
|
|
|
|
2011-08-25 09:39:15 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ['-is_default', 'order']
|
|
|
|
|
2011-08-22 22:04:40 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
|
|
|
|
2011-08-27 10:54:45 +00:00
|
|
|
def model_class(self):
|
|
|
|
return self.model.model.model_class()
|
|
|
|
|
2011-08-22 22:04:40 +00:00
|
|
|
def get_list(self, options):
|
2011-08-27 10:54:45 +00:00
|
|
|
return self.model_class().get_list(options)
|
|
|
|
|
|
|
|
|
|
|
|
class ModelExtra(models.Model):
|
|
|
|
model = models.ForeignKey(ContentType)
|
|
|
|
friendly_name = models.CharField(max_length=128)
|
|
|
|
has_comments = models.BooleanField(default=False)
|
|
|
|
buttons = models.ManyToManyField('ModelButton', through='ModelExtraButton', blank=True)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.friendly_name
|
|
|
|
|
|
|
|
|
|
|
|
class ModelSort(models.Model):
|
|
|
|
model = models.ForeignKey(ModelExtra)
|
|
|
|
operator = models.CharField(max_length=1)
|
|
|
|
field_name = models.CharField(max_length=64)
|
|
|
|
friendly_name = models.CharField(max_length=128)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.friendly_name
|
|
|
|
|
|
|
|
|
|
|
|
class ModelButton(models.Model):
|
|
|
|
name = models.CharField(max_length=64)
|
|
|
|
template = models.TextField(blank=True)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class ModelExtraButton(models.Model):
|
|
|
|
modelextra = models.ForeignKey(ModelExtra)
|
|
|
|
modelbutton = models.ForeignKey(ModelButton)
|
|
|
|
parameters = models.CharField(max_length=64, blank=True)
|
2011-08-22 22:04:40 +00:00
|
|
|
|