Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
65b6698a
Commit
65b6698a
authored
2 months ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Třídění rolí uživatele
Closes
#442
.
parent
615ba5d1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mo/web/org_users.py
+9
-1
9 additions, 1 deletion
mo/web/org_users.py
mo/web/templates/org_org.html
+1
-1
1 addition, 1 deletion
mo/web/templates/org_org.html
mo/web/templates/org_orgs.html
+1
-1
1 addition, 1 deletion
mo/web/templates/org_orgs.html
with
11 additions
and
3 deletions
mo/web/org_users.py
+
9
−
1
View file @
65b6698a
...
...
@@ -5,7 +5,7 @@ from flask_wtf import FlaskForm
from
sqlalchemy
import
or_
,
select
,
Column
from
sqlalchemy.orm
import
joinedload
,
subqueryload
from
sqlalchemy.orm.query
import
Query
from
typing
import
Optional
,
Set
,
Union
,
List
,
Tuple
from
typing
import
Optional
,
Set
,
Union
,
List
,
Tuple
,
Sequence
import
urllib.parse
import
werkzeug.exceptions
import
wtforms
...
...
@@ -29,6 +29,12 @@ from mo.web.imports import ImportForm, generic_import_page
from
mo.web.util
import
PagerForm
def
sorted_user_roles
(
roles
:
Sequence
[
db
.
UserRole
])
->
List
[
db
.
UserRole
]:
# Používá se ve výpisech rolí jednoho uživatele.
# Doporučujeme preloadnout UserRole.place.
return
sorted
(
roles
,
key
=
lambda
ur
:
(
ur
.
year
or
0
,
ur
.
seq
or
0
,
mo
.
rights
.
role_order_by_type
[
ur
.
role
],
ur
.
place
.
level
,
ur
.
category
or
""
,
ur
.
user_role_id
))
class
UsersFilterForm
(
PagerForm
):
# user
search_name
=
mo_fields
.
String
(
"
Jméno/příjmení
"
,
render_kw
=
{
'
autofocus
'
:
True
})
...
...
@@ -280,6 +286,7 @@ def org_orgs() -> str:
can_edit
=
rr
.
have_right
(
Right
.
edit_orgs
),
can_add
=
rr
.
have_right
(
Right
.
add_orgs
),
can_send_email
=
rr
.
can_send_email
(
count
),
sorted_user_roles
=
sorted_user_roles
,
)
...
...
@@ -411,6 +418,7 @@ def org_org(id: int):
roles_by_type
=
mo
.
rights
.
roles_by_type
,
role_errors
=
role_errors
,
form_add_role
=
form_add_role
,
form_remove_role
=
form_remove_role
,
resend_invite_form
=
resend_invite_form
,
sorted_user_roles
=
sorted_user_roles
,
)
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_org.html
+
1
−
1
View file @
65b6698a
...
...
@@ -54,7 +54,7 @@
<th>
Role
<th>
Oblast
<th>
Ročník
<th>
Kategorie
<th
class=
'has-tip'
title=
'Pořadí kola v kategorii'
>
Kolo
<th>
Přidělil
<th>
Akce
</tr>
</thead>
{% for role in user.roles %}
{% for role in
sorted_user_roles(
user.roles
)
%}
<tr>
<td>
{{ roles_by_type[role.role].name }}
<td><a
href=
"{{ url_for('org_place', id=role.place_id) }}"
>
{{ role.place.type_name() + ": " + role.place.name or '*' }}
</a>
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_orgs.html
+
1
−
1
View file @
65b6698a
...
...
@@ -85,7 +85,7 @@
<td>
{% if user.is_system %}systémový uživatel{% elif user.is_admin %}správce{% elif user.roles|count == 0 %}
<i>
žádná role
</i>
{% endif %}
{% if user.roles|count > 0 %}
<ul>
{% for role in user.roles %}
{% for role in
sorted_user_roles(
user.roles
)
%}
{% if role.user_role_id in marked_roles_id %}
<li><b>
{{ role }}
</b></li>
{% else %}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment