human
Complete this python program:
def group():
assistant
#Here is the Python program you requested.

    """Groups RESTful CRUD Controller
    - used to control membership of a group cc\d on Alerts
    """
    def prep(r):
        table = r.table
        tablename = 'pr_group'
        s3db.configure(tablename, deletable=False)
        if r.component:
            ctable = s3db.pr_group_membership
            ctable.group_head.readable = ctable.group_head.writable = False
            f = ctable.person_id
            settings.pr.request_dob = False
            settings.pr.request_gender = False
            f.requires = s3base.IS_ADD_PERSON_WIDGET2()
            f.widget = s3base.S3AddPersonWidget2(controller='deploy')
            list_fields = ['person_id', 'comments']
            s3db.configure('pr_group_membership', list_fields=list_fields)
        elif (not r.id):
            ltable = s3db.org_organisation_team
            query = (((table.deleted == False) & (table.system == False)) & (table.group_type == 5))
            organisation_id = auth.user.organisation_id
            if organisation_id:
                left = ltable.on(((ltable.group_id == table.id) & ((ltable.organisation_id == organisation_id) | (ltable.organisation_id == None))))
            else:
                left = None
            groups = db(query).select(table.id, ltable.organisation_id, left=left)
            if (organisation_id and (len(groups) > 1)):
                _channels = groups.find((lambda row: (row['org_organisation_team.organisation_id'] == organisation_id)))
                if (not _channels):
                    _channels = groups.find((lambda row: (row['org_organisation_team.organisation_id'] == None)))
                record = _channels.first()
            else:
                record = groups.first()
            if record:
                record_id = record.id
                r.id = record_id
                r.resource.add_filter((table.id == record_id))
                r.method = 'update'
            else:
                r.method = 'create'
        return True
    s3.prep = prep
    return s3_rest_controller('pr', 'group')