Пример #1
0
    def post(self):
        '''For uploading urls to the bands other websites
		'''
        try:
            artist = self.get_artist_from_session()
        except self.SessionError:
            return self.redirect(ARTIST_LOGIN)

        # f**k bitches, accumulate urls
        defined_urls = {
            'bandcamp_url': self.request.get('bandcamp_url', None),
            'facebook_url': self.request.get('facebook_url', None),
            'myspace_url': self.request.get('myspace_url', None),
            'tumblr_url': self.request.get('tumblr_url', None),
            'twitter_url': self.request.get('twitter_url', None),
            'youtube_url': self.request.get('youtube_url', None),
            'website_url': self.request.get('website_url', None)
        }
        # store urls
        for url_id, url in defined_urls.iteritems():
            setattr(artist, url_id, url)

        # store extraneous urls
        other_urls = self.request.get_all('other_urls')
        artist.other_urls = other_urls

        # store the artists email
        email = self.request.get('email', None)
        if email is not None:
            artist.email = email

        #=======================================================================
        # Update city information
        #=======================================================================

        city_name = self.request.get('locality') or ' '
        if city_name is not ' ':
            admin1 = self.request.get('administrative_area_level_1', '') or ' '
            country = self.request.get('country', '') or ' '
            lat = self.request.get('lat')
            lon = self.request.get('lon')
            geo_point = ndb.GeoPt('{},{}'.format(lat, lon))

            # create the global city entity in the db
            city = utils.fetch_city_from_path(country, admin1, city_name,
                                              geo_point)
            # create a version of the city to be stored on the artist
            city_property = city.to_city_property()
            # artist.cities is a list, pass city_property as a singleton
            artist.cities = [
                city_property,
            ]
            # store the city name because, shit will break if we dont
            artist.city = city_name
        # store changes
        artist.put()

        # return to the manage page
        return self.redirect(ARTIST_MANAGE)
Пример #2
0
	def post(self):
		'''For uploading urls to the bands other websites
		'''
		try:
			artist = self.get_artist_from_session()
		except self.SessionError:
			return self.redirect(ARTIST_LOGIN)
		
		# f**k bitches, accumulate urls
		defined_urls = {
			'bandcamp_url' : self.request.get('bandcamp_url',None),
			'facebook_url' : self.request.get('facebook_url',None),
			'myspace_url' : self.request.get('myspace_url',None),
			'tumblr_url' : self.request.get('tumblr_url',None),
			'twitter_url' : self.request.get('twitter_url',None),
			'youtube_url' : self.request.get('youtube_url',None),
			'website_url' : self.request.get('website_url',None)
		}
		# store urls
		for url_id,url in defined_urls.iteritems():
			setattr(artist, url_id, url)
		
		# store extraneous urls
		other_urls = self.request.get_all('other_urls')
		artist.other_urls = other_urls
		
		# store the artists email
		email = self.request.get('email',None)
		if email is not None:
			artist.email = email
		
		#=======================================================================
		# Update city information
		#=======================================================================
		
		
		city_name = self.request.get('locality') or ' '
		if city_name is not ' ':
			admin1 = self.request.get('administrative_area_level_1','') or ' '
			country = self.request.get('country','') or ' '
			lat = self.request.get('lat')
			lon = self.request.get('lon')
			geo_point = ndb.GeoPt('{},{}'.format(lat,lon))
			
			# create the global city entity in the db
			city = utils.fetch_city_from_path(country, admin1, city_name, geo_point)
			# create a version of the city to be stored on the artist
			city_property = city.to_city_property()
			# artist.cities is a list, pass city_property as a singleton
			artist.cities = [city_property,]
			# store the city name because, shit will break if we dont
			artist.city = city_name
		# store changes
		artist.put()
		
		# return to the manage page
		return self.redirect(ARTIST_MANAGE)
Пример #3
0
    def get(self):
        '''
		Adds cities to all the spoofed artists
		'''
        if os.environ['SERVER_SOFTWARE'].startswith('Development') == False:
            self.say('This handler can not be accessed')
            return
        cities = ['c' * i for i in range(1, 10)]
        states = ['s' * i for i in range(1, 10)]
        countries = ['y' * i for i in range(1, 10)]

        city_keys = []
        for y in countries:
            for s in states:
                for c in cities:
                    lat = random.uniform(41.9, 42.9)
                    lon = random.uniform(-70.9, -71.9)
                    #					gstring = '{},{}'.format(lat,lon)
                    geo_point = ndb.GeoPt(lat, lon)
                    city = utils.fetch_city_from_path(y, s, c, geo_point)
                    city_keys.append(city)

#		allston = utils.fetch_city_from_path('United States', 'MA', 'Allston', ndb.GeoPt('42.3539038, -71.1337112'))
#		boston = utils.fetch_city_from_path('United States', 'MA', 'Boston', ndb.GeoPt('42.353, -71.133'))
#		somerville = utils.fetch_city_from_path('United States', 'MA', 'Somerville', ndb.GeoPt('42.3875968, -71.0994968'))
#
#		city_keys = [allston,boston,somerville]
        artists = models.Artist.query().iter(batch_size=50)
        for a in artists:
            #			del a._properties['city_keys']
            #			del a._properties['ghash']
            city = random.choice(city_keys)
            a.cities.append(
                models.CityProperty(city_key=city.key, ghash=city.ghash))
            #			a.ghash = city.ghash
            #			a.city_keys.append(city.key)
            a.put()


#			self.say(a.key)
        self.say('Done!')
Пример #4
0
	def get(self):
		'''
		Adds cities to all the spoofed artists
		'''
		if os.environ['SERVER_SOFTWARE'].startswith('Development') == False:
			self.say('This handler can not be accessed')
			return
		cities = ['c'*i for i in range(1,10)]
		states = ['s'*i for i in range(1,10)]
		countries = ['y'*i for i in range(1,10)]
		
		city_keys = []
		for y in countries:
			for s in states:
				for c in cities:
					lat = random.uniform(41.9,42.9)
					lon = random.uniform(-70.9,-71.9)
#					gstring = '{},{}'.format(lat,lon)
					geo_point = ndb.GeoPt(lat,lon)
					city = utils.fetch_city_from_path(y,s,c,geo_point)
					city_keys.append(city)
					
#		allston = utils.fetch_city_from_path('United States', 'MA', 'Allston', ndb.GeoPt('42.3539038, -71.1337112'))
#		boston = utils.fetch_city_from_path('United States', 'MA', 'Boston', ndb.GeoPt('42.353, -71.133'))
#		somerville = utils.fetch_city_from_path('United States', 'MA', 'Somerville', ndb.GeoPt('42.3875968, -71.0994968'))
#		
#		city_keys = [allston,boston,somerville]
		artists = models.Artist.query().iter(batch_size = 50)
		for a in artists:
#			del a._properties['city_keys']
#			del a._properties['ghash']
			city = random.choice(city_keys)
			a.cities.append(models.CityProperty(city_key = city.key, ghash = city.ghash))
#			a.ghash = city.ghash
#			a.city_keys.append(city.key)
			a.put()
#			self.say(a.key)
		self.say('Done!')