Example #1
0
    def get_all_alerts(self, type=None):

        params = {'$or': [{'rule_type': 'server'}, {'rule_type': 'process'}]}

        if type != None:
            params = {'$or': [{'rule_type': type}]}

        count = self.collection.find(params).count()

        if count == 0:
            return None
        else:
            rules = self.collection.find(params)

            rules_list = []
            for rule in rules:
                sms_recepients = rule.get('sms_recepients', None)
                if sms_recepients:
                    rule['sms_recepients'] = [
                        sms_recepient_model.get_by_id(x)
                        for x in sms_recepients
                    ]

                email_recepients = rule.get('email_recepients', None)
                if email_recepients:
                    rule['email_recepients'] = [
                        email_recepient_model.get_by_id(x)
                        for x in email_recepients
                    ]

                rules_list.append(rule)

            return rules_list
Example #2
0
    def get_alerts(self, type=None):
        params = {"rule_type": type}

        rules = self.collection.find(params).count()

        if rules == 0:
            return None
        else:
            rules = self.collection.find(params)

            rules_list = []
            for rule in rules:
                sms_recepients = rule.get('sms_recepients', None)
                if sms_recepients:
                    rule['sms_recepients'] = [
                        sms_recepient_model.get_by_id(x)
                        for x in sms_recepients
                    ]

                email_recepients = rule.get('email_recepients', None)
                if email_recepients:
                    rule['email_recepients'] = [
                        email_recepient_model.get_by_id(x)
                        for x in email_recepients
                    ]

                rules_list.append(rule)

            return rules_list
Example #3
0
	def post(self):
		post_data = tornado_escape.json_decode(self.request.body)

		recepient_param = post_data.get('recepient')
		recepient = sms_recepient_model.get_by_id(recepient_param)
		
		response = send_test_sms(recepient=recepient['phone'])
Example #4
0
	def get_all_alerts(self, type=None):
		
		params = {'$or' : [{'rule_type':'server'}, {'rule_type':'process'}]}
		
		if type != None:
			params = {'$or' : [{'rule_type':type}]}

		count = self.collection.find(params).count()

		if count == 0:
			return None
		else:
			rules = self.collection.find(params)
		
			rules_list = []
			for rule in rules:
				sms_recepients = rule.get('sms_recepients', None)
				if sms_recepients:
					rule['sms_recepients'] = [sms_recepient_model.get_by_id(x) for x in sms_recepients]

				email_recepients = rule.get('email_recepients', None)
				if email_recepients:
					rule['email_recepients'] = [email_recepient_model.get_by_id(x) for x in email_recepients]
				
				rules_list.append(rule)

			return rules_list
Example #5
0
	def get(self, recepient_id=None):
		errors =  self.session.get('errors',None)
		form_data =  self.session.get('form_data',None)
	  
	  	recepient = sms_recepient_model.get_by_id(recepient_id)

		self.render('settings/sms/edit_recepient.html',
			recepient=recepient,
			errors=errors,
			form_data=form_data)
Example #6
0
	def get_alerts(self, type=None):
		params = {"rule_type": type}
		
		
		rules = self.collection.find(params).count()

		if rules == 0:
			return None
		else:
			rules = self.collection.find(params)

			rules_list = []
			for rule in rules:
				sms_recepients = rule.get('sms_recepients', None)
				if sms_recepients:
					rule['sms_recepients'] = [sms_recepient_model.get_by_id(x) for x in sms_recepients]

				email_recepients = rule.get('email_recepients', None)
				if email_recepients:
					rule['email_recepients'] = [email_recepient_model.get_by_id(x) for x in email_recepients]
				
				rules_list.append(rule)

			return rules_list