list courses v0.1
This commit is contained in:
@@ -105,6 +105,10 @@ def kmltocourse(f):
|
|||||||
|
|
||||||
return polygons
|
return polygons
|
||||||
|
|
||||||
|
from geopy.geocoders import Nominatim
|
||||||
|
geolocator = Nominatim()
|
||||||
|
|
||||||
|
|
||||||
def createcourse(manager,name,polygons):
|
def createcourse(manager,name,polygons):
|
||||||
c = GeoCourse(manager=manager,name=name)
|
c = GeoCourse(manager=manager,name=name)
|
||||||
c.save()
|
c.save()
|
||||||
@@ -115,6 +119,11 @@ def createcourse(manager,name,polygons):
|
|||||||
pp.save()
|
pp.save()
|
||||||
j = 0
|
j = 0
|
||||||
for point in p['points']:
|
for point in p['points']:
|
||||||
|
if i==0 and j==0:
|
||||||
|
loc = geolocator.reverse((point['latitude'],point['longitude']))
|
||||||
|
country = loc.raw['address']['country']
|
||||||
|
c.country = country
|
||||||
|
c.save()
|
||||||
obj = GeoPoint(
|
obj = GeoPoint(
|
||||||
latitude = point['latitude'],
|
latitude = point['latitude'],
|
||||||
longitude = point['longitude'],
|
longitude = point['longitude'],
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import os
|
|||||||
import twitter
|
import twitter
|
||||||
import re
|
import re
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
@@ -31,6 +32,7 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
|
||||||
from rowsandall_app.settings import (
|
from rowsandall_app.settings import (
|
||||||
TWEET_ACCESS_TOKEN_KEY,
|
TWEET_ACCESS_TOKEN_KEY,
|
||||||
TWEET_ACCESS_TOKEN_SECRET,
|
TWEET_ACCESS_TOKEN_SECRET,
|
||||||
@@ -661,6 +663,7 @@ timezones = (
|
|||||||
class GeoCourse(models.Model):
|
class GeoCourse(models.Model):
|
||||||
manager = models.ForeignKey(Rower)
|
manager = models.ForeignKey(Rower)
|
||||||
name = models.CharField(max_length=150,blank=True)
|
name = models.CharField(max_length=150,blank=True)
|
||||||
|
country = models.CharField(max_length=150,blank=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
name = self.name
|
name = self.name
|
||||||
|
|||||||
135
rowers/templates/list_courses.html
Normal file
135
rowers/templates/list_courses.html
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}Rowsandall Courses List{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<style>
|
||||||
|
#mypointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="grid_12">
|
||||||
|
|
||||||
|
<div id="courses_table" class="grid_8 alpha">
|
||||||
|
<h3>Courses</h3>
|
||||||
|
|
||||||
|
{% if courses %}
|
||||||
|
<table width="100%" class="listtable shortpadded">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> Country</th>
|
||||||
|
<th> Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for course in courses %}
|
||||||
|
<td> {{ course.country }} </td>
|
||||||
|
<td> {{ course.name }} </td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p> No courses found </p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="grid_4 omega">
|
||||||
|
<div class="grid_4" id="announcements">
|
||||||
|
{% if announcements %}
|
||||||
|
<h3>What's New?</h3>
|
||||||
|
{% for a in announcements %}
|
||||||
|
<div class="site-announcement-box">
|
||||||
|
<div class="site-announcement">
|
||||||
|
<i>{{ a.created }}:</i>
|
||||||
|
{{ a.announcement|urlize }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<p> </p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="grid_4" id="about">
|
||||||
|
<h3>About</h3>
|
||||||
|
<p>This site is a beta site, pioneering rowing data visualization and analysis. No warranties. The site's author is
|
||||||
|
Sander Roosendaal. A Masters rower.
|
||||||
|
|
||||||
|
Read his <a href="http://blog.rowsandall.com/">blog</a>
|
||||||
|
</p>
|
||||||
|
<div style="text-align: right; padding: 2em">
|
||||||
|
<a href="http://blog.rowsandall.com/">
|
||||||
|
<img src="/static/img/sander.jpg" width="80"></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="grid_6 alpha">
|
||||||
|
{% if rankingonly and not team %}
|
||||||
|
<div class="grid_2 prefix_1 alpha">
|
||||||
|
<a class="button small green" href="/rowers/list-courses">All Courses</a>
|
||||||
|
</div>
|
||||||
|
{% elif not team %}
|
||||||
|
<div class="grid_2 prefix_1 alpha">
|
||||||
|
<a class="button small green" href="/rowers/list-courses/ranking">Ranking Pieces Only</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="grid_2 suffix_1 omega">
|
||||||
|
<a class="button small gray" href="/rowers/courses-join-select">Glue Courses</a>
|
||||||
|
</div>
|
||||||
|
<p> </p>
|
||||||
|
{% if team %}
|
||||||
|
<form id="searchform" action="/rowers/list-courses/team/{{ team.id }}/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
||||||
|
method="get" accept-charset="utf-8">
|
||||||
|
{% else %}
|
||||||
|
<form id="searchform" action="/rowers/list-courses/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
||||||
|
method="get" accept-charset="utf-8">
|
||||||
|
{% endif %}
|
||||||
|
<div class="grid_3 prefix_1 alpha">
|
||||||
|
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
|
||||||
|
</div>
|
||||||
|
<div class="grid_1 omega">
|
||||||
|
<button class="button blue small" type="submit">
|
||||||
|
Search
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 omega">
|
||||||
|
<span class="button gray small">
|
||||||
|
{% if courses.has_previous %}
|
||||||
|
{% if request.GET.q %}
|
||||||
|
<a class="wh" href="?page={{ courses.previous_page_number }}&q={{ request.GET.q }}"><</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="wh" href="?page={{ courses.previous_page_number }}"><</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<span>
|
||||||
|
Page {{ courses.number }} of {{ courses.paginator.num_pages }}.
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% if courses.has_next %}
|
||||||
|
{% if request.GET.q %}
|
||||||
|
<a class="wh" href="?page={{ courses.next_page_number }}&q={{ request.GET.q }}">></a>
|
||||||
|
{% else %}
|
||||||
|
<a class="wh" href="?page={{ courses.next_page_number }}">></a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -143,6 +143,7 @@ urlpatterns = [
|
|||||||
url(r'^u/(?P<userid>\d+)/list-workouts/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.workouts_view),
|
url(r'^u/(?P<userid>\d+)/list-workouts/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.workouts_view),
|
||||||
url(r'^list-workouts/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.workouts_view),
|
url(r'^list-workouts/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.workouts_view),
|
||||||
url(r'^list-workouts/$',views.workouts_view),
|
url(r'^list-workouts/$',views.workouts_view),
|
||||||
|
url(r'^list-courses/$',views.courses_view),
|
||||||
url(r'^addmanual/$',views.addmanual_view),
|
url(r'^addmanual/$',views.addmanual_view),
|
||||||
url(r'^team-compare-select/team/(?P<teamid>\d+)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.team_comparison_select),
|
url(r'^team-compare-select/team/(?P<teamid>\d+)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.team_comparison_select),
|
||||||
url(r'^team-compare-select/team/(?P<teamid>\d+)/$',views.team_comparison_select),
|
url(r'^team-compare-select/team/(?P<teamid>\d+)/$',views.team_comparison_select),
|
||||||
|
|||||||
@@ -6045,6 +6045,19 @@ def boxplot_view(request,userid=0,
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
# List Courses
|
||||||
|
@login_required()
|
||||||
|
def courses_view(request):
|
||||||
|
r = getrower(request.user)
|
||||||
|
|
||||||
|
courses = GeoCourse.objects.all().order_by("country")
|
||||||
|
|
||||||
|
return render(request,'list_courses.html',
|
||||||
|
{'courses':courses,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
# List Workouts
|
# List Workouts
|
||||||
@login_required()
|
@login_required()
|
||||||
def workouts_view(request,message='',successmessage='',
|
def workouts_view(request,message='',successmessage='',
|
||||||
|
|||||||
Reference in New Issue
Block a user