From 56f3b54f6ab4807ed6af8d5a0ffbceb89119f2af Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 24 Oct 2011 03:13:38 +0100 Subject: [PATCH] script licenses list --- itf/scriptbank/models.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/itf/scriptbank/models.py b/itf/scriptbank/models.py index 068a104..c4e7cf7 100755 --- a/itf/scriptbank/models.py +++ b/itf/scriptbank/models.py @@ -99,7 +99,7 @@ class Script(ItfModel): -class License(models.Model): +class License(ItfModel): letter = models.CharField(max_length=2) name = models.CharField(max_length=255) short_description = models.TextField() @@ -107,9 +107,26 @@ class License(models.Model): legal_file = models.FileField(upload_to='upload/licenses/legal/') typ = models.CharField(choices=LICENSE_TYPE_CHOICES, max_length=32) + title_field = 'name' + def __unicode__(self): return self.typ + ": " + self.letter + ": " + self.name + def list_dict(self): + return { + 'id': self.id, + 'title': self.name + } + + def info_dict(self): + return { + 'id': self.id, + 'letter': self.letter, + 'short_description': self.short_description, + 'readable_file': self.readable_file.url, + 'legal_file': self.legal_file.url, + 'typ': self.typ + } class Review(models.Model): script = models.ForeignKey(Script)