add filters to instances page

This commit is contained in:
Izalia Mae 2020-05-02 02:57:23 -04:00
parent 4f0b99b71a
commit 21368f9886
3 changed files with 19 additions and 11 deletions

View file

@ -22,8 +22,8 @@ summary:hover {
}
#paw_logo_container {
width: 25px;
height: 25px;
width: 50px;
height: 50px;
}
#content {

View file

@ -39,15 +39,12 @@
%h2{'class': 'title'} Requests
%table{'id': 'request', 'class': 'list'}
%tr{'class': 'header'}
%td
%td
-if len(requests) > 0
-for instance in requests
%tr{'class': 'instance'}
%td{'class': 'col1'}
%a{'href': 'https://{{instance.domain}}/about', 'target': '_new'}= instance.domain
%td{'class': 'button'}= instance.software
%form{'action': '/paws/action/add?list=={listtype}', 'method': 'post'}
%input{'name': 'name', 'value': '{{instance.domain}}', 'hidden': None}
%td{'class': 'button'}
@ -68,17 +65,21 @@
-if listtype == 'instances'
%center
%h2{'class': 'title'} Instances
%a{'href': '?'} All
|
%a{'href': '?type=accept'} Accepted
|
%a{'href': '?type=deny'} Denied
%br
%br
%table{'id': 'accept', 'class': 'list'}
%tr{'class': 'header'}
%td
%td
-if len(instances) > 0
-for instance in instances
%tr{'class': 'instance'}
%td{'class': 'col1'}
%a{'href': 'https://{{instance.domain}}/about', 'target': '_new'}= instance.domain
%td{'class': 'button'}= instance.software
%form{'action': '/paws/action/add?list=={listtype}', 'method': 'post'}
%input{'name': 'name', 'value': '{{instance.domain}}', 'hidden': None}
%td{'class': 'button'}
@ -102,6 +103,7 @@
%form{'action': '/paws/action/add', 'method': 'post'}
%td{'class': 'col1'}
%input{'type': 'text', 'name': 'name', 'placeholder': 'mastodon.social'}
%td{'class': 'button'}
%td{'class': 'button'}
%input{'type': 'submit', 'name': 'action', 'value': 'Accept'}
%td{'class': 'col2 button'}

View file

@ -79,10 +79,16 @@ class lists(aiohttp.web.View):
async def get(self):
request = self.request
listtype = request.match_info['list']
state = request.query.get('type', None)
if request['admin']:
if state not in ['accept', 'deny']:
instances = pawsdb.instances.search(query.state != 'request')
else:
instances = pawsdb.instances.search(query.state == state)
requests = pawsdb.instances.search(query.state == 'request')
instances = pawsdb.instances.search(query.state != 'request')
signlist = [line['domain'] for line in pawsdb.whitelist.all()]
signlist.sort()
data = {