示例#1
0
 def get(self):
     Login = users.get_current_user()
     q = user.gql('WHERE Email=\''+Login.email()+'\'')
     if q.count() == 0:
         u= user(FirstName = "",
             LastName = "",
             Email = Login.email(),
             Image = 'http://nfs-tr.com/images/avatars/003.png',
             Headline = 'Awesomness',
             TimeCredit = random.randint(0,10),
             Involvement = random.randint(0,1000),
             Awards = []
             )
         u.put()
       
       
     self.response.headers['Content-Type'] = 'text/plain'
     self.response.out.write('Hello, ' + Login.email())
示例#2
0
    def get(self):
        query = user.all(keys_only=True)
        entries =query.fetch(1000)
        db.delete(entries)
        query = category.all(keys_only=True)
        entries =query.fetch(1000)
        db.delete(entries)
        query = service.all(keys_only=True)
        entries =query.fetch(1000)
        db.delete(entries)
        query = skill.all(keys_only=True)
        entries =query.fetch(1000)
        db.delete(entries)        
        query = skillstouser.all(keys_only=True)
        entries =query.fetch(1000)
        db.delete(entries)
        query = comment.all(keys_only=True)
        entries =query.fetch(1000)
        db.delete(entries)

        # Store category & Skills
        for Category in ConfigCategories:
          c = category(Name=Category)
          c.put()
          for Skill in ConfigCategories[Category]:
            skill(Name=Skill,Category=c).put()

        # Define profiles + link to Skills
        for User in ConfigProfils:
          u =  user(FirstName = User['FirstName'],
            LastName = User['LastName'],
            Email = User['Email'],
            Image = User['Image'],
            Headline = User['Headline'],
            TimeCredit = User['TimeCredit'],
            Involvement = User['Involvement'],
            Address = User['Address'],
            Awards = []
            )
          u.put()       

          for Skill in User["Skills"]:
            s = skill.gql("WHERE Name='"+Skill+"'").run().next() 
            skillstouser(Skill=s,User=u).put()  

        # Friends
        for User in ConfigProfils:
          if User.has_key('Friends'):
              for FriendEmail in User['Friends']:
                FriendUser = user.gql("WHERE Email='%s'" % FriendEmail).run().next()
                u = user.gql("WHERE Email='%s'" % User['Email']).run().next()
                u.Friends.append(FriendUser.key())
              u.put() 

        #Service
        for Service in ConfigServices:
          ## all FK needed
          User = user.gql("WHERE Email='"+Service["Requester"]+"'").run().next()
          Skill = skill.gql("WHERE Name='"+Service["Skill"]+"'").run().next()

          ser = service(
            Title =  Service['Title'],
            Description = Service['Description'],
            Requester = User ,
            TimeNeeded = Service['TimeNeeded'],
            Skill = Skill,
            Geoloc = Service['Geoloc'],
            StartDate = datetime.strptime(Service['StartDate'],'%Y-%M-%d'),
            EndDate = datetime.strptime(Service['EndDate'],'%Y-%M-%d'),
            Comments = []
          )
          if Service.has_key("Responder"):
            Responder = user.gql("WHERE Email='"+Service["Responder"]+"'").run().next()
            ser.Responder = Responder
          if Service.has_key('Comments'):
            for C in Service["Comments"]:
              User = user.gql("WHERE Email='"+C["Owner"]+"'").run().next()
              c  = comment(
                Owner = User,
                Comment = C["Comment"]
              )
              c.put()
              ser.Comments.append(c.key().id())
          ser.put()

        # Service Applicants
        for SAppl in ServiceApplicants:
            # FK
            Service = service.gql("WHERE Title='%s'" % SAppl['Service']).run().next()
            Applicant = user.gql("WHERE Email='%s'" % SAppl['Applicant']).run().next()
            serviceapplicants(
                Date = datetime.strptime(SAppl['Date'], '%Y-%M-%d'),
                Service = Service,
                Applicant = Applicant
            ).put()

        self.response.headers['Content-Type'] = 'text/html; charset=UTF-8'
        self.response.write("Done")