def update_bookmarks(self, node_token): user_id = global_session.session['user_id'] impersonating = global_session.session['impersonating'] # only update bookmarks for proper users if user_id and not impersonating: try: session = r.Session() result = r.search_single_data("bookmarks", {"user_id" : user_id, "_core_id" : node_token.bookmark["_core_id"]}, fields = ['entity_table', '_core_id'], ) result["accessed_date"] = util.convert_value(datetime.datetime.now()) util.load_local_data(r, result) except custom_exceptions.SingleResultError: result = {"__table": "bookmarks", "_core_id": node_token.bookmark["_core_id"], "user_id": user_id, "entity_table": node_token.bookmark["table_name"], "accessed_date": util.convert_value(datetime.datetime.now())} # save util.load_local_data(r, result) result['title'] = node_token.bookmark.get("title") else: # anonymous user result = {"_core_id": node_token.bookmark["_core_id"], "entity_table": node_token.bookmark["table_name"], "accessed_date": util.convert_value(datetime.datetime.now())} # update bookmark output to front-end result["title"] = node_token.get_title() node_token.bookmark = result
def call(self, node_token): # retrieve the posted data to populate the form data = node_token.get_node_data() print data new_data = dict() node_token.set_layout_buttons([['save', 'f@new_person.SaveContact:_'], ['cancel', 'BACK'],] ) new_data["name"] = data.get("name") communication = data.get("communication") if communication: comms = parse_communication(communication, display = True) new_data["email.email"] = comms["email"] new_data["address.postcode"] = comms["postcode"] new_data["telephone.number"] = comms["phone_number"] new_data["dob"] = util.convert_value(comms["dob"]) node_token.set_layout_title("Enter details") self["main"].show(node_token, new_data)