A corporation manager and dashboard for EVE Online
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.
 
 
 
 
 

40 rivejä
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. from flask import abort, g
  3. from flask_mako import render_template
  4. from ._provided import blueprint, config
  5. def get_current():
  6. """Return the name of the currently selected campaign, or None."""
  7. if not config["enabled"]:
  8. return None
  9. setting = g.auth.get_character_modprop("campaigns", "current")
  10. if not setting or setting not in config["enabled"]:
  11. return config["enabled"][0]
  12. return setting
  13. def home():
  14. """Render and return the main campaign page."""
  15. return render_template("campaigns/campaign.mako", current=get_current())
  16. def navitem():
  17. """Render and return the navigation item for this module."""
  18. current = get_current()
  19. if current:
  20. result = render_template("campaigns/navitem.mako", current=current)
  21. return result.decode("utf8")
  22. @blueprint.rroute("/campaign")
  23. def campaign():
  24. """Render and return the current campaign page."""
  25. return home()
  26. @blueprint.rroute("/settings/campaign/<campaign>", methods=["POST"])
  27. def set_campaign(campaign):
  28. """Update the user's currently selected campaign."""
  29. if campaign not in config["enabled"]:
  30. abort(404)
  31. g.auth.set_character_modprop("campaigns", "current", campaign)
  32. return "", 204