| |
@@ -4,7 +4,9 @@
|
| |
import hubs.models
|
| |
|
| |
from hubs.app import app, OIDC
|
| |
- from hubs.utils.views import authenticated, is_safe_url, login_required
|
| |
+ from hubs.utils import hubname2monogramcolour
|
| |
+ from hubs.utils.views import (authenticated, is_safe_url,
|
| |
+ login_required, get_user_details)
|
| |
|
| |
|
| |
@app.route('/')
|
| |
@@ -21,21 +23,48 @@
|
| |
@app.route('/groups/')
|
| |
@login_required
|
| |
def groups():
|
| |
- # Get the list of promoted and non-promoted group hubs from the DB
|
| |
- promoted_names = app.config.get('PROMOTED_GROUPS')
|
| |
+ current_user = get_user_details()
|
| |
+ urls = {
|
| |
+ "allGroups": flask.url_for("groups"),
|
| |
+ }
|
| |
+ flash_messages = [
|
| |
+ {"msg": msg[1], "type": msg[0]} for msg in
|
| |
+ flask.get_flashed_messages(with_categories=True)
|
| |
+ ]
|
| |
+
|
| |
groups = hubs.models.Hub.all_group_hubs()
|
| |
- promoted = [g for g in groups if g.name in promoted_names]
|
| |
- secondary = [g for g in groups if g.name not in promoted_names]
|
| |
+ hubslist = []
|
| |
+ for group in groups:
|
| |
+ hub = group.get_props()
|
| |
+ hub["monogram_colour"] = hubname2monogramcolour(hub["name"])
|
| |
+ hub["hub_url"] = flask.url_for('hub', name=hub["name"])
|
| |
+
|
| |
+ member_count = len(hub["users"]["member"])
|
| |
+ owner_count = len(hub["users"]["owner"])
|
| |
+ hub["member_count"] = member_count + owner_count
|
| |
+
|
| |
+ subscriber_count = len(hub["users"]["subscriber"])
|
| |
+ hub["subscriber_count"] = subscriber_count
|
| |
+
|
| |
+ hubslist.append(hub)
|
| |
|
| |
name_of_the_month = app.config.get('HUB_OF_THE_MONTH')
|
| |
- hub_of_the_month = hubs.models.Hub.by_name(name_of_the_month)
|
| |
+ hub_of_the_month = hubs.models.Hub.by_name(name_of_the_month).get_props()
|
| |
|
| |
return flask.render_template(
|
| |
- 'groups.html',
|
| |
- promoted=promoted,
|
| |
- secondary=secondary,
|
| |
- hub_of_the_month=hub_of_the_month,
|
| |
- )
|
| |
+ 'react.html',
|
| |
+ page_title="All Groups",
|
| |
+ initial_state=dict(
|
| |
+ ui=dict(
|
| |
+ page="Groups",
|
| |
+ flashMessages=flash_messages,
|
| |
+ ),
|
| |
+ urls=urls,
|
| |
+ currentUser=current_user,
|
| |
+ hubslist={"hubs": hubslist,
|
| |
+ "hub_of_the_month": hub_of_the_month}
|
| |
+ ),
|
| |
+ )
|
| |
|
| |
|
| |
@app.route('/login/', methods=('GET', 'POST'))
|
| |