Esempio n. 1
0
def add_contributor(username):
    """
    Used when adding an existent contributor to an existent album
    """
    try:
        get_contributor_by_username(username)
        raise AttributeError("%s username alredy exists" % username)
    except DynamoDBKeyNotFoundError:
        pass
    
   # print( "Username: %s" % username)
    contrib = Contributor(username=username)
    contrib.save()
    return contrib
Esempio n. 2
0
def add_contributor_album(slug, username):
    """
    Used when adding an existent contributor to an existent album
    """
    contrib = Contributor.get(username)
    album = Album.get(slug)
    ContributorAlbum(slug=album.slug, username=contrib.username).save()
Esempio n. 3
0
def get_contributors():
    return Contributor.scan({})
Esempio n. 4
0
def get_album_contributors(album):
    return [Contributor.get(x.username) for x in ContributorAlbum.scan({"slug": condition.EQ(album.slug)})]
Esempio n. 5
0
def delete_contributor_by_username(username):
    Contributor.get(username).delete()
    [x.delete() for x in ContributorAlbum.scan({"username": condition.EQ(username)})]
Esempio n. 6
0
def get_contributor_by_username(username):
    return Contributor.get(username)