new database format, rudimentary search function
git-svn-id: http://yolanda.mister-muffin.de/svn@414 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
1b78258dbf
commit
002e384004
4 changed files with 46 additions and 21 deletions
|
@ -7,6 +7,10 @@ log = logging.getLogger(__name__)
|
||||||
class AccountController(BaseController):
|
class AccountController(BaseController):
|
||||||
|
|
||||||
def index(self):
|
def index(self):
|
||||||
|
c.message = {
|
||||||
|
'type': 'warning',
|
||||||
|
'text': 'Your username will be saved indefinitely.'
|
||||||
|
}
|
||||||
return render('/xhtml/account.mako')
|
return render('/xhtml/account.mako')
|
||||||
|
|
||||||
def __before__(self):
|
def __before__(self):
|
||||||
|
@ -17,16 +21,16 @@ class AccountController(BaseController):
|
||||||
#FIXME: do not operate in stateless mode - replace store with local
|
#FIXME: do not operate in stateless mode - replace store with local
|
||||||
# openid store (app global) to make login faster with less overhead
|
# openid store (app global) to make login faster with less overhead
|
||||||
self.consumer = Consumer(self.openid_session, None)
|
self.consumer = Consumer(self.openid_session, None)
|
||||||
openid = request.params.get('username', None)
|
openid = request.params.get('openid_identifier', None)
|
||||||
try:
|
try:
|
||||||
authrequest = self.consumer.begin(openid)
|
authrequest = self.consumer.begin(openid)
|
||||||
except DiscoveryFailure, e:
|
except DiscoveryFailure, e:
|
||||||
# invalid openid
|
# invalid openid
|
||||||
c.message = {
|
c.message = {
|
||||||
'type': 'error',
|
'type': 'error',
|
||||||
'text': 'You were not logged on due to entering an invalid OpenID.'
|
'text': 'You were not logged on due to the given OpenID being invalid.'
|
||||||
}
|
}
|
||||||
return render('/xhtml/index.mako')
|
return render('/xhtml/account.mako')
|
||||||
|
|
||||||
redirecturl = authrequest.redirectURL(
|
redirecturl = authrequest.redirectURL(
|
||||||
h.url_for('',qualified=True),
|
h.url_for('',qualified=True),
|
||||||
|
|
|
@ -27,13 +27,18 @@ class SearchController(BaseController):
|
||||||
|
|
||||||
c.query = request.params['query']
|
c.query = request.params['query']
|
||||||
|
|
||||||
raw_results = model.Video.query.filter_by(dc_title=c.query).all()
|
# extremely simple search
|
||||||
|
raw_results = []
|
||||||
|
raw_results.extend(model.Video.query.filter_by(dc_title=c.query).all())
|
||||||
|
raw_results.extend(model.Video.query.filter(model.Video.dc_creator.has(name=c.query)).all())
|
||||||
|
raw_results.extend(model.Video.query.filter(model.Video.dc_contributor.any(name=c.query)).all())
|
||||||
|
|
||||||
if not raw_results:
|
if not raw_results:
|
||||||
c.message = {
|
c.message = {
|
||||||
'type': 'warning'
|
'type': 'warning',
|
||||||
|
'text': 'No results for query "%s".' % c.query
|
||||||
}
|
}
|
||||||
c.message['text']='No results for query "%s".' % c.query
|
# c.message['text']='No results for query "%s".' % c.query
|
||||||
return render('/xhtml/results.mako')
|
return render('/xhtml/results.mako')
|
||||||
|
|
||||||
c.results = []
|
c.results = []
|
||||||
|
|
|
@ -58,17 +58,18 @@ class UploadController(BaseController):
|
||||||
# TODO: set up safeguards against omitted / wrong data
|
# TODO: set up safeguards against omitted / wrong data
|
||||||
|
|
||||||
# set up database entry
|
# set up database entry
|
||||||
|
|
||||||
video = model.Video(
|
video = model.Video(
|
||||||
|
|
||||||
# Dublin Core terms
|
# Dublin Core terms
|
||||||
dc_title = request.params['title'],
|
dc_title = request.params['dc_title'],
|
||||||
dc_creator = request.params['creator'],
|
dc_subject = [model.DC_Subject(name=subject.lstrip()) for subject in request.params['dc_subject'].split(',')],
|
||||||
dc_subject = request.params['subject'],
|
dc_creator = model.DC_Creator(name = request.params['dc_creator']),
|
||||||
|
|
||||||
dc_abstract = request.params['abstract'],
|
dc_abstract = request.params['dc_abstract'],
|
||||||
|
|
||||||
# TODO: enable several contributors
|
# TODO: enable several contributors
|
||||||
dc_contributor = '',
|
dc_contributor = [model.DC_Contributor(name=contributor.lstrip()) for contributor in request.params['dc_contributor'].split(',')],
|
||||||
|
|
||||||
# TODO: insert real data
|
# TODO: insert real data
|
||||||
dc_created = datetime(9999,9,9).strftime("%Y-%m-%d %H:%M:%S"),
|
dc_created = datetime(9999,9,9).strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
|
@ -82,23 +83,24 @@ class UploadController(BaseController):
|
||||||
|
|
||||||
dc_identifier = '',
|
dc_identifier = '',
|
||||||
dc_source = '',
|
dc_source = '',
|
||||||
dc_language = request.params['language'],
|
dc_language = request.params['dc_language'],
|
||||||
|
|
||||||
# TODO: insert videolength
|
# TODO: insert videolength
|
||||||
dc_extent = timedelta(0),
|
dc_extent = timedelta(0),
|
||||||
|
|
||||||
dc_spatial = request.params['spatial'],
|
dc_spatial = request.params['dc_spatial'],
|
||||||
dc_temporal = datetime(9999,9,9).strftime("%Y-%m-%d %H:%M:%S"),
|
dc_temporal = datetime(9999,9,9).strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
|
|
||||||
dc_rightsHolder = '',
|
dc_rightsHolder = '',
|
||||||
|
|
||||||
# Creative Commons properties
|
# Creative Commons properties
|
||||||
cc_commercial = (request.params['commercial'] == 'commercial'),
|
cc_commercial = (request.params['commercial'] == 'cc_commercial'),
|
||||||
cc_sharealike = (request.params['modification'] == 'sharealike'),
|
cc_sharealike = (request.params['modification'] == 'cc_sharealike'),
|
||||||
cc_derivatives = (request.params['modification'] != 'noderivatives'),
|
cc_derivatives = (request.params['modification'] != 'cc_noderivatives'),
|
||||||
|
|
||||||
sha256=sha256
|
sha256=sha256
|
||||||
)
|
)
|
||||||
|
|
||||||
model.session.commit()
|
model.session.commit()
|
||||||
|
|
||||||
# copy file to temporary destination
|
# copy file to temporary destination
|
||||||
|
|
|
@ -3,16 +3,14 @@ from elixir import *
|
||||||
class Video(Entity):
|
class Video(Entity):
|
||||||
using_options(tablename='videos')
|
using_options(tablename='videos')
|
||||||
|
|
||||||
# Important: Keep this in sync with upload.py !
|
|
||||||
|
|
||||||
# Dublin Core terms
|
# Dublin Core terms
|
||||||
dc_title = Field(Unicode(255))
|
dc_title = Field(Unicode(255))
|
||||||
dc_creator = Field(Unicode(255))
|
dc_creator = ManyToOne('DC_Creator')
|
||||||
dc_subject = Field(UnicodeText)
|
dc_subject = ManyToMany('DC_Subject')
|
||||||
|
|
||||||
dc_abstract = Field(UnicodeText)
|
dc_abstract = Field(UnicodeText)
|
||||||
|
|
||||||
dc_contributor = Field(Unicode(255))
|
dc_contributor = ManyToMany('DC_Contributor')
|
||||||
|
|
||||||
dc_created = Field(DateTime)
|
dc_created = Field(DateTime)
|
||||||
dc_valid = Field(DateTime)
|
dc_valid = Field(DateTime)
|
||||||
|
@ -41,3 +39,19 @@ class Video(Entity):
|
||||||
|
|
||||||
# everything else
|
# everything else
|
||||||
sha256 = Field(String(64))
|
sha256 = Field(String(64))
|
||||||
|
|
||||||
|
# Dublin Core terms
|
||||||
|
|
||||||
|
class DC_Creator(Entity):
|
||||||
|
name = Field(Unicode(255))
|
||||||
|
videos = OneToMany('Video')
|
||||||
|
|
||||||
|
class DC_Subject(Entity):
|
||||||
|
name = Field(Unicode(32))
|
||||||
|
videos = ManyToMany('Video')
|
||||||
|
|
||||||
|
class DC_Contributor(Entity):
|
||||||
|
name = Field(Unicode(255))
|
||||||
|
videos = ManyToMany('Video')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue