def avatar(): '''CUSTOMIZATION PAGE/STORE FOR YOUR AVATAR''' if 'username' not in session: return redirect(url_for('index')) username = session['username'] eyes_price = { 'eyes1': 0, 'eyes10': 1250, 'eyes2': 1250, 'eyes3': 1250, 'eyes4': 1250, 'eyes6': 2500, 'eyes9': 2500, 'eyes5': 5000, 'eyes7': 5000 } noses_price = { 'nose2': 0, 'nose3': 1250, 'nose4': 1250, 'nose5': 1250, 'nose6': 2500, 'nose7': 2500, 'nose8': 5000, 'nose9': 5000 } mouths_price = { 'mouth1': 0, 'mouth3': 1250, 'mouth5': 1250, 'mouth6': 1250, 'mouth7': 2500, 'mouth9': 2500, 'mouth10': 5000, 'mouth11': 5000 } colors_price = {'FF3333':0, 'FF3333':1250, '4DA6FF':1250, '66FF99':1250,\ 'FFA366':1250, 'BF80FF': 2500, 'C55EB1':2500,\ 'FFFFFF':5000, '5A6358': 5000, '000000': 5000} owned_eyes = db.get_value(username, 'eyes').split(',') owned_noses = db.get_value(username, 'noses').split(',') owned_mouths = db.get_value(username, 'mouths').split(',') owned_colors = db.get_value(username, 'color').split(',') eyes = db.get_current(username, 'eyes') nose = db.get_current(username, 'noses') mouth = db.get_current(username, 'mouths') color = db.get_current(username, 'color') url = api.customAvatarLink(eyes, nose, mouth, color) print(url) money = db.getUserBigcoin(username) return render_template('avatar.html', username = username, url = url, eyes = eyes_price, noses = noses_price, mouths = mouths_price, colors = colors_price,\ bigcoin = money, owned_eyes = owned_eyes, owned_noses = owned_noses, owned_mouths = owned_mouths, owned_colors = owned_colors)
def get_avatar_json(): '''RETRIEVES AND RETURNS CURRENT USER'S AVATAR JSON DATA ''' username = session['username'] d = {} d['eyes'] = db.get_current(username, 'eyes') d['nose'] = db.get_current(username, 'noses') d['mouth'] = db.get_current(username, 'mouths') d['color'] = db.get_current(username, 'color') return json.dumps(d)
def get_avatar_from_get(): '''GETS AVATAR FORM''' username = request.args['username'] eyes = db.get_current(username, 'eyes') nose = db.get_current(username, 'noses') mouth = db.get_current(username, 'mouths') color = db.get_current(username, 'color') url = api.customAvatarLink(eyes, nose, mouth, color) print('GETTING AVATAR\n\tUsername: {}\n\tURL: {}\n'.format(username, url)) print(url) return url
def get_avatar(): '''RETRIEVES AND RETURNS CURRENT USER'S AVATAR URL''' username = session['username'] eyes = db.get_current(username, 'eyes') nose = db.get_current(username, 'noses') mouth = db.get_current(username, 'mouths') color = db.get_current(username, 'color') url = api.customAvatarLink(eyes, nose, mouth, color) print('GETTING AVATAR\n\tUsername: {}\n\tURL: {}\n'.format(username, url)) print(url) return url
def profile(): '''PROFILE PAGE OF USER''' if 'username' not in session: return redirect(url_for('index')) username = session['username'] eyes = db.get_current(username, 'eyes') nose = db.get_current(username, 'noses') mouth = db.get_current(username, 'mouths') color = db.get_current(username, 'color') url = api.customAvatarLink(eyes, nose, mouth, color) money = db.getUserBigcoin(username) return render_template('profile.html', username=username, url=url, bigcoin=money)
def view_profile(project_name, p_id): '''PROFILE PAGES OF OTHER USERS''' if 'username' not in session: return redirect(url_for('index')) username = pqs('user='******'username'])['user'][0] print('username', username) user_info = db.get_info(username) print(user_info) eyes = db.get_current(username, 'eyes') nose = db.get_current(username, 'noses') mouth = db.get_current(username, 'mouths') color = db.get_current(username, 'color') url = api.customAvatarLink(eyes, nose, mouth, color) my_eyes = db.get_current(session['username'], 'eyes') my_nose = db.get_current(session['username'], 'noses') my_mouth = db.get_current(session['username'], 'mouths') my_color = db.get_current(session['username'], 'color') my_url = api.customAvatarLink(my_eyes, my_nose, my_mouth, my_color) print(url) money = db.getUserBigcoin(session['username']) return render_template('view_profile.html', username=username, url=url, my_url=my_url, user_info=user_info, project_name=project_name, p_id=p_id, bigcoin=money)
def get_dashboard(): '''PROCESSES AND RENDERS THE DASHBOARD AND ITS COMPONENTS FOR DISPLAY''' username = session['username'] pid = request.args['pid'] project_name = db.get_project(pid) print("\n\n\nPID: {}\n\n\n".format(pid)) messages = sorted(db.get_t_msgs(pid), key=lambda x: x[3], reverse=True) print("\n\n\nPRIVATE MESSAGES:\n{}\n\n".format(messages)) tasks = sorted(db.get_tasks_pid(pid), key=lambda x: x[2], reverse=True) print('\n\n\nTASKS\n') for i in tasks: print('\t{}\n'.format(i)) print('\n\n') if len(tasks) > 0: # for status bar # [notstarted, working, done] statusList = [0, 0, 0] for task in tasks: statusList[task[4]] += 1 notstarted = (statusList[0] * 100) // len(tasks) working = (statusList[1] * 100) // len(tasks) done = 100 - (notstarted + working) else: done = notstarted = working = 'no tasks' # for team members tab thing teammates = db.get_teammates(pid) print('teammates', teammates) teammate_tasks = {} print('\n\n\nTEAMMATES:\n{}\n\n\n\n'.format(teammates)) for user in teammates: user = user[0] teammate_tasks[user] = sorted(db.get_tasks_username(pid, user), key=lambda x: x[2], reverse=True) print('USER: {}\nTASKS: {}\n\n'.format(user, teammate_tasks[user])) teammate_pfp_urls = {} for mate in teammates: name = mate[0] eyes = db.get_current(name, 'eyes') nose = db.get_current(name, 'noses') mouth = db.get_current(name, 'mouths') color = db.get_current(name, 'color') teammate_pfp_urls[name] = api.customAvatarLink(eyes, nose, mouth, color) print('teammate_pfp_urls', teammate_pfp_urls) print("TEAMMATETASKS.ITEMS\n\n") for key, val in teammate_tasks.items(): print("KEY: {}\nVAL: {}\n\n".format(key, val)) print("\n\nEND") raw_user_tasks = sorted(db.get_tasks_username(pid, username), key=lambda x: x[2], reverse=True) user_tasks = [] for i in raw_user_tasks: if i[4] == 1: user_tasks.append(i) return render_template('dashboardSNIPPET.html', messages=messages[:5], done=str(done), working=str(working), notstarted=str(notstarted), user_tasks=user_tasks, teammates=teammates, username=username, teammate_pfp_urls=teammate_pfp_urls, p_id=pid, project_name=project_name, teammate_tasks=teammate_tasks)
def get_snippet(): '''PULLS UP VARIOUS PIECES OF HTML FOR VARIOUS PARTS OF SITE DEPENDING ON REQUESTED SNIPPET (INFO SENT VIA ARGUMENT)(Joan)''' snippet = request.args['snippet'] print('Getting snippet: {}'.format(snippet)) if snippet == 'projectList' and 'username' in session: projectDict = db.get_projects(session['username']) print('Project dict: {}'.format(projectDict)) return render_template('{}SNIPPET.html'.format(snippet), projectDict=projectDict) if snippet == 'privateInbox' and 'username' in session: username = session['username'] pid = request.args['pid'] private_messages = db.get_p_msgs(pid, username) teammates = db.get_teammates(pid) print(teammates) print('private messages', private_messages) msg_list = [] for tup in private_messages: print('\ntup', tup) name = tup[1] eyes = db.get_current(name, 'eyes') nose = db.get_current(name, 'noses') mouth = db.get_current(name, 'mouths') color = db.get_current(name, 'color') url = api.customAvatarLink(eyes, nose, mouth, color) msg_list.append([tup, url]) print('\n\n\nMESSAGE LIST\n\t{}\n\n\n'.format(msg_list)) return render_template('{}SNIPPET.html'.format(snippet), private_messages=msg_list, teammates=teammates, username=username, p_id=pid, project_name=db.get_project(pid)) if snippet == 'tasks' and 'username' in session: pid = request.args['pid'] tasks = sorted(db.get_tasks_username(pid, session['username']), key=lambda x: x[2], reverse=True) unstarted = [] workingon = [] done = [] for task in tasks: if task[4] == 0: unstarted.append(task) elif task[4] == 1: workingon.append(task) elif task[4] == 2: done.append(task) task_dict = { 'unstarted': unstarted, 'workingon': workingon, 'done': done } print('TASK_DICT', task_dict) return render_template('{}SNIPPET.html'.format(snippet), task_dict=task_dict) if snippet == 'teamInbox' and 'username' in session: pid = request.args['pid'] team_messages = db.get_t_msgs(pid)[::-1] print("TEAM MESSAGES:\n{}".format(team_messages)) teammates = db.get_teammates(pid) teammate_pfp_urls = {} for mate in teammates: name = mate[0] eyes = db.get_current(name, 'eyes') nose = db.get_current(name, 'noses') mouth = db.get_current(name, 'mouths') color = db.get_current(name, 'color') teammate_pfp_urls[name] = api.customAvatarLink( eyes, nose, mouth, color) print('teammate_pfp_urls', teammate_pfp_urls) return render_template('{}SNIPPET.html'.format(snippet), pid=pid, project_name=db.get_project(pid), team_messages=team_messages, teammate_pfp_urls=teammate_pfp_urls) return render_template('{}SNIPPET.html'.format(snippet))