From de863465d215ba6874a3abcf6d86b291feb2ad2f Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 27 Dec 2016 21:45:55 -0500 Subject: [PATCH] Campaign module style tweaks. --- calefaction/modules/campaigns/getters.py | 9 ++++++--- static/main.css | 28 ++++++++++++++++++---------- templates/campaigns/campaign.mako | 12 ++++++++---- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/calefaction/modules/campaigns/getters.py b/calefaction/modules/campaigns/getters.py index ecf770e..9cbb653 100644 --- a/calefaction/modules/campaigns/getters.py +++ b/calefaction/modules/campaigns/getters.py @@ -12,6 +12,8 @@ from ...database import Database as MainDB __all__ = ["get_current", "get_overview", "get_summary", "get_unit"] +_MAX_STALENESS = 60 * 60 + CampaignDB.path = str(Path(MainDB.path).parent / "db_campaigns.sqlite3") app.before_request(CampaignDB.pre_hook) @@ -28,8 +30,8 @@ def _update_operation(cname, opname, new): qualifiers = operation["qualifiers"] show_isk = operation.get("isk", True) - primary = 42 - secondary = 63 + primary = __import__("random").randint(10, 99) + secondary = __import__("random").randint(100000, 50000000) g.campaign_db.set_overview(cname, opname, primary, secondary) def get_current(): @@ -49,13 +51,14 @@ def get_overview(cname, opname): Updates the database if necessary, so this can take some time. """ + maxdelta = timedelta(seconds=_MAX_STALENESS) with _lock: last_updated = g.campaign_db.check_operation(cname, opname) if last_updated is None: logger.debug("Adding campaign=%s operation=%s", cname, opname) _update_operation(cname, opname, new=True) g.campaign_db.add_operation(cname, opname) - elif datetime.utcnow() - last_updated > timedelta(seconds=60 * 60): + elif datetime.utcnow() - last_updated > maxdelta: logger.debug("Updating campaign=%s operation=%s", cname, opname) _update_operation(cname, opname, new=False) g.campaign_db.touch_operation(cname, opname) diff --git a/static/main.css b/static/main.css index 4ddb284..0bba3a3 100644 --- a/static/main.css +++ b/static/main.css @@ -376,30 +376,30 @@ h2 .disabled::after { justify-content: space-between; } -.operation .overview .primary { - line-height: 60px; +.operation .primary .num { height: 60px; + line-height: 60px; } -.operation .overview .primary.big { +.operation .big { font-size: 300%; } -.operation .overview .primary.medium { +.operation .medium { font-size: 200%; } -.operation .overview .primary.small { +.operation .small { font-size: 150%; } -.operation .overview .unit { +.operation .unit { font-style: italic; } @media (min-width: 800px) { #operations { - margin: 1em; + margin: 1em 2em; } #operations section { @@ -410,6 +410,14 @@ h2 .disabled::after { margin: 0 0.75em; text-align: center; } + + .operation .secondary { + margin-top: 0.5em; + } + + .operation .secondary .unit { + margin-left: 0.15em; + } } @media (max-width: 799px) { @@ -421,12 +429,12 @@ h2 .disabled::after { margin: 0.5em 0; } - .operation .overview > div { + .operation .primary, .operation .primary .unit { display: inline-block; } - .operation .overview .unit { - margin-left: 0.25em; + .operation .unit { + margin-left: 0.15em; } } diff --git a/templates/campaigns/campaign.mako b/templates/campaigns/campaign.mako index 3cc07b1..2e25652 100644 --- a/templates/campaigns/campaign.mako +++ b/templates/campaigns/campaign.mako @@ -23,11 +23,15 @@ ${operation["title"] | h}
-
${"{:,}".format(primary)}
-
${mod.get_unit(operation, primary)}
+
+ ${"{:,}".format(primary)} +
${mod.get_unit(operation, primary)}
+
% if secondary is not None: -
${"{:,}".format(secondary)}
-
${mod.get_unit(operation, secondary, primary=False)}
+
+ ${"{:,}".format(secondary)} + ${mod.get_unit(operation, secondary, primary=False)} +
% endif
% if summary: