3 from django
.core
.management
.base
import BaseCommand
5 from mygpo
.decorators
import repeat_on_conflict
6 from mygpo
.core
.models
import Podcast
7 from mygpo
.users
.models
import User
8 from mygpo
.db
.couchdb
.podcast
import podcast_for_url
9 from mygpo
.db
.couchdb
.user
import add_published_objs
12 class Command(BaseCommand
):
14 Makes the specified user a publisher for the specified podcast.
16 The user is specified by its username, the podcast is specified by one of
20 def handle(self
, *args
, **options
):
23 print >> sys
.stderr
, 'Usage: ./manage.py make-publisher <username> <podcast-url-1> [<podcast-url-2> ...]'
28 user
= User
.get_user(username
)
30 print >> sys
.stderr
, 'User %s does not exist' % username
34 podcasts
= map(podcast_for_url
, urls
)
35 ids
= map(Podcast
.get_id
, podcasts
)
36 add_published_objs(user
, ids
)