adding tagcloud everywhere, patching the database into an unusable mess
git-svn-id: http://yolanda.mister-muffin.de/svn@419 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
76cbc8dde7
commit
05bdaab9f0
4 changed files with 43 additions and 14 deletions
|
@ -8,13 +8,7 @@ class IndexController(BaseController):
|
|||
|
||||
def index(self):
|
||||
|
||||
tags = {}
|
||||
for tag in model.DC_Subject.query.all():
|
||||
if tag.name in tags.keys():
|
||||
tags[tag.name]+=1
|
||||
else:
|
||||
tags[tag.name] = 1
|
||||
c.tagcloud = tags
|
||||
# TODO: write elixir devs a mail to see how this works un-hackish
|
||||
|
||||
return render('/xhtml/index.mako')
|
||||
|
||||
|
|
|
@ -59,18 +59,23 @@ class UploadController(BaseController):
|
|||
|
||||
# set up database entry
|
||||
|
||||
raise RuntimeError
|
||||
|
||||
video = model.Video(
|
||||
|
||||
# Dublin Core terms
|
||||
dc_title = request.params['dc_title'],
|
||||
dc_alternative = request.params['dc_title'],
|
||||
dc_subject = [model.DC_Subject(name=subject.lstrip()) for subject in request.params['dc_subject'].split(',')],
|
||||
dc_creator = model.DC_Creator(name = request.params['dc_creator']),
|
||||
|
||||
dc_subject = [model.DC_Subject(name=u'lol'), model.DC_Subject(name=u'wut')],
|
||||
# dc_subject = self.getsubjects(),
|
||||
# dc_creator = model.DC_Creator(name = request.params['dc_creator']),
|
||||
|
||||
dc_abstract = request.params['dc_abstract'],
|
||||
|
||||
# TODO: enable several contributors
|
||||
dc_contributor = [model.DC_Contributor(name=contributor.lstrip()) for contributor in request.params['dc_contributor'].split(',')],
|
||||
# dc_contributor = [model.DC_Contributor(name=contributor.lstrip()) for contributor in request.params['dc_contributor'].split(',')],
|
||||
# dc_contributor = [model.DC_Contributor(name=u'lol'), model.DC_Contributor(name=u'wut')],
|
||||
|
||||
# TODO: insert real data
|
||||
dc_created = datetime(9999,9,9).strftime("%Y-%m-%d %H:%M:%S"),
|
||||
|
@ -136,3 +141,13 @@ class UploadController(BaseController):
|
|||
videoencode = encode.Encode(source,destination)
|
||||
videoencode.run()
|
||||
os.unlink(source)
|
||||
|
||||
def getsubjects(self):
|
||||
dc_subject = []
|
||||
for subject in request.params['dc_subject'].split(','):
|
||||
s = model.DC_Subject.get_by(name=subject.lstrip())
|
||||
if s:
|
||||
dc_subject.append(s)
|
||||
else:
|
||||
dc_subject.append(model.DC_Subject(name=subject.lstrip()))
|
||||
return dc_subject
|
||||
|
|
|
@ -23,6 +23,18 @@ class BaseController(WSGIController):
|
|||
# available in environ['pylons.routes_dict']
|
||||
return WSGIController.__call__(self, environ, start_response)
|
||||
|
||||
def __before__(self):
|
||||
|
||||
tags = {}
|
||||
for tag in model.DC_Subject.query.all():
|
||||
if tag.name in tags.keys():
|
||||
tags[tag.name]+=1
|
||||
else:
|
||||
tags[tag.name] = 1
|
||||
c.tagcloud = tags
|
||||
|
||||
print "__before__ %s" % tags
|
||||
|
||||
# Include the '_' function in the public names
|
||||
__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \
|
||||
or __name == '_']
|
||||
|
|
|
@ -2,7 +2,7 @@ from elixir import *
|
|||
from sqlalchemy import UniqueConstraint
|
||||
|
||||
class Video(Entity):
|
||||
using_options(tablename='videos')
|
||||
# using_options(tablename='videos')
|
||||
|
||||
# Dublin Core terms
|
||||
dc_title = Field(Unicode(255))
|
||||
|
@ -45,15 +45,23 @@ class Video(Entity):
|
|||
# Dublin Core terms
|
||||
|
||||
class DC_Creator(Entity):
|
||||
name = Field(Unicode(255), unique = True)
|
||||
name = Field(Unicode(255), primary_key = True)
|
||||
videos = OneToMany('Video')
|
||||
|
||||
def __repr__(self):
|
||||
return '<Creator "%s">' % self.name
|
||||
|
||||
class DC_Subject(Entity):
|
||||
name = Field(Unicode(32), unique = True)
|
||||
name = Field(Unicode(32), primary_key = True)
|
||||
videos = ManyToMany('Video')
|
||||
|
||||
def __repr__(self):
|
||||
return '<Tag "%s">' % self.name
|
||||
|
||||
class DC_Contributor(Entity):
|
||||
name = Field(Unicode(255), unique = True)
|
||||
name = Field(Unicode(255), primary_key = True)
|
||||
videos = ManyToMany('Video')
|
||||
|
||||
def __repr__(self):
|
||||
return '<Contributor "%s">' % self.name
|
||||
|
||||
|
|
Loading…
Reference in a new issue