Archived
Filter list of lists
Also add gunicorn dep
This commit is contained in:
1 parent
5ab8aff240
commit
aaaa03a2c7
3 files changed
+44
-8
No files matched your search
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
from contextlib import contextmanager as _contextmanager
|
||||
from fabric.api import run, sudo, env, cd, prefix
|
||||
|
||||
env.use_ssh_config = True
|
||||
env.hosts = ['lynx.neuf.no']
|
||||
env.project_path = '/var/www/neuf.no/mailman2-api-minimal'
|
||||
env.user = 'gitdeploy'
|
||||
env.activate = 'source {}/venv/bin/activate'.format(env.project_path)
|
||||
|
||||
|
||||
@_contextmanager
|
||||
def virtualenv():
|
||||
with cd(env.project_path), prefix(env.activate):
|
||||
yield
|
||||
|
||||
|
||||
def deploy():
|
||||
with virtualenv():
|
||||
run('git pull') # Get source
|
||||
run('pip install -r requirements.txt') # install deps in virtualenv
|
||||
|
||||
# Reload mxapi.neuf.no
|
||||
sudo('/usr/bin/supervisorctl pid mailman-api.neuf.no | xargs kill -HUP', shell=False)
|
||||
+19
-7
@@ -28,12 +28,12 @@ def list_lists_with_members():
|
||||
dest_regex = request.args.get('destination_regex')
|
||||
|
||||
lists_w_members = []
|
||||
for listname in Utils.list_names():
|
||||
if listname == 'mailman':
|
||||
for list_name in Utils.list_names():
|
||||
if list_name == 'mailman':
|
||||
continue
|
||||
|
||||
mlist = MailList.MailList(listname, lock=False)
|
||||
source = mlist.GetListEmail()
|
||||
m_list = MailList.MailList(list_name, lock=False)
|
||||
source = m_list.GetListEmail()
|
||||
|
||||
# Correct domain
|
||||
if domain_name and not source.split()[-1].endswith(domain_name):
|
||||
@@ -43,7 +43,7 @@ def list_lists_with_members():
|
||||
if source_regex and not matches_regex(source_regex, source):
|
||||
continue
|
||||
|
||||
destinations = mlist.getMembers()
|
||||
destinations = m_list.getMembers()
|
||||
|
||||
# Matching at least one destination
|
||||
if dest_regex and not matches_regex(dest_regex, "\n".join(destinations)):
|
||||
@@ -53,7 +53,7 @@ def list_lists_with_members():
|
||||
'destinations': destinations,
|
||||
'name': source,
|
||||
'type': 'mailman',
|
||||
'admin_url': 'https://lists.neuf.no/admin/{}/'.format(listname),
|
||||
'admin_url': 'https://lists.neuf.no/admin/{}/'.format(list_name),
|
||||
'admin_type': 'selfservice',
|
||||
'num': len(destinations)
|
||||
})
|
||||
@@ -66,7 +66,19 @@ def list_lists_with_members():
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def list_lists():
|
||||
return jsonify({'lists': Utils.list_names()})
|
||||
all_lists = Utils.list_names()
|
||||
email = request.args.get('email')
|
||||
if not email:
|
||||
return jsonify({'lists': all_lists})
|
||||
|
||||
lists = []
|
||||
for list_name in all_lists:
|
||||
m_list = MailList.MailList(list_name, lock=False)
|
||||
members = m_list.getMembers()
|
||||
if email in members:
|
||||
lists.append(list_name)
|
||||
|
||||
return jsonify({'lists': lists})
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
Flask==0.10.1
|
||||
Flask==0.12.2
|
||||
gunicorn==19.7.1
|
||||
Reference in new issue
Block a user