Beispiel #1
0
    def handle(self, *args, **options):

        reload = 'reload' in args
        retry = 'retry' in args

        map = models.UserPreferences.objects.filter(location__isnull=False).exclude(location__exact='')
        if not reload:
            map = map.filter(location_changed__exact=True)
        geolocator = Nominatim()
        for user in map:
            getLatLong(geolocator, user, retry)

        map = models.UserPreferences.objects.filter(latitude__isnull=False).select_related('user')

        mapcount = map.count()
        f = open('mapcount.json', 'w')
        print >> f, mapcount
        f.close()

        mapcache = ""
        for u in map:
            mapcache += "  {'username': '******',\
  'avatar': '%s',\
  'location': '%s',\
  'icon': '%s',\
  'latlong': new google.maps.LatLng(%f, %f) },\
" % (escape(u.user.username), escape(getUserAvatar(u.user, 200)), escape(u.location), escape(chibiimage(u.best_girl)), u.latitude, u.longitude)
        with open('map.json', 'w') as f:
            f.write(mapcache.encode('UTF-8'))
        f.close()
Beispiel #2
0
def latlong(opt):
    reload, retry = opt['reload'], opt['retry']
    map = models.UserPreferences.objects.filter(
        location__isnull=False).exclude(location__exact='')
    if not reload:
        map = map.filter(location_changed__exact=True)
    geolocator = Nominatim()
    for user in map:
        getLatLong(geolocator, user, retry)

    map = models.UserPreferences.objects.filter(
        latitude__isnull=False).select_related('user')

    mapcount = map.count()
    f = open('mapcount.json', 'w')
    print >> f, mapcount
    f.close()

    mapcache = ""
    for u in map:
        mapcache += "  {'username': '******',\
  'avatar': '%s',\
  'location': '%s',\
  'icon': '%s',\
  'latlong': new google.maps.LatLng(%f, %f) },\
" % (escape(u.user.username), escape(getUserAvatar(u.user,
                                                   200)), escape(u.location),
        escape(
         chibiimage(u.best_girl if u.best_girl else 'Alpaca',
                    small=True,
                    force_first=True)), u.latitude, u.longitude)
    with open('map.json', 'w') as f:
        f.write(mapcache.encode('UTF-8'))
    f.close()
Beispiel #3
0
def _getUserAvatar(user, size=200):
    return getUserAvatar(user, size)
Beispiel #4
0
def gravatar(value, size=200):
    return getUserAvatar(value, size)
def _getUserAvatar(user, size=200):
    return getUserAvatar(user, size)
Beispiel #6
0
def gravatar(value, size=200):
    return getUserAvatar(value, size)