forked from Github-Mirrors/canaille
Groups field options are available groups
This commit is contained in:
parent
75df94216a
commit
8d7bb821e7
3 changed files with 17 additions and 5 deletions
|
@ -4,7 +4,7 @@ from flask import current_app
|
|||
from flask_babel import lazy_gettext as _
|
||||
from flask_wtf import FlaskForm
|
||||
from flask_wtf.file import FileField, FileRequired
|
||||
from .models import User
|
||||
from .models import User, Group
|
||||
|
||||
|
||||
class LoginForm(FlaskForm):
|
||||
|
@ -127,7 +127,6 @@ PROFILE_FORM_FIELDS = dict(
|
|||
"placeholder": _("1234"),
|
||||
},
|
||||
),
|
||||
groups=wtforms.SelectMultipleField(_("Groups"), choices=["foo", "bar"])
|
||||
)
|
||||
|
||||
|
||||
|
@ -139,4 +138,6 @@ def profile_form(field_names):
|
|||
for name in field_names
|
||||
if PROFILE_FORM_FIELDS.get(name)
|
||||
}
|
||||
if "groups" in field_names:
|
||||
fields["groups"] = wtforms.SelectMultipleField(_("Groups"), choices=[group[0] for group in Group.available_groups()])
|
||||
return wtforms.form.BaseForm(fields)
|
||||
|
|
|
@ -358,3 +358,14 @@ def foo_group(user, slapd_connection):
|
|||
)
|
||||
g.save(slapd_connection)
|
||||
return g
|
||||
|
||||
@pytest.fixture
|
||||
def groups(foo_group, admin, slapd_connection):
|
||||
Group.ocs_by_name(slapd_connection)
|
||||
bar_group = Group(
|
||||
objectClass = ["groupOfNames"],
|
||||
member=[admin.dn],
|
||||
cn="bar",
|
||||
)
|
||||
bar_group.save(slapd_connection)
|
||||
return (foo_group, bar_group)
|
|
@ -2,9 +2,9 @@ import mock
|
|||
from canaille.models import User
|
||||
|
||||
|
||||
def test_profile(testclient, slapd_connection, logged_user, foo_group):
|
||||
def test_profile(testclient, slapd_connection, logged_user, groups):
|
||||
res = testclient.get("/profile/user", status=200)
|
||||
assert res.form["groups"].options == [('foo', False, 'foo')]
|
||||
assert set(res.form["groups"].options) == set([("foo", False, "foo"), ("bar", False, "bar")])
|
||||
|
||||
res.form["uid"] = "user"
|
||||
res.form["givenName"] = "given_name"
|
||||
|
|
Loading…
Reference in a new issue