Esempio n. 1
0
    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)
Esempio n. 2
0
 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()
Esempio n. 3
0
    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
Esempio n. 4
0
    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
Esempio n. 5
0
 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)
Esempio n. 6
0
    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
Esempio n. 7
0
    def filterNotes(self, data):
        # nowtime = timezone.now()
        nowtime = JingoTimezone.getLocalTime()
        # retrieve user filter
        uCTags = self.getUserCategoryTagsList(data)

        # retrieve notesets
        nlist1 = Note_Time.objects.filter(n_repeat=0, n_start_time__lte=nowtime, n_stop_time__gte=nowtime).values(
            "noteid"
        )
        nlist2 = Note_Time.objects.raw(
            "Select noteid From Note_Time Where n_repeat=1 And Time(Now()) Between Time(n_start_time) And Time(n_stop_time)"
        ).values("noteid")
        nlist = nlist1 + nlist2
        notesets = Note.objects.filter(n_visibility__in=[0, 1], noteid__in=nlist)
        return data
Esempio n. 8
0
 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)
Esempio n. 9
0
 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
Esempio n. 10
0
    def filterNotes(self, data):
        #nowtime = timezone.now()
        nowtime = JingoTimezone.getLocalTime()
        # retrieve user filter
        uCTags = self.getUserCategoryTagsList(data)

        # retrieve notesets
        nlist1 = Note_Time.objects.filter(
            n_repeat=0, n_start_time__lte=nowtime,
            n_stop_time__gte=nowtime).values('noteid')
        nlist2 = Note_Time.objects.raw(
            "Select noteid From Note_Time Where n_repeat=1 And Time(Now()) Between Time(n_start_time) And Time(n_stop_time)"
        ).values('noteid')
        nlist = nlist1 + nlist2
        notesets = Note.objects.filter(n_visibility__in=[0, 1],
                                       noteid__in=nlist)
        return data