From 03c91df45b5227842579ee5b0a8b52741b6d1cb2 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 14 Nov 2022 21:19:07 +0100 Subject: [PATCH] nog mooier fitleren --- rowers/templates/forcecurve_analysis.html | 21 ++++++++++++----- rowers/templates/instroke_analysis.html | 2 +- rowers/views/analysisviews.py | 28 ++++++++++++++++++----- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/rowers/templates/forcecurve_analysis.html b/rowers/templates/forcecurve_analysis.html index 4582a95b..79638221 100644 --- a/rowers/templates/forcecurve_analysis.html +++ b/rowers/templates/forcecurve_analysis.html @@ -19,7 +19,7 @@

Force Curve Analysis for {{ rower.user.first_name }} {{ rower.user.last_name }}

-
+
    {% if the_div %}
  • @@ -28,6 +28,18 @@
  • {% endif %} +
  • + + {{ searchform.as_table }} + {{ dateform.as_table }} + +
  • + +
  • +
    + {% csrf_token %} + +
  • {% if analyses %} {% for analysis in analyses %}
  • @@ -84,14 +96,11 @@ {% endfor %} {% else %}
  • -

    You have not saved any analyses for {{ rower.user.first_name }}

    +

    No analyses found for {{ rower.user.first_name }}

  • {% endif %} +
-{% csrf_token %} - - - {% endblock %} diff --git a/rowers/templates/instroke_analysis.html b/rowers/templates/instroke_analysis.html index e7016c13..df08a4c4 100644 --- a/rowers/templates/instroke_analysis.html +++ b/rowers/templates/instroke_analysis.html @@ -95,7 +95,7 @@ {% endfor %} {% else %}
  • -

    You have not saved any analyses for {{ rower.user.first_name }}

    +

    No analyses found for {{ rower.user.first_name }}

  • {% endif %} diff --git a/rowers/views/analysisviews.py b/rowers/views/analysisviews.py index 26a765dd..eda36d47 100644 --- a/rowers/views/analysisviews.py +++ b/rowers/views/analysisviews.py @@ -1974,12 +1974,26 @@ class SavedAnalysisView(UserPassesTestMixin, View): self.searchform = SearchForm() if query: query_list = query.split() - self.analyses = self.analyses.filter( - reduce(operator.and_, - (Q(name__icontains=q) for q in query_list)) | - reduce(operator.and_, - (Q(notes__icontains=q) for q in query_list)) - ) + if self.analysis_class == InStrokeAnalysis: + self.analyses = self.analyses.filter( + reduce(operator.and_, + (Q(name__icontains=q) for q in query_list)) | + reduce(operator.and_, + (Q(notes__icontains=q) for q in query_list)) | + reduce(operator.and_, + (Q(metric__icontains=q) for q in query_list)) | + reduce(operator.and_, + (Q(workout__name__icontains=q) for q in query_list)) + ) + else: + self.analyses = self.analyses.filter( + reduce(operator.and_, + (Q(name__icontains=q) for q in query_list)) | + reduce(operator.and_, + (Q(notes__icontains=q) for q in query_list)) | + reduce(operator.and_, + (Q(workout__name__icontains=q) for q in query_list)) + ) self.searchform = SearchForm(initial={'q': query}) date_initial = {} if startdate: @@ -2023,6 +2037,8 @@ class SavedAnalysisView(UserPassesTestMixin, View): 'the_script': self.script, 'the_div': self.div, 'selected': self.selected, + 'searchform': self.searchform, + 'dateform': self.dateform, })