##// END OF EJS Templates
pep8ify
marcink -
r1212:50e41777 beta
parent child Browse files
Show More
@@ -33,6 +33,7 b' from rhodecode.lib.utils import OrderedD'
33 33
34 34 log = logging.getLogger(__name__)
35 35
36
36 37 class BranchesController(BaseRepoController):
37 38
38 39 @LoginRequired()
@@ -40,6 +40,7 b' from rhodecode.lib.helpers import RepoPa'
40 40
41 41 log = logging.getLogger(__name__)
42 42
43
43 44 class ChangelogController(BaseRepoController):
44 45
45 46 @LoginRequired()
@@ -67,14 +68,14 b' class ChangelogController(BaseRepoContro'
67 68 p = int(request.params.get('page', 1))
68 69 branch_name = request.params.get('branch', None)
69 70 c.total_cs = len(c.rhodecode_repo)
70 c.pagination = RepoPage(c.rhodecode_repo, page=p, item_count=c.total_cs,
71 items_per_page=c.size, branch_name=branch_name)
71 c.pagination = RepoPage(c.rhodecode_repo, page=p,
72 item_count=c.total_cs, items_per_page=c.size,
73 branch_name=branch_name)
72 74
73 75 self._graph(c.rhodecode_repo, c.total_cs, c.size, p)
74 76
75 77 return render('changelog/changelog.html')
76 78
77
78 79 def _graph(self, repo, repo_size, size, p):
79 80 """
80 81 Generates a DAG graph for mercurial
@@ -43,6 +43,7 b' from vcs.utils.ordered_dict import Order'
43 43
44 44 log = logging.getLogger(__name__)
45 45
46
46 47 class ChangesetController(BaseRepoController):
47 48
48 49 @LoginRequired()
@@ -94,7 +95,6 b' class ChangesetController(BaseRepoContro'
94 95 except IndexError:
95 96 changeset_parent = None
96 97
97
98 98 #==================================================================
99 99 # ADDED FILES
100 100 #==================================================================
@@ -106,17 +106,20 b' class ChangesetController(BaseRepoContro'
106 106 c.sum_added += node.size
107 107 if c.sum_added < self.cut_off_limit:
108 108 f_gitdiff = differ.get_gitdiff(filenode_old, node)
109 diff = differ.DiffProcessor(f_gitdiff, format='gitdiff').as_html()
109 diff = differ.DiffProcessor(f_gitdiff,
110 format='gitdiff').as_html()
110 111
111 112 else:
112 diff = wrap_to_table(_('Changeset is to big and was cut'
113 ' off, see raw changeset instead'))
113 diff = wrap_to_table(_('Changeset is to big and '
114 'was cut off, see raw '
115 'changeset instead'))
114 116 c.cut_off = True
115 117 break
116 118
117 119 cs1 = None
118 120 cs2 = node.last_changeset.raw_id
119 c.changes[changeset.raw_id].append(('added', node, diff, cs1, cs2))
121 c.changes[changeset.raw_id].append(('added', node,
122 diff, cs1, cs2))
120 123
121 124 #==================================================================
122 125 # CHANGED FILES
@@ -126,7 +129,8 b' class ChangesetController(BaseRepoContro'
126 129 try:
127 130 filenode_old = changeset_parent.get_node(node.path)
128 131 except ChangesetError:
129 filenode_old = FileNode(node.path, '', EmptyChangeset())
132 filenode_old = FileNode(node.path, '',
133 EmptyChangeset())
130 134
131 135 if filenode_old.is_binary or node.is_binary:
132 136 diff = wrap_to_table(_('binary file'))
@@ -134,25 +138,30 b' class ChangesetController(BaseRepoContro'
134 138
135 139 if c.sum_removed < self.cut_off_limit:
136 140 f_gitdiff = differ.get_gitdiff(filenode_old, node)
137 diff = differ.DiffProcessor(f_gitdiff, format='gitdiff').as_html()
141 diff = differ.DiffProcessor(f_gitdiff,
142 format='gitdiff')\
143 .as_html()
138 144 if diff:
139 145 c.sum_removed += len(diff)
140 146 else:
141 diff = wrap_to_table(_('Changeset is to big and was cut'
142 ' off, see raw changeset instead'))
147 diff = wrap_to_table(_('Changeset is to big and '
148 'was cut off, see raw '
149 'changeset instead'))
143 150 c.cut_off = True
144 151 break
145 152
146 153 cs1 = filenode_old.last_changeset.raw_id
147 154 cs2 = node.last_changeset.raw_id
148 c.changes[changeset.raw_id].append(('changed', node, diff, cs1, cs2))
155 c.changes[changeset.raw_id].append(('changed', node,
156 diff, cs1, cs2))
149 157
150 158 #==================================================================
151 159 # REMOVED FILES
152 160 #==================================================================
153 161 if not c.cut_off:
154 162 for node in changeset.removed:
155 c.changes[changeset.raw_id].append(('removed', node, None, None, None))
163 c.changes[changeset.raw_id].append(('removed', node, None,
164 None, None))
156 165
157 166 if len(c.cs_ranges) == 1:
158 167 c.changeset = c.cs_ranges[0]
@@ -184,7 +193,8 b' class ChangesetController(BaseRepoContro'
184 193 diff = _('binary file') + '\n'
185 194 else:
186 195 f_gitdiff = differ.get_gitdiff(filenode_old, node)
187 diff = differ.DiffProcessor(f_gitdiff, format='gitdiff').raw_diff()
196 diff = differ.DiffProcessor(f_gitdiff,
197 format='gitdiff').raw_diff()
188 198
189 199 cs1 = None
190 200 cs2 = node.last_changeset.raw_id
@@ -196,7 +206,8 b' class ChangesetController(BaseRepoContro'
196 206 diff = _('binary file')
197 207 else:
198 208 f_gitdiff = differ.get_gitdiff(filenode_old, node)
199 diff = differ.DiffProcessor(f_gitdiff, format='gitdiff').raw_diff()
209 diff = differ.DiffProcessor(f_gitdiff,
210 format='gitdiff').raw_diff()
200 211
201 212 cs1 = filenode_old.last_changeset.raw_id
202 213 cs2 = node.last_changeset.raw_id
@@ -205,10 +216,12 b' class ChangesetController(BaseRepoContro'
205 216 response.content_type = 'text/plain'
206 217
207 218 if method == 'download':
208 response.content_disposition = 'attachment; filename=%s.patch' % revision
219 response.content_disposition = 'attachment; filename=%s.patch' \
220 % revision
209 221
210 222 parent = True if len(c.changeset.parents) > 0 else False
211 c.parent_tmpl = 'Parent %s' % c.changeset.parents[0].raw_id if parent else ''
223 c.parent_tmpl = 'Parent %s' \
224 % c.changeset.parents[0].raw_id if parent else ''
212 225
213 226 c.diffs = ''
214 227 for x in c.changes:
@@ -27,7 +27,7 b' import cgi'
27 27 import logging
28 28 import paste.fileapp
29 29
30 from pylons import tmpl_context as c, request, config
30 from pylons import tmpl_context as c, request, config, url
31 31 from pylons.i18n.translation import _
32 32 from pylons.middleware import media_path
33 33
@@ -35,6 +35,7 b' from rhodecode.lib.base import BaseContr'
35 35
36 36 log = logging.getLogger(__name__)
37 37
38
38 39 class ErrorController(BaseController):
39 40 """Generates error documents as and when they are required.
40 41
@@ -46,7 +47,8 b' class ErrorController(BaseController):'
46 47 """
47 48
48 49 def __before__(self):
49 pass#disable all base actions since we don't need them here
50 #disable all base actions since we don't need them here
51 pass
50 52
51 53 def document(self):
52 54 resp = request.environ.get('pylons.original_response')
@@ -55,23 +57,20 b' class ErrorController(BaseController):'
55 57 log.debug('### %s ###', resp.status)
56 58
57 59 e = request.environ
58 c.serv_p = r'%(protocol)s://%(host)s/' % {
59 'protocol': e.get('wsgi.url_scheme'),
60 'host':e.get('HTTP_HOST'),
61 }
62
60 c.serv_p = r'%(protocol)s://%(host)s/' \
61 % {'protocol': e.get('wsgi.url_scheme'),
62 'host': e.get('HTTP_HOST'), }
63 63
64 64 c.error_message = cgi.escape(request.GET.get('code', str(resp.status)))
65 65 c.error_explanation = self.get_error_explanation(resp.status_int)
66 66
67 67 #redirect to when error with given seconds
68 68 c.redirect_time = 0
69 c.redirect_module = _('Home page')# name to what your going to be redirected
69 c.redirect_module = _('Home page')
70 70 c.url_redirect = "/"
71 71
72 72 return render('/errors/error_document.html')
73 73
74
75 74 def img(self, id):
76 75 """Serve Pylons' stock images"""
77 76 return self._serve_file(os.path.join(media_path, 'img', id))
@@ -96,7 +95,8 b' class ErrorController(BaseController):'
96 95 code = 500
97 96
98 97 if code == 400:
99 return _('The request could not be understood by the server due to malformed syntax.')
98 return _('The request could not be understood by the server'
99 ' due to malformed syntax.')
100 100 if code == 401:
101 101 return _('Unauthorized access to resource')
102 102 if code == 403:
@@ -104,4 +104,5 b' class ErrorController(BaseController):'
104 104 if code == 404:
105 105 return _('The resource could not be found')
106 106 if code == 500:
107 return _('The server encountered an unexpected condition which prevented it from fulfilling the request.')
107 return _('The server encountered an unexpected condition'
108 ' which prevented it from fulfilling the request.')
@@ -35,6 +35,7 b' from webhelpers.feedgenerator import Ato'
35 35
36 36 log = logging.getLogger(__name__)
37 37
38
38 39 class FeedController(BaseRepoController):
39 40
40 41 @LoginRequired(api_access=True)
@@ -71,7 +72,8 b' class FeedController(BaseRepoController)'
71 72 def atom(self, repo_name):
72 73 """Produce an atom-1.0 feed via feedgenerator module"""
73 74 feed = Atom1Feed(title=self.title % repo_name,
74 link=url('summary_home', repo_name=repo_name, qualified=True),
75 link=url('summary_home', repo_name=repo_name,
76 qualified=True),
75 77 description=self.description % repo_name,
76 78 language=self.language,
77 79 ttl=self.ttl)
@@ -89,11 +91,11 b' class FeedController(BaseRepoController)'
89 91 response.content_type = feed.mime_type
90 92 return feed.writeString('utf-8')
91 93
92
93 94 def rss(self, repo_name):
94 95 """Produce an rss2 feed via feedgenerator module"""
95 96 feed = Rss201rev2Feed(title=self.title % repo_name,
96 link=url('summary_home', repo_name=repo_name, qualified=True),
97 link=url('summary_home', repo_name=repo_name,
98 qualified=True),
97 99 description=self.description % repo_name,
98 100 language=self.language,
99 101 ttl=self.ttl)
@@ -73,7 +73,6 b' class FilesController(BaseRepoController'
73 73 h.flash(str(e), category='warning')
74 74 redirect(h.url('files_home', repo_name=repo_name, revision='tip'))
75 75
76
77 76 def __get_filenode_or_redirect(self, repo_name, cs, path):
78 77 """
79 78 Returns file_node, if error occurs or given path is directory,
@@ -84,7 +83,6 b' class FilesController(BaseRepoController'
84 83 :param path: path to lookup
85 84 """
86 85
87
88 86 try:
89 87 file_node = cs.get_node(path)
90 88 if file_node.is_dir():
@@ -104,7 +102,6 b' class FilesController(BaseRepoController'
104 102 redirect(url('files_home', repo_name=c.repo_name,
105 103 revision=cs.raw_id, f_path=f_path))
106 104
107
108 105 c.changeset = self.__get_cs_or_redirect(revision, repo_name)
109 106 c.branch = request.GET.get('branch', None)
110 107 c.f_path = f_path
@@ -144,7 +141,6 b' class FilesController(BaseRepoController'
144 141 redirect(h.url('files_home', repo_name=repo_name,
145 142 revision=revision))
146 143
147
148 144 return render('files/files.html')
149 145
150 146 def rawfile(self, repo_name, revision, f_path):
@@ -205,7 +201,6 b' class FilesController(BaseRepoController'
205 201
206 202 return cs.get_chunked_archive(stream=None, kind=fileformat)
207 203
208
209 204 def diff(self, repo_name, f_path):
210 205 diff1 = request.GET.get('diff1')
211 206 diff2 = request.GET.get('diff2')
@@ -231,7 +226,6 b' class FilesController(BaseRepoController'
231 226 return redirect(url('files_home',
232 227 repo_name=c.repo_name, f_path=f_path))
233 228
234
235 229 if c.action == 'download':
236 230 diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2),
237 231 format='gitdiff')
@@ -252,7 +246,8 b' class FilesController(BaseRepoController'
252 246
253 247 if node1.is_binary or node2.is_binary:
254 248 c.cur_diff = _('Binary file')
255 elif node1.size > self.cut_off_limit or node2.size > self.cut_off_limit:
249 elif node1.size > self.cut_off_limit or \
250 node2.size > self.cut_off_limit:
256 251 c.cur_diff = _('Diff is too big to display')
257 252 else:
258 253 diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2),
@@ -263,7 +258,8 b' class FilesController(BaseRepoController'
263 258 #default option
264 259 if node1.is_binary or node2.is_binary:
265 260 c.cur_diff = _('Binary file')
266 elif node1.size > self.cut_off_limit or node2.size > self.cut_off_limit:
261 elif node1.size > self.cut_off_limit or \
262 node2.size > self.cut_off_limit:
267 263 c.cur_diff = _('Diff is too big to display')
268 264 else:
269 265 diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2),
@@ -35,6 +35,7 b' from rhodecode.lib.base import BaseContr'
35 35
36 36 log = logging.getLogger(__name__)
37 37
38
38 39 class HomeController(BaseController):
39 40
40 41 @LoginRequired()
@@ -41,10 +41,9 b' from rhodecode.model.db import UserLog, '
41 41
42 42 log = logging.getLogger(__name__)
43 43
44
44 45 class JournalController(BaseController):
45 46
46
47
48 47 def __before__(self):
49 48 super(JournalController, self).__before__()
50 49 self.rhodecode_user = self.rhodecode_user
@@ -75,7 +74,6 b' class JournalController(BaseController):'
75 74 return c.journal_data
76 75 return render('journal/journal.html')
77 76
78
79 77 def _get_daily_aggregate(self, journal):
80 78 groups = []
81 79 for k, g in groupby(journal, lambda x:x.action_as_day):
@@ -88,7 +86,6 b' class JournalController(BaseController):'
88 86
89 87 return groups
90 88
91
92 89 def _get_journal_data(self, following_repos):
93 90 repo_ids = [x.follows_repository.repo_id for x in following_repos
94 91 if x.follows_repository is not None]
@@ -113,7 +110,6 b' class JournalController(BaseController):'
113 110 else:
114 111 journal = []
115 112
116
117 113 return journal
118 114
119 115 @LoginRequired()
@@ -141,12 +137,9 b' class JournalController(BaseController):'
141 137 except:
142 138 raise HTTPBadRequest()
143 139
144
145 140 log.debug('token mismatch %s vs %s', cur_token, token)
146 141 raise HTTPBadRequest()
147 142
148
149
150 143 @LoginRequired()
151 144 def public_journal(self):
152 145 # Return a rendered template
@@ -168,7 +161,6 b' class JournalController(BaseController):'
168 161 return c.journal_data
169 162 return render('journal/public_journal.html')
170 163
171
172 164 @LoginRequired(api_access=True)
173 165 def public_journal_atom(self):
174 166 """
@@ -41,6 +41,7 b' from rhodecode.model.user import UserMod'
41 41
42 42 log = logging.getLogger(__name__)
43 43
44
44 45 class LoginController(BaseController):
45 46
46 47 def __before__(self):
@@ -93,7 +94,8 b' class LoginController(BaseController):'
93 94 def register(self):
94 95 user_model = UserModel()
95 96 c.auto_active = False
96 for perm in user_model.get_by_username('default', cache=False).user_perms:
97 for perm in user_model.get_by_username('default',
98 cache=False).user_perms:
97 99 if perm.permission.permission_name == 'hg.register.auto_activate':
98 100 c.auto_active = True
99 101 break
@@ -41,6 +41,7 b' from whoosh.query import Phrase'
41 41
42 42 log = logging.getLogger(__name__)
43 43
44
44 45 class SearchController(BaseController):
45 46
46 47 @LoginRequired()
@@ -59,7 +60,6 b' class SearchController(BaseController):'
59 60 'repository':'repository'}\
60 61 .get(c.cur_type, 'content')
61 62
62
63 63 if c.cur_query:
64 64 cur_query = c.cur_query.lower()
65 65
@@ -67,8 +67,8 b' class SearchController(BaseController):'
67 67 p = int(request.params.get('page', 1))
68 68 highlight_items = set()
69 69 try:
70 idx = open_dir(config['app_conf']['index_dir']
71 , indexname=IDX_NAME)
70 idx = open_dir(config['app_conf']['index_dir'],
71 indexname=IDX_NAME)
72 72 searcher = idx.searcher()
73 73
74 74 qp = QueryParser(search_type, schema=SCHEMA)
@@ -103,7 +103,6 b' class SearchController(BaseController):'
103 103 page=p, item_count=res_ln,
104 104 items_per_page=10, url=url_generator)
105 105
106
107 106 except QueryParserError:
108 107 c.runtime = _('Invalid search query. Try quoting it.')
109 108 searcher.close()
@@ -46,6 +46,7 b' from rhodecode.model.db import User'
46 46
47 47 log = logging.getLogger(__name__)
48 48
49
49 50 class SettingsController(BaseRepoController):
50 51
51 52 @LoginRequired()
@@ -99,7 +100,8 b' class SettingsController(BaseRepoControl'
99 100 def update(self, repo_name):
100 101 repo_model = RepoModel()
101 102 changed_name = repo_name
102 _form = RepoSettingsForm(edit=True, old_data={'repo_name':repo_name})()
103 _form = RepoSettingsForm(edit=True,
104 old_data={'repo_name': repo_name})()
103 105 try:
104 106 form_result = _form.to_python(dict(request.POST))
105 107 repo_model.update(repo_name, form_result)
@@ -126,7 +128,6 b' class SettingsController(BaseRepoControl'
126 128
127 129 return redirect(url('repo_settings_home', repo_name=changed_name))
128 130
129
130 131 @HasRepoPermissionAllDecorator('repository.admin')
131 132 def delete(self, repo_name):
132 133 """DELETE /repos/repo_name: Delete an existing item"""
@@ -34,8 +34,6 b' from rhodecode.lib.helpers import RepoPa'
34 34 log = logging.getLogger(__name__)
35 35
36 36
37
38
39 37 class ShortlogController(BaseRepoController):
40 38
41 39 @LoginRequired()
@@ -46,7 +44,8 b' class ShortlogController(BaseRepoControl'
46 44
47 45 def index(self):
48 46 p = int(request.params.get('page', 1))
49 c.repo_changesets = RepoPage(c.rhodecode_repo, page=p, items_per_page=20)
47 c.repo_changesets = RepoPage(c.rhodecode_repo, page=p,
48 items_per_page=20)
50 49 c.shortlog_data = render('shortlog/shortlog_data.html')
51 50 if request.params.get('partial'):
52 51 return c.shortlog_data
@@ -51,6 +51,7 b' except ImportError:'
51 51 import simplejson as json
52 52 log = logging.getLogger(__name__)
53 53
54
54 55 class SummaryController(BaseRepoController):
55 56
56 57 @LoginRequired()
@@ -66,13 +67,12 b' class SummaryController(BaseRepoControll'
66 67
67 68 c.following = self.scm_model.is_following_repo(repo_name,
68 69 self.rhodecode_user.user_id)
70
69 71 def url_generator(**kw):
70 72 return url('shortlog_home', repo_name=repo_name, **kw)
71 73
72 c.repo_changesets = RepoPage(c.rhodecode_repo, page=1, items_per_page=10,
73 url=url_generator)
74
75
74 c.repo_changesets = RepoPage(c.rhodecode_repo, page=1,
75 items_per_page=10, url=url_generator)
76 76
77 77 if self.rhodecode_user.username == 'default':
78 78 #for default(anonymous) user we don't need to pass credentials
@@ -82,10 +82,10 b' class SummaryController(BaseRepoControll'
82 82 username = str(self.rhodecode_user.username)
83 83 password = '@'
84 84
85 uri = u'%(protocol)s://%(user)s%(password)s%(host)s%(prefix)s/%(repo_name)s' % {
86 'protocol': e.get('wsgi.url_scheme'),
85 uri = u'%(proto)s://%(user)s%(pass)s%(host)s%(prefix)s/%(repo_name)s' \
86 % {'proto': e.get('wsgi.url_scheme'),
87 87 'user':username,
88 'password':password,
88 'pass': password,
89 89 'host':e.get('HTTP_HOST'),
90 90 'prefix':e.get('SCRIPT_NAME'),
91 91 'repo_name':repo_name, }
@@ -156,8 +156,6 b' class SummaryController(BaseRepoControll'
156 156
157 157 return render('summary/summary.html')
158 158
159
160
161 159 def _get_download_links(self, repo):
162 160
163 161 download_l = []
@@ -32,6 +32,7 b' from rhodecode.lib.utils import OrderedD'
32 32
33 33 log = logging.getLogger(__name__)
34 34
35
35 36 class TagsController(BaseRepoController):
36 37
37 38 @LoginRequired()
General Comments 0
You need to be logged in to leave comments. Login now