예제 #1
0
def save_schedule():
    myEmail = utils.get_email_from_token(request.args.get('token'))
    times = request.get_json().get('schedule')
    params = {'where':json.dumps({'member_email': myEmail})}
    schedule = ParseDriver.make_parse_get_request('/1/classes/Commitments', params)['results']
    s = {'member_email': myEmail, 'commitments': times}
    print 'schedule was '+str(s)
    if len(schedule) == 0:
        ParseDriver.make_parse_post_request('/1/classes/Commitments', s)
    else:
        sid = schedule[0].get('objectId')
        ParseDriver.make_parse_put_request('/1/classes/Commitments/'+sid, s)
    return 'ok'
예제 #2
0
def save_golink():
     myEmail = utils.get_email_from_token(request.args.get('token'))
     golink = request.get_json()
     golink_id = golink.get('objectId')
     golink['member_email'] = myEmail
     permissions = golink.get('permissions')
     if permissions == None or permissions == '':
         golink['permissions'] = 'Anyone'
     if golink_id == None or golink_id == '':
         print 'creating a new golink'
         ParseDriver.make_parse_post_request('/1/classes/ParseGoLink', golink)
     else:
         print 'editing an existing golink'
         ParseDriver.make_parse_put_request('/1/classes/ParseGoLink/'+golink_id, golink)
     return 'ok'
예제 #3
0
def save_blogpost():
     myEmail =utils.get_email_from_token(request.args.get('token')) 
     post = request.get_json()
     post['last_editor'] = myEmail
     # date = datetime.datetime.utcnow().strftime('%Y-%m-%dT%M:%S.000Z')
     # post['timestamp'] = {'__type': 'Date', 'iso': date}
     objectId = post.get('objectId')
     if objectId != None and objectId != '':
          print 'this is an existing post'
          url = '/1/classes/BlogPost/'+objectId
          ParseDriver.make_parse_put_request(url, post)
     else: 
          print 'this is a new post'
          post['author'] = myEmail
          print post
          resp = ParseDriver.make_parse_post_request('/1/classes/BlogPost', post)
          print resp
     return 'ok'
예제 #4
0
def record_attendance():
     form = request.get_json()
     myEmail = utils.get_email_from_token(request.args.get('token'))
     event_id = form.get('event_id')
     email = form.get('email')
     params = {'where': json.dumps({'event_id': event_id, 'member_email': email})}
     ems = ParseDriver.make_parse_get_request('/1/classes/ParseEventMember', params)['results']
     myPosition = utils.get_position_from_email(myEmail)
     if myPosition == 'exec':
          myPosition = 'chair'
     if len(ems) == 0:
          print 'there are no ems that match'
          data = {'event_id': event_id, 'member_email': email, 'type': myPosition}
          ParseDriver.make_parse_post_request('/1/classes/ParseEventMember', data)
     else:
          print 'there are matching ems ('+str(len(ems))+')'
          em = ems[0]
          url = '/1/classes/ParseEventMember/'+em['objectId']
          data = {'type':myPosition}
          ParseDriver.make_parse_put_request(url,  data)

     return 'ok'