summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2011-12-08 22:43:54 (GMT)
committerLuke Macken <lmacken@redhat.com>2011-12-08 22:44:43 (GMT)
commite3b86e505bc0bc3d9449fc207867273bc1f487cb (patch)
treec118fbd57095bc661cbc9becd74b50ba0e164e37
parent0a9763cecd5829cf9af072bf813b617cec0bb3e6 (diff)
downloadfedoracommunity-e3b86e505bc0bc3d9449fc207867273bc1f487cb.zip
fedoracommunity-e3b86e505bc0bc3d9449fc207867273bc1f487cb.tar.gz
fedoracommunity-e3b86e505bc0bc3d9449fc207867273bc1f487cb.tar.xz
Add a release filter for our patches widget
-rw-r--r--fedoracommunity/widgets/package/sources.py29
-rw-r--r--fedoracommunity/widgets/package/templates/package_spec.mak16
-rw-r--r--fedoracommunity/widgets/package/templates/patches.mak16
3 files changed, 39 insertions, 22 deletions
diff --git a/fedoracommunity/widgets/package/sources.py b/fedoracommunity/widgets/package/sources.py
index 313c8e3..783ac08 100644
--- a/fedoracommunity/widgets/package/sources.py
+++ b/fedoracommunity/widgets/package/sources.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import git
import tw2.core as twc
from mako.template import Template
@@ -75,29 +76,39 @@ class Spec(twc.Widget):
def prepare(self):
super(Spec, self).prepare()
self.package_name = self.kwds['package_name']
- repo = FedoraGitRepo(self.package_name)
- self.text = highlight(repo.get_spec(), BashLexer(),
- HtmlFormatter(full=True, linenos=True, nobackground=True))
+ self.branch = self.kwds.get('branch', 'master')
+ try:
+ repo = FedoraGitRepo(self.package_name, branch=self.branch)
+ self.text = highlight(repo.get_spec(), BashLexer(),
+ HtmlFormatter(full=True, linenos=True, nobackground=True))
+ except git.NoSuchPathError:
+ self.text = "No %s branch for %s" % (self.branch, self.package_name)
class Patches(twc.Widget):
kwds = twc.Param(default=None)
- patches = twc.Param(default=None)
+ patches = twc.Param(default={})
package = twc.Variable()
- diffstat = twc.Variable()
+ diffstat = twc.Variable(default='')
+ releases = ReleaseFilter
template = 'mako:fedoracommunity.widgets.package.templates.patches'
def prepare(self):
super(Patches, self).prepare()
self.package = self.kwds['package_name']
- repo = FedoraGitRepo(self.package)
- self.patches = repo.get_patches()
- self.diffstat = repo.get_diffstat()
+ self.branch = self.kwds.get('branch', 'master')
+ try:
+ repo = FedoraGitRepo(self.package, branch=self.branch)
+ self.patches = repo.get_patches()
+ self.diffstat = repo.get_diffstat()
+ except git.NoSuchPathError:
+ self.text = "No %s branch for %s" % (self.branch, self.package)
class Patch(twc.Widget):
package = twc.Param('The name of the package')
patch = twc.Param('The filename of the patch')
+ branch = twc.Param('The git branch', default='master')
diffstat = twc.Param('The diffstat for this patch', default=True)
text = twc.Variable('The text of the patch')
changelog = twc.Variable('The changelog of this patch')
@@ -105,7 +116,7 @@ class Patch(twc.Widget):
def prepare(self):
super(Patch, self).prepare()
- repo = FedoraGitRepo(self.package)
+ repo = FedoraGitRepo(self.package, branch=self.branch)
diff = repo.get_patch(self.patch)
if self.diffstat:
self.diffstat = repo.get_diffstat(self.patch)
diff --git a/fedoracommunity/widgets/package/templates/package_spec.mak b/fedoracommunity/widgets/package/templates/package_spec.mak
index a3a3f0d..b51b83f 100644
--- a/fedoracommunity/widgets/package/templates/package_spec.mak
+++ b/fedoracommunity/widgets/package/templates/package_spec.mak
@@ -1,19 +1,13 @@
<script type="text/javascript">
-
-function done_cb(data) {
- $('#specfile').html(data['text']);
-}
-
function on_change(self) {
- moksha.connector_load('git', 'get_spec', {
- 'package': '${w.package_name}',
- 'branch': self.value
- }, done_cb);
+ $('#specfile').load('/_w/package.sources.spec #specfile', {
+ 'package_name': '${w.package_name}',
+ 'branch': self.value
+ });
}
-
</script>
-${w.children[0].display(package=w.package_name, on_change='on_change')}
+${w.children[0].display(on_change='on_change')}
<br/>
diff --git a/fedoracommunity/widgets/package/templates/patches.mak b/fedoracommunity/widgets/package/templates/patches.mak
index 04b56c2..72406b8 100644
--- a/fedoracommunity/widgets/package/templates/patches.mak
+++ b/fedoracommunity/widgets/package/templates/patches.mak
@@ -1,4 +1,16 @@
-<div class="patches">
+<script type="text/javascript">
+function on_change(self) {
+ console.log('patch change');
+ $('#patches').load('/_w/package.sources.patches #patches', {
+ 'package_name': '${w.package}',
+ 'branch': self.value
+ });
+}
+</script>
+
+${w.children[0].display(on_change='on_change')}
+
+<div id="patches" class="patches">
<%namespace file="diffstat.mak" import="render_diffstat"/>
<a class="frame_link" href="#" onclick="return toggle_diffstat()">Show summary of all patches</a>
@@ -31,7 +43,7 @@ function toggle_patch(patch) {
tr.addClass('active-patch').after(
$('<tr/>', {id: 'patch'}).addClass('patch-content').append(
$('<td/>', {colspan: 3}).load('/widgets/package.sources.patch',
- {package: '${w.package}', patch: patch})));
+ {package: '${w.package}', patch: patch, branch: $('#release_select').val()})));
return false;
}