Example #1
0
    def form_valid(self, form):
        location = form.cleaned_data["locations"]
        if location == "":
            nodes.flush_session(self.request)
        else:
            node_backend, node_id = location.split("-", 1)
            self.request.session[nodes.SESSION_KEY] = node_id
            self.request.session[nodes.BACKEND_SESSION_KEY] = node_backend
            self.request.session[nodes.MOCKING_SESSION_KEY] = True

        return super(LocationsView, self).form_valid(form)
Example #2
0
    def form_valid(self, form):
        location = form.cleaned_data['location']

        if location == forms.NO_MOCKING_ID:
            nodes.flush_session(self.request)
        else:
            node_backend, node_id = nodes_models.Node.parse_full_node_id(location)
            self.request.session[nodes.SESSION_KEY] = node_id
            self.request.session[nodes.BACKEND_SESSION_KEY] = node_backend
            self.request.session[nodes.MOCKING_SESSION_KEY] = True

        return super(LocationView, self).form_valid(form)