##// END OF EJS Templates
controllers: simplify request.GET.get for safe_int...
Mads Kiilerich -
r5992:fb64046d default
parent child Browse files
Show More
@@ -135,7 +135,7 b' class AdminController(BaseController):'
135
135
136 users_log = users_log.order_by(UserLog.action_date.desc())
136 users_log = users_log.order_by(UserLog.action_date.desc())
137
137
138 p = safe_int(request.GET.get('page', 1), 1)
138 p = safe_int(request.GET.get('page'), 1)
139
139
140 def url_generator(**kw):
140 def url_generator(**kw):
141 return url.current(filter=c.search_term, **kw)
141 return url.current(filter=c.search_term, **kw)
@@ -97,7 +97,7 b' class GistsController(BaseController):'
97 gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC)
97 gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC)
98
98
99 c.gists = gists
99 c.gists = gists
100 p = safe_int(request.GET.get('page', 1), 1)
100 p = safe_int(request.GET.get('page'), 1)
101 c.gists_pager = Page(c.gists, page=p, items_per_page=10)
101 c.gists_pager = Page(c.gists, page=p, items_per_page=10)
102 return render('admin/gists/index.html')
102 return render('admin/gists/index.html')
103
103
@@ -64,7 +64,7 b' class NotificationsController(BaseContro'
64 notif = NotificationModel().query_for_user(self.authuser.user_id,
64 notif = NotificationModel().query_for_user(self.authuser.user_id,
65 filter_=request.GET.getall('type'))
65 filter_=request.GET.getall('type'))
66
66
67 p = safe_int(request.GET.get('page', 1), 1)
67 p = safe_int(request.GET.get('page'), 1)
68 c.notifications = Page(notif, page=p, items_per_page=10)
68 c.notifications = Page(notif, page=p, items_per_page=10)
69 c.pull_request_type = Notification.TYPE_PULL_REQUEST
69 c.pull_request_type = Notification.TYPE_PULL_REQUEST
70 c.comment_type = [Notification.TYPE_CHANGESET_COMMENT,
70 c.comment_type = [Notification.TYPE_CHANGESET_COMMENT,
@@ -111,7 +111,7 b' class ChangelogController(BaseRepoContro'
111 c.size = int(session.get('changelog_size', default))
111 c.size = int(session.get('changelog_size', default))
112 # min size must be 1
112 # min size must be 1
113 c.size = max(c.size, 1)
113 c.size = max(c.size, 1)
114 p = safe_int(request.GET.get('page', 1), 1)
114 p = safe_int(request.GET.get('page'), 1)
115 branch_name = request.GET.get('branch', None)
115 branch_name = request.GET.get('branch', None)
116 if (branch_name and
116 if (branch_name and
117 branch_name not in c.db_repo_scm_instance.branches and
117 branch_name not in c.db_repo_scm_instance.branches and
@@ -47,7 +47,7 b' class FollowersController(BaseRepoContro'
47 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
47 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
48 'repository.admin')
48 'repository.admin')
49 def followers(self, repo_name):
49 def followers(self, repo_name):
50 p = safe_int(request.GET.get('page', 1), 1)
50 p = safe_int(request.GET.get('page'), 1)
51 repo_id = c.db_repo.repo_id
51 repo_id = c.db_repo.repo_id
52 d = UserFollowing.get_repo_followers(repo_id) \
52 d = UserFollowing.get_repo_followers(repo_id) \
53 .order_by(UserFollowing.follows_from)
53 .order_by(UserFollowing.follows_from)
@@ -112,7 +112,7 b' class ForksController(BaseRepoController'
112 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
112 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
113 'repository.admin')
113 'repository.admin')
114 def forks(self, repo_name):
114 def forks(self, repo_name):
115 p = safe_int(request.GET.get('page', 1), 1)
115 p = safe_int(request.GET.get('page'), 1)
116 repo_id = c.db_repo.repo_id
116 repo_id = c.db_repo.repo_id
117 d = []
117 d = []
118 for r in Repository.get_repo_forks(repo_id):
118 for r in Repository.get_repo_forks(repo_id):
@@ -192,7 +192,7 b' class JournalController(BaseController):'
192 @NotAnonymous()
192 @NotAnonymous()
193 def index(self):
193 def index(self):
194 # Return a rendered template
194 # Return a rendered template
195 p = safe_int(request.GET.get('page', 1), 1)
195 p = safe_int(request.GET.get('page'), 1)
196 c.user = User.get(self.authuser.user_id)
196 c.user = User.get(self.authuser.user_id)
197 c.following = self.sa.query(UserFollowing) \
197 c.following = self.sa.query(UserFollowing) \
198 .filter(UserFollowing.user_id == self.authuser.user_id) \
198 .filter(UserFollowing.user_id == self.authuser.user_id) \
@@ -328,7 +328,7 b' class JournalController(BaseController):'
328 @LoginRequired()
328 @LoginRequired()
329 def public_journal(self):
329 def public_journal(self):
330 # Return a rendered template
330 # Return a rendered template
331 p = safe_int(request.GET.get('page', 1), 1)
331 p = safe_int(request.GET.get('page'), 1)
332
332
333 c.following = self.sa.query(UserFollowing) \
333 c.following = self.sa.query(UserFollowing) \
334 .filter(UserFollowing.user_id == self.authuser.user_id) \
334 .filter(UserFollowing.user_id == self.authuser.user_id) \
@@ -197,7 +197,7 b' class PullrequestsController(BaseRepoCon'
197 c.closed = request.GET.get('closed') or ''
197 c.closed = request.GET.get('closed') or ''
198 c.pull_requests = PullRequestModel().get_all(repo_name, from_=c.from_, closed=c.closed)
198 c.pull_requests = PullRequestModel().get_all(repo_name, from_=c.from_, closed=c.closed)
199 c.repo_name = repo_name
199 c.repo_name = repo_name
200 p = safe_int(request.GET.get('page', 1), 1)
200 p = safe_int(request.GET.get('page'), 1)
201
201
202 c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=100)
202 c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=100)
203
203
@@ -85,7 +85,7 b' class SearchController(BaseRepoControlle'
85 log.debug(cur_query)
85 log.debug(cur_query)
86
86
87 if c.cur_query:
87 if c.cur_query:
88 p = safe_int(request.GET.get('page', 1), 1)
88 p = safe_int(request.GET.get('page'), 1)
89 highlight_items = set()
89 highlight_items = set()
90 try:
90 try:
91 idx = open_dir(config['app_conf']['index_dir'],
91 idx = open_dir(config['app_conf']['index_dir'],
General Comments 0
You need to be logged in to leave comments. Login now