Esempio n. 1
0
    def get(self):
        latitude = float(self.request.get('a'))
        longitude = float(self.request.get('o'))
        bottomLeft = '%(a)f,%(o)f' % {'a':latitude - 1, 'o':longitude - 1}
        topRight = '%(a)f,%(o)f' % {'a':latitude + 1, 'o':longitude + 1}

        # All knowers in this region
        knowers = Knower.all().filter('location > ', bottomLeft).filter('location > ', topRight).fetch(1024)
    
        # All knowledges in this region
        knowledges = Knowledge.all().filter('location > ', bottomLeft).filter('location > ', topRight)
        
        # All pains
        pains = knowledges.filter('info = ', 'p').fetch(1024)
        painCredits = dict()
        for k in pains: painCredits[k.account] = Knower.all().filter('account = ', k.account).fetch(1)[0].credits
        wet = 0
        for c in painCredits.values(): wet += c
        
        # All fines
        fines = knowledges.filter('info = ', 'f').fetch(1024)
        fineCredits = dict()
        for k in fines: fineCredits[k.account] = Knower.all().filter('account = ', k.account).fetch(1)[0].credits
        dry = 0
        for c in fineCredits.values(): dry += c
        
        # All unknowns
        unknownCredits = dict()
        for k in knowers:
            if not painCredits.has_key(k) and not fineCredits.has_key(k): unknownCredits[k.account] = k.credits
        unknown = 0
        for c in unknownCredits.values(): unknown += c * DECREMENT_OF_UNKNOWN
        
        self.response.out.write(wet / (wet + dry + unknown) * SELF_CONFIDENCE)
Esempio n. 2
0
    def get(self):
        account = users.get_current_user()
        if account == None:
            self.redirect(
                users.create_login_url(dest_url='/main',
                                       federated_identity='gmail.com'))
        else:
            if Knower.all().filter('account = ', account).count(1) == 0:
                Knower(credits=0, fines=0, pains=0).put()

            with open("main.html") as f:
                for line in f:
                    self.response.out.write(line)
Esempio n. 3
0
    def get(self):
        latitude = float(self.request.get('a'))
        longitude = float(self.request.get('o'))
        bottomLeft = '%(a)f,%(o)f' % {'a': latitude - 1, 'o': longitude - 1}
        topRight = '%(a)f,%(o)f' % {'a': latitude + 1, 'o': longitude + 1}

        # All knowers in this region
        knowers = Knower.all().filter('location > ', bottomLeft).filter(
            'location > ', topRight).fetch(1024)

        # All knowledges in this region
        knowledges = Knowledge.all().filter('location > ', bottomLeft).filter(
            'location > ', topRight)

        # All pains
        pains = knowledges.filter('info = ', 'p').fetch(1024)
        painCredits = dict()
        for k in pains:
            painCredits[k.account] = Knower.all().filter(
                'account = ', k.account).fetch(1)[0].credits
        wet = 0
        for c in painCredits.values():
            wet += c

        # All fines
        fines = knowledges.filter('info = ', 'f').fetch(1024)
        fineCredits = dict()
        for k in fines:
            fineCredits[k.account] = Knower.all().filter(
                'account = ', k.account).fetch(1)[0].credits
        dry = 0
        for c in fineCredits.values():
            dry += c

        # All unknowns
        unknownCredits = dict()
        for k in knowers:
            if not painCredits.has_key(k) and not fineCredits.has_key(k):
                unknownCredits[k.account] = k.credits
        unknown = 0
        for c in unknownCredits.values():
            unknown += c * DECREMENT_OF_UNKNOWN

        self.response.out.write(wet / (wet + dry + unknown) * SELF_CONFIDENCE)
Esempio n. 4
0
 def get(self):
     account = users.get_current_user()
     if account == None:
         self.redirect(users.create_login_url(dest_url='/main', federated_identity='gmail.com'))
     else:
         if Knower.all().filter('account = ', account).count(1) == 0:
             Knower(credits = 0, fines = 0, pains = 0).put()
             
         with open("main.html") as f:
             for line in f:
                 self.response.out.write(line)
Esempio n. 5
0
    def get(self):
        p = self.request.params.mixed()
        p['u'] = users.get_current_user()
        Knowledge(info=p['i'], location='%(a)s,%(o)s' % p).put()

        knower = Knower.all().filter('account = ', p['u']).fetch(1)[0]
        knower.location = '%(a)s,%(o)s' % p
        knower.credits += 1
        if p['i'] == 'p':
            knower.pains += 1
        else:
            knower.fines += 1
        knower.put()

        self.response.out.write('%(u)s reports %(i)s from %(a)s,%(o)s.' % p)
Esempio n. 6
0
 def get(self):
     p = self.request.params.mixed()
     p['u'] = users.get_current_user()
     Knowledge(info=p['i'], location='%(a)s,%(o)s' % p).put()
     
     knower = Knower.all().filter('account = ', p['u']).fetch(1)[0]
     knower.location = '%(a)s,%(o)s' % p
     knower.credits += 1
     if p['i'] == 'p':
         knower.pains += 1
     else:
         knower.fines += 1
     knower.put()
     
     self.response.out.write('%(u)s reports %(i)s from %(a)s,%(o)s.' % p)