Subversion Repositories SmartDukaan

Rev

Rev 18271 | Rev 18830 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18271 Rev 18384
Line 2125... Line 2125...
2125
        mc.set("cached_app_offers_"+str(retailerId), finalAppOffersMap, 120)
2125
        mc.set("cached_app_offers_"+str(retailerId), finalAppOffersMap, 120)
2126
    else:
2126
    else:
2127
        print 'No Offers'
2127
        print 'No Offers'
2128
        mc.set("cached_app_offers_"+str(retailerId), {}, 10)              
2128
        mc.set("cached_app_offers_"+str(retailerId), {}, 10)              
2129
        
2129
        
2130
def sendNotification(userIds, campaignName, title, message,notificationtype, url, expiresat='2999-01-01'):
2130
def sendNotification(userIds, campaignName, title, message,notificationtype, url, expiresat='2999-01-01', sendsms=False, smstext=None):
2131
    campaignId = addNotificationCampaign(campaignName, title, message, notificationtype, url, None)
2131
    campaignId = addNotificationCampaign(campaignName, title, message, notificationtype, url, None, sendsms, smstext)
2132
    payload = {}
2132
    payload = {}
2133
    payload["user_id"]= userIds[0]
2133
    payload["user_id"]= userIds[0]
2134
    payload["type"]="pending"
2134
    payload["type"]="pending"
2135
    payload["notification_campaign_id"]= campaignId
2135
    payload["notification_campaign_id"]= campaignId
2136
    payload["status"]=0
2136
    payload["status"]=0
Line 2142... Line 2142...
2142
    pushpostrequest = urllib2.Request("http://45.33.50.227:3001/addPushNotification")
2142
    pushpostrequest = urllib2.Request("http://45.33.50.227:3001/addPushNotification")
2143
    pushpostrequest.add_header('Content-Type', 'application/json')
2143
    pushpostrequest.add_header('Content-Type', 'application/json')
2144
    response = urllib2.urlopen(pushpostrequest, jsonObj).read()
2144
    response = urllib2.urlopen(pushpostrequest, jsonObj).read()
2145
    print response
2145
    print response
2146
        
2146
        
2147
def addNotificationCampaign(name, title, message, type, url, sql):
2147
def addNotificationCampaign(name, title, message, type, url, sql, sendsms, smstext):
2148
    notificationCampaign = notification_campaigns()
2148
    notificationCampaign = notification_campaigns()
2149
    notificationCampaign.name = name
2149
    notificationCampaign.name = name
2150
    notificationCampaign.title = title
2150
    notificationCampaign.title = title
2151
    notificationCampaign.type = type
2151
    notificationCampaign.type = type
2152
    notificationCampaign.message = message
2152
    notificationCampaign.message = message
2153
    notificationCampaign.url = url
2153
    notificationCampaign.url = url
2154
    notificationCampaign.sql = sql
2154
    notificationCampaign.sql = sql
2155
    notificationCampaign.expiresat = datetime(2999, 1, 1)
2155
    notificationCampaign.expiresat = datetime(2999, 1, 1)
2156
    notificationCampaign.status = 'active'
2156
    notificationCampaign.status = 'active'
2157
    notificationCampaign.created = datetime.now()
2157
    notificationCampaign.created = datetime.now()
-
 
2158
    notificationCampaign.sendsms = sendsms
-
 
2159
    notificationCampaign.messagetext = smstext
2158
    
2160
    
2159
    session.commit()
2161
    session.commit()
2160
    campaignId = notificationCampaign.id
2162
    campaignId = notificationCampaign.id
2161
    
2163
    
2162
    session.close()
2164
    session.close()