def collections(): """ Show a filtered list of all tree collections in the system. """ view_dict = get_opentree_services_method_urls(request) view_dict['maintenance_info'] = get_maintenance_info(request) return view_dict
def create(): # Block (redirect) if we've suspended study editing maintenance_info = get_maintenance_info(request) if maintenance_info.get('maintenance_in_progress', False): redirect(URL('curator', 'default', 'index', vars={"maintenance_notice":"true"})) pass view_dict = get_opentree_services_method_urls(request) view_dict['message'] = "study/create" return view_dict
def index(): """ Offer creation (or uploading) of a name-mapping dataset """ response.view = 'tnrs.html' view_dict = get_opentree_services_method_urls(request) #view_dict['message'] = "This would appear at bottom of page.." view_dict['maintenance_info'] = get_maintenance_info(request) view_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request) return view_dict
def index(): """ Show an introduction page for visitors, or personalized curation dashboard for a logged-in user. """ #response.flash = T("Welcome to web2py!") view_dict = get_opentree_services_method_urls(request) view_dict['maintenance_info'] = get_maintenance_info(request) if False: ## auth.is_logged_in(): # user is logged in, bounce to their personal dashboard redirect(URL('dashboard')) else: # anonymous visitor, show a general info page return view_dict
def edit(): # Block (redirect) if we've suspended study editing maintenance_info = get_maintenance_info(request) if maintenance_info.get('maintenance_in_progress', False): redirect(URL('curator', 'study', 'view', vars={"maintenance_notice":"true"}, args=request.args)) # Fetch a fresh list of search contexts for TNRS? see working example in # the header search of the main opentree webapp view_dict = get_opentree_services_method_urls(request) view_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request) view_dict['studyID'] = request.args[0] view_dict['latestSynthesisSHA'] = _get_latest_synthesis_sha_for_study_id(view_dict['studyID']) view_dict['viewOrEdit'] = 'EDIT' return view_dict
def view(): """ Allow any visitor to view (read-only!) a study on the 'master' branch ? OR can this include work-in-progress from a personal branch? """ response.view = 'study/edit.html' view_dict = get_opentree_services_method_urls(request) view_dict['maintenance_info'] = get_maintenance_info(request) #view_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request) view_dict['studyID'] = request.args[0] view_dict['latestSynthesisSHA'] = _get_latest_synthesis_sha_for_study_id(view_dict['studyID']) view_dict['viewOrEdit'] = 'VIEW' view_dict['userCanEdit'] = auth.is_logged_in() and True or False; return view_dict
def edit(): # Block (redirect) if we've suspended study editing maintenance_info = get_maintenance_info(request) if maintenance_info.get('maintenance_in_progress', False): redirect( URL('curator', 'study', 'view', vars={"maintenance_notice": "true"}, args=request.args)) # Fetch a fresh list of search contexts for TNRS? see working example in # the header search of the main opentree webapp view_dict = get_opentree_services_method_urls(request) view_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names( request) view_dict['treesQueuedForSynthesis'] = fetch_trees_queued_for_synthesis( request) view_dict['studyID'] = request.args[0] view_dict['latestSynthesisSHA'], view_dict[ 'latestSynthesisTreeIDs'] = _get_latest_synthesis_details_for_study_id( view_dict['studyID']) view_dict['viewOrEdit'] = 'EDIT' return view_dict
def profile(): """ shows a personalized profile for any user (default = the current logged-in user) http://..../{app}/default/profile/[username] """ view_dict = get_opentree_services_method_urls(request) view_dict['maintenance_info'] = get_maintenance_info(request) # if the URL has a [username], try to load their information if len(request.args) > 0: # try to load a profile for the specified userid, using the GitHub API specified_userid = request.args[0] view_dict['userid'] = specified_userid view_dict['active_user_found'] = False # fetch the JSON for this user's activities json_response = _fetch_github_api( verb='GET', url='/users/{0}'.format(specified_userid)) error_msg = json_response.get('message', None) view_dict['error_msg'] = error_msg if error_msg: # pass error to the page for display print("ERROR FETCHING INFO FOR USERID: ", specified_userid) print(error_msg) view_dict['user_info'] = None view_dict['opentree_activity'] = None else: # pass user info to the page for display view_dict['user_info'] = json_response activity = _get_opentree_activity( userid=specified_userid, username=view_dict['user_info'].get('name', specified_userid)) if activity: view_dict['active_user_found'] = True else: view_dict['active_user_found'] = False view_dict['error_msg'] = 'Not active in OpenTree' view_dict['opentree_activity'] = activity view_dict['is_current_user_profile'] = False if view_dict['active_user_found'] == True and auth.is_logged_in(): current_userid = auth.user and auth.user.github_login or None if specified_userid == current_userid: view_dict['is_current_user_profile'] = True return view_dict else: # No userid was provided in the URL. Instead, we should try to bounce to the # current user's profile if they're logged in (or try to force a login). if auth.is_logged_in(): current_userid = auth.user and auth.user.github_login or None # redirect to the fully expanded profile URL expanded_url = URL('curator', 'default', 'profile', args=(current_userid, ), vars=request.vars) redirect(expanded_url) else: # try to force a login and return here redirect( URL('curator', 'user', 'login', vars=dict( _next=URL(args=request.args, vars=request.vars))))
def profile(): """ shows a personalized profile for any user (default = the current logged-in user) http://..../{app}/default/profile/[username] """ view_dict = get_opentree_services_method_urls(request) view_dict['maintenance_info'] = get_maintenance_info(request) # if the URL has a [username], try to load their information if len(request.args) > 0: # try to load a profile for the specified userid, using the GitHub API specified_userid = request.args[0] view_dict['userid'] = specified_userid view_dict['active_user_found'] = False # fetch the JSON for this user's activities json_response = _fetch_github_api(verb='GET', url='/users/{0}'.format(specified_userid)) error_msg = json_response.get('message', None) view_dict['error_msg'] = error_msg if error_msg: # pass error to the page for display print("ERROR FETCHING INFO FOR USERID: ", specified_userid) print(error_msg) view_dict['user_info'] = None view_dict['opentree_activity'] = None else: # pass user info to the page for display view_dict['user_info'] = json_response activity = _get_opentree_activity( userid=specified_userid, username=view_dict['user_info'].get('name', specified_userid) ) if activity: view_dict['active_user_found'] = True else: view_dict['active_user_found'] = False view_dict['error_msg'] = 'Not active in OpenTree' view_dict['opentree_activity'] = activity view_dict['is_current_user_profile'] = False if view_dict['active_user_found'] == True and auth.is_logged_in(): current_userid = auth.user and auth.user.github_login or None if specified_userid == current_userid: view_dict['is_current_user_profile'] = True return view_dict else: # No userid was provided in the URL. Instead, we should try to bounce to the # current user's profile if they're logged in (or try to force a login). if auth.is_logged_in(): current_userid = auth.user and auth.user.github_login or None # redirect to the fully expanded profile URL expanded_url = URL('curator', 'default', 'profile', args=(current_userid,), vars=request.vars) redirect(expanded_url) else: # try to force a login and return here redirect(URL('curator', 'user', 'login', vars=dict(_next=URL(args=request.args, vars=request.vars))))