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')
|
contentid = self.data.get('contentid')
|
||||||
if not contentid:
|
if not contentid:
|
||||||
return None
|
return None
|
||||||
|
data = None
|
||||||
|
content = None
|
||||||
if type == 'list':
|
if type == 'list':
|
||||||
content = List.get(contentid).json(keys=content_keys)
|
content = List.get(contentid)
|
||||||
content['link'] = '/list==' + quote(content['user'] + ':' + content['name'])
|
data = content.json(keys=content_keys)
|
||||||
|
data['link'] = '/list==' + quote(data['user'] + ':' + data['name'])
|
||||||
elif type == 'edit':
|
elif type == 'edit':
|
||||||
content = Edit.get(contentid).json(keys=content_keys)
|
content = Edit.get(contentid)
|
||||||
content['link'] = '/edits' + quote(content['user'] + ':' + content['name'])
|
data = content.json(keys=content_keys)
|
||||||
|
data['link'] = '/edits' + quote(data['user'] + ':' + data['name'])
|
||||||
elif type == 'collection':
|
elif type == 'collection':
|
||||||
content = Collection.get(contentid).json(keys=content_keys)
|
content = Collection.get(contentid)
|
||||||
content['link'] = '/documents/collection==' + quote(content['user'] + ':' + content['name'])
|
data = content.json(keys=content_keys)
|
||||||
else:
|
data['link'] = '/documents/collection==' + quote(data['user'] + ':' + data['name'])
|
||||||
content = None
|
if content and content.status == 'private':
|
||||||
return content
|
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):
|
def json(self, keys=None):
|
||||||
j = {
|
j = {
|
||||||
|
|
|
@ -105,6 +105,6 @@ def getHomeItems(request, data):
|
||||||
qs = models.Item.objects.all().order_by('-active', 'index', 'created')
|
qs = models.Item.objects.all().order_by('-active', 'index', 'created')
|
||||||
if 'active' in data:
|
if 'active' in data:
|
||||||
qs = qs.filter(active=data['active'] is True)
|
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)
|
return render_to_json_response(response)
|
||||||
actions.register(getHomeItems)
|
actions.register(getHomeItems)
|
||||||
|
|
Loading…
Reference in a new issue