def perform_youradminactivities(user_info, ln): """Return text for the `Your Admin Activities' box. Analyze whether user UID has some admin roles, and if yes, then print suitable links for the actions he can do. If he's not admin, print a simple non-authorized message.""" your_role_actions = acc_find_user_role_actions(user_info) your_roles = [] your_admin_activities = [] guest = int(user_info['guest']) for (role, action) in your_role_actions: if role not in your_roles: your_roles.append(role) if action not in your_admin_activities: your_admin_activities.append(action) if SUPERADMINROLE in your_roles: for action in ("runbibedit", "cfgbibformat", "cfgoaiharvest", "cfgoairepository", "cfgbibrank", "cfgbibindex", "cfgwebaccess", "cfgwebcomment", "cfgwebsearch", "cfgwebsubmiit", "cfgbibknowledge", "runbatchuploader"): if action not in your_admin_activities: your_admin_activities.append(action) return websession_templates.tmpl_account_adminactivities( ln = ln, uid = user_info['uid'], guest = guest, roles = your_roles, activities = your_admin_activities, )
def perform_youradminactivities(user_info, ln): """Return text for the `Your Admin Activities' box. Analyze whether user UID has some admin roles, and if yes, then print suitable links for the actions he can do. If he's not admin, print a simple non-authorized message.""" your_role_actions = acc_find_user_role_actions(user_info) your_roles = [] your_admin_activities = [] guest = int(user_info['guest']) for (role, action) in your_role_actions: if role not in your_roles: your_roles.append(role) if action not in your_admin_activities: your_admin_activities.append(action) if SUPERADMINROLE in your_roles: for action in ("runbibedit", "cfgbibformat", "cfgoaiharvest", "cfgoairepository", "cfgbibrank", "cfgbibindex", "cfgwebaccess", "cfgwebcomment", "cfgwebsearch", "cfgwebsubmiit", "cfgbibknowledge", "runbatchuploader"): if action not in your_admin_activities: your_admin_activities.append(action) return websession_templates.tmpl_account_adminactivities( ln=ln, uid=user_info['uid'], guest=guest, roles=your_roles, activities=your_admin_activities, )
def get_user_level(uid): ''' Finds and returns the aid-universe-internal numeric user level @param uid: the user's id @type uid: int @return: A numerical representation of the maximum access level of a user @rtype: int ''' actions = [row[1] for row in acc_find_user_role_actions({'uid': uid})] return max([dbapi.resolve_paper_access_right(acc) for acc in actions])
def perform_display_account(req, username, bask, aler, sear, msgs, loan, grps, sbms, appr, admn, ln, comments): """Display a dynamic page that shows the user's account.""" # load the right message language _ = gettext_set_language(ln) uid = getUid(req) user_info = collect_user_info(req) #your account if int(user_info['guest']): user = "******" login = "******" % (CFG_SITE_SECURE_URL, ln) accBody = _("You are logged in as guest. You may want to %(x_url_open)slogin%(x_url_close)s as a regular user.") %\ {'x_url_open': '<a href="' + login + '">', 'x_url_close': '</a>'} accBody += "<br /><br />" bask=aler=msgs=comments= _("The %(x_fmt_open)sguest%(x_fmt_close)s users need to %(x_url_open)sregister%(x_url_close)s first") %\ {'x_fmt_open': '<strong class="headline">', 'x_fmt_close': '</strong>', 'x_url_open': '<a href="' + login + '">', 'x_url_close': '</a>'} sear= _("No queries found") else: user = username accBody = websession_templates.tmpl_account_body( ln = ln, user = user, ) #Display warnings if user is superuser roles = acc_find_user_role_actions(user_info) warnings = "0" warning_list = [] for role in roles: if "superadmin" in role: warnings = "1" break if warnings == "1": warning_list.extend(superuser_account_warnings()) # Display the warning if the email of the user is autogenerated email_autogenerated_warning = external_user_warning(uid) if email_autogenerated_warning: warnings = "1" warning_list.append(email_autogenerated_warning) #check if tickets ok tickets = (acc_authorize_action(user_info, 'runbibedit')[0] == 0) return websession_templates.tmpl_account_page( ln = ln, warnings = warnings, warning_list = warning_list, accBody = accBody, baskets = bask, alerts = aler, searches = sear, messages = msgs, loans = loan, groups = grps, submissions = sbms, approvals = appr, tickets = tickets, administrative = admn, comments = comments, )
def perform_display_account(req, username, bask, aler, sear, msgs, loan, grps, sbms, appr, admn, ln, comments): """Display a dynamic page that shows the user's account.""" # load the right message language _ = gettext_set_language(ln) uid = getUid(req) user_info = collect_user_info(req) #your account if int(user_info['guest']): user = "******" login = "******" % (CFG_SITE_SECURE_URL, ln) accBody = _("You are logged in as guest. You may want to %(x_url_open)slogin%(x_url_close)s as a regular user.") %\ {'x_url_open': '<a href="' + login + '">', 'x_url_close': '</a>'} accBody += "<br /><br />" bask=aler=msgs=comments= _("The %(x_fmt_open)sguest%(x_fmt_close)s users need to %(x_url_open)sregister%(x_url_close)s first") %\ {'x_fmt_open': '<strong class="headline">', 'x_fmt_close': '</strong>', 'x_url_open': '<a href="' + login + '">', 'x_url_close': '</a>'} sear = _("No queries found") else: user = username accBody = websession_templates.tmpl_account_body( ln=ln, user=user, ) #Display warnings if user is superuser roles = acc_find_user_role_actions(user_info) warnings = "0" warning_list = [] for role in roles: if "superadmin" in role: warnings = "1" break if warnings == "1": warning_list.extend(superuser_account_warnings()) # Display the warning if the email of the user is autogenerated email_autogenerated_warning = external_user_warning(uid) if email_autogenerated_warning: warnings = "1" warning_list.append(email_autogenerated_warning) #check if tickets ok tickets = (acc_authorize_action(user_info, 'runbibedit')[0] == 0) return websession_templates.tmpl_account_page( ln=ln, warnings=warnings, warning_list=warning_list, accBody=accBody, baskets=bask, alerts=aler, searches=sear, messages=msgs, loans=loan, groups=grps, submissions=sbms, approvals=appr, tickets=tickets, administrative=admn, comments=comments, )