heavy changes to models, beware

This commit is contained in:
Sanj 2011-09-06 08:27:15 +05:30
commit 20fadccaa4
4 changed files with 47 additions and 28 deletions

View File

@ -9,6 +9,7 @@ class TabsInline(admin.StackedInline):
class ModuleAdmin(admin.ModelAdmin):
inlines = [TabsInline]
prepopulated_fields = {'slug': ('title',)}
save_on_top = True
# list_display = ('name', 'order',)
# list_editable = ['order']

View File

@ -3,8 +3,8 @@ from django.contrib.contenttypes.models import ContentType
class Module(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField()
title = models.CharField(max_length=255, help_text="Title of Module. eg. Best Practices")
slug = models.SlugField(help_text="short name of module to be used for url. eg. bestpractices")
def __unicode__(self):
return self.title
@ -15,12 +15,13 @@ class Module(models.Model):
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)
title = models.CharField(max_length=64, help_text="Display title for tab")
slug = models.SlugField(help_text="short name for tab, to be used in url, eg. faq")
text = models.TextField(help_text="text to show up in LHS for tab")
model = models.ForeignKey("ModelExtra", help_text="Database model object tab is linked to (chose from list or ask for one to be created.)")
is_default = models.BooleanField(default=False, help_text="Whether this should be the default displayed tab.")
order = models.IntegerField(default=1, help_text="Make number higher to send it lower in order (default will always show first)")
is_displayed = models.BooleanField(default=True, help_text="Uncheck to hide tab")
class Meta:
ordering = ['-is_default', 'order']
@ -36,10 +37,12 @@ class ModuleTab(models.Model):
class ModelExtra(models.Model):
model = models.ForeignKey(ContentType)
friendly_name = models.CharField(max_length=128)
has_comments = models.BooleanField(default=False)
model = models.ForeignKey(ContentType, help_text="Chose from the list of death at your own peril.")
friendly_name = models.CharField(max_length=128, help_text="Used as display name in Admin, never to user. eg. Best Practices FAQ")
has_comments = models.BooleanField(default=False, help_text="Will there be comments attached to this?")
buttons = models.ManyToManyField('ModelButton', through='ModelExtraButton', blank=True)
has_list = models.BooleanField(default=True)
default_image = models.ImageField(upload_to='upload/images/model_defaults/', max_length=255, blank=True)
def __unicode__(self):
return self.friendly_name
@ -47,17 +50,18 @@ class ModelExtra(models.Model):
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)
operator = models.CharField(max_length=1, help_text="This should be either + or -.")
field_name = models.CharField(max_length=64, help_text="Name of field on which sorting should take place, eg. title")
friendly_name = models.CharField(max_length=128, help_text="And now, what shall we call it for the user? eg. By Title (A-Z)")
def __unicode__(self):
return self.friendly_name
class ModelButton(models.Model):
name = models.CharField(max_length=64)
template = models.TextField(blank=True)
name = models.CharField(max_length=64, help_text="Name of button, eg. Download")
icon = models.ImageField(upload_to='upload/images/button_icons/', blank=True, help_text="pretty icon for the button")
template = models.TextField(blank=True, help_text="you should never need to edit this field. please don't.")
def __unicode__(self):
return self.name
@ -66,5 +70,5 @@ class ModelButton(models.Model):
class ModelExtraButton(models.Model):
modelextra = models.ForeignKey(ModelExtra)
modelbutton = models.ForeignKey(ModelButton)
parameters = models.CharField(max_length=64, blank=True)
parameters = models.CharField(max_length=64, blank=True, help_text="if the button needs a parameter, give it here, if you dont know what this is, leave it blank.")

View File

@ -9,7 +9,7 @@ margin-left:auto;
position:relative;}
#leftColumn
{width:306px;
{width:300px;
height:620px; /*SANJ to change height in JS according to screen*/
background-color:#FFF;
margin-top:-8px; /*had to give this because of shadow*/
@ -21,7 +21,8 @@ border-radius:8px;
-webkit-box-shadow:2px 3px 20px #252425;
box-shadow:2px 3px 20px #252425;
position:relative;
float:left;}
float:left;
padding-right:6px;}
#topText
{font-size:24px;
@ -149,27 +150,37 @@ clear:both;}
{padding-top:6px;}
.selectMenu select
{color:#3B3B39;
{border:1px solid #f7bd00;
background-color:#f7bd00;
color:#3B3B39;
-moz-border-radius:8px;
-webkit-border-radius:8px;
border-radius:8px;
border:2px outset #f0f0f0;
background-color:#f0f0f0;
/*background-color:#f0f0f0;*/
outline:none;}
.selectMenu select:focus
{border:1px solid #f7bd00;
background-color:#f7bd00;}
{}
#listLeft
{position:relative;}
{position:relative;
}
.tabListItem
{text-overflow:ellipsis;
overflow:hidden;
white-space:nowrap;
width:100%;}
#listLeft ul
{color:#f7bd00;
{color:#898989; /*was originally f7bd00*/
list-style-image:url(/static/images/noel/disc.png);
list-style-type:disc;
list-style-position:inside;
padding-left:16px;
overflow:hidden; /*this prevents the box shadow from sticking out on the right*/}
overflow:hidden; /*this prevents the box shadow from sticking out on the right*/
}
#listLeft ul span
{color:#898989;}
@ -184,6 +195,8 @@ padding-bottom:6px;
cursor:pointer;
}
#listLeft ul li a, #listLeft ul li a:link, #listLeft ul li a:visited, #listLeft ul li a:active
{color:#898989;
text-decoration:none;}
@ -288,7 +301,8 @@ clear:both;}
height:100%; /*IS THIS REQUIRED??*/
background-color:#FFF;
color:#3b3b39;
font-size:12.5px;
font-size:14px;
line-height:16px;
font-family:Arial, Helvetica, 'DejaVu Sans', sans-serif;
padding:20px;
margin-top:20px;

View File

@ -67,7 +67,7 @@
<ul>
<li id="loadingList">Loading...</li>
{% for l in default_list %}
<li class="tabListItem"><a href="{{ l.url }}" data-id="{{ l.id }}"><span>{{ l.title|slice:"30" }}{% if l.title|length > 30 %}...{% endif %}</span></a></li>
<li class="tabListItem"><a href="{{ l.url }}" data-id="{{ l.id }}"><span>{{ l.title }}</span></a></li>
{% endfor %}
<!-- <li><a href=""><span>The Mystery of vanishing rights<span></a></li> -->
</ul>