def perform_sendtrackback(recid, url, title, excerpt, blog_name, blog_id, source, current_user): """ Send trackback @param recid: recid """ # assume unsuccessful request status = 400 xml_response = '<response>' xml_error_response = """<error>1</error> <message>%s</message> """ blacklist_match = infix_exists_for_url_in_list(url, CFG_WEBLINKBACK_LIST_TYPE['BLACKLIST']) whitelist_match = infix_exists_for_url_in_list(url, CFG_WEBLINKBACK_LIST_TYPE['WHITELIST']) # faulty request, url argument not set if url in (CFG_WEBLINKBACK_SUBSCRIPTION_DEFAULT_ARGUMENT_NAME, None, ''): xml_response += xml_error_response % CFG_WEBLINKBACK_TRACKBACK_SUBSCRIPTION_ERROR_MESSAGE['BAD_ARGUMENT'] # request refused: whitelist match has precedence over blacklist match elif blacklist_match and not whitelist_match: xml_response += xml_error_response % CFG_WEBLINKBACK_TRACKBACK_SUBSCRIPTION_ERROR_MESSAGE['BLACKLIST'] # request accepted: will be either approved automatically or pending else: status = 200 linkback_id = create_trackback(recid, url, title, excerpt, blog_name, blog_id, source, current_user) # approve request automatically from url in whitelist if whitelist_match: approve_linkback(linkback_id, current_user) xml_response += '</response>' return xml_response, status
def approve(self, req, form): """ Approve a linkback """ argd = wash_urlargd(form, {'linkbackid': (int, -1)}) authorization = self.check_authorization_moderatelinkbacks(req, argd) if not authorization: approve_linkback(argd['linkbackid'], collect_user_info(req)) return self.display(req, form) else: return authorization
def approve(self, req, form): """ Approve a linkback """ argd = wash_urlargd(form, {'linkbackid': (int, -1)}) authorization = self.check_authorization_moderatelinkbacks(req, argd) if not authorization: approve_linkback(argd['linkbackid'], collect_user_info(req)) return self.display(req, form) else: return authorization
def perform_moderate_linkback(req, linkbackid, action): """ Moderate linkbacks @param linkbackid: linkback id @param action: of CFG_WEBLINKBACK_ADMIN_MODERATION_ACTION @return CFG_WEBLINKBACK_ACTION_RETURN_CODE """ if action == CFG_WEBLINKBACK_ADMIN_MODERATION_ACTION['APPROVE']: approve_linkback(linkbackid, collect_user_info(req)) elif action == CFG_WEBLINKBACK_ADMIN_MODERATION_ACTION['REJECT']: reject_linkback(linkbackid, collect_user_info(req)) else: return CFG_WEBLINKBACK_ACTION_RETURN_CODE['INVALID_ACTION'] return CFG_WEBLINKBACK_ACTION_RETURN_CODE['OK']
def perform_moderate_linkback(req, linkbackid, action): """ Moderate linkbacks @param linkbackid: linkback id @param action: of CFG_WEBLINKBACK_ADMIN_MODERATION_ACTION @return CFG_WEBLINKBACK_ACTION_RETURN_CODE """ if action == CFG_WEBLINKBACK_ADMIN_MODERATION_ACTION['APPROVE']: approve_linkback(linkbackid, collect_user_info(req)) elif action == CFG_WEBLINKBACK_ADMIN_MODERATION_ACTION['REJECT']: reject_linkback(linkbackid, collect_user_info(req)) else: return CFG_WEBLINKBACK_ACTION_RETURN_CODE['INVALID_ACTION'] return CFG_WEBLINKBACK_ACTION_RETURN_CODE['OK']
def perform_sendtrackback(recid, url, title, excerpt, blog_name, blog_id, source, current_user): """ Send trackback @param recid: recid """ # assume unsuccessful request status = 400 xml_response = '<response>' xml_error_response = """<error>1</error> <message>%s</message> """ blacklist_match = infix_exists_for_url_in_list( url, CFG_WEBLINKBACK_LIST_TYPE['BLACKLIST']) whitelist_match = infix_exists_for_url_in_list( url, CFG_WEBLINKBACK_LIST_TYPE['WHITELIST']) # faulty request, url argument not set if url in (CFG_WEBLINKBACK_SUBSCRIPTION_DEFAULT_ARGUMENT_NAME, None, ''): xml_response += xml_error_response % CFG_WEBLINKBACK_TRACKBACK_SUBSCRIPTION_ERROR_MESSAGE[ 'BAD_ARGUMENT'] # request refused: whitelist match has precedence over blacklist match elif blacklist_match and not whitelist_match: xml_response += xml_error_response % CFG_WEBLINKBACK_TRACKBACK_SUBSCRIPTION_ERROR_MESSAGE[ 'BLACKLIST'] # request accepted: will be either approved automatically or pending else: status = 200 linkback_id = create_trackback(recid, url, title, excerpt, blog_name, blog_id, source, current_user) # approve request automatically from url in whitelist if whitelist_match: approve_linkback(linkback_id, current_user) xml_response += '</response>' return xml_response, status