first cut of oil archive model and some exposure via the controller

This commit is contained in:
j 2007-03-20 15:52:10 +00:00
commit cf7248c95d
7 changed files with 168 additions and 41 deletions

View file

@ -1,10 +1,52 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2
from datetime import datetime
from turbogears.database import PackageHub
from sqlobject import *
from turbogears import identity
hub = PackageHub("oilarchive")
__connection__ = hub
class ArchiveItem(SQLObject):
hash = UnicodeCol(alternateId = True)
title = UnicodeCol()
description = UnicodeCol()
author = UnicodeCol()
text = UnicodeCol() #Fulltext
url = UnicodeCol()
downloadURL = UnicodeCol()
icon = UnicodeCol()
releaseDate = DateTimeCol()
pubDate = DateTimeCol()
size = IntCol()
rights = IntCol() #-> int: 0 (free) - 5 (unfree)
archiveName = UnicodeCol()
archiveType = UnicodeCol()
def _get_year(self):
return self.releaseDate.strftime('%Y')
def _get_json(self):
return dict(
title = self.title,
description = self.description,
author = self.author,
url = self.url,
icon = '/view/%s/icon' % self.hash,
releaseDate = self.releaseDate,
pubDate = self.pubDate,
size = self.size,
)
def Archive(SQLObject):
archiveName = UnicodeCol()
url = UnicodeCol()
archiveType = UnicodeCol()
# identity models.
class Visit(SQLObject):