Exemple #1
0
 def __createnotification(self, requestid, state, requesttype, userid):
     notification = self.__preparenotification(state)
     if state == 'Closed' or state == 'Archived':
         notificationservice().dismissnotificationsbyid(
             requestid, requesttype)
     return notificationservice().createnotification(
         {"message": notification}, requestid, requesttype, "State", userid)
Exemple #2
0
 def createdueevent(self):
     try: 
         _today = self.gettoday()
         notificationservice().dismissremindernotification("ministryrequest", self.__notificationtype())            
         ca_holidays = self.getholidays()
         _upcomingdues = FOIMinistryRequest.getupcominglegislativeduerecords()
         for entry in _upcomingdues:
             _duedate = self.formatduedate(entry['duedate'])
             message = None
             if  _duedate == _today:                
                 message = self.__todayduemessage()     
             elif  self.getpreviousbusinessday(entry['duedate'],ca_holidays) == _today:
                 message = self.__upcomingduemessage(_duedate)
             self.__createnotification(message,entry['foiministryrequestid'])
         return DefaultMethodResult(True,'Legislative reminder notifications created',_today)
     except BusinessException as exception:            
         current_app.logger.error("%s,%s" % ('Legislative reminder Notification Error', exception.message))
         return DefaultMethodResult(False,'Legislative reminder notifications failed',_today)
Exemple #3
0
 def createcommentevent(self, commentid, requesttype, userid):
     try:
         _comment = self.__getcomment(commentid, requesttype)
         notificationservice().createcommentnotification(
             self.getcommentmessage(commentid, _comment), _comment,
             self.__getcommenttype(_comment), requesttype, userid)
         if _comment["taggedusers"] != '[]':
             notificationservice().createcommentnotification(
                 self.getcommentmessage(commentid, _comment), _comment,
                 "Tagged User Comments", requesttype, userid)
         _pushnotifications = notificationservice().getcommentnotifications(
             commentid)
         self.__publishnotification(commentid, _pushnotifications)
         return DefaultMethodResult(True, 'Comment notifications created',
                                    commentid)
     except BusinessException as exception:
         current_app.logger.error(
             "%s,%s" % ('Comment Notification Error', exception.message))
         return DefaultMethodResult(False, 'Comment notifications failed',
                                    commentid)
Exemple #4
0
 def get():
     try:
         result = notificationservice().getnotifications(
             AuthHelper.getuserid())
         return json.dumps(result), 200
     except ValueError:
         return {'status': 500, 'message': "Invalid Request Id"}, 500
     except KeyError as err:
         return {'status': False, 'message': err.messages}, 400
     except BusinessException as exception:
         return {
             'status': exception.status_code,
             'message': exception.message
         }, 500
Exemple #5
0
 def delete(type=None, idnumber=None, notficationid=None):
     try:
         result = notificationservice().dismissnotification(
             AuthHelper.getuserid(), type, idnumber, notficationid)
         if result.success == True:
             return {
                 'status': result.success,
                 'message': result.message,
                 'id': result.identifier
             }, 200
         return {
             'status': result.success,
             'message': result.message,
             'id': result.identifier
         }, 500
     except ValueError:
         return {'status': 500, 'message': "Invalid Request Id"}, 500
     except KeyError as err:
         return {'status': False, 'message': err.messages}, 400
     except BusinessException as exception:
         return {
             'status': exception.status_code,
             'message': exception.message
         }, 500
Exemple #6
0
 def __createnotification(self, message, requestid):
     if message is not None: 
         return notificationservice().createremindernotification({"message" : message}, requestid, "ministryrequest", self.__notificationtype(), self.__defaultuserid())
Exemple #7
0
 def __createnotification(self, requestid, requesttype, userid,
                          isministryuser):
     notification = self.__preparenotification()
     return notificationservice().createnotification(
         {"message": notification}, requestid, requesttype,
         self.__assignmenttype(isministryuser), userid)