-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglweb.py
More file actions
52 lines (38 loc) · 1.39 KB
/
glweb.py
File metadata and controls
52 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from flask import Flask, render_template, flash
from gitlab import *
app = Flask(__name__)
app.config.from_object(__name__)
@app.route('/')
def home():
# flash('New entry was successfully posted')
# flash('This is a second flash')
return render_template('home.html')
@app.route('/list')
def list():
return_list = []
if not getToken() or not getURL():
print('use glconfig to configure your GitLab instance.')
else:
gld = glUserData(getURL(), getToken())
gl_data = gld.data()
for i, u in enumerate(gl_data):
if u['state'] == 'active':
return_list.append({
'name': u['name'],
'email': u['email'],
'state': u['state'],
'last_sign_in_at': u['last_sign_in_at'],
'seq': i
})
def getKey(item):
return '{0}{1}'.format(item['last_sign_in_at'], item['name'])
sorted_return_list = sorted(return_list, reverse=True, key=getKey)
for i, item in enumerate(sorted_return_list):
item['seq'] = i+1
sorted_return_list = sorted(sorted_return_list, key=getKey)
return render_template('show_users.html', entries=sorted_return_list)
if __name__ == '__main__':
app.debug = True
# set the secret key. keep this really secret:
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
app.run()