Browse Source

First pass at "thank you" page (and related processing/error pages) is complete.

Dan Helfman 11 years ago
parent
commit
f6538ad3a5
6 changed files with 144 additions and 7 deletions
  1. 52
    5
      controller/Users.py
  2. 1
    0
      static/html/robots.txt
  3. 25
    0
      view/Processing_note.py
  4. 33
    0
      view/Thanks_error_note.py
  5. 31
    0
      view/Thanks_note.py
  6. 2
    2
      view/Upgrade_note.py

+ 52
- 5
controller/Users.py View File

@@ -18,6 +18,9 @@ from view.Main_page import Main_page
18 18
 from view.Redeem_reset_note import Redeem_reset_note
19 19
 from view.Redeem_invite_note import Redeem_invite_note
20 20
 from view.Blank_page import Blank_page
21
+from view.Thanks_note import Thanks_note
22
+from view.Thanks_error_note import Thanks_error_note
23
+from view.Processing_note import Processing_note
21 24
 
22 25
 
23 26
 USERNAME_PATTERN = re.compile( "^[a-zA-Z0-9]+$" )
@@ -978,8 +981,6 @@ class Users( object ):
978 981
     PAYPAL_URL = u"https://www.sandbox.paypal.com/cgi-bin/webscr"
979 982
     #PAYPAL_URL = u"https://www.paypal.com/cgi-bin/webscr"
980 983
 
981
-    print params
982
-
983 984
     # check that payment_status is Completed
984 985
     payment_status = params.get( u"payment_status" )
985 986
     if payment_status and payment_status != u"Completed":
@@ -1067,6 +1068,52 @@ class Users( object ):
1067 1068
 
1068 1069
     return dict()
1069 1070
 
1070
-  @expose()
1071
-  def thanks( self ):
1072
-    pass # TODO
1071
+  @expose( view = Main_page )
1072
+  @grab_user_id
1073
+  def thanks( self, **params ):
1074
+    """
1075
+    Provide the information necessary to display the subscription thanks page.
1076
+    """
1077
+    anonymous = self.__database.select_one( User, User.sql_load_by_username( u"anonymous" ) )
1078
+    if anonymous:
1079
+      main_notebook = self.__database.select_one( Notebook, anonymous.sql_load_notebooks( undeleted_only = True ) )
1080
+    else:
1081
+      main_notebook = None
1082
+
1083
+    result = self.current( params.get( u"user_id" ) )
1084
+
1085
+    rate_plan = params.get( u"item_number", "" )
1086
+    try:
1087
+      rate_plan = int( rate_plan )
1088
+    except ValueError:
1089
+      rate_plan = None
1090
+
1091
+    retry_count = params.get( u"retry_count", "" )
1092
+    try:
1093
+      retry_count = int( retry_count )
1094
+    except ValueError:
1095
+      retry_count = None
1096
+
1097
+    # if there's no rate plan or we've retried too many times, give up and display an error
1098
+    RETRY_TIMEOUT = 30
1099
+    if rate_plan is None or retry_count > RETRY_TIMEOUT:
1100
+      note = Thanks_error_note()
1101
+    # if the rate plan of the subscription matches the user's current rate plan, success
1102
+    elif rate_plan == result[ u"user" ].rate_plan:
1103
+      note = Thanks_note( self.__rate_plans[ rate_plan ][ u"name" ].capitalize() )
1104
+    # otherwise, display an auto-reloading "processing..." page
1105
+    else:
1106
+      note = Processing_note( rate_plan, retry_count )
1107
+
1108
+    result[ "notebook" ] = main_notebook
1109
+    result[ "startup_notes" ] = self.__database.select_many( Note, main_notebook.sql_load_startup_notes() )
1110
+    result[ "total_notes_count" ] = self.__database.select_one( Note, main_notebook.sql_count_notes() )
1111
+    result[ "note_read_write" ] = False
1112
+    result[ "notes" ] = [ Note.create(
1113
+      object_id = u"thanks",
1114
+      contents = unicode( note ),
1115
+      notebook_id = main_notebook.object_id,
1116
+    ) ]
1117
+    result[ "invites" ] = []
1118
+
1119
+    return result

+ 1
- 0
static/html/robots.txt View File

@@ -1,6 +1,7 @@
1 1
 # prevent bots from signing up for demo accounts
2 2
 User-agent: *
3 3
 Disallow: /users/demo
4
+Disallow: /users/thanks
4 5
 Disallow: /notebooks/download_html/
5 6
 
6 7
 # this crawler is completely broken and requests many invalid URLs

+ 25
- 0
view/Processing_note.py View File

@@ -0,0 +1,25 @@
1
+from Tags import Html, Head, Meta, H3, P
2
+
3
+
4
+class Processing_note( Html ):
5
+  def __init__( self, rate_plan, retry_count ):
6
+    if not retry_count:
7
+      retry_count = 0
8
+
9
+    retry_count += 1
10
+
11
+    Html.__init__(
12
+      self,
13
+      Head(
14
+        Meta(
15
+          http_equiv = u"Refresh",
16
+          content = u"2; URL=/users/thanks?item_number=%s&retry_count=%s" % ( rate_plan, retry_count ),
17
+        ),
18
+      ),
19
+      H3( u"processing..." ),
20
+      P(
21
+        """
22
+        Your subscription is being processed. This shouldn't take more than a minute. Please wait...
23
+        """,
24
+      ),
25
+    )

+ 33
- 0
view/Thanks_error_note.py View File

@@ -0,0 +1,33 @@
1
+from Tags import Span, H3, P, A
2
+
3
+
4
+class Thanks_error_note( Span ):
5
+  def __init__( self ):
6
+    Span.__init__(
7
+      self,
8
+      H3( u"thank you" ),
9
+      P(
10
+        u"""
11
+        Thank you for upgrading your Luminotes account!
12
+        """,
13
+      ),
14
+      P(
15
+        u"""
16
+        Luminotes has not yet received confirmation of your subscription. If your
17
+        account is not automatically upgraded within the next few minutes, please
18
+        """,
19
+        A( u"contact support", href = u"/contact_info", target = "_top" ),
20
+        u"""
21
+        for assistance.
22
+        """,
23
+      ),
24
+      P(
25
+        u"""
26
+        Note: You can check the current status of your account by refreshing the
27
+        """,
28
+        A( u"upgrade", href = u"/upgrade", target = "_top" ),
29
+        u"""
30
+        page while logged in.
31
+        """
32
+      ),
33
+    )

+ 31
- 0
view/Thanks_note.py View File

@@ -0,0 +1,31 @@
1
+from Tags import Span, H3, P, A
2
+
3
+
4
+class Thanks_note( Span ):
5
+  def __init__( self, rate_plan_name ):
6
+    Span.__init__(
7
+      self,
8
+      H3( u"thank you" ),
9
+      P(
10
+        u"""
11
+        Thank you for upgrading your Luminotes account! 
12
+        """,
13
+      ),
14
+      P(
15
+        u"""
16
+        Your account has been upgraded to Luminotes %s. Please click on
17
+        one of your notebooks to the right to get started with your newly
18
+        upgraded wiki.
19
+        """ % rate_plan_name,
20
+      ),
21
+      P(
22
+        u"""
23
+        If you have any questions about your upgraded wiki, or anything else,
24
+        please
25
+        """,
26
+        A( u"contact support", href = u"/contact_info", target = "_top" ),
27
+        u"""
28
+        for assistance.
29
+        """,
30
+      ),
31
+    )

+ 2
- 2
view/Upgrade_note.py View File

@@ -62,10 +62,10 @@ class Upgrade_note( Span ):
62 62
         id = u"upgrade_table_area",
63 63
       ),
64 64
 
65
-      user and user.rate_plan > 0 and P(
65
+      user and P(
66 66
         u"You're currently subscribed to Luminotes %s." % 
67 67
         rate_plans[ user.rate_plan ][ u"name" ].capitalize(),
68
-        unsubscribe_button,
68
+        ( user.rate_plan > 0 ) and unsubscribe_button or None,
69 69
       ) or None,
70 70
 
71 71
       H3( u"share your notebook" ),

Loading…
Cancel
Save