def get(self): user = users.get_current_user() userid = user.user_id() q1 = GoogleSLIds.all().filter("google_id =", userid) q2 = GoogleSLIds.all().filter("google_id =", userid) q3 = GoogleSLIds.all().filter("google_id =", userid) if q1.count() == 0: message = ''' You do not have any SL names linked to this acount. Enter a SL username to be verified. You will get an IM to complte the verifcation. <br /> '''+form self.response.out.write(head+message+end)#promt to add name to list else: q1.filter("verifed =", True) if not q1.count() == 0: message = "Verifed names:<br />" for x in q1: message += x.sl_name+"<br />" av = x.sl_key subdictown = {} subdictsecown = {} ownersubs = relations.getby_subj_type(av, 'owns') for sub in ownersubs: id = sub.obj_id if id not in subdictown: subdictown[id] = relations.key2name(id) else: #delete duplicates sub.delete() secownersubs = relations.getby_subj_type(av, 'secowns') for sub in secownersubs: id = sub.obj_id if id not in (subdictown or subdictsecown):#since you can be both an owner and a secowner, ignore those here already in the owner list subdictsecown[id] = relations.key2name(id) out = '' for sub in subdictown: out += '<a href="/map/?key=%s">%s</a> own <br />' % (sub, subdictown[sub]) for sub in subdictsecown: out += '<a href="/map/?key=%s">%s</a> secown <br />' % (sub, subdictsecown[sub]) message += out q2.filter("verifed =", False) if not q2.count() == 0: message += "You have the following names waiting to be verifed: <br />" for x in q2: message += x.sl_name+"<br />" message += form #at least one acount verifed self.response.out.write(head+message+end) else: message = "You have the following names waiting to be verifed: <br />" results = q2.fetch(10) for x in results: message += x.sl_name+"<br />" message += form self.response.out.write(head+message+end)#show the acocounts not verifed and promt or more
def get(self): key = self.request.path.split("/")[-1].split("?")[0] verify = GoogleSLIds.get(key) verify.verifed = True verify.put() logging.info('%s vefifed that %s can access their info' % (verify.sl_name, verify.google_email)) message = ''' You have verifed that %s is owned by %s. <br /> <a href="/webinterface/">click here to use the webinterface.</a> ''' % (verify.sl_name, verify.google_email) self.response.out.write(head+message+end)
import logging import datetime from model import GoogleSLIds from google.appengine.ext import db time = datetime.datetime.utcnow() time += datetime.timedelta(-1) query = GoogleSLIds.gql("WHERE verifed = :1 AND datetime <= :2", False, time) logging.info("%s verification tries were removed.", query.count()) db.delete(query.fetch(50))
def getownerlist(userid): ownerlist = memcache.get(userid + "ownerlist") if ownerlist is not None: sublist = memcache.get(userid + "subs").keys() checksubs = memcache.get_multi(sublist) for sub in checksubs: if checksubs[sub] is not None: memcache.delete_multi(sublist) ownerlist = getownerlist(userid) break return ownerlist else: q1 = GoogleSLIds.all().filter("google_id =", userid) q2 = GoogleSLIds.all().filter("google_id =", userid) q3 = GoogleSLIds.all().filter("google_id =", userid) if not q1.count() == 0: q1.filter("verifed =", True) if not q1.count() == 0: ownerlist = 'Verifed names:<br /><table border="1">' subdict = {} subdictown = {} subdictsecown = {} for x in q1: ownerlist += '<tr><td colspan="2">' + x.sl_name + "</td></tr>" av = x.sl_key subdictownloc = {} subdictsecownloc = {} ownersubs = relations.getby_subj_type(av, 'owns') for sub in ownersubs: id = sub.obj_id if id not in subdictownloc: subdictownloc[id] = relations.key2name(id) else: #delete duplicates sub.delete() secownersubs = relations.getby_subj_type(av, 'secowns') for sub in secownersubs: id = sub.obj_id if id not in ( subdictownloc or subdictsecownloc ): #since you can be both an owner and a secowner, ignore those here already in the owner list subdictsecownloc[id] = relations.key2name(id) out = '' subdictown.update(subdictownloc) subdictsecown.update(subdictsecownloc) subsortedown = sorted(subdictownloc.items(), key=itemgetter(1)) subsortedsecown = sorted(subdictsecownloc.items(), key=itemgetter(1)) for sub in subsortedown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Owner</td></tr>' % ( sub[0], sub[1]) for sub in subsortedsecown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Sec. Owner</td></tr>' % ( sub[0], sub[1]) ownerlist += out ownerlist += '</table>' q2.filter("verifed =", False) if not q2.count() == 0: ownerlist += "You have the following names waiting to be verifed: <br />" for x in q2: ownerlist += x.sl_name + "<br />" ownerlist += form subdict.update(subdictown) subdict.update(subdictsecown) memcache.set(userid + "ownerlist", ownerlist, 600) memcache.set(userid + "subs", subdict, 600) memcache.set(userid + "ownsubs", subdictown, 600) memcache.set(userid + "secownsubs", subdictsecown, 600) return ownerlist else: logging.warning( '%s is trying to get %s page but does not have any verified users' % (useremail, param2)) return "error" else: logging.warning( '%s is trying to get %s page but does not have any verified or unvierified users' % (useremail, param2)) return "error"
def getownerlist(userid): ownerlist = memcache.get(userid+"ownerlist") if ownerlist is not None: sublist = memcache.get(userid+"subs").keys() checksubs = memcache.get_multi(sublist) for sub in checksubs: if checksubs[sub] is not None: memcache.delete_multi(sublist) ownerlist = getownerlist(userid) break return ownerlist else: q1 = GoogleSLIds.all().filter("google_id =", userid) q2 = GoogleSLIds.all().filter("google_id =", userid) q3 = GoogleSLIds.all().filter("google_id =", userid) if not q1.count() == 0: q1.filter("verifed =", True) if not q1.count() == 0: ownerlist = 'Verifed names:<br /><table border="1">' subdict = {} subdictown = {} subdictsecown = {} for x in q1: ownerlist += '<tr><td colspan="2">'+x.sl_name+"</td></tr>" av = x.sl_key subdictownloc = {} subdictsecownloc = {} ownersubs = relations.getby_subj_type(av, 'owns') for sub in ownersubs: id = sub.obj_id if id not in subdictownloc: subdictownloc[id] = relations.key2name(id) else: #delete duplicates sub.delete() secownersubs = relations.getby_subj_type(av, 'secowns') for sub in secownersubs: id = sub.obj_id if id not in (subdictownloc or subdictsecownloc):#since you can be both an owner and a secowner, ignore those here already in the owner list subdictsecownloc[id] = relations.key2name(id) out = '' subdictown.update(subdictownloc) subdictsecown.update(subdictsecownloc) subsortedown = sorted(subdictownloc.items(), key=itemgetter(1)) subsortedsecown = sorted(subdictsecownloc.items(), key=itemgetter(1)) for sub in subsortedown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Owner</td></tr>' % (sub[0], sub[1]) for sub in subsortedsecown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Sec. Owner</td></tr>' % (sub[0], sub[1]) ownerlist += out ownerlist +='</table>' q2.filter("verifed =", False) if not q2.count() == 0: ownerlist += "You have the following names waiting to be verifed: <br />" for x in q2: ownerlist += x.sl_name+"<br />" ownerlist += form subdict.update(subdictown) subdict.update(subdictsecown) memcache.set(userid+"ownerlist", ownerlist, 600) memcache.set(userid+"subs", subdict, 600) memcache.set(userid+"ownsubs", subdictown, 600) memcache.set(userid+"secownsubs", subdictsecown, 600) return ownerlist else: logging.warning('%s is trying to get %s page but does not have any verified users' % (useremail, param2)) return "error" else: logging.warning('%s is trying to get %s page but does not have any verified or unvierified users' % (useremail, param2)) return "error"
def post(self): user = users.get_current_user() a = GoogleSLIds().gql("WHERE google_id = :1 AND sl_name = :2", user.user_id(), self.request.get("username")).get() if (a is None): a = GoogleSLIds() if not (a.verifed): a.google_id = user.user_id() a.google_email = user.email() a.sl_name = self.request.get("username") a.sl_key = relations.name2key(a.sl_name) a.datetime = datetime.datetime.utcnow() a.vericode = GenVeriCode() if not a.sl_key == None: #notify in world object a.sentim = False logging.info('%s asked to be linked to %s and was found in the database' % (a.google_email, a.sl_name)) else: a.sentim = True #cannot send an IM so mark as sent. logging.info('%s asked to be linked to %s but was not found in the database.' % (a.google_email, a.sl_name)) a.put() message = ''' If we have records of '''+a.sl_name+''' then a IM has been sent. <br /> Enter a SL username to be verified. You will get an IM to complete the verification. <br /> '''+form else: message = ''' You have already verified '''+a.sl_name+'''. <br /> Enter a SL username to be verified. You will get an IM to complete the verification. <br /> '''+form self.response.out.write(head+message+end)