Skip to content

Instantly share code, notes, and snippets.

@jmwenda
Created February 10, 2012 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmwenda/1784845 to your computer and use it in GitHub Desktop.
Save jmwenda/1784845 to your computer and use it in GitHub Desktop.
masomo models
#have to add subject here because of the import
class Subject(models.Model):
name = models.CharField("Subject", max_length=45)
description = models.TextField("Description", max_length=255)
def __unicode__(self):
return self.name
@models.permalink
def get_absolute_url(self):
return ('curricula',(),{})
#lets deal with the contents here
class Chapter(models.Model):
subject = models.ForeignKey(Subject)
title = models.CharField("Title", max_length=45)
description = models.TextField("Description", max_length=255)
def __unicode__(self):
return self.title
@models.permalink
def get_absolute_url(self):
return ('chapters',(),{})
class Topic(models.Model):
chapter = models.ForeignKey(Chapter)
title = models.CharField("title", max_length=25)
def __unicode__(self):
return self.title
@models.permalink
def get_absolute_url(self):
return ('topics',(),{})
class Page(models.Model):
topic = models.ForeignKey(Topic)
pagelabel = models.CharField("Label", max_length=25)
def __unicode__(self):
return self.pagelabel
@models.permalink
def get_absolute_url(self):
return ('pages',(),{})
class Content(models.Model):
#subject = models.ForeignKey(Subject)
#chapter = ChainedForeignKey(Chapter, chained_field="subject", chained_model_field="subject")
#topic = ChainedForeignKey(Topic,chained_field="chapter",chained_model_field="chapter")
page = ChainedForeignKey(Page,chained_field="topic",chained_model_field="topic")
description = models.TextField("Description", max_length=255)
value = models.TextField("Value", max_length=255)
resource = models.FileField(upload_to='resources',blank="true")
def __unicode__(self):
return self.description
@models.permalink
def get_absolute_url(self):
return ('content',(),{})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment