Exemple #1
0
def find_issues(request):
    lat = request.REQUEST.get('lat')
    lon = request.REQUEST.get('lon')

    if lat is None or lon is None:
        raise Http404
        
    nearby_issues = fixmystreet.find_nearby_issues(lat=lat, lon=lon)

    rss_items = []
    
    for issue in nearby_issues:
        issue_url = request.build_absolute_uri( '/issue/' + str(issue['id']) )

        description_start = '<h2><a href="' + issue_url + '">Follow me to play</a></h2><br><br>'

        # Not sure why this is not working... should strip out the 'Report on FixMyStreet' link
        # description_end = ''.join(BeautifulSoup( issue['summary'] ).findAll( lambda tag: tag.name != 'a' ))
        issue_soup = BeautifulSoup(issue['summary'])
        description_end = ' '.join([x for x in issue_soup.contents if isinstance(x, NavigableString)])

        item = GeoRSS.GeoRSSItem(
            title        = issue['name'],
            link         = issue_url,
            description  = description_start + description_end,
            guid         = GeoRSS.Guid( issue_url ),
            pubDate      = datetime.datetime.now(),    # FIXME
            geo_lat    = str(issue['lat']),
            geo_long   = str(issue['lon']),
        )


        rss_items.append( item )

    rss = GeoRSS.GeoRSS(
        title         = "FixMyStreet Game",
        link          = request.build_absolute_uri(),
        description   = "Foo",
        lastBuildDate = datetime.datetime.now(),
        items         = rss_items,
    )
    
    return HttpResponse(
        content = rss.to_xml(),
        content_type = 'application/rss+xml'
    )
Exemple #2
0
def found_you(request):
    lat = request.REQUEST.get('lat')
    lon = request.REQUEST.get('lon')

    nearby_issues = fixmystreet.find_nearby_issues(lat=lat, lon=lon)

    # FIXME - sort out hardcoded domain name
    rss_url = "http://fmsgame.mysociety.org/find_issues?lon=%(lon)s&lat=%(lat)s" %dict(lon=lon, lat=lat)
    google_map_url = "http://maps.google.com/maps?q=%s" %urllib.quote(rss_url)

    extra_context = {
        'google_map_url': google_map_url,
        'issue_count': len(nearby_issues),
        }

    context = context_instance=RequestContext(request)
    return render_to_response('located.html', extra_context, context)
Exemple #3
0
def found_you(request):
    lat = request.REQUEST.get('lat')
    lon = request.REQUEST.get('lon')

    nearby_issues = fixmystreet.find_nearby_issues(lat=lat, lon=lon)

    # FIXME - sort out hardcoded domain name
    rss_url = "http://fmsgame.mysociety.org/find_issues?lon=%(lon)s&lat=%(lat)s" % dict(
        lon=lon, lat=lat)
    google_map_url = "http://maps.google.com/maps?q=%s" % urllib.quote(rss_url)

    extra_context = {
        'google_map_url': google_map_url,
        'issue_count': len(nearby_issues),
    }

    context = context_instance = RequestContext(request)
    return render_to_response('located.html', extra_context, context)
Exemple #4
0
def find_issues(request):
    lat = request.REQUEST.get('lat')
    lon = request.REQUEST.get('lon')

    if lat is None or lon is None:
        raise Http404

    nearby_issues = fixmystreet.find_nearby_issues(lat=lat, lon=lon)

    rss_items = []

    for issue in nearby_issues:
        issue_url = request.build_absolute_uri('/issue/' + str(issue['id']))

        description_start = '<h2><a href="' + issue_url + '">Follow me to play</a></h2><br><br>'

        # Not sure why this is not working... should strip out the 'Report on FixMyStreet' link
        # description_end = ''.join(BeautifulSoup( issue['summary'] ).findAll( lambda tag: tag.name != 'a' ))
        issue_soup = BeautifulSoup(issue['summary'])
        description_end = ' '.join(
            [x for x in issue_soup.contents if isinstance(x, NavigableString)])

        item = GeoRSS.GeoRSSItem(
            title=issue['name'],
            link=issue_url,
            description=description_start + description_end,
            guid=GeoRSS.Guid(issue_url),
            pubDate=datetime.datetime.now(),  # FIXME
            geo_lat=str(issue['lat']),
            geo_long=str(issue['lon']),
        )

        rss_items.append(item)

    rss = GeoRSS.GeoRSS(
        title="FixMyStreet Game",
        link=request.build_absolute_uri(),
        description="Foo",
        lastBuildDate=datetime.datetime.now(),
        items=rss_items,
    )

    return HttpResponse(content=rss.to_xml(),
                        content_type='application/rss+xml')