Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
protokollsystem
proto3
Commits
6ae6c26e
Commit
6ae6c26e
authored
Feb 25, 2017
by
Robin Sonnabend
Browse files
Added decision list
parent
a4f71391
Changes
5
Hide whitespace changes
Inline
Side-by-side
models/database.py
View file @
6ae6c26e
...
...
@@ -11,6 +11,7 @@ import os
from
sqlalchemy
import
event
from
sqlalchemy.orm
import
relationship
,
backref
,
sessionmaker
from
sqlalchemy.ext.hybrid
import
hybrid_method
import
config
...
...
@@ -52,6 +53,7 @@ class ProtocolType(db.Model):
return
None
return
candidates
[
0
]
@
hybrid_method
def
has_public_view_right
(
self
,
user
):
return
(
self
.
is_public
or
(
user
is
not
None
and
...
...
@@ -65,12 +67,26 @@ class ProtocolType(db.Model):
return
self
.
has_private_view_right
(
user
)
@
staticmethod
def
get_
avail
able_protocoltypes
(
user
):
def
get_
modifi
able_protocoltypes
(
user
):
return
[
protocoltype
for
protocoltype
in
ProtocolType
.
query
.
all
()
if
protocoltype
.
has_modify_right
(
user
)
]
@
staticmethod
def
get_public_protocoltypes
(
user
):
return
[
protocoltype
for
protocoltype
in
ProtocolType
.
query
.
all
()
if
protocoltype
.
has_public_view_right
(
user
)
]
@
staticmethod
def
get_private_protocoltypes
(
user
):
return
[
protocoltype
for
protocoltype
in
ProtocolType
.
query
.
all
()
if
protocoltype
.
has_private_view_right
(
user
)
]
class
Protocol
(
db
.
Model
):
...
...
server.py
View file @
6ae6c26e
...
...
@@ -18,7 +18,7 @@ from shared import db, date_filter, datetime_filter, date_filter_long, time_filt
from
utils
import
is_past
,
mail_manager
,
url_manager
,
get_first_unused_int
,
set_etherpad_text
,
get_etherpad_text
from
models.database
import
ProtocolType
,
Protocol
,
DefaultTOP
,
TOP
,
Document
,
Todo
,
Decision
,
MeetingReminder
,
Error
from
views.forms
import
LoginForm
,
ProtocolTypeForm
,
DefaultTopForm
,
MeetingReminderForm
,
NewProtocolForm
,
DocumentUploadForm
,
KnownProtocolSourceUploadForm
,
NewProtocolSourceUploadForm
,
ProtocolForm
,
TopForm
,
SearchForm
from
views.tables
import
ProtocolsTable
,
ProtocolTypesTable
,
ProtocolTypeTable
,
DefaultTOPsTable
,
MeetingRemindersTable
,
ErrorsTable
,
TodosTable
,
DocumentsTable
from
views.tables
import
ProtocolsTable
,
ProtocolTypesTable
,
ProtocolTypeTable
,
DefaultTOPsTable
,
MeetingRemindersTable
,
ErrorsTable
,
TodosTable
,
DocumentsTable
,
DecisionsTable
app
=
Flask
(
__name__
)
app
.
config
.
from_object
(
config
)
...
...
@@ -293,7 +293,7 @@ def list_protocols():
@
login_required
def
new_protocol
():
user
=
current_user
()
protocoltypes
=
ProtocolType
.
get_
avail
able_protocoltypes
(
user
)
protocoltypes
=
ProtocolType
.
get_
modifi
able_protocoltypes
(
user
)
form
=
NewProtocolForm
(
protocoltypes
)
upload_form
=
NewProtocolSourceUploadForm
(
protocoltypes
)
if
form
.
validate_on_submit
():
...
...
@@ -549,30 +549,80 @@ def list_todos():
except
(
ValueError
,
TypeError
):
pass
search_term
=
request
.
args
.
get
(
"search"
)
protocoltypes
=
ProtocolType
.
get_
available
_protocoltypes
(
user
)
protocoltypes
=
ProtocolType
.
get_
public
_protocoltypes
(
user
)
search_form
=
SearchForm
(
protocoltypes
)
if
protocoltype_id
is
not
None
:
print
(
protocoltype_id
)
search_form
.
protocoltype
.
data
=
protocoltype_id
protocoltype
=
ProtocolType
.
query
.
filter_by
(
id
=
protocoltype_id
).
first
()
if
search_term
is
not
None
:
search_form
.
search
.
data
=
search_term
base_query
=
Todo
.
query
.
order_by
(
Todo
.
done
).
order_by
(
Todo
.
number
.
desc
())
todos
=
[
todo
for
todo
in
Todo
.
query
.
all
()
if
todo
.
protocoltype
.
has_public_view_right
(
user
)
]
if
protocoltype_id
is
not
None
and
protocoltype_id
!=
-
1
:
base_query
=
base_query
.
filter
(
ProtocolType
.
id
==
protocoltype_id
)
todos
=
[
todo
for
todo
in
todos
if
todo
.
protocoltype
.
id
==
protocoltype_id
]
if
search_term
is
not
None
and
len
(
search_term
.
strip
())
>
0
:
base_query
=
base_query
.
filter
(
Todo
.
description
.
match
(
"%{}%"
.
format
(
search_term
)))
todos
=
[
todo
for
todo
in
todos
if
search_term
.
lower
()
in
todo
.
description
.
lower
()
]
page
=
_get_page
()
page_count
=
int
(
math
.
ceil
(
base_query
.
count
(
)
/
config
.
PAGE_LENGTH
))
page_count
=
int
(
math
.
ceil
(
len
(
todos
)
/
config
.
PAGE_LENGTH
))
if
page
>=
page_count
:
page
=
0
begin_index
=
page
*
config
.
PAGE_LENGTH
end_index
=
(
page
+
1
)
*
config
.
PAGE_LENGTH
todos
=
base_query
.
slice
(
begin_index
,
end_index
).
all
()
# TODO: paginate and search
todos
=
todos
[
begin_index
:
end_index
]
todos_table
=
TodosTable
(
todos
)
return
render_template
(
"todos-list.html"
,
todos
=
todos
,
todos_table
=
todos_table
,
search_form
=
search_form
,
page
=
page
,
page_count
=
page_count
,
page_diff
=
config
.
PAGE_DIFF
,
protocoltype_id
=
protocoltype_id
,
search_term
=
search_term
)
@
app
.
route
(
"/decisions/list"
)
def
list_decisions
():
is_logged_In
=
check_login
()
user
=
current_user
()
protocoltype
=
None
protocoltype_id
=
None
try
:
protocoltype_id
=
int
(
request
.
args
.
get
(
"protocoltype"
))
except
(
ValueError
,
TypeError
):
pass
search_term
=
request
.
args
.
get
(
"search"
)
protocoltypes
=
ProtocolType
.
get_public_protocoltypes
(
user
)
search_form
=
SearchForm
(
protocoltypes
)
if
protocoltype_id
is
not
None
:
search_form
.
protocoltype
.
data
=
protocoltype_id
protocoltype
=
ProtocolType
.
query
.
filter_by
(
id
=
protocoltype_id
).
first
()
if
search_term
is
not
None
:
search_form
.
search
.
data
=
search_term
decisions
=
[
decision
for
decision
in
Decision
.
query
.
all
()
if
decision
.
protocol
.
protocoltype
.
has_public_view_right
(
user
)
]
if
protocoltype_id
is
not
None
and
protocoltype_id
!=
-
1
:
decisions
=
[
decision
for
decision
in
decisions
if
decision
.
protocol
.
protocoltype
.
id
==
protocoltype_id
]
if
search_term
is
not
None
and
len
(
search_term
.
strip
())
>
0
:
decisions
=
[
decision
for
decision
in
decisions
if
search_term
.
lower
()
in
decision
.
content
.
lower
()
]
page
=
_get_page
()
page_count
=
int
(
math
.
ceil
(
len
(
decisions
)
/
config
.
PAGE_LENGTH
))
if
page
>=
page_count
:
page
=
0
begin_index
=
page
*
config
.
PAGE_LENGTH
end_index
=
(
page
+
1
)
*
config
.
PAGE_LENGTH
decisions
=
decisions
[
begin_index
:
end_index
]
decisions_table
=
DecisionsTable
(
decisions
)
return
render_template
(
"decisions-list.html"
,
decisions
=
decisions
,
decisions_table
=
decisions_table
,
search_form
=
search_form
,
page
=
page
,
page_count
=
page_count
,
page_diff
=
config
.
PAGE_DIFF
,
protocoltype_id
=
protocoltype_id
,
search_term
=
search_term
)
@
app
.
route
(
"/document/download/<int:document_id>"
)
def
download_document
(
document_id
):
user
=
current_user
()
...
...
templates/decisions-list.html
0 → 100644
View file @
6ae6c26e
{% extends "layout.html" %}
{% from "macros.html" import render_table, render_form %}
{% block title %}Beschlüsse{% endblock %}
{% macro page_link(page, text) %}
<a
href=
"{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term)}}"
>
{{text}}
</a>
{% endmacro %}
{% block content %}
<div
class=
"container"
>
{{render_form(search_form, class_="form-inline", action_url=url_for("list_decisions"), action_text="Suchen", labels_visible=False, method="GET")}}
{{render_table(decisions_table)}}
<div
class=
"centered"
>
{% if page > page_diff %}
{{page_link(0, "
<
<")}}
{%
endif
%}
{%
for
p
in
range
(
max
(0,
page
-
page_diff
),
min
(
page_count
,
page
+
page_diff
))
%}
{%
if
p
!=
page
%}
{{
page_link
(
p
,
p
+
1)}}
{%
else
%}
Seite
{{
p
+
1}}
{%
endif
%}
{%
endfor
%}
{%
if
page
<
page_count
-
page_diff
%}
{{
page_link
(
page_count
-
1,
"
>
>")}}
{% endif %}
</div>
</div>
{% endblock %}
templates/layout.html
View file @
6ae6c26e
...
...
@@ -22,16 +22,16 @@
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"
#
"
>
Protokolle
</a>
<a
class=
"navbar-brand"
href=
"
{{url_for("
index
")}}
"
>
Protokolle
</a>
</div>
<div
id=
"navbar"
class=
"navbar-collapse collapse"
>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"{{url_for("
index
")}}"
>
Zuhause
</a></li>
{% if check_login() %}
<li><a
href=
"{{url_for("
new_protocol
")}}"
>
Neues Protokoll
</a></li>
{% endif %}
<li><a
href=
"{{url_for("
list_protocols
")}}"
>
Protokolle
</a></li>
<li><a
href=
"{{url_for("
list_todos
")}}"
>
Todos
</a></li>
<li><a
href=
"{{url_for("
list_decisions
")}}"
>
Beschlüsse
</a></li>
{% if check_login() %}
<li><a
href=
"{{url_for("
list_types
")}}"
>
Typen
</a></li>
{% endif %}
...
...
views/tables.py
View file @
6ae6c26e
...
...
@@ -188,6 +188,19 @@ class TodosTable(Table):
todo
.
description
]
class
DecisionsTable
(
Table
):
def
__init__
(
self
,
decisions
):
super
().
__init__
(
"Beschlüsse"
,
decisions
)
def
headers
(
self
):
return
[
"Sitzung"
,
"Beschluss"
]
def
row
(
self
,
decision
):
return
[
Table
.
link
(
url_for
(
"show_protocol"
,
protocol_id
=
decision
.
protocol
.
id
),
decision
.
protocol
.
get_identifier
()),
decision
.
content
]
class
DocumentsTable
(
Table
):
def
__init__
(
self
,
documents
):
super
().
__init__
(
"Anhang"
,
documents
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment