def _doProfile(email, save_request=None): """Get user Profile and return to user, possibly updating it first.""" print("Here Bitch") prof = _getProfileFromEmail(email) print("Profile is", prof) if (prof.email == ''): key = None else: key = prof.key print key flag = 0 college = CollegeDb() print("Save Request", save_request) if save_request: print("Entered here") pf = ProfileMiniForm() for field in pf.all_fields(): #collegeLocation=getattr(save_request,'collegeLocation') #print collegeLocation,"is location" if field.name == 'followsNames' or field.name == 'follows' or field.name == 'clubsJoined' or field.name == 'club_names': continue if hasattr(save_request, field.name): val = getattr(save_request, field.name) if field.name is 'collegeId': #college=CollegeDb.query(CollegeDb.name==val,CollegeDb.location==collegeLocation).fetch() collegeId = ndb.Key('CollegeDb', int(val)) college = collegeId.get() print("coll", collegeId) pylist = [x.key for x in CollegeDb.query()] print pylist if (collegeId in pylist): flag = 1 setattr(prof, 'collegeId', collegeId) else: flag = 0 else: setattr(prof, field.name, val) if flag == 1: k1 = prof.put() if (key == None): length = college.student_count if (length == None): length = 0 length = length + 1 college.student_count = length college.put() print "Inserted" print k1 return _copyProfileToForm(prof)
def createCollege(requestentity=None): newCollege = CollegeDb() query = CollegeDb.query() print "The data got on querying is " , query , " type is ", type(query), "\n" count = 0 names = [] location = [] """profile = Profile(name = 'RJJ', email = '*****@*****.**', phone = '7760532293', password = '******', pid = '1234', isAlumni='N', collegeId= 'NIoTK') profile_key = profile.put() """ for records in query: print"The name of the college is ", records.name , " and location is " , records.location names.append(records.name) location.append(records.location) count += 1 #print "\n" print "count is, " , count collegeName = "" if requestentity: for field in ('name','abbreviation','location','studentSup','alumniSup','email'): val = getattr(requestentity, field) if field == "name": collegeName = getattr(requestentity, field).strip() if val: val = val.strip() print("Value is",val) if field == 'studentSup': setattr(newCollege, 'student_sup', str(val)) elif field == 'alumniSup': setattr(newCollege, 'alumni_sup', str(val)) else: setattr(newCollege, field, str(val)) #Now setting the attributes not recieved from the front-end. setattr(newCollege, 'student_count', 0) setattr(newCollege, 'group_count', 0) newlist = [] setattr(newCollege, 'group_list', newlist) setattr(newCollege,'sup_emailId',requestentity.email) # Making CollegeId newString = "" newString = collegeName[0] for x in xrange(len(collegeName)): if(collegeName[x]==' '): newString+=collegeName[x+1] setattr(newCollege, 'collegeId', newString) print(newCollege) flag = 0 for var in xrange(count): if(newCollege.name==names[var] and newCollege.location==location[var]): flag=1 if(flag): print "Sorry already existing record" else: print "Unique" email = getattr(requestentity, "email") phone = getattr(requestentity, "phone") if(getattr(requestentity, "studentSup")==None): isAlumni = "Yes" person_name = getattr(requestentity, "alumniSup") else: isAlumni = "No" person_name = getattr(requestentity, "studentSup") collegeId = newCollege.put() profile = Profile(name = person_name , email = email, phone = phone, isAlumni=isAlumni, collegeId= collegeId) profile.superadmin.append(collegeId) key1 = profile.put() newCollege.student_count = 1 newCollege.put() return newCollege
def _doProfile(email,save_request=None): """Get user Profile and return to user, possibly updating it first.""" print ("Here Bitch") prof = _getProfileFromEmail(email) print ("Profile is",prof) if(prof.email == ''): key = None else: key = prof.key print key flag=0 college = CollegeDb() print ("Save Request",save_request) if save_request: print ("Entered here") pf = ProfileMiniForm() for field in pf.all_fields(): #collegeLocation=getattr(save_request,'collegeLocation') #print collegeLocation,"is location" if field.name=='followsNames' or field.name=='follows' or field.name=='clubsJoined' or field.name=='club_names': continue if hasattr(save_request, field.name): val = getattr(save_request, field.name) if field.name is 'collegeId': #college=CollegeDb.query(CollegeDb.name==val,CollegeDb.location==collegeLocation).fetch() collegeId = ndb.Key('CollegeDb',int(val)) college = collegeId.get() print ("coll",collegeId) pylist = [x.key for x in CollegeDb.query()] print pylist if(collegeId in pylist): flag = 1 setattr(prof,'collegeId',collegeId) else: flag = 0 else: setattr(prof,field.name,val) if flag==1: k1 = prof.put() if (key==None): length = college.student_count if(length == None): length = 0 length = length + 1 college.student_count = length college.put() print "Inserted" print k1 return _copyProfileToForm(prof)
def createCollege(requestentity=None): newCollege = CollegeDb() query = CollegeDb.query() print "The data got on querying is ", query, " type is ", type(query), "\n" count = 0 names = [] location = [] """profile = Profile(name = 'RJJ', email = '*****@*****.**', phone = '7760532293', password = '******', pid = '1234', isAlumni='N', collegeId= 'NIoTK') profile_key = profile.put() """ for records in query: print "The name of the college is ", records.name, " and location is ", records.location names.append(records.name) location.append(records.location) count += 1 #print "\n" print "count is, ", count collegeName = "" if requestentity: for field in ('name', 'abbreviation', 'location', 'studentSup', 'alumniSup', 'email'): val = getattr(requestentity, field) if field == "name": collegeName = getattr(requestentity, field).strip() if val: val = val.strip() print("Value is", val) if field == 'studentSup': setattr(newCollege, 'student_sup', str(val)) elif field == 'alumniSup': setattr(newCollege, 'alumni_sup', str(val)) else: setattr(newCollege, field, str(val)) #Now setting the attributes not recieved from the front-end. setattr(newCollege, 'student_count', 0) setattr(newCollege, 'group_count', 0) newlist = [] setattr(newCollege, 'group_list', newlist) setattr(newCollege, 'sup_emailId', requestentity.email) # Making CollegeId newString = "" newString = collegeName[0] for x in xrange(len(collegeName)): if (collegeName[x] == ' '): newString += collegeName[x + 1] setattr(newCollege, 'collegeId', newString) print(newCollege) flag = 0 for var in xrange(count): if (newCollege.name == names[var] and newCollege.location == location[var]): flag = 1 if (flag): print "Sorry already existing record" else: print "Unique" email = getattr(requestentity, "email") phone = getattr(requestentity, "phone") if (getattr(requestentity, "studentSup") == None): isAlumni = "Yes" person_name = getattr(requestentity, "alumniSup") else: isAlumni = "No" person_name = getattr(requestentity, "studentSup") collegeId = newCollege.put() profile = Profile(name=person_name, email=email, phone=phone, isAlumni=isAlumni, collegeId=collegeId) profile.superadmin.append(collegeId) key1 = profile.put() newCollege.student_count = 1 newCollege.put() return newCollege