forked from 0x2620/pandora
remove unpublished lists/edits/collections from home
This commit is contained in:
parent
bd867779f0
commit
743b419d19
2 changed files with 20 additions and 10 deletions
|
@ -99,18 +99,28 @@ class Item(models.Model):
|
|||
contentid = self.data.get('contentid')
|
||||
if not contentid:
|
||||
return None
|
||||
data = None
|
||||
content = None
|
||||
if type == 'list':
|
||||
content = List.get(contentid).json(keys=content_keys)
|
||||
content['link'] = '/list==' + quote(content['user'] + ':' + content['name'])
|
||||
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).json(keys=content_keys)
|
||||
content['link'] = '/edits' + quote(content['user'] + ':' + content['name'])
|
||||
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).json(keys=content_keys)
|
||||
content['link'] = '/documents/collection==' + quote(content['user'] + ':' + content['name'])
|
||||
else:
|
||||
content = None
|
||||
return content
|
||||
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 = {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue