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/interactiveplots.py b/rowers/interactiveplots.py index 6ad25d6a..c564f16f 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -1868,7 +1868,7 @@ def course_map(course): var mymap = L.map('map_canvas', {{ center: [{latmean}, {lonmean}], zoom: 13, - layers: [streets, satellite] + layers: [outdoors] }}).setView([{latmean},{lonmean}], 13); var navionics = new JNC.Leaflet.NavionicsOverlay({{ @@ -2076,7 +2076,7 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}): 'time':time-time[0], }) data.append(df) - except Workout.DoesNotExist: + except (Workout.DoesNotExist,KeyError): pass diff --git a/rowers/models.py b/rowers/models.py index f3a540f4..dcebd24e 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -25,7 +25,8 @@ import re import pytz from django_countries.fields import CountryField -from scipy.interpolate import splprep, splev, CubicSpline +from scipy.interpolate import splprep, splev, CubicSpline,interp1d + import numpy as np import shutil @@ -438,8 +439,10 @@ def course_spline(coordinates): tnew = np.linspace(0,1,100) try: - latnew = CubicSpline(t,latitudes,bc_type='clamped')(tnew) - lonnew = CubicSpline(t,longitudes,bc_type='clamped')(tnew) + #latnew = CubicSpline(t,latitudes,bc_type='not-a-knot')(tnew) + #lonnew = CubicSpline(t,longitudes,bc_type='not-a-knot')(tnew) + latnew = interp1d(t,latitudes)(tnew) + lonnew = interp1d(t,longitudes)(tnew) except ValueError: latnew = latitudes lonnew = longitudes @@ -1225,6 +1228,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 @@ -1240,6 +1244,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/plannedsessions.py b/rowers/plannedsessions.py index 7f4d23c0..709ccf1d 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -1400,7 +1400,7 @@ def default_class(r,w,race): agemin__lt=age,agemax__gt=age ).order_by( "agemax","-agemin","boattype","sex", - "weightcategory","referencespeed") + "weightclass","referencespeed") if standards.count()==0: # boolean, boattype, boatclass, adaptiveclass, weightclass, sex, coursestandard, diff --git a/rowers/tasks.py b/rowers/tasks.py index f573ec44..26ef86e3 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -450,6 +450,8 @@ def handle_check_race_course(self, t = time.localtime() timestamp = time.strftime('%b-%d-%Y_%H%M', t) f.write('\n') + f.write('Course id {n}, Record id {m}'.format(n=courseid,m=recordid)) + f.write('\n') f.write(timestamp) f.write(' ') f.write('Found {n} entrytimes'.format(n=len(entrytimes))) 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 @@
+ Filter courses closest to you + {{ city }} {{ country_name }} {{ time_zone }} +
++ All courses +
+ {% endif %} @@ -79,7 +88,7 @@ {% endfor %}{% endif %} - +
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.
- +
You are allowed to have multiple courses in one KML file. Your CrewNerd "courses.kml" file works out of the box
- +The site doesn't test for duplicate courses.
-
+ +Click on the challenge name or on the Details button to see the challenge details (and manage your participation and results). Click on the course name to see the course details.
+ {% if location %} ++ Challenges in your area + {{ city }} {{ country_name }} {{ time_zone }} +
++ All Challenges +
+ {% endif %}