Exemplo n.º 1
0
    def membersubmit(self):
        params = self.request.params
        import transaction
        session = DBSession()
        ourvalues = {}
        try:
            userid = params.get('userid')
            groupid = params.get('groupid')
            player = session.query(Player).filter(Player.id==userid).one()
            group = session.query(Group).filter(Group.id==groupid).one()
            if 'removefromgroup' in params:
                membership = session.query(GroupMembership) \
                    .filter(
                        and_(GroupMembership.groupid==groupid,
                             GroupMembership.userid==userid)) \
                    .first()
                session.delete(membership)
                ourvalues['message'] = 'Succesfully removed %s from %s ' % (player.name, group.name)
                transaction.commit()
            if 'addtogroup' in params:

                membership = GroupMembership(userid, groupid)
                session.add(membership)
                ourvalues['message'] = 'Succesfully added %s to %s ' % (player.name, group.name)
                transaction.commit()

        except:
            pass
        returnvalue =  self.grouplist()
        returnvalue.update(ourvalues)
        return returnvalue
Exemplo n.º 2
0
    def submit(self):
        params = self.request.params
        import transaction
        session = DBSession()
        ourvalues = {}
        try:
            groupid = params.get('groupid')
            group = session.query(Group).filter(Group.id==groupid).one()
            if 'deletegroup' in params:
                ourvalues['message'] = 'Succesfully removed %s ' % group.name

            if 'addgroup' in params:
                groupname = params.get('groupname')
                guildid = params.get('guildid')
                group = Group(groupname, guildid)
                session.add(group)

                ourvalues['message'] = 'Succesfully added %s ' % groupname
        except:
            pass
        returnvalue =  self.grouplist()
        returnvalue.update(ourvalues)
        return returnvalue