Skip to content

Commit

Permalink
🐛 fix redirection from pj generator
Browse files Browse the repository at this point in the history
  • Loading branch information
PitButtchereit committed May 24, 2024
1 parent 4db219d commit 77c80d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tracex_project/patient_journey_generator/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def get_context_data(self, **kwargs):

def form_valid(self, form):
"""Create an empty patient journey instance and save the ID in the orchestrator."""
response = super().form_valid(form)
orchestrator = Orchestrator.get_instance()
form.instance.patient_journey = orchestrator.get_configuration().patient_journey
response = super().form_valid(form)
orchestrator.set_db_objects_id("patient_journey", self.object.id)

return response
Expand All @@ -44,8 +44,6 @@ class JourneyGenerationView(generic.RedirectView):
"""View to inspect the generated patient journey."""

url = reverse_lazy("journey_generator_overview")
template_name = "journey_generation.html"
success_url = reverse_lazy("journey_filter")

def get(self, request, *args, **kwargs):
"""
Expand All @@ -57,8 +55,7 @@ def get(self, request, *args, **kwargs):
orchestrator = Orchestrator()

try:
generated_patient_journey = generate_patient_journey()
configuration = ExtractionConfiguration(patient_journey=generated_patient_journey)
configuration = ExtractionConfiguration(patient_journey=generate_patient_journey())
except Exception as e: # pylint: disable=broad-except
orchestrator.reset_instance()
self.request.session.flush()
Expand Down
1 change: 1 addition & 0 deletions tracex_project/tracex/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def post(self, request):
def get_context_data(self, **kwargs):
"""Return context data and adds a flag indicating whether an API key is set."""
context = super().get_context_data(**kwargs)
self.request.session.flush()
api_key = os.getenv('OPENAI_API_KEY')
context['prompt_for_key'] = not bool(api_key)

Expand Down

0 comments on commit 77c80d1

Please sign in to comment.