Beispiel #1
0
    def updatesave_group_details(self,login,groupid, groupname, userids,desc):

        result = []
        group=Group()
        session=DBHelper().get_session()
        if groupname in constants.DEFAULT_GROUPS:
            user=session.query(User).filter(User.user_name==constants.DEFAULT_USERS[0]).first()
            new_ids =[]
            if userids !="":
                new_ids=(userids).split(',')
            new_ids = [int(id) for id in new_ids]
            if user.user_id not in new_ids:
                raise Exception("Can not remove user "+user.user_name+" from "+groupname)
       
        group=session.query(Group).filter(Group.group_id==groupid).first()
        group.group_name=groupname        
        group.description=desc
        group.modified_date=datetime.now()
        group.modified_by=(login)

        for user in group.users:
            group.users.remove(user)

        if userids !="":
            L=(userids).split(',')
            for i in L:
                user=session.query(User).filter(User.user_id==int(i)).first()
                group.users.append(user)

        DBHelper().update(group)

        return result
Beispiel #2
0
    def save_group_details(self,login,groupid, groupname, userids,desc):

        dupGrp=None
        group=Group()
        db=DBHelper()
        session=DBHelper().get_session()
        dupGrp=session.query(Group).filter(Group.group_name==groupname).first()
        if dupGrp is None:
           result = []
           group.group_name=groupname           
           group.created_by=(login)
           group.modified_by=(login)
           group.created_date=datetime.now()
           group.description=desc

           L=(userids).split(',')
           if userids !="":
              for i in L:
                  user=session.query(User).filter(User.user_id==int(i)).first()
                  group.users.append(user);

           db.add(group)
           return result
        else:
            result="False"
            return result
Beispiel #3
0
    def save_group_details(self, login, groupid, groupname, userids, desc):

        dupGrp = None
        group = Group()
        db = DBHelper()
        session = DBHelper().get_session()
        dupGrp = session.query(Group).filter(
            Group.group_name == groupname).first()
        if dupGrp is None:
            result = []
            group.group_name = groupname
            group.created_by = (login)
            group.modified_by = (login)
            group.created_date = datetime.now()
            group.description = desc

            L = (userids).split(',')
            if userids != "":
                for i in L:
                    user = session.query(User).filter(
                        User.user_id == int(i)).first()
                    group.users.append(user)

            db.add(group)
            return result
        else:
            result = "False"
            return result
Beispiel #4
0
    def updatesave_group_details(self, login, groupid, groupname, userids,
                                 desc):

        result = []
        group = Group()
        session = DBHelper().get_session()
        if groupname in constants.DEFAULT_GROUPS:
            user = session.query(User).filter(
                User.user_name == constants.DEFAULT_USERS[0]).first()
            new_ids = []
            if userids != "":
                new_ids = (userids).split(',')
            new_ids = [int(id) for id in new_ids]
            if user.user_id not in new_ids:
                raise Exception("Can not remove user " + user.user_name +
                                " from " + groupname)

        group = session.query(Group).filter(Group.group_id == groupid).first()
        group.group_name = groupname
        group.description = desc
        group.modified_date = datetime.now()
        group.modified_by = (login)

        for user in group.users:
            group.users.remove(user)

        if userids != "":
            L = (userids).split(',')
            for i in L:
                user = session.query(User).filter(
                    User.user_id == int(i)).first()
                group.users.append(user)

        DBHelper().update(group)

        return result