from gcm import *
import time
from time import time, strftime, gmtime, sleep
import datetime
from BizPit_app.models import *
def notify():
        data1=Payment.objects.filter(User_id=4)
        for d in data1:
	    print "testing..",d.User_id
            user_id=d.User_id
            msg="Testing GCM"
            new_data=Login.objects.get(user_id=4)
	    print "arpita....."
            if(new_data):
                    gcm_id=str(new_data.gcm_id)
                    property_id=str(d.property_id)
                    if(gcm_id != " "):
                            if(d.notification==1 and d.rate=="ND"):
                                    gcm=GCM("AIzaSyBB__xbySh6sq-WbQUuG7ZO_sRr_twbuYM")
                                    data={'property_id': property_id, 'param4': 'message'}
                                    reg_id=gcm_id
				    print "reg_id",reg_id
				    #data = json.dumps(str(values))
				    print "data..",data
                                    response=gcm.json_request(registration_ids = reg_id, data = data)
                                    print "response",response
                            if(d.rate != "ND"):
                                    d.notification = 0
                                    d.save()




notify()
