def addUser(self, data): usr = User() usr.uid = self.getNewUid() usr.u_name = data['u_name'] usr.email = data['email'] usr.password = base64.b64encode(data['password']) #usr.u_timestamp = timezone.now() usr.u_timestamp = JingoTimezone().getLocalTime() usr.save() return User.objects.filter(email=data['email']).values()
def addNoteTimeRange(self, data): if 'n_repeat' not in data: data['n_repeat'] = 0 if len(data['n_start_time']) == 0 or len(data['n_stop_time']) == 0: localtime = JingoTimezone().getLocalTime() data['n_start_time'] = localtime data['n_stop_time'] = localtime + datetime.timedelta(days=1) Note_Time().addNoteTime(data)
def addNote(self, data): newNoteid = self.getNewNoteid() ''' notetime = Note() notetime.note = data['note'] #notetime.n_timestamp = timezone.now() print "======Insert time======" notetime.n_timestamp = JingoTimezone().getLocalTime() notetime.link = '' notetime.noteid = newNoteid notetime.uid = User(uid=data['uid']) if 'radius' in data: notetime.radius = data['radius'] notetime.n_visibility = data['n_visibility'] if 'is_comment' in data: notetime.is_comment = data['is_comment'] else: notetime.is_comment = 0 else: notetime.radius = N_DEFAULT_RADIUS # default 200 yards notetime.n_visibility = 0 # default 0: public notetime.is_comment = IS_COMMENT notetime.n_latitude = data['n_latitude'] notetime.n_longitude = data['n_longitude'] notetime.n_like = N_LIKES notetime.save() ''' if 'radius' in data: radius = data['radius'] n_visibility = data['n_visibility'] if 'is_comment' in data: is_comment = data['is_comment'] else: is_comment = 0 else: radius = N_DEFAULT_RADIUS # default 200 yards n_visibility = 0 # default 0: public is_comment = IS_COMMENT data['n_longitude'] = "%.6f" % float(data['n_longitude']) data['n_latitude'] = "%.6f" % float(data['n_latitude']) timestamp = JingoTimezone().getLocalTime() values = [ data['note'], timestamp, data['link'], newNoteid, data['uid'], radius, n_visibility, data['n_latitude'], data['n_longitude'], is_comment, N_LIKES ] #print values args = dict([('table', 'note'), ('values', values)]) SQLExecuter().doInsertData(args) data['noteid'] = newNoteid return data
def logUserKeywords(self, data, keywords): #currenttime = timezone.now() currenttime = JingoTimezone().getLocalTime() data['u_longitude'] = "%.6f" % float(data['u_longitude']) data['u_latitude'] = "%.6f" % float(data['u_latitude']) for keyword in keywords: values = [ self.getNewLogid(), int(data['uid']), keyword, data['u_longitude'], data['u_latitude'], currenttime ] args = dict([('table', 'log_keywords'), ('values', values)]) SQLExecuter().doInsertData(args)
def addComment(self, data): newCommentid = self.getNewCommentid() data['c_longitude'] = "%.6f" % float(data['c_longitude']) data['c_latitude'] = "%.6f" % float(data['c_latitude']) values = [ newCommentid, int(data['noteid']), JingoTimezone().getLocalTime(), int(data['uid']), float(data['c_latitude']), float(data['c_longitude']), data['comment'] ] #print values args = dict([('table', 'comments'), ('values', values)]) SQLExecuter().doInsertData(args) return newCommentid
def filterNotes(self, data, mode='normal'): localtime = JingoTimezone().getLocalTime() currenttime = localtime.strftime('%Y-%m-%d %H:%M:%S') if mode == 'normal': noteslist = self.getNoteInfoList(currenttime) else: noteslist = self.getNoteInfoListByKewords(data, currenttime) uProfile = self.getUserCategoryTagsList(data) # filter by user's tags noteslist = self.filterByTags(uProfile, noteslist) # filter by user's time range noteslist = self.filterByTime(uProfile, noteslist, currenttime) # filter by visibility and friendship noteslist = self.filterByVisibility(data, uProfile, noteslist) # filter by location noteslist = self.filterByLocation(data, noteslist) #print noteslist return noteslist