Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redeleitsystem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redl
redeleitsystem
Commits
c5901a6a
Commit
c5901a6a
authored
9 years ago
by
Hinrikus Wolf
Browse files
Options
Downloads
Patches
Plain Diff
add current speaker to statements list
parent
a4b6c53f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
migrations/versions/1b175b82cee_.py
+26
-0
26 additions, 0 deletions
migrations/versions/1b175b82cee_.py
models/database.py
+11
-5
11 additions, 5 deletions
models/database.py
modules/admin.py
+9
-3
9 additions, 3 deletions
modules/admin.py
with
46 additions
and
8 deletions
migrations/versions/1b175b82cee_.py
0 → 100644
+
26
−
0
View file @
c5901a6a
"""
empty message
Revision ID: 1b175b82cee
Revises: 3c75c74bb94
Create Date: 2015-11-08 14:06:28.235808
"""
# revision identifiers, used by Alembic.
revision
=
'
1b175b82cee
'
down_revision
=
'
3c75c74bb94
'
from
alembic
import
op
import
sqlalchemy
as
sa
def
upgrade
():
### commands auto generated by Alembic - please adjust! ###
op
.
add_column
(
'
statements
'
,
sa
.
Column
(
'
is_current
'
,
sa
.
Boolean
(),
nullable
=
True
))
### end Alembic commands ###
def
downgrade
():
### commands auto generated by Alembic - please adjust! ###
op
.
drop_column
(
'
statements
'
,
'
is_current
'
)
### end Alembic commands ###
This diff is collapsed.
Click to expand it.
models/database.py
+
11
−
5
View file @
c5901a6a
...
...
@@ -94,9 +94,9 @@ class Topic(db.Model):
def
sorted_statements
(
self
):
statements
=
[
statement
for
statement
in
self
.
statements
if
not
statement
.
executed
]
if
self
.
mode
==
"
fifo
"
:
return
sorted
(
statements
,
key
=
lambda
st
:
-
1
if
st
.
is_meta
else
st
.
id
)
return
sorted
(
statements
,
key
=
lambda
st
:
-
2
if
st
.
is_current
else
-
1
if
st
.
is_meta
else
st
.
id
)
elif
self
.
mode
==
"
balanced
"
:
return
sorted
(
statements
,
key
=
lambda
st
:
-
1
if
st
.
is_meta
else
st
.
speaker
.
count
(
self
))
return
sorted
(
statements
,
key
=
lambda
st
:
-
2
if
st
.
is_current
else
-
1
if
st
.
is_meta
else
st
.
speaker
.
count
(
self
))
else
:
return
statements
...
...
@@ -169,34 +169,40 @@ class Statement(db.Model):
executed
=
db
.
Column
(
db
.
Boolean
)
execution_time
=
db
.
Column
(
db
.
DateTime
)
is_meta
=
db
.
Column
(
db
.
Boolean
,
default
=
False
)
is_current
=
db
.
Column
(
db
.
Boolean
,
default
=
False
)
speaker
=
relationship
(
"
Speaker
"
,
backref
=
backref
(
"
statements
"
,
order_by
=
id
))
topic
=
relationship
(
"
Topic
"
,
backref
=
backref
(
"
statements
"
,
order_by
=
id
))
def
__init__
(
self
,
speaker_id
,
topic_id
,
insertion_time
=
None
,
executed
=
False
,
execution_time
=
None
,
is_meta
=
False
):
def
__init__
(
self
,
speaker_id
,
topic_id
,
insertion_time
=
None
,
executed
=
False
,
execution_time
=
None
,
is_meta
=
False
,
is_current
=
False
):
self
.
speaker_id
=
speaker_id
self
.
topic_id
=
topic_id
self
.
insertion_time
=
insertion_time
or
datetime
.
now
()
self
.
executed
=
executed
self
.
execution_time
=
execution_time
or
datetime
.
now
()
self
.
is_meta
=
is_meta
self
.
is_current
=
is_current
def
__repr__
(
self
):
return
"
<Statement(id={}, speaker={}, topic_id={}, insertion_time={}, executed={}, execution_time={}, is_meta={})>
"
.
format
(
return
"
<Statement(id={}, speaker={}, topic_id={}, insertion_time={}, executed={}, execution_time={}, is_meta={}
, is_current={}
)>
"
.
format
(
self
.
id
,
self
.
speaker
,
self
.
topic_id
,
self
.
insertion_time
,
self
.
executed
,
self
.
execution_time
,
self
.
is_meta
self
.
is_meta
,
self
.
is_current
)
def
done
(
self
):
if
self
.
executed
:
return
False
self
.
executed
=
True
self
.
is_current
=
False
self
.
execution_time
=
datetime
.
now
()
if
self
.
topic
.
sorted_statements
()
is
not
None
and
self
.
topic
.
sorted_statements
():
self
.
topic
.
sorted_statements
()[
0
].
is_current
=
True
return
True
def
undo
(
self
):
...
...
This diff is collapsed.
Click to expand it.
modules/admin.py
+
9
−
3
View file @
c5901a6a
...
...
@@ -282,8 +282,11 @@ def statement_new():
topic
=
Topic
.
query
.
filter_by
(
id
=
form
.
topic
.
data
).
first
()
speaker
=
speaker_by_name_or_number
(
form
.
speaker_name
.
data
,
topic
.
event
.
id
)
if
topic
is
not
None
and
speaker
is
not
None
:
if
speaker
.
count_active
(
topic
)
==
0
or
(
statement
==
"
add_meta_statement
"
and
speaker
.
count_active_meta
(
topic
)
==
0
)
:
statement
=
Statement
(
speaker
.
id
,
topic
.
id
,
is_meta
=
(
statement
==
"
add_meta_statement
"
))
if
speaker
.
count_active
(
topic
)
==
0
or
(
statement
==
"
add_meta_statement
"
and
speaker
.
count_active_meta
(
topic
)
==
0
)
:
statement
=
Statement
(
speaker
.
id
,
topic
.
id
,
is_meta
=
(
statement
==
"
add_meta_statement
"
),
is_current
=
(
not
topic
.
sorted_statements
()))
db
.
session
.
add
(
statement
)
db
.
session
.
commit
()
return
redirect
(
url_for
(
"
.topic_show
"
,
id
=
topic
.
id
))
...
...
@@ -309,12 +312,15 @@ def statement_done():
@admin_permission.require
()
def
statement_delete
():
statement_id
=
request
.
args
.
get
(
"
id
"
,
None
)
topic_id
=
request
.
args
.
get
(
"
topic_id
"
,
None
)
if
statement_id
is
not
None
:
statement
=
Statement
.
query
.
filter_by
(
id
=
statement_id
).
first
()
if
statement
is
not
None
:
topic
=
Topic
.
query
.
filter_by
(
id
=
topic_id
).
first
()
if
len
(
topic
.
sorted_statements
())
>
1
:
topic
.
sorted_statements
()[
1
].
is_current
=
True
db
.
session
.
delete
(
statement
)
db
.
session
.
commit
()
topic_id
=
request
.
args
.
get
(
"
topic_id
"
,
None
)
if
topic_id
is
not
None
:
return
redirect
(
url_for
(
"
.topic_show
"
,
id
=
topic_id
))
return
redirect
(
url_for
(
"
.index
"
))
...
...
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