def get(self): """ Ask for which widget, and then render that widget """ widget = self.request.get("widget") current_session = Session().get_current_session(self) account = current_session.get_account_entity() widget_ref = account.trophyWidget render_path = constants.TEMPLATE_PATHS.RENDER_TROPHY_CASE if widget == "rank": widget_ref = account.rankWidget render_path = constants.TEMPLATE_PATHS.RENDER_RANK elif widget == "points": widget_ref = account.pointsWidget render_path = constants.TEMPLATE_PATHS.RENDER_POINTS elif widget == "leaderboard": widget_ref = account.leaderWidget render_path = constants.TEMPLATE_PATHS.RENDER_LEADERBOARD elif widget == "notifier": widget_ref = account.notifierWidget render_path = constants.TEMPLATE_PATHS.RENDER_NOTIFIER elif widget == "milestones": widget_ref = account.milestoneWidget render_path = constants.TEMPLATE_PATHS.RENDER_MILESTONES values = {"status":"success"} properties = widget_ref.properties() for property in properties: values[property] = getattr(widget_ref, property) self.response.out.write(template.render(render_path, values))
def post(self): """ will handle change of password request, will return success/fail """ current_session = Session().get_current_session(self) email = current_session.get_email() old_password = self.request.get("oldpassword") new_password = self.request.get("newpassword") new_password_again = self.request.get("newpasswordagain") error_message = "" success = False if new_password != new_password_again: error_message = "Passwords do not match." else: """ Make sure that the account authenticates... this is a redundant check """ if accounts_dao.authenticate_web_account(email, old_password): changed = accounts_dao.change_account_password(email, new_password) if changed: success = True else: error_message = "Old password incorrect." template_values = {"preferences_main" : True, "password_change_attempted" : True, 'account_name' : email, "error_message": error_message, "password_changed" : success} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): """ Verify that specified user exists for given account """ current_session = Session().get_current_session(self) email = current_session.get_email() edit_user = self.request.get("name") """ Generate links to see each widget for user """ import hashlib userhash = hashlib.sha1(email + '---' + edit_user).hexdigest() trophy_case_widget_url = "/api/1/getwidget?widget=trophy_case&u=" + userhash points_widget_url = "/api/1/getwidget?widget=points&u=" + userhash rank_widget_url = "/api/1/getwidget?widget=rank&u=" + userhash milestones_widget_url = "/api/1/getwidget?widget=milestones&u=" + userhash template_values = {'users_edit' : True, 'account_name' : current_session.get_email(), 'editusername': edit_user, 'view_trophy_case':trophy_case_widget_url, 'view_points':points_widget_url, 'view_rank':rank_widget_url, 'view_milestones':milestones_widget_url} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): """ Render users template """ current_session = Session().get_current_session(self) email = current_session.get_email() template_values = {'users_main': True, 'account_name': email } self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): current_session = Session().get_current_session(self) template_values = { 'downloads_main': True, 'account_name': current_session.get_email() } self.response.out.write( template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): self.response.out.write("You should be able to see this page, logged in or not...") sess = Session().get_current_session(self) if sess == None: self.response.out.write("<br/>You are not logged in!!") else: self.response.out.write("<br/>You are logged in as:") email = sess.get_email() self.response.out.write("<br/>" + email)
def post(self): current_session = Session().get_current_session(self) acc = current_session.get_account_entity() a_type = self.request.get("type") if a_type not in VALID_ANALYTICS: return json.dumps({'success':'false'}) values = getattr(self, a_type + "_values")(acc) self.response.out.write(json.dumps(values))
def post(self): current_session = Session().get_current_session(self) acc = current_session.get_account_entity() a_type = self.request.get("type") if a_type not in VALID_ANALYTICS: return json.dumps({'success': 'false'}) values = getattr(self, a_type + "_values")(acc) self.response.out.write(json.dumps(values))
def get(self): """ handler for change password template """ current_session = Session().get_current_session(self) template_values = { 'preferences_main': True, 'account_name': current_session.get_email() } self.response.out.write( template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def check_login(self, *args): if self.request.method != 'GET' and self.request.method != 'POST': self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, None)) else: user_session = Session().get_current_session(self) if user_session == None: self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, None)) else: logging.info("LEGIT user session! Email: " + user_session.get_email()) handler_method(self, *args)
def get(self): self.response.out.write("terminating the follow session:") sess = Session().get_current_session(self) if (sess == None): self.response.out.write("<br/>You are not logged in!!") else: self.response.out.write("<br/>You are logged in as:") email = sess.get_email() self.response.out.write("<br/>" + email) sess.terminate()
def get(self): self.response.out.write("<br/>If you reached here you are logged in!") sess = Session().get_current_session(self) if sess == None: self.response.out.write("<br/>You are not logged in!!") else: self.response.out.write("<br/>You are logged in as:") email = sess.get_email() self.response.out.write("<br/>" + email)
def get(self): self.response.out.write("<br/>If you reached here you are logged in!") sess = Session().get_current_session(self) if (sess == None): self.response.out.write("<br/>You are not logged in!!") else: self.response.out.write("<br/>You are logged in as:") email = sess.get_email() self.response.out.write("<br/>" + email)
def get(self): self.response.out.write("terminating the follow session:") sess = Session().get_current_session(self) if sess == None: self.response.out.write("<br/>You are not logged in!!") else: self.response.out.write("<br/>You are logged in as:") email = sess.get_email() self.response.out.write("<br/>" + email) sess.terminate()
def get(self): self.response.out.write( "You should be able to see this page, logged in or not...") sess = Session().get_current_session(self) if (sess == None): self.response.out.write("<br/>You are not logged in!!") else: self.response.out.write("<br/>You are logged in as:") email = sess.get_email() self.response.out.write("<br/>" + email)
def get(self): """ Sleep here... on PROD we hare having race condition, try this out... """ import time time.sleep(0.3) """ Look up value of "of" """ current_session = Session().get_current_session(self) requested_value = self.request.get("of") entity_type = self.request.get("entityType") value = widgets_dao.get_single_widget_value(current_session.get_email(), entity_type, requested_value) self.response.out.write(value)
def get(self): """ Render dashboard """ current_session = Session().get_current_session(self) account = current_session.get_account_entity() api_key = account.apiKey template_values = {'dashboard_main' : True, 'account_name': current_session.get_email(), 'api_key': api_key} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): current_session = Session().get_current_session(self) email = current_session.get_email() account = current_session.get_account_entity() badgeset = badges_dao.get_rendereable_badgeset(account) upload_url = blobstore.create_upload_url('/badge/u') template_values = {'badges_main': True, 'account_name': email, 'badges': badgeset, 'upload_url': upload_url} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email """ notify anonymous account """ userhash = hashlib.sha1(email + '---' + constants.ANONYMOUS_USER).hexdigest() user_ref = users_dao.get_user_with_key(userhash) notifier.user_badge_award(user_ref, "This is a note", "/images/badges/test2.jpg", "Title", account_entity, "anonymous_badge") self.response.out.write("done")
def post(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email ui = ui_api.UserInfuser(email, account_entity.apiKey, sync_all=True) user_id = self.request.get('userid') if not user_id: self.redirect('/adminconsole/users?error=NoUserID') return if user_id == constants.ANONYMOUS_USER: self.redirect('/adminconsole/users?error=InvalidID') return if not users_dao.get_user(email, user_id): self.redirect('/adminconsole/users?error=InvalidID') return award_type = self.request.get('awardtype') if award_type == 'awardbadge': badge_id = self.request.get("badgeid") if not badge_id: logging.error("Badge ID not provided %s" % email) self.redirect('/adminconsole/users?error=BadBadge') badge_key = badges_dao.get_key_from_badge_id(email, badge_id) if not badges_dao.get_badge(badge_key): logging.error("Badge ID does not exist for account %s" % email) self.redirect('/adminconsole/users?error=BadBadge') if not ui.award_badge(user_id, badge_id): self.redirect('/adminconsole/users?error=BadBadge') logging.error( "Make sure the client code urls points to http://<app-id>.appspot.com if this is a custom deploy" ) logging.error( "Account %s is unable to award badge %s to user %s" % (email, badge_id, user_id)) self.redirect('/adminconsole/users?error=BadBadge') elif award_type == 'awardpoints': points = self.request.get("points") try: points = int(points) except: points = 0 if not ui.award_points(user_id, points): logging.error( "Account %s is unable to award points %d to user %s" % (email, points, user_id)) self.redirect('/adminconsole/users?error=InvalidID') else: logging.error( "Received %s for console user award from account %s" % (award_type, email)) self.redirect('/adminconsole/users?error=InvalidID') self.redirect('/adminconsole/users/edit?name=' + user_id)
def get(self): current_session = Session().get_current_session(self) account = current_session.get_account_entity() email = current_session.get_email() """ Get widgets values """ trophy_case_values = widgets_dao.get_trophy_case_properties_to_render( account) rank_values = widgets_dao.get_rank_properties_to_render(account) points_values = widgets_dao.get_points_properties_to_render(account) leaderboard_values = widgets_dao.get_leaderboard_properties_to_render( account) notifier_values = widgets_dao.get_notifier_properties_to_render( account) milestones_values = widgets_dao.get_milestones_properties_to_render( account) """ Preview urls """ trophy_case_preview_url = "" rank_preview_url = "" points_preview_url = "" """ Notifier """ if environment.is_dev(): widget_path = constants.CONSOLE_GET_WIDGET_DEV else: widget_path = constants.CONSOLE_GET_WIDGET_PROD widget_type = "notifier" userhash = hashlib.sha1(email + '---' + constants.ANONYMOUS_USER).hexdigest() notifier_str = "<div style='z-index:9999; overflow: hidden; position: fixed; bottom: 0px; right: 10px;'><iframe style='border:none;' allowtransparency='true' height='" + str( constants.NOTIFIER_SIZE_DEFAULT ) + "px' width='" + str( constants.NOTIFIER_SIZE_DEFAULT ) + "px' scrolling='no' src='" + widget_path + "?widget=" + widget_type + "&u=" + userhash + "&height=" + str( constants.NOTIFIER_SIZE_DEFAULT) + "&width=" + str( constants.NOTIFIER_SIZE_DEFAULT ) + "'>Sorry your browser does not support iframes!</iframe></div>" template_values = { 'features_main': True, 'account_name': current_session.get_email(), 'trophy_case_values': trophy_case_values, 'rank_values': rank_values, 'points_values': points_values, 'notifier_values': notifier_values, 'milestones_values': milestones_values, 'leaderboard_values': leaderboard_values, 'trophy_case_preview_url': trophy_case_preview_url, 'rank_preview_url': rank_preview_url, 'points_preview_url': points_preview_url, 'notifier': notifier_str } self.response.out.write( template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def post(self): """ Ajax call handler to save trophycase features """ current_session = Session().get_current_session(self) property = self.request.get("property") new_value = self.request.get("propertyValue") entity_type = self.request.get("entityType") success = widgets_dao.update_widget_property(current_session.get_email(), entity_type, property, new_value) if success: self.response.out.write("Success") else: self.response.out.write("Failed")
def check_login(self, *args): if self.request.method != 'GET' and self.request.method != 'POST': self.response.out.write( template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, None)) else: user_session = Session().get_current_session(self) if user_session == None: self.response.out.write( template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, None)) else: logging.info("LEGIT user session! Email: " + user_session.get_email()) handler_method(self, *args)
def get(self): """ Ask for which widget, and then render that widget """ widget = self.request.get("widget") current_session = Session().get_current_session(self) account = current_session.get_account_entity() if widget == "rank": widget_ref = account.rankWidget render_path = constants.TEMPLATE_PATHS.RENDER_RANK elif widget == "points": widget_ref = account.pointsWidget render_path = constants.TEMPLATE_PATHS.RENDER_POINTS elif widget == "leaderboard": widget_ref = account.leaderWidget render_path = constants.TEMPLATE_PATHS.RENDER_LEADERBOARD elif widget == "notifier": widget_ref = account.notifierWidget render_path = constants.TEMPLATE_PATHS.RENDER_NOTIFIER elif widget == "milestones": widget_ref = account.milestoneWidget render_path = constants.TEMPLATE_PATHS.RENDER_MILESTONES else: widget = "trophycase" widget_ref = account.trophyWidget render_path = constants.TEMPLATE_PATHS.RENDER_TROPHY_CASE values = {"status":"success"} properties = widget_ref.properties() for property in properties: values[property] = getattr(widget_ref, property) show_with_data = self.request.get("withdata") if(show_with_data == "yes"): """ add appropriate dummy data """ if widget == "trophycase": values["badges"] = self.getDummyBadges() elif widget == "rank": values["rank"] = str(format_integer(random.randint(1,1000))) elif widget == "points": values["points"] = str(format_integer(random.randint(1,10000))) elif widget == "leaderboard": pass elif widget == "notifier": pass elif widget == "milestones": pass self.response.out.write(template.render(render_path, values))
def get(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email """ Notifier """ if environment.is_dev(): widget_path = constants.CONSOLE_GET_WIDGET_DEV else: widget_path = constants.CONSOLE_GET_WIDGET_PROD widget_type = "notifier" userhash = hashlib.sha1(email + '---' + constants.ANONYMOUS_USER).hexdigest() notifier_str = "<div style='z-index:9999; overflow: hidden; position: fixed; bottom: 0px; right: 10px;'><iframe style='border:none;' allowtransparency='true' height='"+str(constants.NOTIFIER_SIZE_DEFAULT)+"px' width='"+str(constants.NOTIFIER_SIZE_DEFAULT)+"px' scrolling='no' src='" + widget_path + "?widget=" + widget_type + "&u=" + userhash + "&height=" +str(Falseconstants.NOTIFIER_SIZE_DEFAULT) + "&width="+str(constants.NOTIFIER_SIZE_DEFAULT)+"'>Sorry your browser does not support iframes!</iframe></div>" self.response.out.write(notifier_str)
def post(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email bk = self.request.get("bk") json_ret = {'success':True, 'reason':'Success. Badge has been deleted'} json_ret = json.dumps(json_ret) try: bk = badges_dao.create_badge_key_with_id(email, bk) badges_dao.delete_badge(bk) except Exception, e: json_ret = {'success':False, 'reason':'Unable to remove badge' + str(e)}
def get(self): """ Ask for which widget, and then render that widget """ widget = self.request.get("widget") current_session = Session().get_current_session(self) account = current_session.get_account_entity() if widget == "rank": widget_ref = account.rankWidget render_path = constants.TEMPLATE_PATHS.RENDER_RANK elif widget == "points": widget_ref = account.pointsWidget render_path = constants.TEMPLATE_PATHS.RENDER_POINTS elif widget == "leaderboard": widget_ref = account.leaderWidget render_path = constants.TEMPLATE_PATHS.RENDER_LEADERBOARD elif widget == "notifier": widget_ref = account.notifierWidget render_path = constants.TEMPLATE_PATHS.RENDER_NOTIFIER elif widget == "milestones": widget_ref = account.milestoneWidget render_path = constants.TEMPLATE_PATHS.RENDER_MILESTONES else: widget = "trophycase" widget_ref = account.trophyWidget render_path = constants.TEMPLATE_PATHS.RENDER_TROPHY_CASE values = {"status": "success"} properties = widget_ref.properties() for property in properties: values[property] = getattr(widget_ref, property) show_with_data = self.request.get("withdata") if (show_with_data == "yes"): """ add appropriate dummy data """ if widget == "trophycase": values["badges"] = self.getDummyBadges() elif widget == "rank": values["rank"] = str(format_integer(random.randint(1, 1000))) elif widget == "points": values["points"] = str(format_integer(random.randint(1, 10000))) elif widget == "leaderboard": pass elif widget == "notifier": pass elif widget == "milestones": pass self.response.out.write(template.render(render_path, values))
def post(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email user = self.request.get("id") if user == constants.ANONYMOUS_USER: json_ret = {"success":False, "reason":"Sorry, you cannot delete this special user."} json_ret = json.dumps(json_ret) self.response.out.write(json_ret) return json_ret = {'success':True, 'reason':'Success. User has been deleted'} json_ret = json.dumps(json_ret) user_hash = hashlib.sha1(email + '---' + user).hexdigest() users_dao.delete_user(user_hash) self.response.out.write(json_ret)
def post(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email ui = ui_api.UserInfuser(email, account_entity.apiKey, sync_all=True) user_id = self.request.get('userid') if not user_id: self.redirect('/adminconsole/users?error=NoUserID') return if user_id == constants.ANONYMOUS_USER: self.redirect('/adminconsole/users?error=InvalidID') return if not users_dao.get_user(email, user_id): self.redirect('/adminconsole/users?error=InvalidID') return award_type = self.request.get('awardtype') if award_type == 'awardbadge': badge_id = self.request.get("badgeid") if not badge_id: logging.error("Badge ID not provided %s"%email) self.redirect('/adminconsole/users?error=BadBadge') badge_key = badges_dao.get_key_from_badge_id(email, badge_id) if not badges_dao.get_badge(badge_key): logging.error("Badge ID does not exist for account %s"%email) self.redirect('/adminconsole/users?error=BadBadge') if not ui.award_badge(user_id, badge_id): self.redirect('/adminconsole/users?error=BadBadge') logging.error("Make sure the client code urls points to http://<app-id>.appspot.com if this is a custom deploy") logging.error("Account %s is unable to award badge %s to user %s"%(email, badge_id, user_id)) self.redirect('/adminconsole/users?error=BadBadge') elif award_type == 'awardpoints': points = self.request.get("points") try: points = int(points) except: points = 0 if not ui.award_points(user_id, points): logging.error("Account %s is unable to award points %d to user %s"%(email, points, user_id)) self.redirect('/adminconsole/users?error=InvalidID') else: logging.error("Received %s for console user award from account %s"%(award_type, email)) self.redirect('/adminconsole/users?error=InvalidID') self.redirect('/adminconsole/users/edit?name=' + user_id)
def get(self): """ Params page, limit """ page = self.request.get("page") limit = self.request.get("limit") order_by = self.request.get("orderby") if page == None or page == "" or limit == None or page == "": self.response.out.write("Error") return try: page = int(page) limit = int(limit) except: self.response.out.write("Error, args must be ints. kthxbye!") return current_session = Session().get_current_session(self) asc = "ASC" if order_by == "points": asc = "DESC" offset = page * limit users = users_dao.get_users_by_page_by_order( current_session.get_account_entity(), offset, limit, order_by, asc) ret_json = "{ \"users\" : [" first = True for user in users: """ Do not send down anonymous user to be displayed """ if user.userid == constants.ANONYMOUS_USER: continue if not first: ret_json += "," first = False ret_json += "{" ret_json += "\"userid\" : \"" + user.userid + "\"," ret_json += "\"points\" : \"" + str(user.points) + "\"," ret_json += "\"rank\" : \"" + str(user.rank) + "\"" ret_json += "}" ret_json += "]}" self.response.out.write(ret_json)
def get(self): current_session = Session().get_current_session(self) email = current_session.get_email() account = current_session.get_account_entity() error = self.request.get("error") has_error = False if error: has_error = True error = getErrorString(error) badgeset = badges_dao.get_rendereable_badgeset(account) upload_url = blobstore.create_upload_url('/badge/u') template_values = {'badges_main': True, 'account_name': email, 'badges': badgeset, 'upload_url': upload_url, 'has_error': has_error, 'error': error} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def post(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email bk = self.request.get("bk") json_ret = { 'success': True, 'reason': 'Success. Badge has been deleted' } json_ret = json.dumps(json_ret) try: bk = badges_dao.create_badge_key_with_id(email, bk) badges_dao.delete_badge(bk) except Exception, e: json_ret = { 'success': False, 'reason': 'Unable to remove badge' + str(e) }
def get(self): """ Render users template """ current_session = Session().get_current_session(self) email = current_session.get_email() error = self.request.get("error") has_error = False if error: has_error = True error = getErrorString(error) email = current_session.get_email() account = current_session.get_account_entity() badges = badges_dao.get_rendereable_badgeset(account) template_values = {'users_main': True, 'account_name': email, 'badges':badges, 'has_error': has_error, 'error': error} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): """ Params page, limit """ page = self.request.get("page") limit = self.request.get("limit") order_by = self.request.get("orderby") if page == None or page == "" or limit == None or page == "": self.response.out.write("Error") return try: page = int(page) limit = int(limit) except: self.response.out.write("Error, args must be ints. kthxbye!") return current_session = Session().get_current_session(self) asc = "ASC" if order_by == "points": asc = "DESC" offset = page*limit users = users_dao.get_users_by_page_by_order(current_session.get_account_entity(), offset, limit, order_by, asc) ret_json = "{ \"users\" : [" first = True for user in users: """ Do not send down anonymous user to be displayed """ if user.userid == constants.ANONYMOUS_USER: continue if not first: ret_json += "," first = False ret_json += "{" ret_json += "\"userid\" : \"" + user.userid + "\"," ret_json += "\"points\" : \"" + str(user.points) + "\"," ret_json += "\"rank\" : \"" + str(user.rank) + "\"" ret_json += "}" ret_json+= "]}" self.response.out.write(ret_json)
def get(self): self.response.out.write("Creating session and setting cookie") import uuid import time created_session = Session().create_session( self, "*****@*****.**", str(uuid.uuid4()), str(time.time() + WEB_ADMIN_PARAMS.VALID_FOR_SECONDS)) if created_session == None: self.response.out.write("<br/>No session created") else: self.response.out.write("<br/>Session was created")
def get(self): current_session = Session().get_current_session(self) account = current_session.get_account_entity() email = current_session.get_email() """ Get widgets values """ trophy_case_values = widgets_dao.get_trophy_case_properties_to_render(account) rank_values = widgets_dao.get_rank_properties_to_render(account) points_values = widgets_dao.get_points_properties_to_render(account) leaderboard_values = widgets_dao.get_leaderboard_properties_to_render(account) notifier_values = widgets_dao.get_notifier_properties_to_render(account) milestones_values = widgets_dao.get_milestones_properties_to_render(account) """ Preview urls """ trophy_case_preview_url = "" rank_preview_url = "" points_preview_url = "" """ Notifier """ if environment.is_dev(): widget_path = constants.CONSOLE_GET_WIDGET_DEV else: widget_path = constants.CONSOLE_GET_WIDGET_PROD widget_type = "notifier" userhash = hashlib.sha1(email + '---' + constants.ANONYMOUS_USER).hexdigest() notifier_str = "<div style='z-index:9999; overflow: hidden; position: fixed; bottom: 0px; right: 10px;'><iframe style='border:none;' allowtransparency='true' height='"+str(constants.NOTIFIER_SIZE_DEFAULT)+"px' width='"+str(constants.NOTIFIER_SIZE_DEFAULT)+"px' scrolling='no' src='" + widget_path + "?widget=" + widget_type + "&u=" + userhash + "&height=" +str(constants.NOTIFIER_SIZE_DEFAULT) + "&width="+str(constants.NOTIFIER_SIZE_DEFAULT)+"'>Sorry your browser does not support iframes!</iframe></div>" template_values = {'features_main' : True, 'account_name' : current_session.get_email(), 'trophy_case_values' : trophy_case_values, 'rank_values':rank_values, 'points_values':points_values, 'notifier_values': notifier_values, 'milestones_values': milestones_values, 'leaderboard_values':leaderboard_values, 'trophy_case_preview_url':trophy_case_preview_url, 'rank_preview_url':rank_preview_url, 'points_preview_url':points_preview_url, 'notifier': notifier_str} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def post(self): current_session = Session().get_current_session(self) account_entity = current_session.get_account_entity() email = account_entity.email new_user_id = self.request.get("id") if new_user_id == constants.ANONYMOUS_USER: self.redirect('/adminconsole/users?error=NoUserID') return profile_name = self.request.get("name") profile_link = self.request.get("profile") profile_img = self.request.get("image") user_key = users_dao.get_user_key(email, new_user_id) new_user = Users(key_name=user_key, userid=new_user_id, isEnabled="yes", accountRef=account_entity, profileName=profile_name, profileLink=profile_link, profileImg=profile_img) users_dao.save_user(new_user, user_key) self.redirect('/adminconsole/users')
def get(self): current_session = Session().get_current_session(self) email = current_session.get_email() account = current_session.get_account_entity() error = self.request.get("error") has_error = False if error: has_error = True error = getErrorString(error) badgeset = badges_dao.get_rendereable_badgeset(account) upload_url = blobstore.create_upload_url('/badge/u') template_values = { 'badges_main': True, 'account_name': email, 'badges': badgeset, 'upload_url': upload_url, 'has_error': has_error, 'error': error } self.response.out.write( template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): """ Render users template """ current_session = Session().get_current_session(self) email = current_session.get_email() error = self.request.get("error") has_error = False if error: has_error = True error = getErrorString(error) email = current_session.get_email() account = current_session.get_account_entity() badges = badges_dao.get_rendereable_badgeset(account) template_values = { 'users_main': True, 'account_name': email, 'badges': badges, 'has_error': has_error, 'error': error } self.response.out.write( template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def post(self): """Get the username and password, hash password. Authenticate, make sure account is enabled then redirect to account page. """ email = self.request.get("email") password = self.request.get("password") logging.info("Attempted log in attempt, email: " + email) template_values = {'error': "error"} if email != None and email != "" and password != None and password != "": entity = accounts_dao.authenticate_web_account(email, password) if entity: update_account.update_account(entity.key().name()) Session().create_session(self, email, str(uuid.uuid4()), str(time.time() + WEB_ADMIN_PARAMS.VALID_FOR_SECONDS)) self.redirect("/adminconsole") else: self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, template_values)) else: self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, template_values))
def post(self): #TODO # IN the future we should try to move this logic to data access utility layer # and have the handler portion be in console.py current_session = Session().get_current_session(self) account = current_session.get_account_entity() if not account: self.response.out.write( "Problem with your account. Please email support.") return #TODO make sure badge name is not taken, or warn if overwritting badge_name = self.request.get("badgename") badge_name = string.replace(badge_name, " ", "_") badge_name = string.replace(badge_name, "-", "_") badge_theme = self.request.get("badgetheme") badge_theme = string.replace(badge_theme, "-", "_") badge_theme = string.replace(badge_theme, " ", "_") badge_des = self.request.get("badgedescription") upload_files = self.get_uploads('file') blob_info = upload_files[0] badge_file_name = blob_info.filename badge_ext = get_file_ext(badge_file_name) if badge_ext not in constants.IMAGE_PARAMS.VALID_EXT_TYPES: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=BadImageType') return logging.info("File ext:" + badge_ext) if not badge_name: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=NoNameGiven') return if not badge_des: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=NoDescriptionGiven') return if not badge_theme: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=NoThemeGiven') return if not blob_info: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=InternalError') return if blob_info.size > constants.MAX_BADGE_SIZE: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=FileTooLarge') return perm = "private" if account.email == constants.ADMIN_ACCOUNT: perm = "public" badge_key = badges_dao.create_badge_key(account.email, badge_theme, badge_name, perm) badge = badges_dao.create_badge_type(badge_key, badge_name, badge_des, account, badge_theme, badge_ext, blob_info=blob_info) self.redirect('/adminconsole/badges')
def post(self): #TODO # IN the future we should try to move this logic to data access utility layer # and have the handler portion be in console.py current_session = Session().get_current_session(self) account = current_session.get_account_entity() if not account: self.response.out.write("Problem with your account. Please email support.") return #TODO make sure badge name is not taken, or warn if overwritting badge_name = self.request.get("badgename") badge_name = string.replace(badge_name, " ", "_") badge_name = string.replace(badge_name, "-", "_") badge_theme = self.request.get("badgetheme") badge_theme= string.replace(badge_theme, "-", "_") badge_theme = string.replace(badge_theme, " ", "_") badge_des = self.request.get("badgedescription") upload_files = self.get_uploads('file') blob_info = upload_files[0] badge_file_name = blob_info.filename badge_ext = get_file_ext(badge_file_name) if badge_ext not in constants.IMAGE_PARAMS.VALID_EXT_TYPES: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=BadImageType') return logging.info("File ext:"+badge_ext) if not badge_name: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=NoNameGiven') return if not badge_des: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=NoDescriptionGiven') return if not badge_theme: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=NoThemeGiven') return if not blob_info: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=InternalError') return if blob_info.size > constants.MAX_BADGE_SIZE: delete_blob(blob_info) self.redirect('/adminconsole/badges?error=FileTooLarge') return perm = "private" if account.email == constants.ADMIN_ACCOUNT: perm = "public" badge_key = badges_dao.create_badge_key(account.email, badge_theme, badge_name, perm) badge = badges_dao.create_badge_type(badge_key, badge_name, badge_des, account, badge_theme, badge_ext, blob_info=blob_info) self.redirect('/adminconsole/badges')
def post(self): #TODO # IN the future we should try to move this logic to data access utility layer # and have the handler portion be in console.py current_session = Session().get_current_session(self) account = current_session.get_account_entity() if not account: self.response.out.write("Problem with your account. Please email support.") return #TODO make sure badge name is not taken, or warn if overwritting badge_name = self.request.get("badgename") badge_name = string.replace(badge_name, " ", "_") badge_name = string.replace(badge_name, "-", "_") badge_theme = self.request.get("badgetheme") badge_theme= string.replace(badge_theme, "-", "_") badge_theme = string.replace(badge_theme, " ", "_") badge_des = self.request.get("badgedescription") upload_files = self.get_uploads('file') blob_info = upload_files[0] badge_file_name = blob_info.filename badge_ext = get_file_ext(badge_file_name) if badge_ext not in constants.IMAGE_PARAMS.VALID_EXT_TYPES: self.redirect_error("Image must be png, jpeg, or gif") return logging.info("File ext:"+badge_ext) if not badge_name: self.redirect_error("No name given") return if not badge_des: self.redirect_error("No description given") return if not badge_theme: self.redirect_error("No theme given") return if not blob_info: self.redirect_error("No file given") return if blob_info.size > constants.MAX_BADGE_SIZE: self.redirect_error("File is too large. Must be smaller than " + str(constants.MAX_BADGE_SIZE) + " bytes") return perm = "private" if account.email == constants.ADMIN_ACCOUNT: perm = "public" badge_key = badges_dao.create_badge_key(account.email, badge_theme, badge_name, perm) badge = badges_dao.create_badge_type(badge_key, badge_name, badge_des, account, badge_theme, badge_ext, blob_info=blob_info) self.redirect('/adminconsole/badges') return # redirect to badge download for viewing values = {"badge_upload_success": True, "account_name": account.email, "badgekey": badge_key, "badgeLink": badge.downloadLink, "badgedescription": badge_des, "badgealt": badge_des, "badgename": badge_name, "badgeperm": perm} self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_DASHBOARD, values))
def get(self): sess = Session().get_current_session(self) if(sess != None): sess.terminate() self.redirect("/adminconsole")
def post(self): #TODO # IN the future we should try to move this logic to data access utility layer # and have the handler portion be in console.py current_session = Session().get_current_session(self) account = current_session.get_account_entity() if not account: self.response.out.write( "Problem with your account. Please email support.") return #TODO make sure badge name is not taken, or warn if overwritting badge_name = self.request.get("badgename") badge_name = string.replace(badge_name, " ", "_") badge_name = string.replace(badge_name, "-", "_") badge_theme = self.request.get("badgetheme") badge_theme = string.replace(badge_theme, "-", "_") badge_theme = string.replace(badge_theme, " ", "_") badge_des = self.request.get("badgedescription") upload_files = self.get_uploads('file') blob_info = upload_files[0] badge_file_name = blob_info.filename badge_ext = get_file_ext(badge_file_name) if badge_ext not in constants.IMAGE_PARAMS.VALID_EXT_TYPES: self.redirect_error("Image must be png, jpeg, or gif") return logging.info("File ext:" + badge_ext) if not badge_name: self.redirect_error("No name given") return if not badge_des: self.redirect_error("No description given") return if not badge_theme: self.redirect_error("No theme given") return if not blob_info: self.redirect_error("No file given") return if blob_info.size > constants.MAX_BADGE_SIZE: self.redirect_error("File is too large. Must be smaller than " + str(constants.MAX_BADGE_SIZE) + " bytes") return perm = "private" if account.email == constants.ADMIN_ACCOUNT: perm = "public" badge_key = badges_dao.create_badge_key(account.email, badge_theme, badge_name, perm) badge = badges_dao.create_badge_type(badge_key, badge_name, badge_des, account, badge_theme, badge_ext, blob_info=blob_info) self.redirect('/adminconsole/badges') return # redirect to badge download for viewing values = { "badge_upload_success": True, "account_name": account.email, "badgekey": badge_key, "badgeLink": badge.downloadLink, "badgedescription": badge_des, "badgealt": badge_des, "badgename": badge_name, "badgeperm": perm } self.response.out.write( template.render(TEMPLATE_PATHS.CONSOLE_DASHBOARD, values))
def get(self): sess = Session().get_current_session(self) if sess != None: sess.terminate() self.redirect("/adminconsole")
def get(self): current_session = Session().get_current_session(self) template_values = {'downloads_main' : True, 'account_name' : current_session.get_email()} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
def get(self): """ handler for change password template """ current_session = Session().get_current_session(self) template_values = {'preferences_main' : True, 'account_name' : current_session.get_email()} self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))