Пример #1
0
def friends():
    projects = db.select_member_projects(current_user.id)
    friends = []
    ids = []
    for project in projects:
        
        users = db.select_project_members(project[0])
        for user in users:
            if user[0] != int(current_user.id):
                ids.append(user[0])
    
    
    for friend_id in ids:       
        friend = db.select_user(friend_id)
        friend = friend[0]
        image = b64encode(friend[4]).decode('"utf-8"')
        indiv = {
                 'first_name': friend[0],
                 'last_name': friend[1],
                 'image': image,
                 'id': friend_id
                }
        friends.append(indiv)

    return render_template('friends.html', friends=friends, title='Friends')
Пример #2
0
def handle_my_message_event(data):
    sender_id = current_user.id
    receiver_id = data['receiver']
    message = data['message']
    db.insert_direct_message(sender_id, receiver_id, message)
    sender = db.select_user(sender_id)[0]
    sender_name = sender[0]
    emit('update', {'display_name': sender_name, 'message': message}, broadcast=True)
Пример #3
0
def handle_my_custom_event(data):
    user_id = current_user.id
    project_id = data['project_id']
    comment = data['comment']
    db.insert_comments(user_id, project_id, comment)
    user = db.select_user(user_id)[0]
    name = user[0] + ' ' + user[1]
    comment = clean_html(comment)
    emit('update', {'name': name, 'project_id': project_id, 'comment': comment}, broadcast=True)
Пример #4
0
 def __init__(self, id):
     user = db.select_user(id)
     if user:
         user = user[0]
         self.id = id
         self.first_name = user[0]
         self.last_name = user[1]
         self.email = user[2]
         self.password = user[3]
         self.image = b64encode(user[4]).decode('"utf-8"')
Пример #5
0
 def logout(self, key):
     select_user = db.select_user(key=key)
     if not select_user['success']:
         return json.dumps({
             'success': 'false',
             'error_type': select_user['error_type']
         })
     delete_user_info = db.delete_user_info(key=key)
     if not delete_user_info['success']:
         return json.dumps({
             'success': 'false',
             'error_type': delete_user_info['error_type']
         })
     return json.dumps({'success': 'true'})
Пример #6
0
def project(project_id):
    data = db.select_project(project_id)
    if data:
        data = data[0]
        image = b64encode(data[3]).decode('"utf-8"')
        author = db.select_user(data[5])[0]
        project = {'title': data[0],
                    'description': data[1],
                    'type': data[2],
                    'image': image,
                    'count': data[4],
                    'id': project_id,
                    'author_name': author[0] + ' ' + author[1]
                    }
        form = CommentForm()
        comment_list = db.select_comment_project(project_id)
        comments = []
        for comment in comment_list:
            user = db.select_user(comment[0])[0]
            x = {'name': user[0] + ' ' + user[1], 'text': comment[1]}
            comments.append(x)
        members_raw = db.select_project_members(project_id)
        members = []
        for member in members_raw:
            member_id = member[0]
            info = db.select_user(member_id)
            info = info[0]
            indiv = {
                'id': member_id,
                'name': info[0] + ' ' + info[1],
                'image': b64encode(info[4]).decode('"utf-8"')
            }
            members.append(indiv)
        joined = len(members)
        return render_template('project.html', project=project, form=form, comments=comments, joined=joined, members=members, title=project.get('title'))
    return render_template('404.html'), 404
Пример #7
0
def dm(friend_id):
    user_id = current_user.id
    messages = []
    friend = db.select_user(friend_id)[0]
    first_name = friend[0]
    last_name = friend[1]
    full_name = first_name + ' ' + last_name
    messages_list = db.select_messages(current_user.id, friend_id)
    for message in messages_list:
        if message[0] == friend_id:
            indiv = {
                 'first_name': first_name,
                 'message': message[2]
                }
            messages.append(indiv)
        else:
            indiv = {
                 'first_name': current_user.first_name,
                 'message': message[2]
                }
            messages.append(indiv)
    messages.reverse
    form = MessageForm()
    return render_template('dm.html', receiver_id = friend_id, name = full_name, messages=messages, form=form, title='Direct Messages')
Пример #8
0
def get_yesterday_timestamp():
    yesterday = datetime.date.fromtimestamp(time.time() - 60 * 60 * 24)
    return time.mktime(yesterday.timetuple())


def get_timestamp(day):
    return time.mktime(datetime.datetime.strptime(day, "%Y-%m-%d").timetuple())


assert len(sys.argv) == 2, 'Usage : python step.py [YYYY-mm-dd]'
assert get_today_timestamp() > date_to_timestamp(
    sys.argv[1]), 'Input previous day'

day = sys.argv[1]

for user in db.select_user():  #time='2016-09-09' format or yesterday
    user_id = user['user_id']
    if day == 'yesterday':
        timestamp = get_yesterday_timestamp()
    else:
        timestamp = get_timestamp(day)
    print timestamp
    print timestamp + 24 * 60 * 60 - 60
    result = db.select_gps_fitbit(timestamp,
                                  timestamp + 24 * 60 * 60 - 60,
                                  user_id=user_id)
    x = list()
    y = list()
    if not result['success']:
        print result['error_type']
    else: