Example #1
0
    def get(self):
        status = {'0': 'Paused', '1': 'Active', '2': 'Pending'}
        offer_id = self.get_argument('offer_id')
        offer = Offers.find_one(dict(_id=int(offer_id)))
        if not offer:
            self.write(u'The offer is not exist!')
            return
        offer.status = status.get(offer.status)
        if offer.advertiser_id:
            ad = User._get(offer.advertiser_id)
            offer['advertiser'] = ad.account if ad else ''

        category = Category.find_one(
            _id=int(offer.category_id)) if offer.category_id else None
        offer['category'] = category.name if category else ''

        category = Category.find_one(
            _id=int(offer.category_id)) if offer.category_id else None
        offer['category'] = category.name if category else ''

        if offer.access_status == '1':
            offer.access_status = 'Public'
        elif offer.access_status == '2':
            offer.access_status = 'Need Approve'
        else:
            offer.access_status = 'Private'

        if offer.platform == '1':
            offer.platform = 'IOS'
        elif offer.platform == '2':
            offer.platform = 'ANDROID'
        elif offer.platform == '0':
            offer.platform = 'All'

        offer_affiliates = OAffiliate._query(offer_ids=[offer_id])
        for off_aff in offer_affiliates:
            affiliate = User.find_one(dict(_id=int(off_aff.affiliate_id)))
            affiliate_extend = Affiliate.find_one(
                dict(user_id=int(off_aff.affiliate_id)))
            if not affiliate_extend or not affiliate_extend.account_manager:
                off_aff['am_name'] = ''
            elif off_aff.status == '1':
                am = User.find_one(
                    dict(_id=int(affiliate_extend.account_manager)))
                off_aff['am_name'] = am.account
            off_aff['affiliate_name'] = affiliate.account if affiliate else ''
            if off_aff.status == '1':
                off_aff['application_status'] = 'Approved'
            elif off_aff.status == '2':
                off_aff['application_status'] = 'Pending'
            else:
                off_aff['application_status'] = 'Rejected'

        self.render(offer=offer, offer_affiliates=offer_affiliates)
Example #2
0
    def get(self):
        offer_ids = self.get_arguments('offer_ids[]')
        active_offer_affiliate = OfferAffiliate._query(offer_ids=offer_ids)

        affiliate_emails = []
        for off_aff in active_offer_affiliate:
            aff_id = off_aff.affiliate_id
            if aff_id:
                aff = User.find_one(dict(_id=int(aff_id)))
                if aff:
                    affiliate_emails.append(','.join(aff.email))

        self.finish(dict(affiliate_emails=affiliate_emails))
Example #3
0
    def get(self, action):
        obj_list = []
        if action == 'affiliate':
            offer_id = self.get_argument('offer_id')
            off_affs = OAffiliates._query(offer_ids=[offer_id])
            obj_ids = [off_aff.affiliate_id for off_aff in off_affs]
            affilate_extends = Affiliate.find(
                dict(account_manager={"$ne": ''}, status={'$ne': '0'}))
            objs = User.find(
                dict(_id={
                    "$in": [
                        int(aff.user_id) for aff in affilate_extends
                        if aff.account_manager
                    ]
                },
                     deleted=False))
            res = dict(affiliates=obj_list)

        elif action == 'offers':
            affiliate_id = self.get_argument('affiliate_id')
            off_affs = OAffiliates._query(affiliate_id=affiliate_id)
            obj_ids = [off_aff.offer_id for off_aff in off_affs]
            objs = Offers.find({
                'status': {
                    '$ne': '0'
                },
                'is_api': {
                    "$ne": True
                }
            })
            res = dict(offers=obj_list)

        for obj in objs:
            if int(obj._id) not in obj_ids:
                obj_list.append(obj)

        self.finish(res)
Example #4
0
    def get(self):
        affiliate_user_id = self.get_argument('affiliate_id')
        affiliate = Affiliate.find_one(dict(user_id=int(affiliate_user_id)))
        affiliate_user = User.find_one(dict(_id=int(affiliate_user_id)))
        if not affiliate or not affiliate_user:
            self.write(u'The affiliate is not exist!')
            return
        affiliate._id = affiliate.user_id
        affiliate['name'] = affiliate_user.account
        affiliate['email'] = affiliate_user.email
        affiliate['skype_id'] = affiliate_user.skype_id

        offer_affiliates = OAffiliate._query(affiliate_id=affiliate._id)
        for off_aff in offer_affiliates:
            offer = Offers.find_one(dict(_id=int(off_aff.offer_id)))
            off_aff['offer_title'] = offer.title if offer else ''
            if off_aff.status == '1':
                off_aff['application_status'] = 'Approved'
            elif off_aff.status == '2':
                off_aff['application_status'] = 'Pending'
            else:
                off_aff['application_status'] = 'Rejected'
        self.render(affiliate=affiliate, offer_affiliates=offer_affiliates)
Example #5
0
 def get(self):
     affiliate_id = self.current_user_id
     off_affs = OfferAffiliate._query(affiliate_id=affiliate_id)
     offer_ids = [off_aff.offer_id for off_aff in off_affs]
     offers = Offers.find(dict(_id={'$in': offer_ids}))
     self.render(countries=_c().countries, offers=offers)