Parent: [2aae89] (diff)

Child: [65b74c] (diff)

Download this file

controllers.py    94 lines (75 with data), 2.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from tg import expose, url, override_template
from tg.decorators import with_trailing_slash, without_trailing_slash
from pylons import c
from webob import exc
from pyforge.controllers import repository
from pyforge.lib.security import require, has_artifact_access
from .widgets import SVNRevisionWidget, SVNLog
revision_widget = SVNRevisionWidget()
log_widget = SVNLog()
def on_import():
BranchBrowser.CommitBrowserClass = CommitBrowser
CommitBrowser.TreeBrowserClass = TreeBrowser
TreeBrowser.FileBrowserClass = FileBrowser
class BranchBrowser(repository.BranchBrowser):
def _check_security(self):
require(has_artifact_access('read', c.app.repo))
def __init__(self):
super(BranchBrowser, self).__init__(None)
@expose('forgesvn.templates.index')
@with_trailing_slash
def index(self, limit=None, page=0, count=0, **kw):
c.log_widget=log_widget
return super(BranchBrowser, self).index(limit, page, count)
@expose('forgesvn.templates.log')
@with_trailing_slash
def log(self, limit=None, page=0, count=0, **kw):
c.log_widget=log_widget
return super(BranchBrowser, self).index(limit, page, count)
@expose()
def _lookup(self, rev, *remainder):
return CommitBrowser(rev), remainder
class CommitBrowser(repository.CommitBrowser):
revision_widget = SVNRevisionWidget()
def __init__(self, rev):
if rev == 'LATEST':
if c.app.repo.latest:
rev = c.app.repo.latest.revision.number
else:
rev = 0
try:
rev = int(rev)
except ValueError:
raise exc.HTTPNotFound()
super(CommitBrowser, self).__init__(rev)
@expose('forgesvn.templates.commit')
@with_trailing_slash
def index(self, **kw):
result = super(CommitBrowser, self).index()
if not self._commit:
return result
if self._revision > 1:
result['prev'] = '../%s/' % (self._revision - 1)
else:
result['prev'] = None
if self._revision < c.app.repo.latest.revision.number:
result['next'] = '../%s/' % (self._revision + 1)
else:
result['next'] = None
c.revision_widget = revision_widget
return result
class TreeBrowser(repository.TreeBrowser):
@expose('forgesvn.templates.tree')
@with_trailing_slash
def index(self, **kw):
return super(TreeBrowser, self).index()
class FileBrowser(repository.FileBrowser):
@expose('forgesvn.templates.file')
@without_trailing_slash
def index(self, **kw):
if 'diff' in kw:
override_template(self.index, 'genshi:forgesvn.templates.diff')
return self.diff(int(kw['diff']))
result = super(FileBrowser, self).index(**kw)
return result
on_import()