Esempio n. 1
0
def get_impl(Model, Message, itemId):
    return ferris3.ToolChain(itemId) \
        .ndb.get() \
        .raise_if(None, ferris3.NotFoundException()) \
        .ndb.check_kind(Model) \
        .messages.serialize(Message) \
        .value()
Esempio n. 2
0
    def by_channel(delf, request, channelid=(str, )):
        cha_msgs = PushMessage.query(PushMessage.channel_id == channelid)

        if cha_msgs is not None:
            return f3.messages.serialize_list(MultiMessage, cha_msgs)
        else:
            raise f3.NotFoundException()
Esempio n. 3
0
	def resend_sms_verification(delf,request,objectId=(str,)):
		subscriber_value= Subscriber.get_by_obj_id(objectId).get()		
		if subscriber_value is not None:
			client = TwilioRestClient(twilio_acc, twilio_tkn)
 			message = client.messages.create(to="+"+subscriber_value.phone_number,
 					 from_="+12057915054", body="You verification code is: "+subscriber_value.sms_verification_code);
 		else:
				raise f3.NotFoundException()
Esempio n. 4
0
	def remove_channel(delf,request,channelid=(str,),objectId=(str,)):
		subscriber_value= Subscriber.get_by_obj_id(objectId).get()
		if subscriber_value is not None:
			subscriber_value.channels.remove(channelid)
			subscriber_value.put()
		else:
			raise f3.NotFoundException()
		return f3.messages.serialize(SubMsg, subscriber_value)
Esempio n. 5
0
    def by_ids(self, request, channels=(str, )):
        selected_channels = channels.split(",")
        cha_msgs = Channel.query(Channel.short_id.IN(selected_channels))

        if cha_msgs is not None:
            return f3.messages.serialize_list(MultiMessage, cha_msgs)
        else:
            raise f3.NotFoundException()
Esempio n. 6
0
    def by_latest(delf, request):

        cha_msgs = PushMessage.query().order(-PushMessage.date)

        if cha_msgs is not None:
            return f3.messages.serialize_list(MultiMessage, cha_msgs)
        else:
            raise f3.NotFoundException()
Esempio n. 7
0
	def verify_sms(delf,request,objectId=(str,), verification_code=(str,)):
		subscriber_value= Subscriber.get_by_obj_id(objectId).get()
		if subscriber_value is not None:
			if subscriber_value.sms_verification_code == verification_code:
				subscriber_value.sms_verified=True
				subscriber_value.put()
			else:
				raise f3.NotFoundException()
		return f3.messages.serialize(SubMsg, subscriber_value)
Esempio n. 8
0
    def by_city(self, request, city=(str, ), country=(str, )):
        parsed_city_key = (city + "-" + country).lower()
        city_key = ndb.Key(City, parsed_city_key)
        if (city_key):
            cha_msgs = Channel.query(Channel.city == city_key)

            if cha_msgs is not None:
                return f3.messages.serialize_list(MultiMessage, cha_msgs)
            else:
                raise f3.NotFoundException()
Esempio n. 9
0
    def by_channels(
        self,
        request,
    ):

        cha_msgs = Channel.query(Channel.is_featured == True)

        if cha_msgs is not None:
            return f3.messages.serialize_list(MultiMessage, cha_msgs)
        else:
            raise f3.NotFoundException()
Esempio n. 10
0
def update_impl(Model, Message, itemId, request):
    item = ferris3.ToolChain(itemId) \
        .ndb.get() \
        .raise_if(None, ferris3.NotFoundException()) \
        .ndb.check_kind(Model) \
        .value()

    return ferris3.ToolChain(request) \
        .messages.deserialize(item) \
        .ndb.put() \
        .messages.serialize(Message) \
        .value()
Esempio n. 11
0
	def validate(delf,request,objectId=(str,), password=(str,)):
		subscriber_value= Subscriber.get_by_obj_id(objectId).get();
		if SHA256.new(password).hexdigest() == subscriber_value.password :
			return f3.messages.serialize(SubMsg, subscriber_value)
		else:
			raise f3.NotFoundException()