Add a sanity check
authorCharles Connell <charles@connells.org>
Tue, 11 Mar 2014 17:06:40 +0000 (13:06 -0400)
committerCharles Connell <charles@connells.org>
Tue, 11 Mar 2014 17:06:40 +0000 (13:06 -0400)
karmaworld/apps/notes/management/commands/populate_filepicker.py

index 1c9403650e5beb4e5833776007f17d2f9bc13fc6..b8ecc8a0ec8580d08822eb7d2152677294cc52d5 100644 (file)
@@ -27,13 +27,15 @@ class Command(BaseCommand):
                 print "Skipping {0}".format(str(note))
                 continue
 
-            # grab the html from inside the note and process it
-            html_resp = requests.get('http:{0}{1}'.format(settings.S3_URL, note.get_relative_s3_path()))
-            if html_resp.status_code is not 200:
-                print html_resp.text
-                continue
-
-            html = html_resp.text
+            if note.static_html:
+                # grab the html from inside the note and process it
+                html_resp = requests.get('http:{0}{1}'.format(settings.S3_URL, note.get_relative_s3_path()))
+                if html_resp.status_code is not 200:
+                    print html_resp.text
+                    continue
+                html = html_resp.text
+            else:
+                html = note.html
 
             fp_policy_json = '{{"expiry": {0}, "call": ["pick","store","read","stat"]}}'
             fp_policy_json = fp_policy_json.format(int(time.time() + 31536000))
@@ -66,6 +68,9 @@ class Command(BaseCommand):
                 print str(note)
                 continue
 
+            if get_resp.text != html:
+                print "The content at the new Filepicker URL does not match the original note contents!"
+
             note.save()