Commits

Guido Draheim  committed ff3a909

channelsconf generation -> test with screen "channels.conf text"

  • Participants
  • Parent commits 3aeda8f

Comments (0)

Files changed (4)

File src/dvbcronrecording/channels.de.po

 msgid "channel.conf show"
 msgstr "channel.conf Ansicht"
 
+msgid "channel.conf text"
+msgstr "channel.conf Text"
+
 msgid "action buttons"
 msgstr "Betriebsschalter"
 

File src/dvbcronrecording/channels.py

 from tuning import tuning_adapter_list
 
 from db.session import db_cnx, commit #@UnresolvedImport
-from db.schema import RecordingChannels
+from db.schema import RecordingChannels, RecordingChannelsConf
 import sqlalchemy as _as
 
 
         # ------------------------------------------------
         message = ""
         
+        if page in [ "text" ]:
+            return self.show_text(req, page)
         args = req.args
         if page in [ None, '', 'list' ]:
             pass
         # database commit and return page content
         commit()
 
-        add_stylesheet(req, 'common/css/wiki.css')
-        add_stylesheet(req, PACKAGE+'/css/recordingchannels.css')
-        add_script(req, 'common/js/trac.js')
-        add_script(req, 'common/js/wikitoolbar.js')
-        
+       
         if not message: message = translate("please do not use umlauts")
         message += translate("?problem")
         newchannel_list = self._newchannel_list(req)
         data['message'] = message
         data['title'] = translate('Channel List')
         data['adapterlist'] = self._adapter_list(req)
+        data["adapter"] = req.args.get("adapter", "0")
         data['new_datalist'] = newchannel_list
         data["_pagenum"] = req.args.get("_pagenum", "0")
         data["_pagesize"] = req.args.get("_pagesize", "10")
         data['appends'] = req.perm.has_permission(CHANNELS_VIEW);
         data['author'] = req.authname or ""
         data['_'] = translate
+        add_stylesheet(req, 'common/css/wiki.css')
+        add_stylesheet(req, PACKAGE+'/css/recordingchannels.css')
+        add_script(req, 'common/js/trac.js')
+        add_script(req, 'common/js/wikitoolbar.js')
+        return ('channels_list.html', data, None)
 
-        return ('channels_list.html', data, None)
+    def show_text(self, req, page):
+        # passing variables to template
+        translate = Translate("channels", req.locale)
+        adapter = req.args["adapter"]
+        conf = self.channelsconf_for_adapter(adapter)
+        data = {}
+        data['message'] = "" 
+        data['title'] = translate('channels.conf text') + adapter
+        data['adapterlist'] = self._adapter_list(req)
+        data["adapter"] = adapter
+        data['text'] = "\n".join(conf)
+        data["rows"] = len(conf)
+        data['_'] = translate
+        add_stylesheet(req, 'common/css/wiki.css')
+        add_stylesheet(req, PACKAGE+'/css/recordingchannels.css')
+        add_script(req, 'common/js/trac.js')
+        add_script(req, 'common/js/wikitoolbar.js')
+        return ('channels_text.html', data, None)
 
     # ====================================================================
     
         for entry in q.all():
             logg.debug("   found %s" % entry.title)
             logg.debug("      at %s\n" % entry.adapter)
-            item = channelconfitem()
+            item = RecordingChannelsItem()
             item.adapter = entry.adapter
             item.title = entry.title
             item.channel = entry.title  
             yield item
+    def channelname_list_for_adapter(self, req, adapter = 0):
+        """ Returns list of the adapter settings """
+        logg.debug("channels.conf for adapter %s" % adapter)
+        q = db_cnx(self.env).query(RecordingChannels.channelname)
+        q = q.filter_by( adapter = adapter)
+        entries = []
+        for entry in q.all():
+            entries.append(entry.channelname)
+        return sorted(entries)
+    def channelsconflist_for_adapter(self, adapter):
+        logg.debug("channels.conf for adapter %s" % adapter)
+        session = db_cnx(self.env)
+        q = session.query(RecordingChannels)
+        q = q.filter_by( adapter = adapter)
+        channels = {}
+        for entry in q.all():
+            channels[entry.title] = entry.channelname
+        q = session.query(RecordingChannelsConf)
+        q = q.filter_by( adapter = adapter )
+        for entry in q.all():
+            if entry.title in channels:
+                item = RecordingChannelsConfItem()
+                item.title = channels[entry.title]
+                item.frequency = entry.frequency
+                item.polarity = entry.polarity
+                item.source = entry.source
+                item.symbolrate = entry.symbolrate
+                item.vpid = entry.vpid
+                item.apid = entry.apid
+                item.tpid = entry.tpid
+                yield item
+    def channelsconf_for_adapter(self, adapter):
+        return list(self._channelsconf_for_adapter(adapter))
+    def _channelsconf_for_adapter(self, adapter):
+        for item in self.channelsconflist_for_adapter(adapter):
+            yield ":".join([str(item.title),
+                             str(item.frequency),
+                             str(item.polarity),
+                             str(item.source),
+                             str(item.symbolrate),
+                             str(item.vpid),
+                             str(item.apid),
+                             str(item.tpid),                             
+                             ])
 
-class channelconfitem: pass
+class RecordingChannelsItem: pass
+class RecordingChannelsConfItem: pass

File src/dvbcronrecording/templates/channels_list.html

     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:py="http://genshi.edgewall.org/"
-      xmlns:xi="http://www.w3.org/2001/XInclude">
-  <xi:include href="layout.html" />
-  <xi:include href="macros.html" />
-<head><title>${title}</title></head>
+	xmlns:py="http://genshi.edgewall.org/"
+	xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="layout.html" />
+<xi:include href="macros.html" />
+<head>
+<title>${title}</title>
+</head>
 <body>
-<div id="ctxtnav" class="nav">
-</div>
+	<div id="ctxtnav" class="nav"></div>
 
-<div id="content" class="channelslist">
-  <h1>
-    ${title}
-  </h1>
-  <xi:include href="channels_nav.html" />
-  <xi:include href="channelsconf_nav.html" />
-  <div>${message}</div><br />
+	<div id="content" class="channelslist">
+		<h1>${title}</h1>
+		<xi:include href="channels_nav.html" />
+		<xi:include href="channelsconf_nav.html" />
+                <div>
+                        <!--  -->
+                        &nbsp; &nbsp; &nbsp; &nbsp;
+                        <form method="post" action="${href.recording('channels/text')}"
+                                class="actionform">
+                                <select name="adapter">
+                                        <option py:for="adaptername in sorted(adapterlist)" 
+                                           value="${adaptername}"
+                                           selected="${adaptername == adapter or None}">
+                                                ${adaptername}</option>
+                                </select>
+                                <input type="submit" value="${_('channels.conf text')}"
+                                        class="actionbutton"></input>
+                        </form>
+                </div>
+		
+		
+		<div>${message}</div>
+		<br />
 
-  <table cellpadding="0" cellspacing="0">
-        <tr>
-      <th>x</th>
-      <th class="id">#</th>
-      <th class="channelname">${_('channelname')}&nbsp;</th>
-      <th class="adapter">${_('adapter')}&nbsp;</th>
-      <th class="title">${_('channel.conf title')}&nbsp;</th>
-      <th>${_('action buttons')}</th>
-      </tr>
-      
-    <py:if test="perm.has_permission('DVBREC_CHANNELS_EDIT')">
-  <div py:for="item in new_datalist">
-    <form method="post" action="${href.recording('channels/newentry')}">
-      <tr>
-      <td class="id new" colspan="2">${_('NEW')}</td>
-      <td class="channelname"><input type="text" name="channelname" value="${item.channelname}"></input></td>
-      <td class="adapter">
-            <select name="adapter">
-                <option py:for="adapter in sorted(adapterlist)" 
-                        value="${adapter}">
-                        ${adapter}
-                </option>
-            </select>
-      </td>
-      <td class="title"><input type="text" name="title" value="${item.title}"></input></td>
-      <td class="action"><input type="submit" value="${_('insert')}"></input></td>
-      </tr>
-     </form>    
-  </div>    
-    </py:if>
+		<table cellpadding="0" cellspacing="0">
+			<tr>
+				<th>x</th>
+				<th class="id">#</th>
+				<th class="channelname">${_('channelname')}&nbsp;</th>
+				<th class="adapter">${_('adapter')}&nbsp;</th>
+				<th class="title">${_('channel.conf title')}&nbsp;</th>
+				<th>${_('action buttons')}</th>
+			</tr>
 
-  <div py:for="item in datalist">
-  <form method="post" action="${href.recording('channels/update')}">
-    <tr class="status${item.status}">
-      <td>
-        <py:if test="perm.has_permission('DVBREC_CHANNELS_EDIT')">
-          <span  class="deletebutton">
-          <a href="${href.recording('channels/delete')}?id=${item.id}">
-                   &#x2716;
-          </a>
-          </span>
-        </py:if>
-      </td>
-      <td class="id">
-          ${item.id}<input type="hidden" name="id" value="${item.id}"></input>
-      </td>
-      <td>
-         <input type="text" name="channelname" value="${item.channelname}" 
-             style="width: 6em" /></td>
-      <td class="adapter">
-            <select name="adapter">
-                <option py:for="adapter in sorted(adapterlist)" 
-                        value="${adapter}">
-                        ${adapter}
-                </option>
-            </select>
-      </td>
-      <td class="title"><input type="text" name="title" value="${item.title}"></input></td>
-      <td class="action">
-        <py:if test="perm.has_permission('DVBREC_CHANNELS_EDIT')">
-          <input type="submit" value="${_('update')}" class="actionbutton" />
-        </py:if>
-      </td>
-    </tr>
-    </form>
-  </div>
-  </table>
-  <xi:include href="paginator_datalist.html" />
-</div>
-<hr />
-</body></html>
+			<py:if test="perm.has_permission('DVBREC_CHANNELS_EDIT')">
+				<div py:for="item in new_datalist">
+					<form method="post" action="${href.recording('channels/newentry')}">
+						<tr>
+							<td class="id new" colspan="2">${_('NEW')}</td>
+							<td class="channelname"><input type="text"
+								name="channelname" value="${item.channelname}"></input>
+							</td>
+							<td class="adapter"><select name="adapter">
+									<option py:for="adapter in sorted(adapterlist)"
+										value="${adapter}">${adapter}</option>
+							</select></td>
+							<td class="title"><input type="text" name="title"
+								value="${item.title}"></input>
+							</td>
+							<td class="action"><input type="submit"
+								value="${_('insert')}"></input>
+							</td>
+						</tr>
+					</form>
+				</div>
+			</py:if>
+
+			<div py:for="item in datalist">
+				<form method="post" action="${href.recording('channels/update')}">
+					<tr class="status${item.status}">
+						<td><py:if test="perm.has_permission('DVBREC_CHANNELS_EDIT')">
+								<span class="deletebutton"> <a
+									href="${href.recording('channels/delete')}?id=${item.id}">
+										&#x2716; </a> </span>
+							</py:if></td>
+						<td class="id">${item.id}<input type="hidden" name="id"
+							value="${item.id}"></input></td>
+						<td><input type="text" name="channelname"
+							value="${item.channelname}" style="width: 6em" />
+						</td>
+						<td class="adapter"><select name="adapter">
+								<option py:for="adapter in sorted(adapterlist)"
+									value="${adapter}">${adapter}</option>
+						</select></td>
+						<td class="title"><input type="text" name="title"
+							value="${item.title}"></input>
+						</td>
+						<td class="action"><py:if
+								test="perm.has_permission('DVBREC_CHANNELS_EDIT')">
+								<input type="submit" value="${_('update')}" class="actionbutton" />
+							</py:if></td>
+					</tr>
+				</form>
+			</div>
+		</table>
+		<xi:include href="paginator_datalist.html" />
+		<div>
+			<!--  -->
+			&nbsp; &nbsp; &nbsp; &nbsp;
+			<form method="post" action="${href.recording('channels/text')}"
+				class="actionform">
+				<select name="adapter">
+					<option py:for="adapter in sorted(adapterlist)" value="${adapter}">
+						${adapter}</option>
+				</select>
+				<input type="submit" value="${_('channels.conf text')}"
+					class="actionbutton"></input>
+			</form>
+		</div>
+	</div>
+
+	<hr />
+</body>
+</html>

File src/dvbcronrecording/templates/channels_text.html

+<!DOCTYPE html
+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+	xmlns:py="http://genshi.edgewall.org/"
+	xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="layout.html" />
+<xi:include href="macros.html" />
+<head>
+<title>${title}</title>
+</head>
+<body>
+	<div id="ctxtnav" class="nav"></div>
+	<div id="content" class="channelslist">
+		<h1>${title}</h1>
+		<xi:include href="channels_nav.html" />
+		<xi:include href="channelsconf_nav.html" />
+		<div>
+			<!--  -->
+			&nbsp; &nbsp; &nbsp; &nbsp;
+			<form method="post" action="${href.recording('channels/text')}"
+				class="actionform">
+				<select name="adapter">
+					<option py:for="adaptername in sorted(adapterlist)"
+						value="${adaptername}"
+						selected="${adaptername == adapter or None}">
+						${adaptername}</option>
+				</select>
+				<input type="submit" value="${_('channels.conf text')}"
+					class="actionbutton"></input>
+			</form>
+		</div>
+
+
+
+		<div>${message}</div>
+		<br />
+		<form>
+			<textarea cols="80" rows="${rows or 10}">${text}</textarea>
+		</form>
+	</div>
+
+	<hr />
+</body>
+</html>