|
9 | 9 | import tasklists |
10 | 10 | from task_database import (get_taskCurrent, generate_task, complete_task, get_task_progress, |
11 | 11 | get_task_lists, manual_complete_tasks, manual_revert_tasks, |
12 | | - uncomplete_all_tasks, lms_status_change, |
| 12 | + uncomplete_all_tasks, lms_status_change, update_imported_tasks, |
13 | 13 | official_status_change, username_change, official_icon, unofficial_icon, get_taskCurrent_tier, generate_task_for_tier, |
14 | 14 | complete_task_unofficial_tier, get_user, get_leaderboard) |
15 | 15 | import send_grid_email |
16 | 16 | from rank_check import get_collection_log, check_collection_log |
17 | | -from templesync import check_logs, read_json_file |
| 17 | +from templesync import check_logs, read_json_file, import_logs |
18 | 18 |
|
19 | 19 | app = Flask(__name__) |
20 | 20 |
|
@@ -446,34 +446,39 @@ def dashboard(): |
446 | 446 | def collection_log_check(): |
447 | 447 | form_data = request.form |
448 | 448 | rs_username = form_data['username'] |
449 | | - easy_check = check_logs(rs_username, read_json_file('tasks/easy.json')) |
450 | | - medium_check = check_logs(rs_username, read_json_file('tasks/medium.json')) |
451 | | - hard_check = check_logs(rs_username, read_json_file('tasks/hard.json')) |
452 | | - elite_check = check_logs(rs_username, read_json_file('tasks/elite.json')) |
| 449 | + easy_check = check_logs(rs_username, read_json_file('tasks/easy.json'), 'check') |
| 450 | + medium_check = check_logs(rs_username, read_json_file('tasks/medium.json'), 'check') |
| 451 | + hard_check = check_logs(rs_username, read_json_file('tasks/hard.json'), 'check') |
| 452 | + elite_check = check_logs(rs_username, read_json_file('tasks/elite.json'),'check') |
453 | 453 |
|
454 | 454 | return render_template('collection_log_check.html', |
455 | 455 | rs_username = rs_username, |
456 | 456 | easy_check = easy_check, |
457 | 457 | medium_check = medium_check, |
458 | 458 | hard_check = hard_check, |
459 | 459 | elite_check= elite_check) |
460 | | - log_data = get_collection_log(rs_username) |
461 | | - if log_data[0] == 200: |
462 | | - easy_check = check_collection_log(tasklists.easy, log_data[1]) |
463 | | - medium_check = check_collection_log(tasklists.medium, log_data[1]) |
464 | | - hard_check = check_collection_log(tasklists.hard, log_data[1]) |
465 | | - elite_check = check_collection_log(tasklists.elite, log_data[1]) |
466 | | - |
467 | | - return render_template('collection_log_check.html', |
468 | | - rs_username = rs_username, |
469 | | - easy_check= easy_check, |
470 | | - medium_check= medium_check, |
471 | | - hard_check = hard_check, |
472 | | - elite_check = elite_check |
473 | | - ) |
474 | | - else: |
475 | | - print(log_data) |
476 | | - return render_template('collection_log_check_error.html', rs_username=rs_username, error=log_data[1]) |
| 460 | + |
| 461 | +@app.route('/collectionlog_import/', methods = ['POST']) |
| 462 | +@login_required |
| 463 | +def collection_log_import(): |
| 464 | + form_data = request.form |
| 465 | + rs_username = form_data['username'] |
| 466 | + easy_import = check_logs('Gerni Task', read_json_file('tasks/easy.json'), 'import') |
| 467 | + medium_import = check_logs('Gerni Task', read_json_file('tasks/medium.json'), 'import') |
| 468 | + hard_import = check_logs('Gerni Task', read_json_file('tasks/hard.json'), 'import') |
| 469 | + elite_import = check_logs('Gerni Task', read_json_file('tasks/elite.json'), 'import') |
| 470 | + all_tasks = [easy_import, medium_import, hard_import, elite_import] |
| 471 | + update = update_imported_tasks(session['username'], all_tasks, form_data['username']) |
| 472 | + |
| 473 | + return render_template('collection_log_import.html', |
| 474 | + rs_username = rs_username, |
| 475 | + easy = len(easy_import), |
| 476 | + medium = len(medium_import), |
| 477 | + hard = len(hard_import), |
| 478 | + elite = len(elite_import)) |
| 479 | + |
| 480 | + |
| 481 | + return {'message': easy_import} |
477 | 482 |
|
478 | 483 | # AJAX route for generating a task. |
479 | 484 | @app.route('/generate/', methods=['POST']) |
@@ -838,7 +843,30 @@ def wall_of_pain(): |
838 | 843 | **context |
839 | 844 | ) |
840 | 845 |
|
841 | | - |
| 846 | +@app.route('/sync-collection-logs/', methods=['GET']) |
| 847 | +@login_required |
| 848 | +def sync_collection_logs(): |
| 849 | + user_info = BasePageInfo() |
| 850 | + progress = get_task_progress(user_info.username) |
| 851 | + context = { |
| 852 | + 'easy': progress['easy']['percent_complete'], |
| 853 | + 'medium': progress['medium']['percent_complete'], |
| 854 | + 'hard': progress['hard']['percent_complete'], |
| 855 | + 'elite': progress['elite']['percent_complete'], |
| 856 | + 'master' : progress['master']['percent_complete'], |
| 857 | + 'passive' : progress['passive']['percent_complete'], |
| 858 | + 'extra' : progress['extra']['percent_complete'], |
| 859 | + 'allPets' : progress['all_pets']['percent_complete'], |
| 860 | + } |
| 861 | + return render_template( |
| 862 | + 'temple-sync.html', |
| 863 | + username=user_info.username, |
| 864 | + email_verify=user_info.email_bool, |
| 865 | + email_val=user_info.email_val, |
| 866 | + rank_icon=user_info.rank_icon, |
| 867 | + taskapp_email=taskapp_email, |
| 868 | + **context |
| 869 | + ) |
842 | 870 | #route for Rank Check Page |
843 | 871 | @app.route('/rank-check/', methods=['GET']) |
844 | 872 | @login_required |
|
0 commit comments