def forwards(self, orm): print "Generating secret hash codes for existing albums...\n" albums_qs = Album.objects.all(); for album in albums_qs: if not album.secretHash: album.secretHash = Album.generate_secret_hash_for(album) album.save() message = u"%d, %s, %s" % (album.id, album.title, album.secretHash) print(message.encode("ascii", "backslashreplace")) print "\n"
def forwards(self, orm): print "Generating secret hash codes for existing albums...\n" albums_qs = Album.objects.all() for album in albums_qs: if not album.secretHash: album.secretHash = Album.generate_secret_hash_for(album) album.save() message = u"%d, %s, %s" % (album.id, album.title, album.secretHash) print(message.encode("ascii", "backslashreplace")) print "\n"
def random_picks_album_list(context, number_of_random_picks = 4): """ Outputs HTML and JavaScript code needed to render the Random Picks list of albums. """ random_picks = Album.pseudo_random_public_ones(number_of_random_picks) if random_picks: number_of_random_picks = len(random_picks) if number_of_random_picks < 3: number_of_random_picks = 0 random_picks = None elif number_of_random_picks > 4: number_of_random_picks = (number_of_random_picks / 4) * 4 random_picks = random_picks[0:number_of_random_picks] return { "id": new_pseudo_unique_id(), "random_pick_albums": random_picks, "number_of_random_picks": number_of_random_picks, "site_domain": context.get("site_domain") }
def random_picks_album_list(context, number_of_random_picks=4): """ Outputs HTML and JavaScript code needed to render the Random Picks list of albums. """ random_picks = Album.pseudo_random_public_ones(number_of_random_picks) if random_picks: number_of_random_picks = len(random_picks) if number_of_random_picks < 3: number_of_random_picks = 0 random_picks = None elif number_of_random_picks > 4: number_of_random_picks = (number_of_random_picks / 4) * 4 random_picks = random_picks[0:number_of_random_picks] return { "id": new_pseudo_unique_id(), "random_pick_albums": random_picks, "number_of_random_picks": number_of_random_picks, "site_domain": context.get("site_domain") }