Browse Source

Allow accessing individual campaigns directly.

master
Ben Kurtovic 4 years ago
parent
commit
f8713d9357
4 changed files with 20 additions and 5 deletions
  1. +15
    -3
      calefaction/modules/campaigns.py
  2. +1
    -1
      templates/campaigns/campaign.mako
  3. +3
    -0
      templates/campaigns/empty.mako
  4. +1
    -1
      templates/campaigns/navitem.mako

+ 15
- 3
calefaction/modules/campaigns.py View File

@@ -31,9 +31,21 @@ def navitem():
return result.decode("utf8")

@blueprint.rroute("/campaign")
def campaign():
def current_campaign():
"""Render and return the current campaign page."""
return home()
current = get_current()
if current:
return redirect(url_for(".campaign", name=current), 303)
return render_template("campaigns/empty.mako")

@blueprint.rroute("/campaigns/<name>")
def campaign(name):
"""Render and return a campaign page."""
if name not in config["enabled"]:
abort(404)
campaign = config["campaigns"][name]
return render_template(
"campaigns/campaign.mako", name=name, campaign=campaign)

@blueprint.rroute("/settings/campaign", methods=["POST"])
def set_campaign():
@@ -42,4 +54,4 @@ def set_campaign():
if campaign not in config["enabled"]:
abort(400)
g.auth.set_character_modprop("campaigns", "current", campaign)
return redirect(url_for(".campaign"), 303)
return redirect(url_for(".campaign", name=campaign), 303)

+ 1
- 1
templates/campaigns/campaign.mako View File

@@ -1,6 +1,6 @@
<%inherit file="../_default.mako"/>
<%block name="title">
${self.maketitle(campaign["title"], "Campaign")}
${self.maketitle(campaign["title"], "Campaigns")}
</%block>
<h2><span class="understate">Campaign:</span> ${campaign["title"] | h}</h2>
<p>Hello! ...</p>

+ 3
- 0
templates/campaigns/empty.mako View File

@@ -1,2 +1,5 @@
<%inherit file="../_default.mako"/>
<%block name="title">
${self.maketitle("Campaigns")}
</%block>
<p>No campaigns currently.</p>

+ 1
- 1
templates/campaigns/navitem.mako View File

@@ -12,5 +12,5 @@ Campaign:
</form>
% else:
<% campaign = g.config.modules.campaigns.config["campaigns"][current] %>
<a href="${url_for('campaigns.campaign')}">${campaign["title"]}</a>
<a href="${url_for('campaigns.campaign', name=current)}">${campaign["title"]}</a>
% endif

Loading…
Cancel
Save