Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
c716b741
Commit
c716b741
authored
Sep 01, 2016
by
Julian Rother
Browse files
Log edits to changelog and enhance changelog page
parent
76ad54b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
db.py
View file @
c716b741
...
...
@@ -99,6 +99,8 @@ def ldapget(user):
conn
=
ldap3
.
Connection
(
'ldaps://rumo.fsmpi.rwth-aachen.de'
,
auto_bind
=
True
)
conn
.
search
(
"ou=users,dc=fsmpi,dc=rwth-aachen,dc=de"
,
"(uid=%s)"
%
user
,
attributes
=
ldap3
.
ALL_ATTRIBUTES
)
if
not
conn
.
entries
:
return
{}
e
=
conn
.
entries
[
0
]
return
{
'uid'
:
user
,
'givenName'
:
e
.
givenName
.
value
,
'sn'
:
e
.
sn
.
value
}
else
:
...
...
server.py
View file @
c716b741
...
...
@@ -132,10 +132,15 @@ def login():
if
request
.
method
==
'GET'
:
return
render_template
(
'login.html'
)
user
,
groups
=
ldapauth
(
request
.
form
.
get
(
'user'
),
request
.
form
.
get
(
'password'
))
if
user
and
'users'
in
groups
:
session
[
'user'
]
=
ldapget
(
user
)
else
:
if
not
user
or
not
'users'
in
groups
:
flash
(
'Login fehlgeschlagen!'
)
return
render_template
(
'login.html'
)
session
[
'user'
]
=
ldapget
(
user
)
dbuser
=
query
(
'SELECT * FROM users WHERE name = ?'
,
user
)
if
not
dbuser
:
query
(
'INSERT INTO users (name, realname, fsacc, level, calendar_key, rfc6238) VALUES (?, ?, ?, 1, "", "")'
,
user
,
session
[
'user'
][
'givenName'
],
user
)
dbuser
=
query
(
'SELECT * FROM users WHERE name = ?'
,
user
)
session
[
'user'
][
'dbid'
]
=
dbuser
[
0
][
'id'
]
return
redirect
(
request
.
values
.
get
(
'ref'
,
url_for
(
'index'
)))
@
app
.
route
(
'/logout'
,
methods
=
[
'GET'
,
'POST'
])
...
...
@@ -164,6 +169,10 @@ def edit():
table
,
id
,
column
=
key
.
split
(
'.'
,
2
)
assert
table
in
tabs
assert
column
in
tabs
[
table
][
2
]
old
=
query
(
'SELECT %s AS value FROM %s WHERE %s = ?'
%
(
column
,
table
,
tabs
[
table
][
1
]),
id
)
query
(
'''INSERT INTO changelog ("when", who, "table", id_key, id_value, field, value_old, value_new, executed)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)'''
,
datetime
.
now
(),
session
[
'user'
][
'dbid'
],
table
,
tabs
[
table
][
1
],
id
,
column
,
old
[
0
][
'value'
],
val
)
query
(
'UPDATE %s SET %s = ? WHERE %s = ?'
%
(
tabs
[
table
][
0
],
column
,
tabs
[
table
][
1
]),
val
,
id
)
query
(
'COMMIT'
)
...
...
@@ -254,4 +263,5 @@ def stats():
@
register_navbar
(
'Changelog'
,
'book'
)
@
mod_required
def
log
():
return
render_template
(
'log.html'
,
changelog
=
query
(
'SELECT * FROM changelog ORDER BY "when" LIMIT 10'
))
changelog
=
query
(
'SELECT * FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY "when" DESC LIMIT 10'
)
return
render_template
(
'log.html'
,
changelog
=
changelog
)
templates/log.html
View file @
c716b741
...
...
@@ -18,7 +18,11 @@
{% for i in changelog %}
<tr>
<td>
{{i.when}}
</td>
{% if i.realname %}
<td>
{{i.realname}} ({{i.who}})
</td>
{% else %}
<td>
{{i.who}}
</td>
{% endif %}
<td>
{{i.path}}
</td>
<td>
"{{i.value_old}}"
</td>
<td>
"{{i.value_new}}"
</td>
...
...
Write
Preview
Supports
Markdown
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