Пример #1
0
 def new_campaign(self, struct):
     '''
         New campaign
     '''
     try:
         campaign = campaigns.Campaign(struct)
         campaign.validate()
         campaign = clean_structure(campaign)
     except Exception, e:
         logging.error(e)
         raise e
Пример #2
0
 def replace_campaign(self, account, campaign_uuid, struct):
     '''
         Replace campaign
     '''
     try:
         campaign = campaigns.Campaign(struct)
         campaign.validate()
         campaign = clean_structure(campaign)
     except Exception, e:
         logging.error(e)
         raise e
Пример #3
0
 def modify_campaign(self, account, campaign_uuid, struct):
     '''
         Modify campaign
     '''
     try:
         campaign = campaigns.ModifyCampaign(struct)
         campaign.validate()
         campaign = clean_structure(campaign)
     except Exception, e:
         logging.error(e)
         raise e
Пример #4
0
    def new_contact(self, struct):
        '''
            New contact event
        '''
        # currently we are changing this in two steps, first create de index with a structure file
        search_index = 'sparta_index'
        # on the riak database with riak-admin bucket-type create `bucket_type`
        # remember to activate it with riak-admin bucket-type activate
        bucket_type = 'sparta'
        # the bucket name can be dynamic
        bucket_name = 'leads'

        try:
            event = contacts.Contact(struct)
            event.validate()
            event = clean_structure(event)
        except Exception, e:
            raise e
Пример #5
0
 def get_campaign(self, account, campaign_uuid):
     '''
         Get campaign
     '''
     message = None
     try:
         result = yield self.db.campaigns.find_one(
             {
             'account':account,
             'uuid':campaign_uuid},
             {'_id':0}
         )
         if result:
             campaign = campaigns.Campaign(result)
             campaign.validate()
             message = clean_structure(campaign)
     except Exception, e:
         logging.exception(e)
         raise e
Пример #6
0
    def new_directory(self, struct, callback):
        '''
            New mango account
        '''
        account_type = struct['account_type']

        try:
            if 'user' in account_type:
                account = accounts.User(struct)
            elif 'org' in account_type:
                account = accounts.Org(struct)
            else:
                callback(None, account_type)
                return

            account.validate()
            account = clean_structure(account)

        except Exception, e:
            callback(None, e)
            return