Skip to content

Commit

Permalink
Add a link to /usertraffic instead of gauge
Browse files Browse the repository at this point in the history
Refs #395
  • Loading branch information
lukasjuhrich authored and georgeto committed Jan 24, 2019
1 parent 53f0201 commit 6f8f3a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sipa/initialization.py
Expand Up @@ -17,6 +17,7 @@
from sipa.defaults import DEFAULT_CONFIG
from sipa.flatpages import CategorizedFlatPages
from sipa.model import build_backends_ext
from sipa.model.misc import should_display_traffic_data
from sipa.session import SeparateLocaleCookieSessionInterface
from sipa.utils import replace_empty_handler_callables, url_self
from sipa.utils.babel_utils import get_weekday
Expand Down Expand Up @@ -75,6 +76,7 @@ def init_app(app, **kwargs):
get_weekday=get_weekday,
possible_locales=possible_locales,
get_attribute_endpoint=get_attribute_endpoint,
should_display_traffic_data=should_display_traffic_data,
traffic_chart=provide_render_function(generate_traffic_chart),
current_datasource=backends.current_datasource,
form_label_width_class="col-sm-{}".format(form_label_width),
Expand Down
9 changes: 9 additions & 0 deletions sipa/model/misc.py
@@ -1,6 +1,15 @@
from collections import namedtuple

from flask import request
from flask_login import current_user

from sipa.backends import backends

TransactionTuple = namedtuple('Transaction', ['datum', 'value'])

PaymentDetails = namedtuple('PaymentDetails', 'recipient bank iban bic purpose')


def should_display_traffic_data():
return ((current_user.is_authenticated and current_user.has_connection)
or backends.user_from_ip(request.remote_addr) is not None )
5 changes: 5 additions & 0 deletions sipa/templates/base.html
Expand Up @@ -229,6 +229,11 @@ <h1>AG DSN</h1>
<div id="sidebar" class="col-sm-3">
{% block sidebar %}
<div>
{% if should_display_traffic_data() -%}
<div class="module"><h2>
<a href="{{ url_for('generic.usertraffic') }}"><span class="glyphicon glyphicon-stats"></span> Traffic</a>
</h2></div>
{%- endif %}
<div id="row-contact">
<div class="module">
<h2>{{ _("Kontakt") }} </h2>
Expand Down

0 comments on commit 6f8f3a9

Please sign in to comment.