def send_pending_linkbacks_notification(linkback_type): """ Send notification emails to all linkback moderators for all pending linkbacks @param linkback_type: of CFG_WEBLINKBACK_LIST_TYPE """ pending_linkbacks = get_all_linkbacks( linkback_type=CFG_WEBLINKBACK_TYPE['TRACKBACK'], status=CFG_WEBLINKBACK_STATUS['PENDING']) if pending_linkbacks: pending_count = len(pending_linkbacks) cutoff_text = '' if pending_count > CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL: cutoff_text = ' (Printing only the first %s requests)' % CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL content = """There are %(count)s new %(linkback_type)s requests which you should approve or reject%(cutoff)s: """ % { 'count': pending_count, 'linkback_type': linkback_type, 'cutoff': cutoff_text } for pending_linkback in pending_linkbacks[ 0:CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL]: content += """ For %(recordURL)s from %(origin_url)s. """ % { 'recordURL': generate_redirect_url(pending_linkback[2]), 'origin_url': pending_linkback[1] } for email in acc_get_authorized_emails('moderatelinkbacks'): send_email(CFG_SITE_ADMIN_EMAIL, email, 'Pending ' + linkback_type + ' requests', content)
def send_pending_linkbacks_notification(linkback_type): """ Send notification emails to all linkback moderators for all pending linkbacks @param linkback_type: of CFG_WEBLINKBACK_LIST_TYPE """ pending_linkbacks = get_all_linkbacks(linkback_type=CFG_WEBLINKBACK_TYPE['TRACKBACK'], status=CFG_WEBLINKBACK_STATUS['PENDING']) if pending_linkbacks: pending_count = len(pending_linkbacks) cutoff_text = '' if pending_count > CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL: cutoff_text = ' (Printing only the first %s requests)' % CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL content = """There are %(count)s new %(linkback_type)s requests which you should approve or reject%(cutoff)s: """ % {'count': pending_count, 'linkback_type': linkback_type, 'cutoff': cutoff_text} for pending_linkback in pending_linkbacks[0:CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL]: content += """ For %(recordURL)s from %(origin_url)s. """ % {'recordURL': generate_redirect_url(pending_linkback[2]), 'origin_url': pending_linkback[1]} for email in acc_get_authorized_emails('moderatelinkbacks'): send_email(CFG_SITE_ADMIN_EMAIL, email, 'Pending ' + linkback_type + ' requests', content)
def get_user_collections(req): """ Return collections for which the user is moderator """ user_info = collect_user_info(req) res = [] collections = run_sql('SELECT name FROM collection') for collection in collections: collection_emails = acc_get_authorized_emails('moderatecomments', collection=collection[0]) if user_info['email'] in collection_emails or isUserAdmin(user_info): res.append(collection[0]) return res