GitHub PullRequestReviewCommentEvent at 2014-02-05 22:22:52
Repository: qiime_web_app
Actor: adamrp
Payload: {"comment":{"url":"https://api.github.com/repos/qiime/qiime_web_app/pulls/comments/9481294","id":9481294,"diff_hunk":"@@ -0,0 +1,245 @@\n+<%\n+__author__ = \"Emily TerAvest\"\n+__copyright__ = \"Copyright 2009-2010, Qiime Web Analysis\"\n+__credits__ = [\"Emily TerAvest\"]\n+__license__ = \"GPL\"\n+__version__ = \"1.0.0.dev\"\n+__maintainer__ = [\"Emily TerAvest\"]\n+__email__ = \"emily.teravest@colorado.edu\"\n+__status__ = \"Development\"\n+\n+'''This page allows the user to supply their username, then a new password is \n+generated and emailed to the user.'''\n+\n+from mod_python import Session\n+from data_access_connections import data_access_factory\n+from enums import ServerConfig\n+from random import choice\n+from time import strftime\n+from utils.mail import send_email, can_send_mail\n+\n+%>\n+<!-- header information -->\n+\n+<!DOCTYPE html>\n+<html lang=\"en\">\n+    <head>\n+        <meta charset=\"utf-8\">\n+        <title>American Gut Password Reset</title>\n+        <script src=\"js/jquery-1.9.1.js\"></script>\n+        <script src=\"js/jquery-ui-1.10.1.custom.min.js\"></script>\n+        <script src=\"js/jquery.ui.timepicker.js\"></script>\n+        <script src=\"js/american_gut.js\"></script>\n+        <link rel=\"stylesheet\" type=\"text/css\" href=\"style/americangut.css\">\n+        <link rel=\"stylesheet\" type=\"text/css\" href=\"style/menu.css\">\n+        <link rel=\"stylesheet\" type=\"text/css\" href=\"style/ui-lightness/jquery-ui-1.10.1.custom.min.css\">\n+        <link rel=\"icon\" type=\"image/ico\" href=\"img/favicon.ico\">\n+    </head>\n+    <body>\n+        <div class=\"wrapper clearfix\">\n+            <div class=\"header clearfix\">\n+                <img id=\"logo\" src=\"img/ag_logo.jpg\">\n+            </div>\n+            <br>\n+            <div class=\"left menuwrapper\">\n+                <div id=\"cssmenu\">\n+                    <ul>\n+                    <li><a href=\"https://fundrazr.com/campaigns/4Tqx5\" target=\"_blank\">Join the Project</a></li>\n+                    <li class=\"has-sub\"><a><span>Participant Resources</span></a>\n+                        <ul>\n+                            <li><a href=\"#faq0\">American Gut 101</a></li>\n+                            <li><a href=\"img/full_instructions.pdf\" target=\"_blank\">Kit Instructions</a></li>\n+                            <li><a href=\"international_shipping.psp?lan=en\">International Shipping</a></li>\n+                            <li class=\"last\"><a  href=\"international_shipping.psp?lan=es\">International Shipping (Espa&ntilde;ol)</a></li>\n+                        </ul>\n+                    </li>\n+                    <li><a href=\"index.psp\">Participant Login</a></li>\n+                    </ul>\n+                </div>\n+            </div>\n+<script type=\"text/javascript\"> \n+$(document).ready(function(){\n+\n+\t$(\"ul.subnav\").parent().append(\"<span></span>\"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav\n+\t\n+\t$(\"ul.topnav li span\").click(function() { //When trigger is clicked...\n+\t\t\n+\t\t//Following events are applied to the subnav itself (moving subnav up and down)\n+\t\t$(this).parent().find(\"ul.subnav\").slideDown('fast').show(); //Drop down the subnav on click\n+\n+\t\t$(this).parent().hover(function() {\n+\t\t}, function(){\t\n+\t\t\t$(this).parent().find(\"ul.subnav\").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up\n+\t\t});\n+\n+\t\t//Following events are applied to the trigger (Hover events for the trigger)\n+\t\t}).hover(function() { \n+\t\t\t$(this).addClass(\"subhover\"); //On hover over, add class \"subhover\"\n+\t\t}, function(){\t//On Hover Out\n+\t\t\t$(this).removeClass(\"subhover\"); //On hover out, remove class \"subhover\"\n+\t});\n+\n+});\n+</script>\n+\n+\n+<!-- stylesheet information for the validaton fields -->\n+<style type=\"text/css\">\n+\tlabel {  width: 10em; }\n+\tbr { clear: both; }\n+\tinput { margin-left: .5em; float: left; border: 1px solid black; margin-bottom: .5em;  }\n+\tinput.submit { float: none; }\n+\tinput.error { border: 1px solid red; width: auto; }\n+\tlabel.error {\n+\t\tbackground: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/unchecked.gif') no-repeat;\n+\t\tpadding-left: 16px;\n+\t\tmargin-left: .3em;\n+\t}\n+\tlabel.valid {\n+\t\tbackground: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/checked.gif') no-repeat;\n+\t\tdisplay: block;\n+\t\twidth: 16px;\n+\t\theight: 16px;\n+\t}\n+</style>\n+</head>\n+<body>\n+\n+\n+<div class=\"content\">\n+\n+<hr/>\n+\n+<form target=\"_top\" id=\"send_me_home\" name=\"send_me_home\" action=\"fusebox.psp\" method=\"post\">\n+    <input type=\"hidden\" id=\"page\" name=\"page\" value=\"select_task.psp\" />\n+</form>\n+<!--\n+<table class=\"header_table\">\n+<tr><td>Forgot Password</td></tr>\n+</table>\n+-->\n+\n+<br/>\n+\n+<%\n+agDataAccess= data_access_factory(ServerConfig.data_access_type, 'american_gut')\n+#if the form has new_password and confirm_password we want to change the password\n+if form.has_key('new_password') and form.has_key('confirm_password'):\n+    new_password = form['new_password'];\n+    confirm_password = form['confirm_password']\n+    if new_password != confirm_password:\n+        req.write('Passwords did not match, please try again')\n+    else:\n+        email = form['email'].replace('%40', '@')\n+        supplied_kit_id = form['kit_id']\n+        kit_details = agDataAccess.getAGKitDetails(supplied_kit_id)\n+        swabs_per_kit = kit_details['swabs_per_kit']\n+        kit_verification_code = kit_details['kit_verification_code']\n+        ag_kit_id = kit_details['ag_kit_id']\n+        agDataAccess.updateAGKit(ag_kit_id, supplied_kit_id,\n+            new_password, swabs_per_kit, kit_verification_code)\n+        MESSAGE = ('This is a courtesy email to confirm that you have '\n+                'changed your password for your kit with ID %s. '\n+                'If you did not request this change, please email us '\n+                'immediately at info@americangut.org.' % supplied_kit_id)\n+        req.write('<p>Your password has been changed</p>')\n+        if can_send_mail():\n+                send_email(MESSAGE, 'American Gut Password Reset', email)\n+        else:\n+                req.write(\"Mail can be sent only from microbio.me domain.\")\n+                req.write('<p>%s</p>' % MESSAGE)\n+\n+# if the form was submitted with passcode we want to display the password form\n+elif form.has_key('passcode') and form.has_key('kit_id') and form.has_key('email'):\n+    #if passcode is in the form we are resetting from a forgotten password\n+    kit_id = form['kit_id']\n+    email = form['email'].replace('@','%40')\n+    isvalid = agDataAccess.ag_verify_kit_password_change_code(form['email'], kit_id,form['passcode'])\n+    if isvalid: \n+        #req.write('<p>Please enter new password</p>')\n+%>\n+        <div id=\"content\" class=\"content\">\n+\n+<form id=\"reset_password\" method=\"post\" action=\"forgot_password.psp\">\n+    <table>\n+    <tr><td><h2>Please enter new password</h2></td></tr>\n+    <tr><td>New Passord:</td><td><input type=\"password\" id=\"new_password\" name=\"new_password\" /></td>\n+    <td><a href=\"#\" class=\"help\" title=\"The new password you would like to use to log in from now on.\">(?)</a></td>\n+    </tr>\n+    <tr><td>Confrim Password:</td><td><input type=\"password\" id=\"confirm_password\" name=\"confirm_password\"/></td>\n+    <td><a href=\"#\" class=\"help\" title=\"Repeat your New Password again, exactly as before. We ask you to repeat it here so that you don't accidentally change your password to something you did not intend.\">(?)</a></td>\n+    </tr>\n+    <tr><td colspan=\"2\"><input type=\"submit\" value=\"Change Password\" /></tr>\n+    </table>\n+    <input type=\"hidden\" id=\"kit_id\" name=\"kit_id\" value=<%= '\"'+kit_id+'\"' %>>\n+    <input type=\"hidden\" id=\"email\" name=\"email\" value=<%= '\"'+email+'\"' %>>\n+</form>\n+</div>\n+<%\n+    else:\n+        req.write('<p>Your password change code is not valid Please try again</p>')\n+#if the form has kit_id and email only then we want to generate  a passcode\n+elif form.has_key('kit_id') and form.has_key('email'):\n+    agDataAccess= data_access_factory(ServerConfig.data_access_type, 'american_gut')\n+    kitids = agDataAccess.getAGKitbyEmail(form['email'])\n+    \n+    #if the kit id matches the email generate and send an email \n+    if form['kit_id'] in kitids:\n+        if agDataAccess.ag_is_kit_verified(form['kit_id']):\n+            #can only change password if kit is verified\n+            alphabet = \"ABCDEFGHIJKLMNOPQRSTUZWXYZ\"\n+            alphabet += alphabet.lower()\n+            alphabet += \"01234567890\"\n+            new_act_code=''.join([choice(alphabet) for i in range(20)])\n+            \n+            # add new pass to the database\n+            updated_data = agDataAccess.ag_set_pass_change_code( form['email'], form['kit_id'], new_act_code )\n+            \n+            MESSAGE=('I reset the password on American Gut Kit ID %s please click '\n+                     'the link below within two hours\\n'\n+                     'http://microbio.me/americangut/forgot_password.psp?email=%s;'\n+                     'kit_id=%s;passcode=%s' % (form['kit_id'], form['email'].replace('@','%40'),","path":"www/americangut/forgot_password.psp","position":201,"original_position":201,"commit_id":"81e0d12ff11a651af65e5cfd5550ab492560b9bb","original_commit_id":"81e0d12ff11a651af65e5cfd5550ab492560b9bb","user":{"login":"adamrp","id":2574407,"avatar_url":"https://gravatar.com/avatar/f02990b66a519545b89fb0357d4b4bda?d=https%3A%2F%2Fidenticons.github.com%2Fb9d28a5852c58f6a7b299c9a6d24ce44.png&r=x","gravatar_id":"f02990b66a519545b89fb0357d4b4bda","url":"https://api.github.com/users/adamrp","html_url":"https://github.com/adamrp","followers_url":"https://api.github.com/users/adamrp/followers","following_url":"https://api.github.com/users/adamrp/following{/other_user}","gists_url":"https://api.github.com/users/adamrp/gists{/gist_id}","starred_url":"https://api.github.com/users/adamrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamrp/subscriptions","organizations_url":"https://api.github.com/users/adamrp/orgs","repos_url":"https://api.github.com/users/adamrp/repos","events_url":"https://api.github.com/users/adamrp/events{/privacy}","received_events_url":"https://api.github.com/users/adamrp/received_events","type":"User","site_admin":false},"body":"I had no idea you could use semicolons as query separators in a URL -- pretty neat, and it lets you skip using ```urllib.urlencode```!","created_at":"2014-02-05T22:22:52Z","updated_at":"2014-02-05T22:22:52Z","html_url":"https://github.com/qiime/qiime_web_app/pull/607#discussion_r9481294","pull_request_url":"https://api.github.com/repos/qiime/qiime_web_app/pulls/607","_links":{"self":{"href":"https://api.github.com/repos/qiime/qiime_web_app/pulls/comments/9481294"},"html":{"href":"https://github.com/qiime/qiime_web_app/pull/607#discussion_r9481294"},"pull_request":{"href":"https://api.github.com/repos/qiime/qiime_web_app/pulls/607"}}}}