예제 #1
0
 def getAllGroups(self):
     dao = groupDAO()
     result = dao.getAllGroups()
     mapped_result = []
     for r in result:
         mapped_result.append(self.mapToDict(r))
     return jsonify(Group=mapped_result)
예제 #2
0
 def getGroupByCreation(self, gcreation):
     dao = groupDAO()
     result = dao.getGroupByCreation(gcreation)
     mapped_result = []
     if not result:
         return jsonify(Error="NOT FOUND"), 404
     else:
         for r in result:
             mapped_result.append(self.mapToDict(r))
         return jsonify(Group=mapped_result)
예제 #3
0
 def getGroupsByName(self, gname):
     dao = groupDAO()
     result = dao.getGroupsByName(gname)
     mapped_result = []
     if not result:
         return jsonify(Error="NOT FOUND"), 404
     else:
         for r in result:
             mapped_result.append(self.mapToDict(r))
         return jsonify(Group=mapped_result)
예제 #4
0
    def getByUserId(self, uid):

        dao = groupDAO()
        result = dao.getByUserId(uid)
        mapped_result = []
        if not result:
            return jsonify(Error="NOT FOUND"), 404
        else:
            for r in result:
                mapped_result.append(self.mapToDict(r))
            return jsonify(Group=mapped_result)
예제 #5
0
    def getMessagesByGroupId(self, gid):

        dao = groupDAO()
        result = dao.getMessagesByGroupId(gid)
        mapped_result = []
        if not result:
            return jsonify(Error="NOT FOUND"), 404
        else:
            for r in result:
                mapped_result.append(self.mapGroupMessagesToDict(r))
            return jsonify(GroupMessages=mapped_result)
예제 #6
0
    def insertCredentialsJSON(self, json):

        gname = json.get('gName')
        gdescription = json.get('gdescription')
        gcreation = json.get('gcreation')
        adminId = json.get('gadminID')
        print("GroupHandler")
        print(gname)
        print(gdescription)
        print(gcreation)
        print(adminId)

        if gname and gcreation and gdescription and adminId:
            gid = groupDAO().insert(gname, gdescription, gcreation, adminId)
            mapped_result = self.buildGroupDict(gid, gname, gdescription,
                                                gcreation, adminId)
            return jsonify(Group=mapped_result), 201
        else:
            return jsonify(Error="Unexpected attributes in post request"), 404