[xiph-commits] r3225 - in arkaiv/trunk/arkaiv: controllers model templates

dcrowdy at svn.annodex.net dcrowdy at svn.annodex.net
Wed Sep 5 22:34:39 PDT 2007


Author: dcrowdy
Date: 2007-09-05 22:34:38 -0700 (Wed, 05 Sep 2007)
New Revision: 3225

Modified:
   arkaiv/trunk/arkaiv/controllers/page.py
   arkaiv/trunk/arkaiv/controllers/page.pyc
   arkaiv/trunk/arkaiv/model/__init__.py
   arkaiv/trunk/arkaiv/model/__init__.pyc
   arkaiv/trunk/arkaiv/templates/playlists.mak
   arkaiv/trunk/arkaiv/templates/searchresults.mak
Log:
Items as well as clips can be added to playlists when searching meta tags.


Modified: arkaiv/trunk/arkaiv/controllers/page.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/page.py	2007-09-06 03:03:52 UTC (rev 3224)
+++ arkaiv/trunk/arkaiv/controllers/page.py	2007-09-06 05:34:38 UTC (rev 3225)
@@ -97,10 +97,24 @@
         c.playlists = model.getplaylists()
         return render('/playlists.mak')
 
-    def addtoplaylist(self):
+    def additemstoplaylist(self):
+        nmetas = int(request.params['nummetas'])
+        playlist = request.params['playlist']
+        for i in range(nmetas):
+            try:
+                itemid = request.params[str(i)]
+                model.additemtoplaylist(playlist, itemid)
+            #    print clipid
+            except:
+                pass
+
+        redirect_to(action='playlistpage')
+
+
+    def addclipstoplaylist(self):
         nclips = int(request.params['numclips'])
         playlist = request.params['playlist']
-        print playlist
+        #print playlist
         for i in range(nclips):
             try:
                 clipid = request.params[str(i)]
@@ -109,19 +123,36 @@
             except:
                 pass
 
-        return
+        redirect_to(action='playlistpage')
 
     def displayplaylist(self):
         # Need to extract appropriate info for the playlist selected
         playlistid = int(request.params['id'])
         
         clips = model.getclipsfromplaylist(playlistid)
-        print clips
+        items = model.getitemsfromplaylist(playlistid)
         # send a list of dictionaries to the template
         c.cliplist = []
         for clip in clips:
-            clipdict = {}
-            item = model.getitemforclip(clip.ixc)
+            if (clip != None):
+                clipdict = {}
+                item = model.getitemforclip(clip.ixc)
+                sourceid = model.getsourcesforitem(item.ixi)
+                oggsource = model.getsourcepath(sourceid)
+                #print oggsource
+                cmmlfile = model.getitemcmmlfile(item.ixi)
+                #print cmmlfile
+                urlpath = split(cmmlfile, path_base)
+                # Now split off the extension
+                urlpath = os.path.splitext(urlpath[1])[0]
+                #clipimageurl = media_url_base + os.path.dirname(urlpath) + "/"
+                #print clipimageurl
+                clipdict['id'] = clip.ixc
+                clipdict['url'] = media_url_base + urlpath + ".anx" + "?id=" + clip.id
+                c.cliplist.append(clipdict)
+        
+        for item in items:
+            itemdict = {}
             sourceid = model.getsourcesforitem(item.ixi)
             oggsource = model.getsourcepath(sourceid)
             #print oggsource
@@ -132,10 +163,9 @@
             urlpath = os.path.splitext(urlpath[1])[0]
             #clipimageurl = media_url_base + os.path.dirname(urlpath) + "/"
             #print clipimageurl
-            clipdict['id'] = clip.ixc
-            clipdict['url'] = media_url_base + urlpath + ".anx" + "?id=" + clip.id
-            print clipdict['url']
-            c.cliplist.append(clipdict)
+            itemdict['id'] = ""
+            itemdict['url'] = media_url_base + urlpath + ".anx" + "?id=0"
+            c.cliplist.append(itemdict)
 
         return render('/playlistview.mak')
 
@@ -143,7 +173,7 @@
         collectionlist = model.getcollections()
         c.collectioninfo = ""
         for collection in collectionlist:
-            print collection.name
+            #print collection.name
             c.collectioninfo = c.collectioninfo + "<option>" + collection.name + "</option>"
 
         return render('/addannodexindirform.mak')
@@ -159,7 +189,7 @@
         toedit = request.params['edit']
         try:
             c.playclip = request.params['playclip']
-            print c.playclip
+            #print c.playclip
         except:
             c.playclip = ""
 
@@ -417,7 +447,7 @@
                 clipdict['img_src'] = ""
             model.addclip(clipdict)
 
-        print cliplist
+        #print cliplist
         # Extract meta info from the head and add to database
         parser = cmmlParser()
         parser.setcmmlfilename(newcmmlname)

Modified: arkaiv/trunk/arkaiv/controllers/page.pyc
===================================================================
(Binary files differ)

Modified: arkaiv/trunk/arkaiv/model/__init__.py
===================================================================
--- arkaiv/trunk/arkaiv/model/__init__.py	2007-09-06 03:03:52 UTC (rev 3224)
+++ arkaiv/trunk/arkaiv/model/__init__.py	2007-09-06 05:34:38 UTC (rev 3225)
@@ -329,6 +329,18 @@
     sac.session.flush()
     return
 
+def additemtoplaylist(list, itemid):
+    p_q = sac.query(Playlist)
+    p = p_q.get_by(name=list)
+    pi = Playlistitems()
+    #pi.ixc = clipid
+    pi.ixi = itemid
+    pi.ixp = p.ixp
+
+    sac.session.flush()
+    return
+
+
 def getclipsfromplaylist(listid):
     pi_q = sac.query(Playlistitems)
     pi = pi_q.filter_by(ixp=listid)
@@ -340,6 +352,23 @@
         
     return cliplist
 
+def getitemsfromplaylist(listid):
+    """ This gets items in the playlist that have no clip info
+
+    """
+    pi_q = sac.query(Playlistitems)
+    pi = pi_q.filter_by(ixp=listid)
+    i_q = sac.query(Item)
+    itemlist = []
+    for item in pi:
+        #print item.ixc
+        if (not item.ixc):
+            i = i_q.get_by(ixi=item.ixi)
+            itemlist.append(i)
+
+    return itemlist
+
+
 def addsource(itemname, source, cmmlfile):
     new_item = Item()
     new_source = Source()

Modified: arkaiv/trunk/arkaiv/model/__init__.pyc
===================================================================
(Binary files differ)

Modified: arkaiv/trunk/arkaiv/templates/playlists.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/playlists.mak	2007-09-06 03:03:52 UTC (rev 3224)
+++ arkaiv/trunk/arkaiv/templates/playlists.mak	2007-09-06 05:34:38 UTC (rev 3225)
@@ -6,8 +6,6 @@
 % for p in c.playlists:
 <li>
 ${ h.link_to(p.name, h.url(action="displayplaylist", id=p.ixp))}
-${p.ixp}
-${p.name}
 </li>
 % endfor
 

Modified: arkaiv/trunk/arkaiv/templates/searchresults.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/searchresults.mak	2007-09-06 03:03:52 UTC (rev 3224)
+++ arkaiv/trunk/arkaiv/templates/searchresults.mak	2007-09-06 05:34:38 UTC (rev 3225)
@@ -11,24 +11,38 @@
 % endfor
 <hr>
 <p>Meta names:</p>
+<form name='metas' action='additemstoplaylist'>
 <table>
 <tr>
 <td>Name</td>
 <td>Content</td>
 <td></td>
 </tr>
+<%
+i = 0
+%>
 % for metaresult in c.metas:
 <tr>
 <td>${metaresult['meta'].name}</td>
 <td>${metaresult['meta'].content}</td>
 <td>${ h.link_to(metaresult['item'].name, h.url(action="displayitem", edit="no", id=metaresult['item'].ixi))}</td>
+<td><input type='checkbox' name='${i}' value='${metaresult['item'].ixi}'></td>
 </tr>
+<%
+i = i + 1
+%>
 % endfor
 </table>
+Playlist:
+${ h.select("playlist", c.playlistinfo)}
+
+${ h.hidden_field('nummetas', value=i) }
+${ h.submit('Add') } 
+</form>
 <hr>
 Clips:
 <table>
-<form name='clips' action='addtoplaylist'>
+<form name='clips' action='addclipstoplaylist'>
 <tr>
 <td>id</td>
 <td>desc</td>
@@ -43,7 +57,6 @@
 <td>${clipresult['clip'].desc}</td>
 <td>${ h.link_to(clipresult['item'].name, h.url(action="displayitem", edit="no", id=clipresult['item'].ixi, playclip=clipresult['clip'].id))}</td>
 <td><input type='checkbox' name='${i}' value='${clipresult['clip'].ixc}'></td>
-<td>${i}</td>
 </tr>
 <%
 i = i + 1



More information about the commits mailing list