コード例 #1
0
ファイル: projects.py プロジェクト: aiyappaganesh/underdogs
 def get(self):
     current_time = time.time()
     time_day_back = current_time - (timedelta(seconds=one_day_in_seconds).total_seconds())
     until = self['until'] if self['until'] else str(int(current_time))
     since = self['since'] if self['since'] else str(int(time_day_back))
     params = {'key':typeform_key,
               'completed':True,
               'since':since,
               'until':until}
     url = typeform_url + '?' + urllib.urlencode(params)
     resp = urlfetch.fetch(url, deadline=60)
     result = json.loads(resp.content)
     if 200 <= result['http_status'] < 300:
         for response in result['responses']:
             project = {}
             for question in result['questions']:
                 q = question['question']
                 if q in self.questions_list:
                     qid = str(question['id'])
                     project[self.questions_list[q]] = response['answers'][qid] if qid in response['answers'] else None
             if project:
                 p = Project()
                 p.title = project['title']
                 p.description = project['description']
                 p.end_date = datetime.strptime(str(project['end_day'])+'-'+str(project['end_month'])+'-'+str(project['end_year']), "%d-%m-%Y").date() if project['end_day'] and project['end_month'] and project['end_year'] else None
                 p.category = project['category']
                 p.put() #logging.info(p)
コード例 #2
0
ファイル: projects.py プロジェクト: aiyappaganesh/underdogs
 def create_project(self, image_key):
     p = Project()
     p.title = self['project_title']
     p.description = self['description']
     if self['project_skills']:
         p.skills = self['project_skills'].split(',') if self['project_skills'] else []
     p.end_date = datetime.strptime(str(self['project_end_date']), "%Y-%m-%d").date()
     p.bid = float(self['project_bid'])
     if self['category']:
         p.category = self['category']
     p.image = image_key
     p.put()
     return p
コード例 #3
0
 def create_project(self, image_key):
     p = Project()
     p.title = self['project_title']
     p.description = self['description']
     if self['project_skills']:
         p.skills = self['project_skills'].split(
             ',') if self['project_skills'] else []
     p.end_date = datetime.strptime(str(self['project_end_date']),
                                    "%Y-%m-%d").date()
     p.bid = float(self['project_bid'])
     if self['category']:
         p.category = self['category']
     p.image = image_key
     p.put()
     return p
コード例 #4
0
 def get(self):
     current_time = time.time()
     time_day_back = current_time - (timedelta(
         seconds=one_day_in_seconds).total_seconds())
     until = self['until'] if self['until'] else str(int(current_time))
     since = self['since'] if self['since'] else str(int(time_day_back))
     params = {
         'key': typeform_key,
         'completed': True,
         'since': since,
         'until': until
     }
     url = typeform_url + '?' + urllib.urlencode(params)
     resp = urlfetch.fetch(url, deadline=60)
     result = json.loads(resp.content)
     if 200 <= result['http_status'] < 300:
         for response in result['responses']:
             project = {}
             for question in result['questions']:
                 q = question['question']
                 if q in self.questions_list:
                     qid = str(question['id'])
                     project[self.questions_list[q]] = response['answers'][
                         qid] if qid in response['answers'] else None
             if project:
                 p = Project()
                 p.title = project['title']
                 p.description = project['description']
                 p.end_date = datetime.strptime(
                     str(project['end_day']) + '-' +
                     str(project['end_month']) + '-' +
                     str(project['end_year']),
                     "%d-%m-%Y").date() if project['end_day'] and project[
                         'end_month'] and project['end_year'] else None
                 p.category = project['category']
                 p.put()  #logging.info(p)