Ejemplo n.º 1
0
def check_quota(nb_messages):
    """
    @param nb_messages: max number of messages a user can have
    @return: a dictionary of users over-quota
    """
    where = ''
    no_quota_users = list_users_in_roles(CFG_WEBMESSAGE_ROLES_WITHOUT_QUOTA)
    query_params = []
    if len(no_quota_users) > 0:
        where = """WHERE """
        for uid in no_quota_users[:-1]:
            where += "id_user_to!=%s AND "
            query_params.append(uid)
        where += "id_user_to!=%s"
        query_params.append(no_quota_users[-1])
    query = """SELECT id_user_to,
                      count(id_user_to)
               FROM user_msgMESSAGE
               %s
               GROUP BY id_user_to
               HAVING count(id_user_to)>%%s"""
    query_params.append(nb_messages)
    res = run_sql(query % where, tuple(query_params))
    user_over_quota = {}
    def enter_dict(couple):
        """ enter a tuple in user_over_quota dict """
        user_over_quota[int(couple[0])] = int(couple[1])
    map(enter_dict, res)
    return user_over_quota
Ejemplo n.º 2
0
def perform_request_display(uid,
                            errors=[],
                            warnings=[],
                            infos=[],
                            ln=CFG_SITE_LANG):
    """
    Displays the user's Inbox
    @param uid:   user id

    @return: a (body, [errors], [warnings]) formed tuple
    """
    body = ""
    rows = []
    rows = db.get_all_messages_for_user(uid)
    nb_messages = db.count_nb_messages(uid)
    no_quota_users = list_users_in_roles(CFG_WEBMESSAGE_ROLES_WITHOUT_QUOTA)
    no_quota = False
    if uid in no_quota_users:
        no_quota = True
    body = webmessage_templates.tmpl_display_inbox(messages=rows,
                                                   infos=infos,
                                                   warnings=warnings,
                                                   nb_messages=nb_messages,
                                                   no_quota=no_quota,
                                                   ln=ln)
    return (body, errors, warnings)
def check_quota(nb_messages):
    """
    @param nb_messages: max number of messages a user can have
    @return: a dictionary of users over-quota
    """
    where = ''
    no_quota_users = list_users_in_roles(CFG_WEBMESSAGE_ROLES_WITHOUT_QUOTA)
    query_params = []
    if len(no_quota_users) > 0:
        where = """WHERE """
        for uid in no_quota_users[:-1]:
            where += "id_user_to!=%s AND "
            query_params.append(uid)
        where += "id_user_to!=%s"
        query_params.append(no_quota_users[-1])
    query = """SELECT id_user_to,
                      count(id_user_to)
               FROM user_msgMESSAGE
               %s
               GROUP BY id_user_to
               HAVING count(id_user_to)>%%s"""
    query_params.append(nb_messages)
    res = run_sql(query % where, tuple(query_params))
    user_over_quota = {}

    def enter_dict(couple):
        """ enter a tuple in user_over_quota dict """
        user_over_quota[int(couple[0])] = int(couple[1])

    map(enter_dict, res)
    return user_over_quota
Ejemplo n.º 4
0
def perform_request_display(uid, warnings=[], infos=[], ln=CFG_SITE_LANG):
    """
    Displays the user's Inbox
    @param uid:   user id

    @return: body with warnings
    """
    body = ""
    rows = []
    rows = db.get_all_messages_for_user(uid)
    nb_messages = db.count_nb_messages(uid)
    no_quota_users = list_users_in_roles(CFG_WEBMESSAGE_ROLES_WITHOUT_QUOTA)
    no_quota = False
    if uid in no_quota_users:
        no_quota = True
    body = webmessage_templates.tmpl_display_inbox(messages=rows,
                                                   infos=infos,
                                                   warnings=warnings,
                                                   nb_messages=nb_messages,
                                                   no_quota=no_quota,
                                                   ln=ln)
    return body