Beispiel #1
0
def perform_request_update_group(uid, grpID, group_name, group_description,
        join_policy, ln=CFG_SITE_LANG):
    """Update group datas in database.
    @param uid: user ID
    @param grpID: ID of the group
    @param group_name: name of the group
    @param group_description: description of the group
    @param join_policy: join policy of the group
    @param ln: language
    @return: body with warnings
    """
    body = ''
    warnings = []
    infos = []
    _ = gettext_set_language(ln)
    group_name_available = db.group_name_exist(group_name)
    if group_name == "":
        try:
            raise InvenioWebSessionWarning(_('Please enter a group name.'))
        except InvenioWebSessionWarning, exc:
            register_exception(stream='warning')
            warnings.append(exc.message)
        body = perform_request_edit_group(uid,
                                          grpID,
                                          warnings=warnings,
                                          ln=ln)
Beispiel #2
0
def perform_request_update_group(uid,
                                 grpID,
                                 group_name,
                                 group_description,
                                 join_policy,
                                 ln=CFG_SITE_LANG):
    """Update group datas in database.
    @param uid: user ID
    @param grpID: ID of the group
    @param group_name: name of the group
    @param group_description: description of the group
    @param join_policy: join policy of the group
    @param ln: language
    @return: body with warnings
    """
    body = ''
    warnings = []
    infos = []
    _ = gettext_set_language(ln)
    group_name_available = db.group_name_exist(group_name)
    if group_name == "":
        try:
            raise InvenioWebSessionWarning(_('Please enter a group name.'))
        except InvenioWebSessionWarning, exc:
            register_exception(stream='warning')
            warnings.append(exc.message)
        body = perform_request_edit_group(uid, grpID, warnings=warnings, ln=ln)
def perform_request_update_group(uid, grpID, group_name, group_description,
        join_policy, ln=CFG_SITE_LANG):
    """Update group datas in database.
    @param uid: user ID
    @param grpID: ID of the group
    @param group_name: name of the group
    @param group_description: description of the group
    @param join_policy: join policy of the group
    @param ln: language
    @return: a (body, errors[], warnings[]) formed tuple
    """
    body = ''
    errors = []
    warnings = []
    infos = []
    _ = gettext_set_language(ln)
    group_name_available = db.group_name_exist(group_name)
    if group_name == "":
        warnings.append('WRN_WEBSESSION_NO_GROUP_NAME')
        (body, errors, warnings) = perform_request_edit_group(uid,
            grpID,
            warnings=warnings,
            ln=ln)
    elif not group_name_valid_p(group_name):
        warnings.append('WRN_WEBSESSION_NOT_VALID_GROUP_NAME')
        (body, errors, warnings) = perform_request_edit_group(uid,
            grpID,
            warnings=warnings,
            ln=ln)
    elif join_policy == "-1":
        warnings.append('WRN_WEBSESSION_NO_JOIN_POLICY')
        (body, errors, warnings) = perform_request_edit_group(uid,
            grpID,
            warnings=warnings,
            ln=ln)
    elif (group_name_available and group_name_available[0][0]!= grpID):
        warnings.append('WRN_WEBSESSION_GROUP_NAME_EXISTS')
        (body, errors, warnings) = perform_request_edit_group(uid,
            grpID,
            warnings=warnings,
            ln=ln)

    else:
        grpID = db.update_group_infos(grpID,
            group_name,
            group_description,
            join_policy)
        infos.append(CFG_WEBSESSION_INFO_MESSAGES["GROUP_UPDATED"])
        (body, errors, warnings) = perform_request_groups_display(uid,
            infos=infos,
            errors=errors,
            warnings=warnings,
            ln=CFG_SITE_LANG)

    return (body, errors, warnings)
Beispiel #4
0
def perform_request_create_group(uid, group_name, group_description, join_policy, ln=CFG_SITE_LANG):
    """Create new group.
    @param group_name: name of the group entered
    @param group_description: description of the group entered
    @param join_policy: join  policy of the group entered
    @param ln: language
    @return: a (body, errors, warnings) formed tuple
    warning != [] if group_name or join_policy are not valid
    or if the name already exists in the database
    body="1" if succeed in order to display info on the main page
    """
    _ = gettext_set_language(ln)
    body = ""
    warnings = []
    errors = []
    infos = []
    if group_name == "":
        warnings.append(("WRN_WEBSESSION_NO_GROUP_NAME",))
        (body, errors, warnings) = perform_request_input_create_group(
            group_name, group_description, join_policy, warnings=warnings
        )
    elif not group_name_valid_p(group_name):
        warnings.append("WRN_WEBSESSION_NOT_VALID_GROUP_NAME")
        (body, errors, warnings) = perform_request_input_create_group(
            group_name, group_description, join_policy, warnings=warnings
        )

    elif join_policy == "-1":
        warnings.append("WRN_WEBSESSION_NO_JOIN_POLICY")
        (body, errors, warnings) = perform_request_input_create_group(
            group_name, group_description, join_policy, warnings=warnings
        )
    elif db.group_name_exist(group_name):
        warnings.append("WRN_WEBSESSION_GROUP_NAME_EXISTS")
        (body, errors, warnings) = perform_request_input_create_group(
            group_name, group_description, join_policy, warnings=warnings
        )

    else:
        db.insert_new_group(uid, group_name, group_description, join_policy)
        infos.append(CFG_WEBSESSION_INFO_MESSAGES["GROUP_CREATED"])
        (body, errors, warnings) = perform_request_groups_display(
            uid, infos=infos, errors=errors, warnings=warnings, ln=ln
        )
    return (body, errors, warnings)
Beispiel #5
0
     body = perform_request_input_create_group(group_name,
                                               group_description,
                                               join_policy,
                                               warnings=warnings)
 elif join_policy == "-1":
     try:
         raise InvenioWebSessionWarning(
             _('Please choose a group join policy.'))
     except InvenioWebSessionWarning, exc:
         register_exception(stream='warning')
         warnings.append(exc.message)
     body = perform_request_input_create_group(group_name,
                                               group_description,
                                               join_policy,
                                               warnings=warnings)
 elif db.group_name_exist(group_name):
     try:
         raise InvenioWebSessionWarning(
             _('Group name already exists. Please choose another group name.'
               ))
     except InvenioWebSessionWarning, exc:
         register_exception(stream='warning')
         warnings.append(exc.message)
     body = perform_request_input_create_group(group_name,
                                               group_description,
                                               join_policy,
                                               warnings=warnings)
 else:
     db.insert_new_group(uid, group_name, group_description, join_policy)
     infos.append(CFG_WEBSESSION_INFO_MESSAGES["GROUP_CREATED"])
     body = perform_request_groups_display(uid,
Beispiel #6
0
        body = perform_request_input_create_group(group_name, group_description, join_policy, warnings=warnings)
    elif not group_name_valid_p(group_name):
        try:
            raise InvenioWebSessionWarning(_("Please enter a valid group name."))
        except InvenioWebSessionWarning, exc:
            register_exception(stream="warning")
            warnings.append(exc.message)
        body = perform_request_input_create_group(group_name, group_description, join_policy, warnings=warnings)
    elif join_policy == "-1":
        try:
            raise InvenioWebSessionWarning(_("Please choose a group join policy."))
        except InvenioWebSessionWarning, exc:
            register_exception(stream="warning")
            warnings.append(exc.message)
        body = perform_request_input_create_group(group_name, group_description, join_policy, warnings=warnings)
    elif db.group_name_exist(group_name):
        try:
            raise InvenioWebSessionWarning(_("Group name already exists. Please choose another group name."))
        except InvenioWebSessionWarning, exc:
            register_exception(stream="warning")
            warnings.append(exc.message)
        body = perform_request_input_create_group(group_name, group_description, join_policy, warnings=warnings)
    else:
        db.insert_new_group(uid, group_name, group_description, join_policy)
        infos.append(CFG_WEBSESSION_INFO_MESSAGES["GROUP_CREATED"])
        body = perform_request_groups_display(uid, infos=infos, warnings=warnings, ln=ln)
    return body


def perform_request_input_join_group(uid, group_name, search, warnings=[], ln=CFG_SITE_LANG):
    """Return html for joining new group.
def perform_request_create_group(uid,
        group_name,
        group_description,
        join_policy,
        ln=CFG_SITE_LANG):
    """Create new group.
    @param group_name: name of the group entered
    @param group_description: description of the group entered
    @param join_policy: join  policy of the group entered
    @param ln: language
    @return: a (body, errors, warnings) formed tuple
    warning != [] if group_name or join_policy are not valid
    or if the name already exists in the database
    body="1" if succeed in order to display info on the main page
    """
    _ = gettext_set_language(ln)
    body = ""
    warnings = []
    errors = []
    infos = []
    if group_name == "":
        warnings.append(('WRN_WEBSESSION_NO_GROUP_NAME',))
        (body, errors, warnings) = perform_request_input_create_group(
            group_name,
            group_description,
            join_policy,
            warnings=warnings)
    elif not group_name_valid_p(group_name):
        warnings.append('WRN_WEBSESSION_NOT_VALID_GROUP_NAME')
        (body, errors, warnings) = perform_request_input_create_group(
            group_name,
            group_description,
            join_policy,
            warnings=warnings)

    elif join_policy=="-1":
        warnings.append('WRN_WEBSESSION_NO_JOIN_POLICY')
        (body, errors, warnings) = perform_request_input_create_group(
            group_name,
            group_description,
            join_policy,
            warnings=warnings)
    elif db.group_name_exist(group_name):
        warnings.append('WRN_WEBSESSION_GROUP_NAME_EXISTS')
        (body, errors, warnings) = perform_request_input_create_group(
            group_name,
            group_description,
            join_policy,
            warnings=warnings)

    else:
        db.insert_new_group(uid,
            group_name,
            group_description,
            join_policy)
        infos.append(CFG_WEBSESSION_INFO_MESSAGES["GROUP_CREATED"])
        (body, errors, warnings) = perform_request_groups_display(uid,
            infos=infos,
            errors=errors,
            warnings=warnings,
            ln=ln)
    return (body, errors, warnings)