def admin_collection_copy(request): if request.method != 'POST': raise PopupException(_('POST request required.')) collections = json.loads(request.POST.get('collections')) searcher = DashboardController(request.user) response = { 'result': searcher.copy_collections([collection['id'] for collection in collections]) } return JsonResponse(response)
def admin_collections(request, is_redirect=False, is_mobile=False): existing_hue_collections = DashboardController( request.user).get_search_collections() if request.GET.get('format') == 'json': collections = [] for collection in existing_hue_collections: massaged_collection = collection.to_dict() if request.GET.get('is_mobile'): massaged_collection['absoluteUrl'] = reverse( 'search:index_m') + '?collection=%s' % collection.id massaged_collection['isOwner'] = collection.doc.get().can_write( request.user) collections.append(massaged_collection) return JsonResponse(collections, safe=False) template = 'admin_collections.mako' if is_mobile: template = 'admin_collections_m.mako' return render( template, request, { 'is_embeddable': request.GET.get('is_embeddable', False), 'existing_hue_collections': existing_hue_collections, 'is_redirect': is_redirect })
def index(request, is_mobile=False, is_embeddable=False): hue_collections = DashboardController(request.user).get_search_collections() collection_id = request.GET.get('collection') if not hue_collections or not collection_id: return admin_collections(request, True, is_mobile) try: collection_doc = Document2.objects.get(id=collection_id) if USE_NEW_EDITOR.get(): collection_doc.can_read_or_exception(request.user) else: collection_doc.doc.get().can_read_or_exception(request.user) collection = Collection2(request.user, document=collection_doc) except Exception, e: raise PopupException(e, title=_("Dashboard does not exist or you don't have the permission to access it."))