def get(self): """ Generate several accounts and users to test out stuff with """ for i in range(10): """ create 10 accounts """ email = "user" + str(i) + "@infuser.com" account_entity = accounts_dao.create_account(email, "1111", True) for j in range(random.randint(40,100)): """ create 40-100 users per account """ user_id = "crazy" + str(i) + "crazy" + str(j) + "@someplaceelse" + str(i) + ".com" users_dao.create_new_user(email, user_id) users_dao.set_user_points(email, user_id, random.randint(5,200)) self.response.out.write("Done. :-)")
def get(self): """ Generate several accounts and users to test out stuff with """ for i in range(10): """ create 10 accounts """ email = "user" + str(i) + "@infuser.com" account_entity = accounts_dao.create_account(email, "1111", True) for j in range(random.randint(40, 100)): """ create 40-100 users per account """ user_id = "crazy" + str(i) + "crazy" + str( j) + "@someplaceelse" + str(i) + ".com" users_dao.create_new_user(email, user_id) users_dao.set_user_points(email, user_id, random.randint(5, 200)) self.response.out.write("Done. :-)")
def post(self): isLocal = os.environ['SERVER_SOFTWARE'].startswith('Dev') if not isLocal: return secret = self.request.get('secret') if secret != TOPSECRET: bad_args() return api_key = self.request.get('apikey') account_id = self.request.get('accountid') badge_id = self.request.get('badgeid') badge_theme = self.request.get('theme') if not badge_theme or not badge_id or not account_id or not api_key: ret = bad_args() self.response.out.write(ret) return acc = accounts_dao.create_account(account_id, "xxx000xxx", enable=True) from serverside.entities import memcache_db acc.apiKey = "ABCDEFGHI" memcache_db.save_entity(acc, account_id) # remote paths are used because the SDK cannot fetch from itself # because it is single threaded and would cause deadlock badge_list = ["http://cdn2.iconfinder.com/data/icons/crystalproject/128x128/apps/keditbookmarks.png", "http://cdn4.iconfinder.com/data/icons/Merry_Christmas_by_jj_maxer/golden%20star.png", "http://cdn1.iconfinder.com/data/icons/CrystalClear/128x128/actions/bookmark.png", "http://cdn4.iconfinder.com/data/icons/token/Token,%20128x128,%20PNG/Star-Favorites.png", "http://cdn4.iconfinder.com/data/icons/supermario/PNG/Star.png", "http://cdn5.iconfinder.com/data/icons/SOPHISTIQUE/graphics/png/128/star.png", "http://cdn3.iconfinder.com/data/icons/humano2/128x128/actions/bookmark-new.png", "http://cdn2.iconfinder.com/data/icons/web2/Icons/Favorite_128x128.png", "http://cdn5.iconfinder.com/data/icons/water_gaming_pack/128/star_wars_battlefront.png", "http://cdn2.iconfinder.com/data/icons/spaceinvaders/blackhole.png"] # Create ten badges for ii in range(0,10): newbadge = badge_list[ii] try: result = urlfetch.fetch(url=newbadge) except: error("Is one of the badges no longer available? Check %s"%newbadge) return imgbuf = result.content if len(imgbuf) == 0: error("One of the downloads did not work! url:%s"%newbadge) return badge_key = badges_dao.create_badge_key(account_id, badge_theme, str(ii), "private") # Create the file file_name = files.blobstore.create(mime_type='application/octet-stream') # Open the file and write to it with files.open(file_name, 'a') as f: f.write(imgbuf) # Finalize the file. Do this before attempting to read it. files.finalize(file_name) # Get the file's blob key blob_key = files.blobstore.get_blob_key(file_name) blob_info = blobstore.BlobInfo.get(blob_key) # TODO test with different types of images badges_dao.create_badge_type(badge_key, str(ii), "badge description", acc, badge_theme, "png", blob_info=blob_info) # End of for loop self.response.out.write(success_ret()) return
def post(self): email = self.request.get("email") password = self.request.get("password") repeat_password = self.request.get('repeat_password') show_links = self.request.get("show_links") if not utils.validEmail(email): values = {"success" : False, "message" : "ERROR: You need to provide a valid email address."} if show_links == "yes": values['givelinks'] = True self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_SIGN_UP, values)) logging.error("Bad email %s"%email) return if password != repeat_password: values = {"success" : False, "message" : "ERROR: Passwords did not match."} if show_links == "yes": values['givelinks'] = True logging.error("Bad passwords for email %s"%email) self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_SIGN_UP, values)) return ent_type = 'Accounts' existing_account = memcache_db.get_entity(email, ent_type) if existing_account != None: logging.error('An account already exists with that email: ' + existing_account.email) """ if the account is a test account, activate the account """ if email in constants.TEST_ACCOUNTS and environment.is_dev(): logging.debug("Account is a valid test account") memcache_db.delete_entity(existing_account, email) accounts_dao.create_account(email, password, True) message = "Your test account has been activated!" values = {"success" : True, "message" : message} if show_links == "yes": values['givelinks'] = True elif existing_account.isEnabled == ACCOUNT_STATUS.PENDING_CREATE: """ REPEAT SIGN UP WITH UNACTIVATED ACCOUNT!!!!!!!!! """ """ send the email again with the same activation ID """ pc = pending_create_dao.get_id_by_email(email) activate_url = get_activate_url(pc.id) email_sent = send_email(email, activate_url) logging.info("Repeat sign up for account that was not activated yet. An email will be sent to with same activation link. Email: " + email + ", activation link: " + activate_url) message = "" if email_sent: message = "An email has been sent to you with a link to activate your account!" else: message = "There was an error during account creation. Please send an email to [email protected]" values = {"success" : True, "message" : message} if show_links == "yes": values['givelinks'] = True else: message = "ERROR: An account using this email address already exists. Contact support@appscale for support." values = {"success" : False, "message" : message} if show_links == "yes": values['givelinks'] = True else: """create an account and send an email for validation""" accounts_dao.create_account(email, password) """Add email to pending creates table""" id = str(uuid.uuid4()) pending_create = Pending_Create(key_name=id, id=id, email=email) pending_create.put() """send an email to user to complete set up, get arguments in the string will be email and cookie ID""" activate_url = get_activate_url(id) logging.info("Activation URL for account: " + email + " is " + activate_url) email_sent = send_email(email, activate_url) message = "" if email_sent: message = "Sign up was a success. An activation link has been sent to your email address." else: message = "There was an error during account creation. Please send an email to [email protected]" values = {"success" : True, "message" : message} if show_links == "yes": values['givelinks'] = True """ Render result with whatever values were filled in above """ self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_SIGN_UP, values))
def post(self): email = self.request.get("email") password = self.request.get("password") repeat_password = self.request.get('repeat_password') show_links = self.request.get("show_links") if not utils.validEmail(email): values = {"success" : False, "message" : "ERROR: You need to provide a valid email address."} if show_links == "yes": values['givelinks'] = True self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_SIGN_UP, values)) logging.error("Bad email %s"%email) return if password != repeat_password: values = {"success" : False, "message" : "ERROR: Passwords did not match."} if show_links == "yes": values['givelinks'] = True logging.error("Bad passwords for email %s"%email) self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_SIGN_UP, values)) return ent_type = 'Accounts' existing_account = memcache_db.get_entity(email, ent_type) if existing_account != None: logging.error('An account already exists with that email: ' + existing_account.email) """ if the account is a test account, activate the account """ if email in constants.TEST_ACCOUNTS and environment.is_dev(): logging.debug("Account is a valid test account") memcache_db.delete_entity(existing_account, email) accounts_dao.create_account(email, password, True) message = "Your test account has been activated!" values = {"success" : True, "message" : message} if show_links == "yes": values['givelinks'] = True elif existing_account.isEnabled == ACCOUNT_STATUS.PENDING_CREATE: """ REPEAT SIGN UP WITH UNACTIVATED ACCOUNT!!!!!!!!! """ """ send the email again with the same activation ID """ pc = pending_create_dao.get_id_by_email(email) activate_url = get_activate_url(pc.id) email_sent = send_email(email, activate_url) logging.info("Repeat sign up for account that was not activated yet. An email will be sent to with same activation link. Email: " + email + ", activation link: " + activate_url) message = "" if email_sent: message = "An email has been sent to you with a link to activate your account!" else: message = "There was an error during account creation. Please send an email to [email protected]" values = {"success" : True, "message" : message} if show_links == "yes": values['givelinks'] = True else: message = "ERROR: An account using this email address already exists. Contact support@cloudcaptive for support." values = {"success" : False, "message" : message} if show_links == "yes": values['givelinks'] = True else: """create an account and send an email for validation""" accounts_dao.create_account(email, password) """Add email to pending creates table""" id = str(uuid.uuid4()) pending_create = Pending_Create(key_name=id, id=id, email=email) pending_create.put() """send an email to user to complete set up, get arguments in the string will be email and cookie ID""" activate_url = get_activate_url(id) logging.info("Activation URL for account: " + email + " is " + activate_url) email_sent = send_email(email, activate_url) message = "" if email_sent: message = "Sign up was a success. An activation link has been sent to your email address." else: message = "There was an error during account creation. Please send an email to [email protected]" values = {"success" : True, "message" : message} if show_links == "yes": values['givelinks'] = True """ Render result with whatever values were filled in above """ self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_SIGN_UP, values))