src/templates/people/index.html \
src/templates/people/passwd.html \
src/templates/people/sip.html \
- src/templates/people/stats.html \
src/templates/people/subscribed.html \
src/templates/people/unsubscribe.html \
src/templates/people/unsubscribed.html \
+++ /dev/null
-{% extends "../base.html" %}
-
-{% block title %}{{ _("Statistics") }}{% end block %}
-
-{% block container %}
- <div class="header">
- <div class="container">
- <h1>{{ _("Statistics") }}</h1>
- </div>
- </div>
-
- {% set total_accounts = len(backend.accounts) %}
-
- <div class="container">
- <section>
- <div class="row">
- <div class="col-12 col-lg-3">
- <div class="card mb-3">
- <div class="card-body text-center">
- <h1>{{ total_accounts }}</h1>
- <h5>{{ _("Total Accounts") }}</h5>
-
- <hr>
-
- {% set t = now - datetime.timedelta(days=7) %}
-
- <h1>{{ backend.accounts.count_created_after(t) }}</h1>
- <h5 class="mb-0">{{ _("Created This Week") }}</h5>
-
- <hr>
-
- {% set t = now - datetime.timedelta(days=30) %}
-
- <h1>{{ backend.accounts.count_created_after(t) }}</h1>
- <h5 class="mb-0">{{ _("Created This Month") }}</h5>
-
- {% set pending_registrations = backend.accounts.pending_registrations %}
- {% if pending_registrations %}
- <hr>
-
- <h1>{{ pending_registrations }}</h1>
- <h5 class="mb-0">{{ _("Pending Registrations") }}</h5>
- {% end %}
- </div>
- </div>
- </div>
-
- <div class="col-12 col-lg-9">
- <div class="card">
- <ul class="list-group list-group-flush">
- {% set countries = backend.accounts.countries %}
-
- {% for country in sorted(countries, key=lambda c: countries[c], reverse=True) %}
- <li class="list-group-item d-flex justify-content-between align-items-center">
- <span>
- <span class="flag-icon flag-icon-{{ country.alpha2.lower() }} small mr-1"></span>
- {{ country.apolitical_name }}
- </span>
-
- <span class="badge bg-primary" title="{{ countries[country] }}">
- {{ "%.1f%%" % (countries[country] * 100 / total_accounts) }}
- </span>
- </li>
- {% end %}
- </ul>
- </div>
- </div>
- </div>
- </section>
- </div>
-{% end block %}
</div>
</section>
{% end %}
+
+ {% if current_user and current_user.is_staff() %}
+ {% set total_accounts = len(backend.accounts) %}
+ {% set countries = backend.accounts.countries %}
+
+ {# Stats #}
+
+ <section class="section">
+ <div class="container">
+ <div class="level">
+ <div class="level-item has-text-centered">
+ <div>
+ <p class="heading">{{ _("Total Accounts") }}</p>
+ <p class="title">
+ {{ total_accounts }}
+ </p>
+ </div>
+ </div>
+
+ {% set t = now - datetime.timedelta(days=7) %}
+
+ <div class="level-item has-text-centered">
+ <div>
+ <p class="heading">{{ _("Created This Week") }}</p>
+ <p class="title">
+ {{ backend.accounts.count_created_after(t) }}
+ </p>
+ </div>
+ </div>
+
+ {% set t = now - datetime.timedelta(days=30) %}
+
+ <div class="level-item has-text-centered">
+ <div>
+ <p class="heading">{{ _("Created This Month") }}</p>
+ <p class="title">
+ {{ backend.accounts.count_created_after(t) }}
+ </p>
+ </div>
+ </div>
+
+ {% set pending_registrations = backend.accounts.pending_registrations %}
+ {% if pending_registrations %}
+ <div class="level-item has-text-centered">
+ <div>
+ <p class="heading">{{ _("Pending Registrations") }}</p>
+ <p class="title">
+ {{ pending_registrations }}
+ </p>
+ </div>
+ </div>
+ {% end %}
+ </div>
+ </div>
+ </section>
+
+ {# Countries #}
+
+ <section class="section">
+ <div class="container">
+ <h4 class="title is-4">{{ _("Origin") }}</h4>
+
+ <nav class="panel">
+ {% for country in sorted(countries, key=lambda c: countries[c], reverse=True) %}
+ {% set percentage = countries[country] / total_accounts %}
+
+ <div class="panel-block is-justify-content-space-between">
+ <span>
+ <span class="panel-icon">
+ <i class="flag-icon flag-icon-{{ country.alpha2.lower() }}"
+ aria-hidden="true"></i>
+ </span>
+
+ {{ country.apolitical_name }}
+ </span>
+
+ <span class="tag">
+ {{ "%.1f%%" % (percentage * 100) }}
+ </span>
+ </div>
+ {% end %}
+ </div>
+ </div>
+ </section>
+ {% end %}
{% end %}
{% end block %}
(r"/password\-reset", auth.PasswordResetInitiationHandler),
(r"/password\-reset/([a-z_][a-z0-9_-]{0,31})/(\w+)", auth.PasswordResetHandler),
- # Stats
- (r"/stats", people.StatsHandler),
-
# Serve any static files
(r"/static/(.*)", tornado.web.StaticFileHandler, { "path" : self.settings.get("static_path") }),
self.render("people/group.html", group=group)
-class StatsHandler(auth.CacheMixin, base.BaseHandler):
- @tornado.web.authenticated
- def get(self):
- # Only staff can see stats
- if not self.current_user.is_staff():
- raise tornado.web.HTTPError(403)
-
- self.render("people/stats.html")
-
-
class SubscribeHandler(auth.CacheMixin, base.BaseHandler):
@tornado.web.authenticated
def post(self):