From f6538ad3a5e638dc0bb0f50b11500cc570002580 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Fri, 11 Jan 2008 22:55:04 +0000 Subject: [PATCH] First pass at "thank you" page (and related processing/error pages) is complete. --- controller/Users.py | 57 +++++++++++++++++++++++++++++++++++---- static/html/robots.txt | 1 + view/Processing_note.py | 25 +++++++++++++++++ view/Thanks_error_note.py | 33 +++++++++++++++++++++++ view/Thanks_note.py | 31 +++++++++++++++++++++ view/Upgrade_note.py | 4 +-- 6 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 view/Processing_note.py create mode 100644 view/Thanks_error_note.py create mode 100644 view/Thanks_note.py diff --git a/controller/Users.py b/controller/Users.py index f31225f..52a6a27 100644 --- a/controller/Users.py +++ b/controller/Users.py @@ -18,6 +18,9 @@ from view.Main_page import Main_page from view.Redeem_reset_note import Redeem_reset_note from view.Redeem_invite_note import Redeem_invite_note from view.Blank_page import Blank_page +from view.Thanks_note import Thanks_note +from view.Thanks_error_note import Thanks_error_note +from view.Processing_note import Processing_note USERNAME_PATTERN = re.compile( "^[a-zA-Z0-9]+$" ) @@ -978,8 +981,6 @@ class Users( object ): PAYPAL_URL = u"https://www.sandbox.paypal.com/cgi-bin/webscr" #PAYPAL_URL = u"https://www.paypal.com/cgi-bin/webscr" - print params - # check that payment_status is Completed payment_status = params.get( u"payment_status" ) if payment_status and payment_status != u"Completed": @@ -1067,6 +1068,52 @@ class Users( object ): return dict() - @expose() - def thanks( self ): - pass # TODO + @expose( view = Main_page ) + @grab_user_id + def thanks( self, **params ): + """ + Provide the information necessary to display the subscription thanks page. + """ + anonymous = self.__database.select_one( User, User.sql_load_by_username( u"anonymous" ) ) + if anonymous: + main_notebook = self.__database.select_one( Notebook, anonymous.sql_load_notebooks( undeleted_only = True ) ) + else: + main_notebook = None + + result = self.current( params.get( u"user_id" ) ) + + rate_plan = params.get( u"item_number", "" ) + try: + rate_plan = int( rate_plan ) + except ValueError: + rate_plan = None + + retry_count = params.get( u"retry_count", "" ) + try: + retry_count = int( retry_count ) + except ValueError: + retry_count = None + + # if there's no rate plan or we've retried too many times, give up and display an error + RETRY_TIMEOUT = 30 + if rate_plan is None or retry_count > RETRY_TIMEOUT: + note = Thanks_error_note() + # if the rate plan of the subscription matches the user's current rate plan, success + elif rate_plan == result[ u"user" ].rate_plan: + note = Thanks_note( self.__rate_plans[ rate_plan ][ u"name" ].capitalize() ) + # otherwise, display an auto-reloading "processing..." page + else: + note = Processing_note( rate_plan, retry_count ) + + result[ "notebook" ] = main_notebook + result[ "startup_notes" ] = self.__database.select_many( Note, main_notebook.sql_load_startup_notes() ) + result[ "total_notes_count" ] = self.__database.select_one( Note, main_notebook.sql_count_notes() ) + result[ "note_read_write" ] = False + result[ "notes" ] = [ Note.create( + object_id = u"thanks", + contents = unicode( note ), + notebook_id = main_notebook.object_id, + ) ] + result[ "invites" ] = [] + + return result diff --git a/static/html/robots.txt b/static/html/robots.txt index b79cb91..386f4f8 100644 --- a/static/html/robots.txt +++ b/static/html/robots.txt @@ -1,6 +1,7 @@ # prevent bots from signing up for demo accounts User-agent: * Disallow: /users/demo +Disallow: /users/thanks Disallow: /notebooks/download_html/ # this crawler is completely broken and requests many invalid URLs diff --git a/view/Processing_note.py b/view/Processing_note.py new file mode 100644 index 0000000..bc86139 --- /dev/null +++ b/view/Processing_note.py @@ -0,0 +1,25 @@ +from Tags import Html, Head, Meta, H3, P + + +class Processing_note( Html ): + def __init__( self, rate_plan, retry_count ): + if not retry_count: + retry_count = 0 + + retry_count += 1 + + Html.__init__( + self, + Head( + Meta( + http_equiv = u"Refresh", + content = u"2; URL=/users/thanks?item_number=%s&retry_count=%s" % ( rate_plan, retry_count ), + ), + ), + H3( u"processing..." ), + P( + """ + Your subscription is being processed. This shouldn't take more than a minute. Please wait... + """, + ), + ) diff --git a/view/Thanks_error_note.py b/view/Thanks_error_note.py new file mode 100644 index 0000000..5a59a52 --- /dev/null +++ b/view/Thanks_error_note.py @@ -0,0 +1,33 @@ +from Tags import Span, H3, P, A + + +class Thanks_error_note( Span ): + def __init__( self ): + Span.__init__( + self, + H3( u"thank you" ), + P( + u""" + Thank you for upgrading your Luminotes account! + """, + ), + P( + u""" + Luminotes has not yet received confirmation of your subscription. If your + account is not automatically upgraded within the next few minutes, please + """, + A( u"contact support", href = u"/contact_info", target = "_top" ), + u""" + for assistance. + """, + ), + P( + u""" + Note: You can check the current status of your account by refreshing the + """, + A( u"upgrade", href = u"/upgrade", target = "_top" ), + u""" + page while logged in. + """ + ), + ) diff --git a/view/Thanks_note.py b/view/Thanks_note.py new file mode 100644 index 0000000..3a7a7ce --- /dev/null +++ b/view/Thanks_note.py @@ -0,0 +1,31 @@ +from Tags import Span, H3, P, A + + +class Thanks_note( Span ): + def __init__( self, rate_plan_name ): + Span.__init__( + self, + H3( u"thank you" ), + P( + u""" + Thank you for upgrading your Luminotes account! + """, + ), + P( + u""" + Your account has been upgraded to Luminotes %s. Please click on + one of your notebooks to the right to get started with your newly + upgraded wiki. + """ % rate_plan_name, + ), + P( + u""" + If you have any questions about your upgraded wiki, or anything else, + please + """, + A( u"contact support", href = u"/contact_info", target = "_top" ), + u""" + for assistance. + """, + ), + ) diff --git a/view/Upgrade_note.py b/view/Upgrade_note.py index 5444a1b..b22111a 100644 --- a/view/Upgrade_note.py +++ b/view/Upgrade_note.py @@ -62,10 +62,10 @@ class Upgrade_note( Span ): id = u"upgrade_table_area", ), - user and user.rate_plan > 0 and P( + user and P( u"You're currently subscribed to Luminotes %s." % rate_plans[ user.rate_plan ][ u"name" ].capitalize(), - unsubscribe_button, + ( user.rate_plan > 0 ) and unsubscribe_button or None, ) or None, H3( u"share your notebook" ),