예제 #1
0
 def func_wrapper(request, *args, **kwargs):
     try:
         session = SESSION_DATA.get_session(request)
     except KeyError:
         log_session_error(request)
         return render(request, "stemp/session_not_found.html")
     return func(request, session=session, *args, **kwargs)
예제 #2
0
 def chart_session_store(self, context):
     # Backup current HC to session if view for html is requested,
     # load from session if subsequent view for js is requested.
     session = SESSION_DATA.get_session(self.request)
     if session.highcharts_temp is None:
         context['chart'] = self.build_chart()
         session.highcharts_temp = context['chart']
     else:
         context['chart'] = session.highcharts_temp
         session.highcharts_temp = None
예제 #3
0
def get_clean_session(request):
    """Checks for existing session

    Obtain it using WAM's :class:`wam.user_sessions.sessions.SessionData`
    and delete session data (instantiate
    :class:`stemp_abw.sessions.UserSession`).

    Parameters
    ----------
    request : :obj:`django.core.handlers.wsgi.WSGIRequest`
        Request
    """
    # get current session key
    session_key = request.session.session_key
    # get session (existing or new one if there's none)
    SESSION_DATA.start_session(request, UserSession)
    # if session existed before: delete session data
    if session_key is not None:
        SESSION_DATA.sessions['stemp_abw'][session_key] = UserSession()
예제 #4
0
    def render_to_response(self, context, **response_kwargs):
        session = SESSION_DATA.get_session(self.request)
        results_df = session.simulation.results.layer_results

        options = dict(properties=self.properties,
                       result_property=self.result_property,
                       results_df=results_df,
                       geometry_field=self.geometry_field)
        serializer = ResultLayerDataSerializer(options)
        queryset = self.get_queryset()
        return JsonResponse(serializer.serialize(queryset),
                            safe=True,
                            content_type='application/geo+json')
예제 #5
0
    def get_context_data(self, **kwargs):
        context = super(RegMunEnergyReElDemShareMasterDetailView, self).get_context_data(**kwargs)

        # backup current HC to session if view for html is requested,
        # load from session if subsequent view for js is requested.
        session = SESSION_DATA.get_session(self.request)
        if session.highcharts_temp is None:
            context['chart'] = self.build_chart()
            session.highcharts_temp = context['chart']
        else:
            context['chart'] = session.highcharts_temp
            session.highcharts_temp = None

        return context
예제 #6
0
 def get(request):
     session = SESSION_DATA.get_session(request)
     results = session.simulation.results
     return JsonResponse(results.get_result_charts_data(), safe=True)
예제 #7
0
 def get(request):
     session = SESSION_DATA.get_session(request)
     results = session.simulation.results
     return JsonResponse({'sim_status': results.status}, safe=True)
예제 #8
0
 def func_wrapper(self, request, *args, **kwargs):
     try:
         session = SESSION_DATA.get_session(request)
     except KeyError:
         return render(request, 'stemp_abw/session_not_found.html')
     return func(self, request, session=session, *args, **kwargs)
예제 #9
0
    def get(self, request, *args, **kwargs):
        # Start session (if there's none):
        SESSION_DATA.start_session(request, UserSession)

        context = self.get_context_data()
        return self.render_to_response(context)