remove unpublished lists/edits/collections from home

This commit is contained in:
j 2017-02-15 19:07:36 +01:00
parent bd867779f0
commit 743b419d19
2 changed files with 20 additions and 10 deletions

View file

@ -99,18 +99,28 @@ class Item(models.Model):
contentid = self.data.get('contentid')
if not contentid:
return None
if type == 'list':
content = List.get(contentid).json(keys=content_keys)
content['link'] = '/list==' + quote(content['user'] + ':' + content['name'])
elif type == 'edit':
content = Edit.get(contentid).json(keys=content_keys)
content['link'] = '/edits' + quote(content['user'] + ':' + content['name'])
elif type == 'collection':
content = Collection.get(contentid).json(keys=content_keys)
content['link'] = '/documents/collection==' + quote(content['user'] + ':' + content['name'])
else:
data = None
content = None
return content
if type == 'list':
content = List.get(contentid)
data = content.json(keys=content_keys)
data['link'] = '/list==' + quote(data['user'] + ':' + data['name'])
elif type == 'edit':
content = Edit.get(contentid)
data = content.json(keys=content_keys)
data['link'] = '/edits' + quote(data['user'] + ':' + data['name'])
elif type == 'collection':
content = Collection.get(contentid)
data = content.json(keys=content_keys)
data['link'] = '/documents/collection==' + quote(data['user'] + ':' + data['name'])
if content and content.status == 'private':
self.delete()
data = None
return data
def is_public(self):
type = self.data.get('type')
return type == 'custom' or self.get_content() is not None
def json(self, keys=None):
j = {

View file

@ -105,6 +105,6 @@ def getHomeItems(request, data):
qs = models.Item.objects.all().order_by('-active', 'index', 'created')
if 'active' in data:
qs = qs.filter(active=data['active'] is True)
response['data']['items'] = [i.json() for i in qs]
response['data']['items'] = [i.json() for i in qs if i.is_public()]
return render_to_json_response(response)
actions.register(getHomeItems)