Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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:
            res.append(collection[0])
    return res
Exemplo n.º 4
0
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
Exemplo n.º 5
0
def send_request_notification_to_all_linkback_moderators(recid, origin_url, linkback_type, ln):
    """
    Send notification emails to all linkback moderators for linkback request
    @param recid
    @param origin_url: URL of the requestor
    @param linkback_type: of CFG_WEBLINKBACK_LIST_TYPE
    """
    content = """There is a new %(linkback_type)s request for %(recordURL)s from %(origin_url)s which you should approve or reject.
              """ % {'linkback_type': linkback_type,
                     'recordURL': generate_redirect_url(recid, ln),
                     'origin_url': origin_url}

    html_content = """There is a new %(linkback_type)s request for %(record)s (<a href="%(recordURL)s">%(recordURL)s</a>) from <a href="%(origin_url)s">%(title)s</a> (<a href="%(origin_url)s">%(origin_url)s</a>) which you should approve or reject.
                   """ % {'linkback_type': linkback_type,
                          'record': format_record(recID=recid, of='hs', ln=ln),
                          'recordURL': generate_redirect_url(recid, ln),
                          'origin_url': origin_url,
                          'title': origin_url}

    for email in acc_get_authorized_emails('moderatelinkbacks', collection = guess_primary_collection_of_a_record(recid)):
        send_email(CFG_SITE_ADMIN_EMAIL, email, 'New ' + linkback_type + ' request', content, html_content)