示例#1
0
def results():

    last_evaluated_key = request.args.get("last_evaluated_key", None, type=str)
    prev_evaluated_key = request.args.get("prev_evaluated_key", None, type=str)
    entity_type = request.args["entity_type"]
    term = request.args["term"]

    if entity_type == "artist":
        albums = Artist.find_by_name(term)
        # print(dir(albums))
        return render_template("artist-results.html", albums=albums, term=term)
    elif entity_type == "album":
        albums, last_evaluated_key, prev_evaluated_key = Album.find_by_title(
            term, prev_evaluated_key, last_evaluated_key, PAGE_SIZE)
        return render_template(
            "results.html",
            albums=albums,
            term=term,
            entity_type=entity_type,
            last_evaluated_key=last_evaluated_key,
            prev_evaluated_key=prev_evaluated_key,
        )
    elif entity_type == "track":
        albums = Album.find_by_track(term)
        return render_template("results.html",
                               albums=albums,
                               term=term,
                               entity_type=entity_type)
def results():

    last_evaluated_key = request.args.get('last_evaluated_key', None, type=str)
    prev_evaluated_key = request.args.get('prev_evaluated_key', None, type=str)
    entity_type = request.args['entity_type']
    term = request.args['term']

    if entity_type == 'artist':
        artists = Artist.find_by_name(term)
        return render_template('artist-results.html', artists=artists, term=term)
    elif entity_type == 'album':
        albums, last_evaluated_key, prev_evaluated_key = Album.find_by_title(
            term, prev_evaluated_key, last_evaluated_key, PAGE_SIZE)
        return render_template('results.html', albums=albums, term=term,
                               entity_type=entity_type,
                               last_evaluated_key=last_evaluated_key,
                               prev_evaluated_key=prev_evaluated_key)
    elif entity_type == 'track':
        albums = Album.find_by_track(term)
        return render_template('results.html', albums=albums, term=term,
                               entity_type=entity_type)
示例#3
0
def artist_by_name(name):
    albums = Artist.find_by_name(name)
    return render_template("artist.html", albums=albums, artist_name=name)
示例#4
0
 def mutate(self, args, content, info):
     artist = Artist(artistName=args.get('artistName'))
     ok = True
     return CreateArtist(ok=ok, artist=artist)
def artist_by_id(id):
    artist = Artist.get_by_id(id)
    return render_template('artist.html', artist=artist, albums=artist.albums)
示例#6
0
 def test_artist_track1popularity(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.track1popularity
     self.assertEqual(result, 80)
示例#7
0
 def test_artist_imageLink(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.imageLink
     self.assertTrue(isinstance(result, str))
示例#8
0
 def test_artist_track1(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.track1
     self.assertEqual(result, "TiK ToK")
示例#9
0
 def test_artist_followers(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.followers
     self.assertTrue(isinstance(result, int))
示例#10
0
 def test_artist_spotifyID(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.spotifyID
     self.assertTrue(isinstance(result, str))
示例#11
0
 def test_artist_popularity(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.popularity
     self.assertTrue(isinstance(result, int))
示例#12
0
 def test_artist_genres(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.genres
     self.assertTrue(result)  #check not empty
示例#13
0
 def test_artist_bio(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.bio
     self.assertTrue(isinstance(result, str))
示例#14
0
 def test_artist_name(self):
     artist = Artist.create("kesha", "ACL")
     result = artist.name
     self.assertEqual(result, "Kesha")
示例#15
0
from webapp.models import Artist, Concerts

artistlist = Artist.objects.all()
for artist in artistlist:
    artist.delete()
    
concertlist = Concerts.objects.all()
for c in concertlist:
    artist = Artist.create(c.artists[0], c.concertName)
    if artist is not None:
        try:
            artist.save()
        except:
            continue