From 0b329c260988bd3d6fa44ea3831bbac1dd875d73 Mon Sep 17 00:00:00 2001 From: Peter Tran Date: Mon, 30 Mar 2015 10:44:46 -0400 Subject: [PATCH 1/2] Added pagination for containers. --- swiftbrowser/settings.py | 4 ++ swiftbrowser/templates/containerview.html | 43 +++++++++++++------ swiftbrowser/views.py | 51 ++++++++++++++++++++++- 3 files changed, 85 insertions(+), 13 deletions(-) diff --git a/swiftbrowser/settings.py b/swiftbrowser/settings.py index b88fc2a..9585cbd 100644 --- a/swiftbrowser/settings.py +++ b/swiftbrowser/settings.py @@ -42,3 +42,7 @@ STATIC_URL = "http://cdnjs.cloudflare.com/ajax/libs/" ALLOWED_HOSTS = ['127.0.0.1', 'insert_your_hostname_here'] + +SWIFT_BROWSER_SETTINGS = { + "containers_per_page" : 5 +} \ No newline at end of file diff --git a/swiftbrowser/templates/containerview.html b/swiftbrowser/templates/containerview.html index 8b03d4c..7ad021b 100644 --- a/swiftbrowser/templates/containerview.html +++ b/swiftbrowser/templates/containerview.html @@ -7,10 +7,10 @@ {% include "messages.html" %} - + + - + @@ -20,7 +20,7 @@ @@ -43,7 +43,7 @@
  • {% trans 'Sharing' %}
  • {% endif %} - +
  • {% trans 'Delete container' %} @@ -53,31 +53,50 @@ -
  • + {% empty %} - - + + {% endfor %} - - + +
    - +
    {% trans 'There are no containers in this account yet. Create a new container by clicking the red button.' %}
    - {{account_stat.x_account_bytes_used|filesizeformat}} + {{account_stat.x_account_bytes_used|filesizeformat}} {% if account_stat.x_account_meta_quota_bytes %} {% trans 'of' %} - {{account_stat.x_account_meta_quota_bytes|filesizeformat}} + {{account_stat.x_account_meta_quota_bytes|filesizeformat}} {% endif %} {% trans 'used' %}
    + {% endblock %} diff --git a/swiftbrowser/views.py b/swiftbrowser/views.py index 47a57b2..fad61f4 100644 --- a/swiftbrowser/views.py +++ b/swiftbrowser/views.py @@ -53,11 +53,60 @@ def containerview(request): storage_url = request.session.get('storage_url', '') auth_token = request.session.get('auth_token', '') + # "markers" is a list used to keep track of container names for pagination. + if "markers" not in request.session: + + # The initial marker with an empty string. + request.session["markers"] = [''] + marker = "" + + if("get_next" in request.POST): + + # If requesting the next page, and there are none, + # the marker should be the last not None marker. + if request.session["markers"][-1] is None: + request.session["markers"].pop() + + # Use the latest marker to get the next page. + marker = request.session["markers"][-1] + + elif ("get_previous" in request.POST): + + # Remove the "next" marker + request.session["markers"].pop() + + # Remove the "current" marker if we're not at the very beginning. + if len(request.session["markers"]) != 1: + request.session["markers"].pop() + + # Use the "previous" marker + marker = request.session["markers"][-1] + + else: + # Reset marker stack. + request.session["markers"] = [''] + marker = "" + try: - account_stat, containers = client.get_account(storage_url, auth_token) + account_stat, containers = client.get_account( + storage_url, + auth_token, + marker, + settings.SWIFT_BROWSER_SETTINGS["containers_per_page"]) except client.ClientException: return redirect(login) + # Add the last result to the markers list. + if len(containers) == 5: + new_marker = containers[-1]["name"] + else: + new_marker = None + + request.session["markers"].append(new_marker) + + # Save the session + request.session.modified = True + account_stat = replace_hyphens(account_stat) return render_to_response('containerview.html', { From 8e4705e6ac0974612e669fe51ee7ef2d75628c24 Mon Sep 17 00:00:00 2001 From: Peter Tran Date: Mon, 18 Apr 2016 14:52:20 -0400 Subject: [PATCH 2/2] Test - adding reviewboard config file. --- .reviewboardrc | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .reviewboardrc diff --git a/.reviewboardrc b/.reviewboardrc new file mode 100644 index 0000000..5749a5d --- /dev/null +++ b/.reviewboardrc @@ -0,0 +1,4 @@ +REVIEWBOARD_URL = "sand10.scholarsportal.info/reviews" +REPOSITORY = "Swiftbrowser" +BRANCH = "master" +LAND_DEST_BRANCH = "master"