Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito
Commits
ad488876
Commit
ad488876
authored
May 10, 2018
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pagination
parent
db1a1c78
Pipeline
#88
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
uitwww/actions.py
uitwww/actions.py
+4
-3
No files found.
uitwww/actions.py
View file @
ad488876
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
math
import
time
import
time
import
flask
import
flask
...
@@ -21,7 +22,7 @@ import flask
...
@@ -21,7 +22,7 @@ import flask
from
uitwww
import
auth
from
uitwww
import
auth
ACTIONS_PER_PAGE
=
5
ACTIONS_PER_PAGE
=
2
5
class
PageNotFoundError
(
BaseException
):
class
PageNotFoundError
(
BaseException
):
...
@@ -59,12 +60,12 @@ def list_actions(page=None, session=None):
...
@@ -59,12 +60,12 @@ def list_actions(page=None, session=None):
"SELECT COUNT(*) FROM actions %s;"
%
where
,
*
args
"SELECT COUNT(*) FROM actions %s;"
%
where
,
*
args
)[
0
][
0
]
)[
0
][
0
]
if
page
<
0
or
page
>
total
%
ACTIONS_PER_PAGE
:
if
page
<
0
or
page
>
=
math
.
ceil
(
total
/
ACTIONS_PER_PAGE
)
:
raise
PageNotFoundError
raise
PageNotFoundError
result
[
"current_page"
]
=
page
+
1
result
[
"current_page"
]
=
page
+
1
result
[
"has_prev"
]
=
page
!=
0
result
[
"has_prev"
]
=
page
!=
0
result
[
"has_next"
]
=
page
<
total
%
ACTIONS_PER_PAGE
result
[
"has_next"
]
=
page
+
1
<
math
.
ceil
(
total
/
ACTIONS_PER_PAGE
)
limit
=
"LIMIT ? OFFSET ?"
limit
=
"LIMIT ? OFFSET ?"
args
+=
[
ACTIONS_PER_PAGE
,
page
*
ACTIONS_PER_PAGE
]
args
+=
[
ACTIONS_PER_PAGE
,
page
*
ACTIONS_PER_PAGE
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment