def create_discussion_on_db( discussion_id=0, discussion_path='resources\\discussions\\80919_labeled_trees.txt'): trees = tt.load_list_of_trees(discussion_path) root_tree = trees[discussion_id] dc = DiscussionController() uc = UserController() uc.add_new_user(root_tree['node']['author'], "1234", root_tree['node']['author'], root_tree['node']['author']) root_comment_dict = { "author": root_tree['node']['author'], "text": root_tree['node']['text'], "parentId": None, "discussionId": None, "depth": 0 } discussion_tree = dc.create_discussion( root_tree['node']['extra_data']['title'], ["Life", "Pregnant", "Abortion"], root_comment_dict, {}) [ traverse_add_comments(child, discussion_tree.get_root_comment_id(), 1, discussion_tree.get_id(), dc, uc) for child in root_tree['children'] ]
def create_discussion_on_db(tree): dc = DiscussionController() uc = UserController() uc.add_new_user(tree['node']['author'], "1234", tree['node']['author'], tree['node']['author']) root_comment_dict = {"author": tree['node']['author'], "text": tree['node']['text'], "parentId": None, "discussionId": None, "depth": 0} discussion_tree = dc.create_discussion(tree['node']['extra_data']['title'], ["Life", "Pregnant", "Abortion"], root_comment_dict, {"vis_config": {"graph": True, "alerts": True, "statistics": True}, "extra_config": {}}) dc.add_user_discussion_statistics(tree['node']['author'], discussion_tree.get_id()) [traverse_add_comments(child, discussion_tree.get_root_comment_id(), 1, discussion_tree.get_id(), dc, uc) for child in tree['children']]
def open_user_window(self, user): # Close register window if self.register_view is not None: self.close_register_window() # Hide login window self.login_view.withdraw() # Create UserController with UserView if self.user_controller is None: self.user_controller = UserController(self.master, self.database_model, self.shared_view, user) self.user_controller.logged_user_view.btn_logout.config(command=self.logout) self.user_controller.logged_user_view.focus_force() else: self.logout()
def add_new_user(): user_controller = UserController() return user_controller.add_new_user("gal21", "1234", "gal", "Esco")
from Controllers.user_controller import UserController from itsdangerous import (TimedJSONWebSignatureSerializer as Serializer, BadSignature, SignatureExpired) from Entities.user import Permission # initialization app = Flask(__name__) CORS(app) socket_io = SocketIO(app, cors_allowed_origins='*') app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog' ROOMS = {} # dict to track active rooms simulation_indexes = {} simulation_order = {} # extensions auth = HTTPBasicAuth() user_controller = UserController() discussion_controller = DiscussionController() def verify_auth_token(token): s = Serializer(app.config['SECRET_KEY']) try: data = s.loads(token) except SignatureExpired: return None # valid token, but expired except BadSignature: return None # invalid token user = user_controller.get_user(data['id']) return user