Example #1
0
def stations(request, template_name="stations/stations.html"):
    ''' Return a random Station object, Locations, etc. centered on the Station. '''

    random_station = transform(Station.objects.order_by('?')[:1])
    
    stations = transform(Station.objects.all())
    # clone stations list for text use
    stations_text = stations[:]
        
    featured = random_station[0].name

    # remove featured station from text
    for station in stations_text:
            if featured == station.name:
                stations_text.remove(station)
                break
            
    bbox = boundingBox(random_station[0].geometry.y, random_station[0].geometry.x, .57) # .57 places it exactly on radius edge
    
    markerpos = (bbox[0], bbox[1])
                
    return render_to_response(template_name, {
    'stations': stations,
    'stations_text': stations_text,
    'random_station': random_station,
    'markerpos': markerpos,
    'stationname': random_station[0].name,
    'locations' : Location.objects.all(),
    'photos':   Photo.objects.order_by('?')[:20], # random photos.

    }, context_instance=RequestContext(request)
    )
Example #2
0
def near_stations(location):
    ''' finds the closet station from an arbitrary point'''
    distances = []
    stations = transform(Station.objects.all())
    for station in stations:
        distances.append(distance.distance((location.geometry.y, location.geometry.x), (station.latitude, station.longitude)))
    return distances    
Example #3
0
def locations(request, template_name="location/locations.html"):
    locations = Location.objects.order_by('?')[:30]
                    
    return render_to_response(template_name, {
    'stations': transform(Station.objects.all()),
    'locations' : locations
    }, context_instance=RequestContext(request)
    )
Example #4
0
urlpatterns = patterns('',

    url(r'^help/', direct_to_template, {
        "template": "help/main.html",
    }, name="help"),
    
    url(r'^$', direct_to_template, {
        "template": "homepage.html",
            'extra_context': {
            "shares":       process_shares(list(SharedItem.objects.all().order_by("-share_date")[:15])),
            'latest_users': User.objects.all().order_by('-date_joined')[:5],
            'latest_entries': Entry.objects.filter(status=2).order_by('-published')[:5],
            'ideas':        Idea.objects.order_by('?')[:3], # random ideas.
            'photos':       Photo.objects.all().order_by("-date_received")[:10],
            'locations':    Location.objects.all(), # random places.
            'stations':     transform(Station.objects.all()),
            'random_station' :  transform(Station.objects.order_by('?')[:1]) # center on random station.
        },
    }, name="home"),
    
    # pinax provided
    (r'^account/',  include('account.urls')),
    (r'^announcements/', include('announcements.urls')),
    (r'^comments/', include('threadedcomments.urls')),
    (r'^profiles/', include('profiles.urls')),
    (r'^about/',    include('about.urls')),
    (r'^notices/',  include('notification.urls')), # needed for threadedcomments
    (r'^openid/(.*)', PinaxConsumer()),
    (r'^admin/(.*)', admin.site.root),

    # greenline provided