it/itf/insidepages/models.py

71 lines
1.9 KiB
Python

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()
model = models.ForeignKey("ModelExtra")
is_default = models.BooleanField(default=False)
order = models.IntegerField(default=1)
is_displayed = models.BooleanField(default=True)
class Meta:
ordering = ['-is_default', 'order']
def __unicode__(self):
return self.title
def model_class(self):
return self.model.model.model_class()
def get_list(self, options):
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)