def get(self, reply_key): reply = Reply.get(reply_key) topic = GetKindByNum('Topic', reply.topic_num) ms = re.findall('(@[a-zA-Z0-9\_]+\.?)\s?', reply.content) unique = [] for m in ms: if m.lower() not in unique: unique.append(m.lower()) keys = [] if (len(unique) > 0): for m in unique: m_id = re.findall('@([a-zA-Z0-9\_]+\.?)', m) if (len(m_id) > 0): if (m_id[0].endswith('.') != True): member_username = m_id[0] member = GetMemberByUsername(member_username) if member: if (member.id != topic.member.id) and ( member.id != reply.member.id) and ( member.id not in keys): #q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.max') q = Counter.selectBy(name='notification.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'notification.max' counter.value = 1 #q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.total') q2 = Counter.selectBy( name='notification.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'notification.total' counter2.value = 1 notification = Notification(member=member) notification.num = counter.value notification.type = 'mention_reply' notification.payload = reply.content notification.label1 = topic.title notification.link1 = '/t/' + str( topic.num) + '#reply' + str(topic.replies) notification.member = reply.member notification.for_member_num = member.num keys.append(str(member.id)) counter.sync() counter2.sync() notification.sync() store.commit() #jon add for k in keys: taskqueue.add(url='/notifications/check/' + k)
def post(self, topic_key): topic = db.get(db.Key(topic_key)) combined = topic.title + " " + topic.content ms = re.findall('(@[a-zA-Z0-9\_]+\.?)\s?', combined) unique = [] for m in ms: if m.lower() not in unique: unique.append(m.lower()) keys = [] if (len(unique) > 0): for m in unique: m_id = re.findall('@([a-zA-Z0-9\_]+\.?)', m) if (len(m_id) > 0): if (m_id[0].endswith('.') != True): member_username = m_id[0] member = GetMemberByUsername(member_username) if member: if member.key() != topic.member.key( ) and member.key() not in keys: q = db.GqlQuery( 'SELECT * FROM Counter WHERE name = :1', 'notification.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'notification.max' counter.value = 1 q2 = db.GqlQuery( 'SELECT * FROM Counter WHERE name = :1', 'notification.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'notification.total' counter2.value = 1 notification = Notification(parent=member) notification.num = counter.value notification.type = 'mention_topic' notification.payload = topic.content notification.label1 = topic.title notification.link1 = '/t/' + str( topic.num) + '#reply' + str(topic.replies) notification.member = topic.member notification.for_member_num = member.num keys.append(str(member.key())) counter.put() counter2.put() notification.put() for k in keys: taskqueue.add(url='/notifications/check/' + k)
def get(self, topic_key): topic = Topic.get(topic_key) combined = topic.title + " " + topic.content ms = re.findall('(@[a-zA-Z0-9\_]+\.?)\s?', combined) unique = [] for m in ms: if m.lower() not in unique: unique.append(m.lower()) keys = [] if (len(unique) > 0): for m in unique: m_id = re.findall('@([a-zA-Z0-9\_]+\.?)', m) if (len(m_id) > 0): if (m_id[0].endswith('.') != True): member_username = m_id[0] member = GetMemberByUsername(member_username) if member: if member.id != topic.member.id and member.id not in keys: #q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.max') q = Counter.selectBy(name='notification.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'notification.max' counter.value = 1 #q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.total') q2 = Counter.selectBy(name='notification.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'notification.total' counter2.value = 1 notification = Notification(member=member) notification.num = counter.value notification.type = 'mention_topic' notification.payload = topic.content notification.label1 = topic.title notification.link1 = '/t/' + str(topic.num) + '#reply' + str(topic.replies) notification.member = topic.member notification.for_member_num = member.num keys.append(str(member.id)) counter.sync() counter2.sync() notification.sync() store.commit() #jon add for k in keys: taskqueue.add(url='/notifications/check/' + k)
def post(self, reply_key): reply = db.get(db.Key(reply_key)) topic = GetKindByNum('Topic', reply.topic_num) ms = re.findall('(@[a-zA-Z0-9\_]+\.?)\s?', reply.content) unique = [] for m in ms: if m.lower() not in unique: unique.append(m.lower()) keys = [] if (len(unique) > 0): for m in unique: m_id = re.findall('@([a-zA-Z0-9\_]+\.?)', m) if (len(m_id) > 0): if (m_id[0].endswith('.') != True): member_username = m_id[0] member = GetMemberByUsername(member_username) if member: if (member.key() != topic.member.key()) and (member.key() != reply.member.key()) and (member.key() not in keys): q = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.max') if (q.count() == 1): counter = q[0] counter.value = counter.value + 1 else: counter = Counter() counter.name = 'notification.max' counter.value = 1 q2 = db.GqlQuery('SELECT * FROM Counter WHERE name = :1', 'notification.total') if (q2.count() == 1): counter2 = q2[0] counter2.value = counter2.value + 1 else: counter2 = Counter() counter2.name = 'notification.total' counter2.value = 1 notification = Notification(parent=member) notification.num = counter.value notification.type = 'mention_reply' notification.payload = reply.content notification.label1 = topic.title notification.link1 = '/t/' + str(topic.num) + '#reply' + str(topic.replies) notification.member = reply.member notification.for_member_num = member.num keys.append(str(member.key())) counter.put() counter2.put() notification.put() for k in keys: taskqueue.add(url='/notifications/check/' + k)