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
397978d1
Commit
397978d1
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Enumům přidávám metodu friendly_name()
parent
1eba8913
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
mo/db.py
+9
-3
9 additions, 3 deletions
mo/db.py
mo/rights.py
+5
-6
5 additions, 6 deletions
mo/rights.py
mo/web/org_contest.py
+1
-1
1 addition, 1 deletion
mo/web/org_contest.py
mo/web/templates/org_user.html
+1
-1
1 addition, 1 deletion
mo/web/templates/org_user.html
with
16 additions
and
11 deletions
mo/db.py
+
9
−
3
View file @
397978d1
...
...
@@ -237,9 +237,12 @@ class PartState(MOEnum):
def
choices
(
enum
):
out
=
[]
for
item
in
enum
:
out
.
append
((
item
.
name
,
part_state_names
[
item
]
))
out
.
append
((
item
.
name
,
item
.
friendly_name
()
))
return
out
def
friendly_name
(
self
)
->
str
:
return
part_state_names
[
self
]
part_state_names
=
{
PartState
.
registered
:
'
registrovaný
'
,
...
...
@@ -250,7 +253,6 @@ part_state_names = {
}
class
Participation
(
Base
):
__tablename__
=
'
participations
'
...
...
@@ -285,6 +287,9 @@ class RoleType(MOEnum):
dozor
=
auto
()
opravovatel
=
auto
()
def
friendly_name
(
self
)
->
str
:
return
role_type_names
[
self
]
role_type_names
=
{
RoleType
.
garant
:
'
celostátní garant
'
,
...
...
@@ -294,6 +299,7 @@ role_type_names = {
RoleType
.
opravovatel
:
'
opravovatel
'
,
}
class
UserRole
(
Base
):
__tablename__
=
'
user_roles
'
...
...
@@ -312,7 +318,7 @@ class UserRole(Base):
place
=
relationship
(
'
Place
'
)
def
__str__
(
self
):
parts
=
[
role_type_names
[
self
.
role
]
]
parts
=
[
self
.
role
.
friendly_name
()
]
if
self
.
seq
:
parts
.
append
(
f
"
{
self
.
seq
}
. kola
"
)
if
self
.
year
:
...
...
This diff is collapsed.
Click to expand it.
mo/rights.py
+
5
−
6
View file @
397978d1
...
...
@@ -3,7 +3,6 @@
from
enum
import
Enum
,
auto
from
dataclasses
import
dataclass
from
typing
import
Set
,
List
,
Dict
,
Optional
import
sqlalchemy.orm
as
orm
import
mo.db
as
db
...
...
@@ -28,6 +27,11 @@ class Role:
name
:
str
rights
:
Set
[
Right
]
def
__init__
(
self
,
role
:
db
.
RoleType
,
rights
:
Set
[
Right
]):
self
.
role
=
role
self
.
name
=
role
.
friendly_name
()
self
.
rights
=
rights
# Order in this list represents hierarchy for assign_rights right
# (garant could assign role of garant or garant_kraj, but garant_kraj cannot
...
...
@@ -35,7 +39,6 @@ class Role:
roles
:
List
[
Role
]
=
[
Role
(
role
=
db
.
RoleType
.
garant
,
name
=
db
.
role_type_names
[
db
.
RoleType
.
garant
],
rights
=
{
Right
.
assign_rights
,
Right
.
edit_place
,
...
...
@@ -48,7 +51,6 @@ roles: List[Role] = [
),
Role
(
role
=
db
.
RoleType
.
garant_kraj
,
name
=
db
.
role_type_names
[
db
.
RoleType
.
garant_kraj
],
rights
=
{
Right
.
assign_rights
,
Right
.
edit_place
,
...
...
@@ -61,7 +63,6 @@ roles: List[Role] = [
),
Role
(
role
=
db
.
RoleType
.
garant_okres
,
name
=
db
.
role_type_names
[
db
.
RoleType
.
garant_okres
],
rights
=
{
Right
.
assign_rights
,
Right
.
edit_place
,
...
...
@@ -72,7 +73,6 @@ roles: List[Role] = [
),
Role
(
role
=
db
.
RoleType
.
dozor
,
name
=
db
.
role_type_names
[
db
.
RoleType
.
dozor
],
rights
=
{
Right
.
upload_solutions
,
Right
.
add_users
,
...
...
@@ -80,7 +80,6 @@ roles: List[Role] = [
),
Role
(
role
=
db
.
RoleType
.
opravovatel
,
name
=
db
.
role_type_names
[
db
.
RoleType
.
opravovatel
],
rights
=
{
Right
.
upload_feedback
,
Right
.
edit_points
,
...
...
This diff is collapsed.
Click to expand it.
mo/web/org_contest.py
+
1
−
1
View file @
397978d1
...
...
@@ -267,7 +267,7 @@ def make_contestant_table(round: db.Round, contest: Optional[db.Contest]) -> Tab
'
born_year
'
:
pant
.
birth_year
,
'
region_code
'
:
cell_place_link
(
ct
.
place
,
ct
.
place
.
get_code
()),
'
place_code
'
:
cell_place_link
(
pion
.
place
,
pion
.
place
.
get_code
()),
'
status
'
:
pion
.
state
.
name
,
'
status
'
:
pion
.
state
.
friendly_
name
()
,
})
rows
.
sort
(
key
=
lambda
r
:
r
[
'
sort_key
'
])
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_user.html
+
1
−
1
View file @
397978d1
...
...
@@ -57,7 +57,7 @@
<br>
(ale soutěží v
<a
href=
"{{ url_for('org_place', id=round.place_id) }}"
>
{{ round.place.name }}
</a>
)
{% endif %}
</td>
<td>
{{ round.state.name }}
</td>
<td>
{{ round.state.
friendly_
name
()
}}
</td>
</tr>
{% endfor %}
</table>
...
...
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