def perform_request_delete(comID=-1, recID=-1, uid=-1, reviews="", ln=CFG_SITE_LANG):
    """
    """
    from search_engine import record_exists

    warnings = []

    ln = wash_language(ln)
    comID = wash_url_argument(comID, 'int')
    recID = wash_url_argument(recID, 'int')
    uid = wash_url_argument(uid, 'int')
    # parameter reviews is deduced from comID when needed

    if comID is not None and recID is not None and uid is not None:
        if comID <= 0 and recID <= 0 and uid <= 0:
            if comID != -1:
                warnings.append(("WRN_WEBCOMMENT_ADMIN_INVALID_COMID",))
            return (webcomment_templates.tmpl_admin_delete_form(ln, warnings), None, warnings)

        if comID > 0 and not recID > 0:
            comment = query_get_comment(comID)

            if comment:
                # Figure out if this is a review or a comment
                c_star_score = 5
                if comment[c_star_score] > 0:
                    reviews = 1
                else:
                    reviews = 0
                return (perform_request_comments(ln=ln, comID=comID, recID=recID, reviews=reviews), None, warnings)
            else:
                warnings.append(('WRN_WEBCOMMENT_ADMIN_COMID_INEXISTANT', comID))
                return (webcomment_templates.tmpl_admin_delete_form(ln, warnings), None, warnings)

        elif recID > 0:
            if record_exists(recID):
                comID = ''
                reviews = wash_url_argument(reviews, 'int')
                return (perform_request_comments(ln=ln, comID=comID, recID=recID, reviews=reviews), None, warnings)
            else:
                warnings.append(('WRN_WEBCOMMENT_ADMIN_RECID_INEXISTANT', comID))
                return (webcomment_templates.tmpl_admin_delete_form(ln, warnings), None, warnings)
        else:
            return (webcomment_templates.tmpl_admin_delete_form(ln, warnings), None, warnings)

    else:
        return (webcomment_templates.tmpl_admin_delete_form(ln, warnings), None, warnings)
def perform_request_delete(comID=-1,
                           recID=-1,
                           uid=-1,
                           reviews="",
                           ln=CFG_SITE_LANG):
    """
    """
    from search_engine import record_exists

    warnings = []

    ln = wash_language(ln)
    comID = wash_url_argument(comID, 'int')
    recID = wash_url_argument(recID, 'int')
    uid = wash_url_argument(uid, 'int')
    # parameter reviews is deduced from comID when needed

    if comID is not None and recID is not None and uid is not None:
        if comID <= 0 and recID <= 0 and uid <= 0:
            if comID != -1:
                warnings.append(("WRN_WEBCOMMENT_ADMIN_INVALID_COMID", ))
            return (webcomment_templates.tmpl_admin_delete_form(ln, warnings),
                    None, warnings)

        if comID > 0 and not recID > 0:
            comment = query_get_comment(comID)

            if comment:
                # Figure out if this is a review or a comment
                c_star_score = 5
                if comment[c_star_score] > 0:
                    reviews = 1
                else:
                    reviews = 0
                return (perform_request_comments(ln=ln,
                                                 comID=comID,
                                                 recID=recID,
                                                 reviews=reviews), None,
                        warnings)
            else:
                warnings.append(
                    ('WRN_WEBCOMMENT_ADMIN_COMID_INEXISTANT', comID))
                return (webcomment_templates.tmpl_admin_delete_form(
                    ln, warnings), None, warnings)

        elif recID > 0:
            if record_exists(recID):
                comID = ''
                reviews = wash_url_argument(reviews, 'int')
                return (perform_request_comments(ln=ln,
                                                 comID=comID,
                                                 recID=recID,
                                                 reviews=reviews), None,
                        warnings)
            else:
                warnings.append(
                    ('WRN_WEBCOMMENT_ADMIN_RECID_INEXISTANT', comID))
                return (webcomment_templates.tmpl_admin_delete_form(
                    ln, warnings), None, warnings)
        else:
            return (webcomment_templates.tmpl_admin_delete_form(ln, warnings),
                    None, warnings)

    else:
        return (webcomment_templates.tmpl_admin_delete_form(ln, warnings),
                None, warnings)
예제 #3
0
                if comment[c_star_score] > 0:
                    reviews = 1
                else:
                    reviews = 0
                return (perform_request_comments(ln=ln, comID=comID, recID=recID, reviews=reviews), None, warnings)
            else:
                try:
                    raise InvenioWebCommentWarning(_('Comment ID %s does not exist.') % comID)
                except InvenioWebCommentWarning, exc:
                    register_exception(stream='warning')
                    warnings.append((exc.message, ''))
                #warnings.append(('WRN_WEBCOMMENT_ADMIN_COMID_INEXISTANT', comID))
                return webcomment_templates.tmpl_admin_delete_form(ln, warnings)

        elif recID > 0:
            if record_exists(recID):
                comID = ''
                reviews = wash_url_argument(reviews, 'int')
                return (perform_request_comments(ln=ln, comID=comID, recID=recID, reviews=reviews), None, warnings)
            else:
                try:
                    raise InvenioWebCommentWarning(_('Record ID %s does not exist.') % comID)
                except InvenioWebCommentWarning, exc:
                    register_exception(stream='warning')
                    warnings.append((exc.message, ''))
                #warnings.append(('WRN_WEBCOMMENT_ADMIN_RECID_INEXISTANT', comID))
                return webcomment_templates.tmpl_admin_delete_form(ln, warnings)
        else:
            return webcomment_templates.tmpl_admin_delete_form(ln, warnings)

    else: