diff --git a/rowers/forms.py b/rowers/forms.py index d3b23329..440e38cb 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -947,7 +947,26 @@ class PlanSelectForm(forms.Form): class CourseSelectForm(forms.Form): - course = forms.ModelChoiceField(queryset=GeoCourse.objects.all()) + course = forms.ModelChoiceField(queryset=GeoCourse.objects.filter()) + + def __init__(self, *args, **kwargs): + course = kwargs.pop('course',None) + manager = kwargs.pop('manager',None) + super(CourseSelectForm,self).__init__(*args,**kwargs) + if course is not None: + print('aap',course) + d_min = 0.5*course.distance + d_max = 2*course.distance + country = course.country + countries = ['unknown',country] + print(countries) + self.fields['course'].queryset = self.fields['course'].queryset.filter( + distance__gt = d_min,distance__lt = d_max, + country__in = countries + ).exclude(id=course.id) + if manager is not None: + self.fields['course'].queryset = self.fields['course'].queryset.filter(manager=manager) + print(self.fields['course'].queryset) class WorkoutSingleSelectForm(forms.Form): workout = forms.ModelChoiceField( diff --git a/rowers/models.py b/rowers/models.py index a3f0d391..c292d8eb 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1221,6 +1221,7 @@ class GeoCourse(models.Model): name = models.CharField(max_length=150,blank=True) country = models.CharField(max_length=150,blank=True) notes = models.CharField(blank=True,max_length=200,verbose_name='Course Notes') + def __str__(self): name = self.name country = self.country @@ -1236,6 +1237,10 @@ class GeoCourse(models.Model): d = d, ) + @property + def coord(self): + return course_coord_center(self) + class GeoCourseEditForm(ModelForm): class Meta: model = GeoCourse diff --git a/rowers/templates/course_view.html b/rowers/templates/course_view.html index 312ee33f..b7c9da70 100644 --- a/rowers/templates/course_view.html +++ b/rowers/templates/course_view.html @@ -30,13 +30,16 @@ Notes{{ course.notes|linebreaks }} + + Manager{{ course.manager }} +
  • {{ mapdiv|safe }} - - + + {{ mapscript|safe }}
  • diff --git a/rowers/templates/list_courses.html b/rowers/templates/list_courses.html index 28b44e50..cff254e8 100644 --- a/rowers/templates/list_courses.html +++ b/rowers/templates/list_courses.html @@ -45,7 +45,7 @@ {{ course.distance }} m - + {% endfor %} @@ -64,6 +64,12 @@

    + {% if location %} +

    + Filter nearby courses + All courses +

    + {% endif %}

    Add Courses

    @@ -79,7 +85,7 @@ {% endfor %}

     

    {% endif %} - +
  • @@ -89,27 +95,27 @@ test pieces and measure the time spent on the course (as opposed to the total duration of a workout). This allows you to row and rank marked courses. - + To create a course, you use Google Earth to mark the start and finish lines using polygons. The process is identical to creating custom courses for the CrewNerd - app. - + app. +

    CrewNerd has published a nice video tutorial of the process. Click here to see the video. The part we're interested in starts at 2:05.

    - +

    In addition to start and finish areas, on rowsandall.com you can add additional polygons to mark areas that you must pass (in that order). This allows for courses with turns around buoys, respecting buoy lines, or respecting traffic - patterns on rivers and lakes. + patterns on rivers and lakes.

    - +