Skip to content

Commit

Permalink
new: [organization_bp] New view in order to get the list of members o…
Browse files Browse the repository at this point in the history
…f an organization.
  • Loading branch information
cedricbonhomme committed Oct 25, 2023
1 parent 51f556c commit b002c4e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mosp/templates/organization.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h3>
</div>
<div class="row">
<div class="col">
{{ organization.users | count }} member{{ 's' if organization.users | count > 1 }}
<a href="{{ url_for('organization_bp.members', org_id=organization.id) }}">{{ organization.users | count }} member{{ 's' if organization.users | count > 1 }}</a>
</div>
</div>
<br />
Expand Down
26 changes: 26 additions & 0 deletions mosp/templates/organization_members.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends "layout.html" %}
{% block content %}
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>{{ _('Organization members for') }} <a href="{{ url_for('organization_bp.get', organization_id=organization.id) }}">{{ organization.name }}</a></h1>
</div>
</div>

<br />
<div class="row">
<div class="col-md-12">
<div class="list-group">
{% for member in members %}
<a href="{{ url_for('user_bp.get', login=member.login) }}" class="list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-between">
<p class="mb-1">{{ member.login }}</p>
</div>
</a>
{% endfor %}
</div>
</div>
</div>

</div>
{% endblock %}
13 changes: 13 additions & 0 deletions mosp/views/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,16 @@ def leave(org_id):
db.session.commit()
flash("You left the organization successfully. ", "success")
return redirect(url_for("organization_bp.get", organization_id=org_id))


@organization_bp.route("/members/<org_id>", methods=["GET"])
def members(org_id):
"""Returns the list of members of an organization."""
org = Organization.query.filter(Organization.id == org_id).first()
members = org.users
members.sort(key=lambda user: user.last_seen, reverse=True)
if org:
return render_template(
"organization_members.html", organization=org, members=members
)
return redirect(url_for("organization_bp.get", organization_id=org_id))

0 comments on commit b002c4e

Please sign in to comment.