Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature add tc #467

Merged
merged 69 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b1dee6a
add terms column to groups table + test if terms is immutable
cwcummings Jun 10, 2021
8a248dd
add terms field to group creation page
cwcummings Jun 10, 2021
7bb36de
add terms and conditions info (uneditable) to the Edit Group page
cwcummings Jun 11, 2021
8d0781e
Merge branch 'master' of https://github.com/Ouranosinc/Magpie into fe…
cwcummings Sep 8, 2021
e637e55
check for terms on adding usr to group
cwcummings Sep 10, 2021
ea14913
send email for T&C acceptation for group with terms + use tmp_token i…
cwcummings Sep 13, 2021
37b77c3
send email to confirm user has been added to group following T&C acce…
cwcummings Sep 14, 2021
e2cda93
reorder tests and add t&c support for joining a discoverable group as…
cwcummings Sep 14, 2021
9ee4b0a
add api endpoints to get pending group memberships
cwcummings Sep 16, 2021
82fcb00
adapt ui to display pending users
cwcummings Sep 16, 2021
ebaca98
bugfix: remove all identical tmp_tokens upon T&C confirmation to avoi…
cwcummings Sep 17, 2021
4bf05de
remove any user/group that is already confirmed when getting pending …
cwcummings Sep 17, 2021
553aa90
add comment for checkbox that remain enabled to join groups, even for…
cwcummings Sep 17, 2021
8ef6dd2
bugfix: 500 error when removing last user from a group, from the edit…
cwcummings Sep 17, 2021
51ae1f0
bugfix pending not displayed until refresh on edit_user and account p…
cwcummings Sep 20, 2021
984b1a0
review api documentation
cwcummings Sep 20, 2021
1b8e698
document group definition with terms and conditions feature
cwcummings Sep 20, 2021
d986b4a
update changelog
cwcummings Sep 21, 2021
acdc4fb
fix lint errors
cwcummings Sep 21, 2021
5b6f7b7
Merge branch 'master' of https://github.com/Ouranosinc/Magpie into fe…
cwcummings Sep 21, 2021
2c8c2e9
review code
cwcummings Sep 21, 2021
c9bede9
add ref to send_email call in user_utils, for mocking new tests
cwcummings Sep 21, 2021
f247cb5
change string formatting for py3.5 support
cwcummings Sep 21, 2021
82040c1
moved api tests that require mocked_send_email, to use only local app
cwcummings Sep 21, 2021
79da84f
small fixes after PR feedback
cwcummings Sep 22, 2021
1817df2
add documentation on email templates related to user-group assignment…
cwcummings Sep 22, 2021
c04ae0c
add_group page ui : change T&C input box to a textarea which supports…
cwcummings Sep 22, 2021
95056a4
get pending user/group request routes have been merged to the generic…
cwcummings Sep 23, 2021
cd8b278
fix default value of nullable field to None
cwcummings Sep 23, 2021
e9b4643
modify CHANGES file according to new corrections
cwcummings Sep 23, 2021
e9be507
fix ui missing textarea name
cwcummings Sep 23, 2021
8e6ffd0
fix lint errors
cwcummings Sep 23, 2021
bae3ebd
removed assert 0 for debugging
cwcummings Sep 23, 2021
9deeda6
correction to docstring descriptions
cwcummings Sep 23, 2021
4ef29f7
rename UserGroupType and move status api argument from body to query …
cwcummings Sep 28, 2021
13eb98a
minor improvements to documentation
cwcummings Sep 28, 2021
f4c4645
changed enum.value arguments to use enum directly
cwcummings Sep 28, 2021
9af7715
use sets in usergroups get endpoints
cwcummings Sep 29, 2021
ec7569f
reorganize css for add_group page
cwcummings Sep 29, 2021
a97df1d
add test for all get user/group status cases
cwcummings Sep 29, 2021
64d1cd2
fix linting errors
cwcummings Sep 29, 2021
7d24f23
move failing tests to local only
cwcummings Sep 29, 2021
e5c02e7
remove unused import
cwcummings Sep 29, 2021
ad45e6b
fix missing class name update on ui
cwcummings Sep 29, 2021
b251916
split get usergroups test cases by status
cwcummings Oct 4, 2021
6649af8
reorganize css font styles
cwcummings Oct 4, 2021
f6d8453
add error and success info on ui for assigning a user to a group with…
cwcummings Oct 5, 2021
38d4609
Merge branch 'master' of https://github.com/Ouranosinc/Magpie into fe…
cwcummings Oct 6, 2021
5eeeef2
fix lint errors
cwcummings Oct 6, 2021
2edd90d
membership alerts now in a single file to be reusable
cwcummings Oct 6, 2021
35f1765
fix enum UserGroupStatus usage
cwcummings Oct 18, 2021
4b6eeb5
added new field to get user endpoint, to indicate if user has any pen…
cwcummings Oct 18, 2021
425724b
add test to validate failing assignment to group with terms
cwcummings Oct 18, 2021
7add1c8
minor fixes from PR feedback
cwcummings Oct 18, 2021
209b44c
adjust alert icon color and other minor css fixes
cwcummings Oct 19, 2021
281c0b3
Merge branch 'master' of https://github.com/Ouranosinc/Magpie into fe…
cwcummings Oct 19, 2021
7beb182
fix lint error
cwcummings Oct 19, 2021
a54c89f
ui T&C test : check if group/user is still found in body after accept…
cwcummings Oct 19, 2021
6d30dcb
update create group post request descriptions
cwcummings Oct 21, 2021
fd8faa3
update alembic revision id
cwcummings Oct 22, 2021
14c5c23
reorganize has_pending_group user info
cwcummings Oct 22, 2021
eb884e2
fix lint errors
cwcummings Oct 22, 2021
3e55c9e
add empty get_user_groups_by_status method to UserPending to avoid er…
cwcummings Oct 25, 2021
5752faf
fix new lint errors with stylelint 14.0.0 update
cwcummings Oct 25, 2021
7bc3e24
small correction in docstring
cwcummings Oct 25, 2021
8eb225e
rename get_user_groups_by_status function
cwcummings Oct 26, 2021
287ec83
reset changes on get_user_groups_checked function
cwcummings Oct 26, 2021
b1ea5d4
fix lint error
cwcummings Oct 26, 2021
decc9e2
remove css 3-values notations, using 4-values instead
cwcummings Oct 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"color-hex-case": "upper",
"color-hex-length": "long",
"indentation": [4],
"no-descending-specificity": null
"no-descending-specificity": null,
"property-no-vendor-prefix": null,
"shorthand-property-no-redundant-values": null,
"value-no-vendor-prefix": null
}
}
16 changes: 15 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@ Changes
`Unreleased <https://github.com/Ouranosinc/Magpie/tree/master>`_ (latest)
------------------------------------------------------------------------------------

* Nothing new for the moment.
Features / Changes
~~~~~~~~~~~~~~~~~~~~~
* Add new `Terms and conditions` field for ``Group`` creation. When a request is made to assign a ``User`` to a
``Group`` with terms and conditions, an email is now sent to the ``User`` with the terms and conditions. The ``User``
is assigned to the ``Group`` when receiving the ``User``'s approval of terms and conditions, and another email is
then sent to notify the ``User`` of the successful operation.
* Changed ``/groups/{group_name}/users``, ``/users/current/groups`` and ``/users/{user_name}/groups`` endpoints with
new query parameter `status` to either get active, pending or all ``Users`` or ``Groups``. This new parameter is
useful to display any pending ``Users``/``Groups`` on the UI.
* Added new field `has_pending_group` in the user info returned by ``/users/{user_name}`` endpoint, indicating if
the user has any pending group.

Bug Fixes
~~~~~~~~~~~~~~~~~~~~~
* Fix HTTP ``Internal Server Error [500]`` on the page to edit a ``Group`` when deleting the last ``User`` of a ``Group``.

`3.16.1 <https://github.com/Ouranosinc/Magpie/tree/3.16.1>`_ (2021-10-18)
------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions config/magpie.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ magpie.user_registration_notify_enabled = false
magpie.user_registration_notify_email_recipient =
magpie.user_registration_notify_email_template =

# --- user assignment to groups with t&c ---
magpie.group_terms_submission_email_template =
magpie.group_terms_approved_email_template =

# smtp server configuration
magpie.smtp_user = Magpie
magpie.smtp_from =
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ code.docutils.literal:not(.xref) {

/* overrides and additions */
background-color: #DBDBDD; /* slightly darker than original to make more obvious */
padding: 0.1em 0.1em; /* pad so that background color encapsulate letters going 'lower' (eg: g, j, y) */
padding: 0.1em; /* pad so that background color encapsulate letters going 'lower' (eg: g, j, y) */
white-space: nowrap; /* don't allow breaking on non-word items such as dot in value */
}

Expand Down
38 changes: 38 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,44 @@ approval procedures.

The default template provides details about available template arguments.

.. _config_user_group_assignment:

User-Group Assignment Configuration
-----------------------------------

.. versionadded:: 3.17

Following are the full description of all configuration parameters employed by the :term:`User`-:term:`Group` assignment
procedures, in the case of a :term:`Group` that requires terms and conditions validation by the :term:`User`.

.. envvar:: MAGPIE_GROUP_TERMS_SUBMISSION_EMAIL_TEMPLATE

(Default: |email_uga_submission_mako|_)

.. versionadded:: 3.17

Path to a `Mako Template`_ file providing custom email format to send notification email to the :term:`User`
following submission of the :term:`User` assignment to a :term:`Group` that requires accepting terms and conditions.

When overridden with a custom email format, the contents should provide sufficient details indicating to the
:term:`User` that they must accept the :term:`Group`'s terms and conditions to join it, and that confirmation is
accomplished by visiting the link contained in that email. The confirmation URL would validate that the :term:`User`
accepts the terms and conditions, and would proceed with the assignment of the :term:`User` to the :term:`Group`.
The contents of the email should also include the terms and conditions of the :term:`Group`.

The default template provides details about available template arguments.

.. envvar:: MAGPIE_GROUP_TERMS_APPROVED_EMAIL_TEMPLATE

(Default: |email_uga_approved_mako|_)

.. versionadded:: 3.17

Path to a `Mako Template`_ file providing custom email format to send an email to the :term:`User` related to a
:term:`User`-:term:`Group` assignment to notify them that the terms and conditions were accepted, and that their
account is now a member of the requested :term:`Group`.

The default template provides details about available template arguments.

.. _config_webhook:

Expand Down
5 changes: 4 additions & 1 deletion docs/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ Glossary
Group
Entity on which :term:`Permission` over a :term:`Service` or :term:`Resource` can be applied. Any :term:`User`
can be set as a member of any number of :term:`Group`, making it inherit all applicable set of
:term:`Permission`.
:term:`Permission`. A :term:`Group` can optionally have terms and conditions, which the :term:`User` has to
accept before being assigned to the :term:`Group`. In this case, an email is sent to the :term:`User` upon
request to ask for confirmation. The terms and conditions can only be defined upon the :term:`Group` creation
and can never be modified afterwards.

Immediate Permissions
Describes a :term:`Permission` that originates directly and only from a :term:`Service`.
Expand Down
24 changes: 14 additions & 10 deletions docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@
.. _constants.py: https://github.com/Ouranosinc/Magpie/tree/master/magpie/constants.py
.. _Dockerfile: https://github.com/Ouranosinc/Magpie/tree/master/Dockerfile
.. _docker-compose.yml.example: https://github.com/Ouranosinc/Magpie/tree/master/docker-compose.yml.example
.. |email_ur_submission_mako| replace:: ``magpie/api/template/email_user_registration_submission.mako``
.. _email_ur_submission_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/template/email_user_registration_submission.mako
.. |email_ur_approval_mako| replace:: ``magpie/api/template/email_user_registration_approval.mako``
.. _email_ur_approval_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/template/email_user_registration_approval.mako
.. |email_ur_approved_mako| replace:: ``magpie/api/template/email_user_registration_approved.mako``
.. _email_ur_approved_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/template/email_user_registration_approved.mako
.. |email_ur_declined_mako| replace:: ``magpie/api/template/email_user_registration_declined.mako``
.. _email_ur_declined_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/template/email_user_registration_declined.mako
.. |email_ur_notify_mako| replace:: ``magpie/api/template/email_user_registration_notify.mako``
.. _email_ur_notify_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/template/email_user_registration_notify.mako
.. |email_ur_submission_mako| replace:: ``magpie/api/templates/email_user_registration_submission.mako``
.. _email_ur_submission_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/templates/email_user_registration_submission.mako
.. |email_ur_approval_mako| replace:: ``magpie/api/templates/email_user_registration_approval.mako``
.. _email_ur_approval_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/templates/email_user_registration_approval.mako
.. |email_ur_approved_mako| replace:: ``magpie/api/templates/email_user_registration_approved.mako``
.. _email_ur_approved_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/templates/email_user_registration_approved.mako
.. |email_ur_declined_mako| replace:: ``magpie/api/templates/email_user_registration_declined.mako``
.. _email_ur_declined_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/templates/email_user_registration_declined.mako
.. |email_ur_notify_mako| replace:: ``magpie/api/templates/email_user_registration_notify.mako``
.. _email_ur_notify_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/templates/email_user_registration_notify.mako
ChaamC marked this conversation as resolved.
Show resolved Hide resolved
.. |email_uga_submission_mako| replace:: ``magpie/api/templates/email_group_terms_submission.mako``
.. _email_uga_submission_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/templates/email_group_terms_submission.mako
.. |email_uga_approved_mako| replace:: ``magpie/api/templates/email_group_terms_approved.mako``
.. _email_uga_approved_mako: https://github.com/Ouranosinc/Magpie/blob/master/magpie/api/templates/email_group_terms_approved.mako
.. _magpie-cron: https://github.com/Ouranosinc/Magpie/tree/master/magpie-cron
.. _magpie.env.example: https://github.com/Ouranosinc/Magpie/tree/master/env/magpie.env.example
.. _magpie.ini: https://github.com/Ouranosinc/Magpie/tree/master/config/magpie.ini
Expand Down
24 changes: 24 additions & 0 deletions magpie/alembic/versions/2021-06-09_cb92ff1f81bb_add_group_terms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
add group terms

Revision ID: cb92ff1f81bb
Revises: 35e98bdc8aed
Create Date: 2021-06-09 14:18:32.777082
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "cb92ff1f81bb"
down_revision = "35e98bdc8aed"
branch_labels = None
depends_on = None


def upgrade():
op.add_column("groups", sa.Column("terms", sa.UnicodeText(), nullable=True))


def downgrade():
op.drop_column("groups", "terms")
1 change: 1 addition & 0 deletions magpie/api/management/group/group_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def fmt_grp():
if public_info:
return info
info["discoverable"] = group.discoverable
info["terms"] = group.terms
info["priority"] = "max" if group.priority == math.inf else int(group.priority)
info["member_count"] = group.get_member_count(db_session)
info["user_names"] = [usr.user_name for usr in group.users]
Expand Down
10 changes: 7 additions & 3 deletions magpie/api/management/group/group_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def get_group_resources(group, db_session, service_types=None):
return json_response


def create_group(group_name, description, discoverable, db_session):
# type: (Str, Str, bool, Session) -> HTTPException
def create_group(group_name, description, discoverable, terms, db_session):
# type: (Str, Str, bool, Str, Session) -> HTTPException
"""
Creates a group if it is permitted and not conflicting.

Expand All @@ -85,6 +85,7 @@ def create_group(group_name, description, discoverable, db_session):
"""
description = str(description) if description else None
discoverable = asbool(discoverable)
terms = str(terms) if terms else None
group_content_error = {
"group_name": str(group_name),
"description": description,
Expand All @@ -103,7 +104,10 @@ def create_group(group_name, description, discoverable, db_session):
http_error=HTTPConflict, content=group_content_error,
msg_on_fail=s.Groups_POST_ConflictResponseSchema.description)
new_group = ax.evaluate_call(
lambda: models.Group(group_name=group_name, description=description, discoverable=discoverable), # noqa
lambda: models.Group(group_name=group_name,
description=description,
discoverable=discoverable,
terms=terms), # noqa
fallback=lambda: db_session.rollback(), http_error=HTTPForbidden, content=group_content_error,
msg_on_fail=s.Groups_POST_ForbiddenCreateResponseSchema.description)
ax.evaluate_call(lambda: db_session.add(new_group), fallback=lambda: db_session.rollback(),
Expand Down
36 changes: 30 additions & 6 deletions magpie/api/management/group/group_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from magpie.api.management.group import group_utils as gu
from magpie.api.management.service import service_utils as su
from magpie.constants import get_constant
from magpie.models import TemporaryToken, TokenOperation, UserGroupStatus


@s.GroupsAPI.get(tags=[s.GroupsTag], response_schemas=s.Groups_GET_responses)
Expand All @@ -30,9 +31,10 @@ def create_group_view(request):
Create a group.
"""
group_name = ar.get_value_multiformat_body_checked(request, "group_name")
group_desc = ar.get_multiformat_body(request, "description", default="")
group_desc = ar.get_multiformat_body(request, "description", default=None)
group_disc = asbool(ar.get_multiformat_body(request, "discoverable", default=False))
return gu.create_group(group_name, group_desc, group_disc, request.db)
group_terms = ar.get_multiformat_body(request, "terms", default=None)
return gu.create_group(group_name, group_desc, group_disc, group_terms, request.db)


@s.GroupAPI.get(schema=s.Group_GET_RequestSchema, tags=[s.GroupsTag], response_schemas=s.Group_GET_responses)
Expand Down Expand Up @@ -116,12 +118,34 @@ def delete_group_view(request):
@view_config(route_name=s.GroupUsersAPI.name, request_method="GET")
def get_group_users_view(request):
"""
List all user from a group.
List all users from a group.
Users can be filtered by status depending of input arguments.
"""
group = ar.get_group_matchdict_checked(request)
user_names = ax.evaluate_call(lambda: [user.user_name for user in group.users],
http_error=HTTPForbidden,
msg_on_fail=s.GroupUsers_GET_ForbiddenResponseSchema.description)
status = ar.get_query_param(request, "status", default=UserGroupStatus.ACTIVE.value)
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
ax.verify_param(status, is_in=True, param_compare=UserGroupStatus.values(), param_name="status",
msg_on_fail=s.UserGroup_Check_Status_BadRequestResponseSchema.description,
http_error=HTTPBadRequest)
status = UserGroupStatus.get(status)

user_names = set()
member_user_names = ax.evaluate_call(lambda: set(user.user_name for user in group.users),
http_error=HTTPForbidden,
msg_on_fail=s.GroupUsers_GET_ForbiddenResponseSchema.description)
if status in [UserGroupStatus.ACTIVE, UserGroupStatus.ALL]:
user_names = user_names.union(member_user_names)
if status in [UserGroupStatus.PENDING, UserGroupStatus.ALL]:
# Find all temporary tokens with requested group id that have a pending accept terms request
tmp_tokens = request.db.query(TemporaryToken).filter(TemporaryToken.group_id == group.id)
tmp_tokens = tmp_tokens.filter(TemporaryToken.operation == TokenOperation.GROUP_ACCEPT_TERMS)

# Find and return all user names associated with the discovered tokens
pending_user_names = set(tmp_token.user.user_name for tmp_token in tmp_tokens)

# Remove any user already belonging to the group, in case any tokens are irrelevant.
# Should not happen since related tokens are deleted upon T&C acceptation.
pending_user_names = pending_user_names - member_user_names
user_names = user_names.union(pending_user_names)
return ax.valid_http(http_success=HTTPOk, detail=s.GroupUsers_GET_OkResponseSchema.description,
content={"user_names": sorted(user_names)})

Expand Down
2 changes: 1 addition & 1 deletion magpie/api/management/register/register_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def handle_temporary_token(tmp_token, request):
http_error=HTTPInternalServerError, msg_on_fail="Invalid token.")
ax.verify_param(tmp_token.user, not_none=True,
http_error=HTTPInternalServerError, msg_on_fail="Invalid token.")
uu.assign_user_group(tmp_token.user, tmp_token.group, request.db)
response = uu.handle_user_group_terms_confirmation(tmp_token, request)

elif tmp_token.operation == TokenOperation.USER_PASSWORD_RESET:
ax.verify_param(tmp_token.user, not_none=True,
Expand Down
4 changes: 4 additions & 0 deletions magpie/api/management/register/register_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def join_discoverable_group_view(request):
user = ar.get_logged_user(request)
group = ru.get_discoverable_group_by_name(group.group_name, db_session=request.db)

if group.terms:
# If group requires terms acceptation, send T&C email and await confirmation before adding the user to the group
return uu.send_group_terms_email(user, group, request.db)

ax.verify_param(user.id, param_compare=[usr.id for usr in group.users], not_in=True, with_param=False,
http_error=HTTPConflict, content={"user_name": user.user_name, "group_name": group.group_name},
msg_on_fail=s.RegisterGroup_POST_ConflictResponseSchema.description)
Expand Down
6 changes: 5 additions & 1 deletion magpie/api/management/user/user_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from magpie.api.exception import evaluate_call
from magpie.constants import get_constant
from magpie.models import UserStatuses
from magpie.models import UserGroupStatus, UserStatuses

if TYPE_CHECKING:
from typing import List
Expand Down Expand Up @@ -42,6 +42,10 @@ def fmt_usr():
if not basic_info:
grp_names = group_names if group_names else [grp.group_name for grp in user.groups]
user_info["group_names"] = list(sorted(grp_names))

# indicate if user has any pending T&C groups
user_info["has_pending_group"] = bool(user.get_groups_by_status(UserGroupStatus.PENDING))

# special users not meant to be used as valid "accounts" marked as without an ID
if user.user_name != get_constant("MAGPIE_ANONYMOUS_USER") and status != UserStatuses.Pending:
user_info["user{}id".format(sep)] = int(user.id)
Expand Down
Loading