[xiph-commits] r4038 - in arkaiv/trunk: arkaiv arkaiv/controllers arkaiv/model arkaiv/templates data/templates
dcrowdy at svn.annodex.net
dcrowdy at svn.annodex.net
Sun Sep 27 22:57:38 PDT 2009
Author: dcrowdy
Date: 2009-09-27 22:57:38 -0700 (Sun, 27 Sep 2009)
New Revision: 4038
Modified:
arkaiv/trunk/arkaiv/controllers/collection.py
arkaiv/trunk/arkaiv/controllers/error.pyc
arkaiv/trunk/arkaiv/controllers/playlist.py
arkaiv/trunk/arkaiv/model/__init__.py
arkaiv/trunk/arkaiv/model/__init__.pyc
arkaiv/trunk/arkaiv/templates/addannodexindirform.mak
arkaiv/trunk/arkaiv/templates/collections.mak
arkaiv/trunk/arkaiv/templates/collectionsadmin.mak
arkaiv/trunk/arkaiv/websetup.pyc
arkaiv/trunk/data/templates/addannodexform.mak.pyc
arkaiv/trunk/data/templates/collections.mak.py
arkaiv/trunk/data/templates/collections.mak.pyc
Log:
Initial work on implementation of public and private access to collections using authkit
Modified: arkaiv/trunk/arkaiv/controllers/collection.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/collection.py 2009-09-25 23:03:18 UTC (rev 4037)
+++ arkaiv/trunk/arkaiv/controllers/collection.py 2009-09-28 05:57:38 UTC (rev 4038)
@@ -18,10 +18,17 @@
#@authorize(ValidAuthKitUser())
# @authorize(HasAuthKitRole('admin'))
def list(self):
- c.collections = model.getcollections()
if authorized(HasAuthKitRole('admin')):
+ c.collections = model.getcollections()
return render('/collectionsadmin.mak')
+ #else:
+ if authorized(HasAuthKitRole('internal')):
+ c.collections = model.getcollectionswithrole('internal')
+ publiccollections = model.getcollectionswithrole('public')
+ c.collections.append(publiccollections)
+ return render('/collections.mak')
else:
+ c.collections = model.getcollectionswithrole('public')
return render('/collections.mak')
def displaycollection(self):
@@ -31,7 +38,13 @@
return render('/collectionexpanded.mak')
def addcollection(self):
- model.addnewcollection(request.params['newcollection'])
+ collection = request.params['newcollection']
+ role = request.params['role']
+ try:
+ access = request.params['pri']
+ except:
+ access = 'public'
+ model.addnewcollection(collection, role, access)
c.collections = model.getcollections()
return render('/collections.mak')
Modified: arkaiv/trunk/arkaiv/controllers/error.pyc
===================================================================
(Binary files differ)
Modified: arkaiv/trunk/arkaiv/controllers/playlist.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/playlist.py 2009-09-25 23:03:18 UTC (rev 4037)
+++ arkaiv/trunk/arkaiv/controllers/playlist.py 2009-09-28 05:57:38 UTC (rev 4038)
@@ -53,7 +53,7 @@
items = model.getitemsfromplaylist(playlistid)
# send a list of dictionaries to the template
for clip in clips:
- if (clip != None):
+ if (clip != Non):
item = model.getitemforclip(clip['index'])
clip['name'] = item.name #name of the item the clip belongs to
sourceid = model.getsourcesforitem(item.ixi)
Modified: arkaiv/trunk/arkaiv/model/__init__.py
===================================================================
--- arkaiv/trunk/arkaiv/model/__init__.py 2009-09-25 23:03:18 UTC (rev 4037)
+++ arkaiv/trunk/arkaiv/model/__init__.py 2009-09-28 05:57:38 UTC (rev 4038)
@@ -32,7 +32,9 @@
collections_table = Table('collections', metadata,
Column('ixk', types.Integer, primary_key=True),
- Column('name', types.String())
+ Column('name', types.String()),
+ Column('role', types.String()),
+ Column('access', types.String())
)
items_table = Table('items', metadata,
@@ -47,6 +49,13 @@
Column('ixi', types.Integer, ForeignKey('items.ixi'))
)
+#authorisation_table = Table('authorisation', metadata,
+# Column('ixa', types.Integer, primary_key=True),
+# Column('ixk', types.Integer, ForeignKey('collections.ixk')),
+# Column('role', types.String())
+# Column('access', types.String())
+#)
+
playlists_table = Table('playlists', metadata,
Column('ixp', types.Integer, primary_key=True),
Column('name', types.String())
@@ -285,13 +294,16 @@
return items
-def addnewcollection(name):
- """ Adds a new collection to the database given a name
+def addnewcollection(name, role, access):
+ """ Adds a new collection to the database given a name and access info
"""
newcollection = Collection()
newcollection.name = name
+ newcollection.role = role
+ newcollection.access = access
Session.save(newcollection)
+
Session.commit()
return
@@ -320,15 +332,39 @@
"""
coll_q = Session.query(Collection)
c = coll_q.all()
+# c = coll_q.filter_by()
collections=[]
for n in c:
collection = {}
collection['index'] = n.ixk
collection['name'] = n.name
+ collection['role'] = n.role
+ collection['access'] = n.access
collections.append(collection)
return collections
+def getcollectionswithrole(authrole):
+ """ Gets a list of collections with the stated role
+ returns a list of dicts with keys "index" and "name"
+ """
+# auth_q = Session.query(Authorisation)
+# a = auth_q.filter_by(role=authrole)
+ collections=[]
+ coll_q = Session.query(Collection)
+ c = coll_q.filter_by(role=authrole)
+ for n in c:
+ collection = {}
+ collection['index'] = n.ixk
+ collection['name'] = n.name
+ collection['role'] = n.role
+ collection['access'] = n.access
+ collections.append(collection)
+
+ return collections
+
+
+
def getitemsincollection(id):
""" Gets all items from a collection given a collection index value
Modified: arkaiv/trunk/arkaiv/model/__init__.pyc
===================================================================
(Binary files differ)
Modified: arkaiv/trunk/arkaiv/templates/addannodexindirform.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/addannodexindirform.mak 2009-09-25 23:03:18 UTC (rev 4037)
+++ arkaiv/trunk/arkaiv/templates/addannodexindirform.mak 2009-09-28 05:57:38 UTC (rev 4038)
@@ -4,7 +4,7 @@
<p>
This allows importation of cmml and ogg files, for encoding to annodex format (anx), given a directory. Basically it expects a directory full of cmml and ogg files, in pairs (ie same basename - something.cmml, something.ogg; anotherthing.cmml, anotherthing.ogg).
-${ h.form(h.url(action='addannodexindirmedia'), multipart=True) }
+${ h.form(h.url_for(action='addannodexindirmedia'), multipart=True) }
<table>
<tr>
<td>Directory:</td>
Modified: arkaiv/trunk/arkaiv/templates/collections.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/collections.mak 2009-09-25 23:03:18 UTC (rev 4037)
+++ arkaiv/trunk/arkaiv/templates/collections.mak 2009-09-28 05:57:38 UTC (rev 4038)
@@ -10,10 +10,4 @@
</li>
% endfor
-<hr>
-Add new collection:
-${ h.form(h.url_for(action='addcollection'), multipart=True) }
-${ h.text_field('newcollection') }
-${ h.submit('Add') }
-${ h.end_form() }
Modified: arkaiv/trunk/arkaiv/templates/collectionsadmin.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/collectionsadmin.mak 2009-09-25 23:03:18 UTC (rev 4037)
+++ arkaiv/trunk/arkaiv/templates/collectionsadmin.mak 2009-09-28 05:57:38 UTC (rev 4038)
@@ -5,7 +5,7 @@
% for coll in c.collections:
<li>
- ${ h.link_to(coll['name'], h.url_for(action="displaycollection", edit="no", id=coll['index'], name=coll['name'])) }
+ ${ h.link_to(coll['name'], h.url_for(action="displaycollection", edit="no", id=coll['index'], name=coll['name'])) } ${coll['role']} ${coll['access']}
${ h.form(h.url_for(action='deletecollection', id=coll['index']), multipart=True) }
Delete collection:
${ h.submit('Delete') }
@@ -17,6 +17,9 @@
Add new collection:
${ h.form(h.url_for(action='addcollection'), multipart=True) }
${ h.text_field('newcollection') }
+Role:${ h.text_field('role') }
+Private:
+<input type='checkbox' name='pri' value='private'>
${ h.submit('Add') }
${ h.end_form() }
Modified: arkaiv/trunk/arkaiv/websetup.pyc
===================================================================
(Binary files differ)
Modified: arkaiv/trunk/data/templates/addannodexform.mak.pyc
===================================================================
(Binary files differ)
Modified: arkaiv/trunk/data/templates/collections.mak.py
===================================================================
--- arkaiv/trunk/data/templates/collections.mak.py 2009-09-25 23:03:18 UTC (rev 4037)
+++ arkaiv/trunk/data/templates/collections.mak.py 2009-09-28 05:57:38 UTC (rev 4038)
@@ -3,7 +3,7 @@
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
-_modified_time = 1243827704.853045
+_modified_time = 1254114415.306004
_template_filename='/home/dcrowdy/src/arkaiv/working/trunk/arkaiv/templates/collections.mak'
_template_uri='/collections.mak'
_template_cache=cache.Cache(__name__, _modified_time)
@@ -42,19 +42,7 @@
__M_writer(unicode( h.form(h.url_for(action='deletecollection', id=coll['index']), multipart=True) ))
__M_writer(u' \n</li>\n')
# SOURCE LINE 12
- __M_writer(u'\n<hr>\nAdd new collection:\n')
- # SOURCE LINE 15
- __M_writer(unicode( h.form(h.url_for(action='addcollection'), multipart=True) ))
- __M_writer(u' \n')
- # SOURCE LINE 16
- __M_writer(unicode( h.text_field('newcollection') ))
- __M_writer(u'\n')
- # SOURCE LINE 17
- __M_writer(unicode( h.submit('Add') ))
- __M_writer(u' \n')
- # SOURCE LINE 18
- __M_writer(unicode( h.end_form() ))
- __M_writer(u' \n\n')
+ __M_writer(u'\n\n')
return ''
finally:
context.caller_stack._pop_frame()
Modified: arkaiv/trunk/data/templates/collections.mak.pyc
===================================================================
(Binary files differ)
More information about the commits
mailing list