def index(request): context = {} token_key = getattr(settings, 'AGAVE_TOKEN_SESSION_ID') if token_key in request.session: context['session'] = {'agave': json.dumps(request.session[token_key])} context['unreadNotifications'] = get_number_unread_notifications(request) return render(request, 'designsafe/apps/applications/index.html', context)
def get_context_data(self, **kwargs): context = super(DataBrowserTestView, self).get_context_data(**kwargs) logger.info('Get context Data') context['unreadNotifications'] = get_number_unread_notifications(self.request) resource = kwargs.pop('resource', None) if resource is None: if self.request.user.is_authenticated: resource = 'agave' else: resource = 'public' fm_cls = lookup_file_manager(resource) if fm_cls is None: raise Http404('Unknown resource') file_path = kwargs.pop('file_path', None) try: fm = fm_cls(self.request.user) if not fm.is_search(file_path): listing = fm.listing(file_path) else: d = {} d.update(kwargs) d.update(self.request.GET.dict()) listing = fm.search(**d) except ApiException as e: fm = None action_url = e.extra.get('action_url', None) action_label = e.extra.get('action_label', None) if action_url is None and e.response.status_code == 403: action_url = '{}?next={}'.format(reverse('login'), self.request.path) action_label = 'Log in' listing = { 'source': resource, 'id': file_path, '_error': { 'status': e.response.status_code, 'message': e.response.reason, 'action_url': action_url, 'action_label': action_label }, } sources_api = SourcesApi() source_id = resource if source_id == 'agave': if fm is not None and fm.is_shared(file_path): source_id = '$share' else: source_id = 'mydata' current_source = sources_api.get(source_id) sources_list = sources_api.list() context['angular_init'] = json.dumps({ 'currentSource': current_source, 'sources': sources_list, 'listing': listing, 'state': { 'search': fm.is_search(file_path) if fm is not None else False } }) return context
def get_context_data(self, **kwargs): context = super(BasePrivateTemplate, self).get_context_data(**kwargs) context['unreadNotifications'] = get_number_unread_notifications(self.request) return context
from agavepy.agave import Agave, AgaveException
def index(request): context = { 'unreadNotifications': get_number_unread_notifications(request) } return render(request, 'designsafe/apps/workspace/index.html', context)