Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Make go_start_conversation extend BaseGoCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
JayH5 committed Jun 22, 2015
1 parent 98d2d0a commit 65d5771
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions go/base/management/commands/go_start_conversation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from optparse import make_option

from django.core.management.base import BaseCommand, CommandError
from go.base.command_utils import BaseGoCommand, CommandError

from go.base.utils import vumi_api_for_user
from go.base.command_utils import get_user_by_email


class Command(BaseCommand):
class Command(BaseGoCommand):
help = "Tell a conversation to start"

LOCAL_OPTIONS = [
Expand All @@ -18,10 +15,7 @@ class Command(BaseCommand):
default=False,
help='The account to start a conversation for.'),
]
option_list = BaseCommand.option_list + tuple(LOCAL_OPTIONS)

def get_user_api(self, email):
return vumi_api_for_user(get_user_by_email(email))
option_list = BaseGoCommand.option_list + tuple(LOCAL_OPTIONS)

def handle(self, *apps, **options):
email_address = options['email_address']
Expand All @@ -32,7 +26,7 @@ def handle(self, *apps, **options):
if not conversation_key:
raise CommandError('Please provide --conversation-key.')

user_api = self.get_user_api(email_address)
_, user_api = self.mk_user_api(email_address)
conversation = user_api.get_wrapped_conversation(conversation_key)
if conversation is None:
raise CommandError('Conversation does not exist.')
Expand Down

0 comments on commit 65d5771

Please sign in to comment.