changeset 6029:fb64046d02c2

controllers: simplify request.GET.get for safe_int Don't specify the default value twice - the one for safe_int is enough.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 28 Jul 2016 16:28:34 +0200
parents cf7d952c292f
children 5dfaa9f1fdb2
files kallithea/controllers/admin/admin.py kallithea/controllers/admin/gists.py kallithea/controllers/admin/notifications.py kallithea/controllers/changelog.py kallithea/controllers/followers.py kallithea/controllers/forks.py kallithea/controllers/journal.py kallithea/controllers/pullrequests.py kallithea/controllers/search.py
diffstat 9 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/admin/admin.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/admin/admin.py	Thu Jul 28 16:28:34 2016 +0200
@@ -135,7 +135,7 @@
 
         users_log = users_log.order_by(UserLog.action_date.desc())
 
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
 
         def url_generator(**kw):
             return url.current(filter=c.search_term, **kw)
--- a/kallithea/controllers/admin/gists.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/admin/gists.py	Thu Jul 28 16:28:34 2016 +0200
@@ -97,7 +97,7 @@
             gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC)
 
         c.gists = gists
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
         c.gists_pager = Page(c.gists, page=p, items_per_page=10)
         return render('admin/gists/index.html')
 
--- a/kallithea/controllers/admin/notifications.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/admin/notifications.py	Thu Jul 28 16:28:34 2016 +0200
@@ -64,7 +64,7 @@
         notif = NotificationModel().query_for_user(self.authuser.user_id,
                                             filter_=request.GET.getall('type'))
 
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
         c.notifications = Page(notif, page=p, items_per_page=10)
         c.pull_request_type = Notification.TYPE_PULL_REQUEST
         c.comment_type = [Notification.TYPE_CHANGESET_COMMENT,
--- a/kallithea/controllers/changelog.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/changelog.py	Thu Jul 28 16:28:34 2016 +0200
@@ -111,7 +111,7 @@
             c.size = int(session.get('changelog_size', default))
         # min size must be 1
         c.size = max(c.size, 1)
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
         branch_name = request.GET.get('branch', None)
         if (branch_name and
             branch_name not in c.db_repo_scm_instance.branches and
--- a/kallithea/controllers/followers.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/followers.py	Thu Jul 28 16:28:34 2016 +0200
@@ -47,7 +47,7 @@
     @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
                                    'repository.admin')
     def followers(self, repo_name):
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
         repo_id = c.db_repo.repo_id
         d = UserFollowing.get_repo_followers(repo_id) \
             .order_by(UserFollowing.follows_from)
--- a/kallithea/controllers/forks.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/forks.py	Thu Jul 28 16:28:34 2016 +0200
@@ -112,7 +112,7 @@
     @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
                                    'repository.admin')
     def forks(self, repo_name):
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
         repo_id = c.db_repo.repo_id
         d = []
         for r in Repository.get_repo_forks(repo_id):
--- a/kallithea/controllers/journal.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/journal.py	Thu Jul 28 16:28:34 2016 +0200
@@ -192,7 +192,7 @@
     @NotAnonymous()
     def index(self):
         # Return a rendered template
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
         c.user = User.get(self.authuser.user_id)
         c.following = self.sa.query(UserFollowing) \
             .filter(UserFollowing.user_id == self.authuser.user_id) \
@@ -328,7 +328,7 @@
     @LoginRequired()
     def public_journal(self):
         # Return a rendered template
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
 
         c.following = self.sa.query(UserFollowing) \
             .filter(UserFollowing.user_id == self.authuser.user_id) \
--- a/kallithea/controllers/pullrequests.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/pullrequests.py	Thu Jul 28 16:28:34 2016 +0200
@@ -197,7 +197,7 @@
         c.closed = request.GET.get('closed') or ''
         c.pull_requests = PullRequestModel().get_all(repo_name, from_=c.from_, closed=c.closed)
         c.repo_name = repo_name
-        p = safe_int(request.GET.get('page', 1), 1)
+        p = safe_int(request.GET.get('page'), 1)
 
         c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=100)
 
--- a/kallithea/controllers/search.py	Thu Jul 28 16:28:34 2016 +0200
+++ b/kallithea/controllers/search.py	Thu Jul 28 16:28:34 2016 +0200
@@ -85,7 +85,7 @@
             log.debug(cur_query)
 
         if c.cur_query:
-            p = safe_int(request.GET.get('page', 1), 1)
+            p = safe_int(request.GET.get('page'), 1)
             highlight_items = set()
             try:
                 idx = open_dir(config['app_conf']['index_dir'],