gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-blog] branch master updated: use cached order_id


From: gnunet
Subject: [GNUnet-SVN] [taler-blog] branch master updated: use cached order_id
Date: Thu, 18 Jan 2018 01:46:44 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository blog.

The following commit(s) were added to refs/heads/master by this push:
     new b65bffe  use cached order_id
b65bffe is described below

commit b65bffe7c211ea3a615d9b9745acbe5566302309
Author: Florian Dold <address@hidden>
AuthorDate: Thu Jan 18 01:46:38 2018 +0100

    use cached order_id
---
 talerblog/blog/blog.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py
index b575b9c..893c9fc 100644
--- a/talerblog/blog/blog.py
+++ b/talerblog/blog/blog.py
@@ -132,7 +132,7 @@ def refund(order_id):
     flask.abort(500)
 
 
-def render_article(article_name, data):
+def render_article(article_name, data, order_id):
     article_info = ARTICLES.get(article_name)
     if article_info is None:
         flask.abort(500)
@@ -140,8 +140,7 @@ def render_article(article_name, data):
         if data in article_info.extra_files:
             return flask.send_file(get_image_file(data))
         return "permission denied", 403
-    # needed for refunds
-    order_id = flask.request.args.get("order_id")
+    # the order_id is needed for refunds
     return flask.render_template("templates/article_frame.html",
                                  article_file=get_article_file(article_info),
                                  article_name=article_name,
@@ -168,8 +167,9 @@ def article(article_name, data=None):
     if not session_id:
         session_id = flask.session["uid"] = str(uuid.uuid4())
 
-    if paid_articles_cache.get(session_id + "-" + article_name):
-        return render_article(article_name, data)
+    cached_order_id = paid_articles_cache.get(session_id + "-" + article_name)
+    if cached_order_id:
+        return render_article(article_name, data, cached_order_id)
 
     if order_id and not session_sig:
         # If there was an order_id but no session_sig, either the user played
@@ -187,7 +187,6 @@ def article(article_name, data=None):
         proposal_resp = backend_post("proposal", dict(order=order))
         order_id = proposal_resp["order_id"]
 
-
     pay_params = dict(
         instance=INSTANCE,
         order_id=order_id,
@@ -206,8 +205,8 @@ def article(article_name, data=None):
                                      article_name=article_name)
 
     if pay_status.get("paid"):
-        paid_articles_cache.set(session_id + "-" + article_name, True)
-        return render_article(article_name, data)
+        paid_articles_cache.set(session_id + "-" + article_name, order_id)
+        return render_article(article_name, data, order_id)
 
     # no pay_redirect but article not paid, this should never happen!
     flask.abort(500)

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]