From eb6723e8602da07b8a2e0b32e6498f37ed31de6a Mon Sep 17 00:00:00 2001
From: vibhcool <vibhcool@gmail.com>
Date: Nov 13 2016 19:22:28 +0000
Subject: [PATCH 1/4] fix total pages when no pull requests, forks, issues or repo


---

diff --git a/pagure/ui/app.py b/pagure/ui/app.py
index 3f99321..66ee14e 100644
--- a/pagure/ui/app.py
+++ b/pagure/ui/app.py
@@ -56,7 +56,7 @@ def index():
         SESSION,
         fork=False,
         count=True)
-    total_page = int(ceil(num_repos / float(limit)))
+    total_page = int(ceil(num_repos / float(limit)) if num_repos > 0 else 1)
 
     if authenticated() and flask.request.path == '/':
         return index_auth()
diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index 732c0e4..c69ceb8 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -208,7 +208,7 @@ def request_pulls(repo, username=None, namespace=None):
     else:
         head = 'master'
 
-    total_page = int(ceil(requests_cnt / float(flask.g.limit)))
+    total_page = int(ceil(requests_cnt / float(flask.g.limit)) if requests_cnt > 0 else 1)
 
     return flask.render_template(
         'requests.html',
diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py
index 1a291a7..e94e57c 100644
--- a/pagure/ui/issues.py
+++ b/pagure/ui/issues.py
@@ -542,7 +542,7 @@ def view_issues(repo, username=None, namespace=None):
 
     tag_list = pagure.lib.get_tags_of_project(SESSION, repo)
 
-    total_page = int(ceil(issues_cnt / float(flask.g.limit)))
+    total_page = int(ceil(issues_cnt / float(flask.g.limit)) if issues_cnt > 0 else 1)
 
     return flask.render_template(
         'issues.html',
diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py
index 64819f3..924ca03 100644
--- a/pagure/ui/repo.py
+++ b/pagure/ui/repo.py
@@ -337,7 +337,7 @@ def view_commits(repo, branchname=None, username=None, namespace=None):
                 last_commits.append(commit)
             n_commits += 1
 
-    total_page = int(ceil(n_commits / float(limit)))
+    total_page = int(ceil(n_commits / float(limit)) if n_commits > 0 else 1)
 
     diff_commits = []
     diff_commits_full = []

From 928b55873eb8ffe47511b9f0ac79fb296ff0b500 Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Nov 14 2016 07:31:29 +0000
Subject: [PATCH 2/4] fix pep8 exceeding max characters problem


---

diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index c69ceb8..7bce606 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -208,7 +208,10 @@ def request_pulls(repo, username=None, namespace=None):
     else:
         head = 'master'
 
-    total_page = int(ceil(requests_cnt / float(flask.g.limit)) if requests_cnt > 0 else 1)
+    if(requests_cnt > 0):
+	   total_page = int(ceil(requests_cnt / float(flask.g.limit)))
+	else:
+		total_page = 1
 
     return flask.render_template(
         'requests.html',

From ebb8dd2d42a32e6cd7b6f60f2443ae72d0f083f0 Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Nov 14 2016 07:46:55 +0000
Subject: [PATCH 3/4] fix indentation error


---

diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index 7bce606..ac82fe2 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -209,9 +209,9 @@ def request_pulls(repo, username=None, namespace=None):
         head = 'master'
 
     if(requests_cnt > 0):
-	   total_page = int(ceil(requests_cnt / float(flask.g.limit)))
-	else:
-		total_page = 1
+        total_page = int(ceil(requests_cnt / float(flask.g.limit)))
+    else:
+        total_page = 1
 
     return flask.render_template(
         'requests.html',

From 68e31753fd87dba0032827e9fd62b196b1993760 Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Nov 14 2016 08:03:30 +0000
Subject: [PATCH 4/4] replace with 1 liner if condition


---

diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index ac82fe2..aaccfba 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -208,10 +208,8 @@ def request_pulls(repo, username=None, namespace=None):
     else:
         head = 'master'
 
-    if(requests_cnt > 0):
-        total_page = int(ceil(requests_cnt / float(flask.g.limit)))
-    else:
-        total_page = 1
+    total_page = int(ceil(requests_cnt / float(flask.g.limit)) \
+    if requests_cnt > 0 else 1)
 
     return flask.render_template(
         'requests.html',

