mirror of https://github.com/logos-co/open-law.git
fix display username on setting page
This commit is contained in:
parent
c3fe536e4b
commit
8e59613c72
|
@ -32,7 +32,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for contributor in book.contributors %}
|
{% for contributor in book.contributors %}
|
||||||
<tr class="bg-white border-b dark:bg-gray-900 dark:border-gray-700">
|
<tr class="bg-white border-b dark:bg-gray-900 dark:border-gray-700">
|
||||||
<td class="px-6 py-4">{{ contributor.username }}</td>
|
<td class="px-6 py-4">{{ contributor.user.username }}</td>
|
||||||
<td class="px-6 py-4">{{ contributor.role.name }}</td>
|
<td class="px-6 py-4">{{ contributor.role.name }}</td>
|
||||||
<td class="px-6 py-4"></td>
|
<td class="px-6 py-4"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
from flask.testing import FlaskClient, FlaskCliRunner
|
from flask.testing import FlaskClient, FlaskCliRunner
|
||||||
from click.testing import Result
|
from click.testing import Result
|
||||||
from app import models as m
|
|
||||||
|
from app import models as m, db
|
||||||
from tests.utils import login
|
from tests.utils import login
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,12 +41,12 @@ def test_delete_user(populate: FlaskClient):
|
||||||
login(populate)
|
login(populate)
|
||||||
users = m.User.query.all()
|
users = m.User.query.all()
|
||||||
uc = len(users)
|
uc = len(users)
|
||||||
response = populate.get("/user/delete/1")
|
response = populate.delete("/user/delete/1")
|
||||||
assert m.User.query.count() < uc
|
assert m.User.query.count() < uc
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def test_search_user(populate: FlaskClient):
|
def test_search_user(populate: FlaskClient, runner: FlaskCliRunner):
|
||||||
login(populate)
|
login(populate)
|
||||||
MAX_SEARCH_RESULTS = populate.application.config["MAX_SEARCH_RESULTS"]
|
MAX_SEARCH_RESULTS = populate.application.config["MAX_SEARCH_RESULTS"]
|
||||||
|
|
||||||
|
@ -84,3 +85,18 @@ def test_search_user(populate: FlaskClient):
|
||||||
|
|
||||||
users = response.json.get("users")
|
users = response.json.get("users")
|
||||||
assert not users
|
assert not users
|
||||||
|
|
||||||
|
# add dummmy data
|
||||||
|
runner.invoke(args=["db-populate"])
|
||||||
|
|
||||||
|
response = populate.get("/user/search?q=dummy&book_id=1")
|
||||||
|
assert response.json
|
||||||
|
|
||||||
|
book_1 = db.session.get(m.Book, 1)
|
||||||
|
contributors_ids = [contributor.user_id for contributor in book_1.contributors]
|
||||||
|
|
||||||
|
users = response.json.get("users")
|
||||||
|
assert users
|
||||||
|
for user in users:
|
||||||
|
user_id = user.get("id")
|
||||||
|
assert user_id not in contributors_ids
|
||||||
|
|
Loading…
Reference in New Issue