You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. from flask import (
  2. request,
  3. jsonify,
  4. current_app,
  5. render_template,
  6. send_file,
  7. Blueprint
  8. )
  9. from acks.views import basic_auth
  10. from .quest_manager import (
  11. load_quests,
  12. get_quest_details,
  13. get_quest_archive
  14. )
  15. quest_views = Blueprint(
  16. 'quest_manager',
  17. __name__,
  18. template_folder='templates',
  19. url_prefix='/quest'
  20. )
  21. @quest_views.route('/list')
  22. @basic_auth.required
  23. def quest_list():
  24. quests = load_quests()
  25. return render_template('quest_list.html', quest_map=quests)
  26. @quest_views.route('/detail/<int:level>/<string:quest_name>')
  27. @basic_auth.required
  28. def quest_detail(level, quest_name):
  29. quest = get_quest_details(level, quest_name)
  30. return render_template('quest_detail.html', quest=quest)
  31. @quest_views.route('/detail/<int:level>/<string:quest_name>/download')
  32. @basic_auth.required
  33. def quest_download(level, quest_name):
  34. archive = get_quest_archive(level, quest_name)
  35. return send_file(archive, attachment_filename="acks_{0}.zip".format(quest_name), as_attachment=True)
  36. '''
  37. @npc_views.route('/party')
  38. @npc_views.route('/party/<int:base_level>')
  39. def generate_npc_party(base_level=None):
  40. party = None
  41. if base_level:
  42. party = create_party(base_level)
  43. # If asked for JSON, return the party, otherwise render HTML template
  44. if request.args.get('format', 'html') == 'json':
  45. return jsonify([npc.roll20_format for npc in party])
  46. return render_template('generate_npc_party.html', party=party, base_level=base_level)
  47. @npc_views.route('/single')
  48. @npc_views.route('/single/<int:base_level>/<int:guild_id>')
  49. def generate_single_npc(base_level=None, guild_id=0):
  50. guilds = CharacterClass.query.filter(CharacterClass.bucket.notin_(['Demi-Human'])).all()
  51. npc = None
  52. if base_level:
  53. npc = create_npc(base_level, guild_id)
  54. # If asked for JSON, return the npc, otherwise render HTML template
  55. if request.args.get('format', 'html') == 'json':
  56. return jsonify(npc)
  57. return render_template('generate_single_npc.html', npc=npc, base_level=base_level, guilds=guilds, guild_id=guild_id)
  58. @npc_views.route('/spells')
  59. def spell_list():
  60. spells = Spell.query.all()
  61. return render_template('spell_list.html', spells=spells)
  62. '''