Example #1
0
    def post(self):
        form = loads(self.request.body)
        err = JsOb()
        user = self.current_user
        if not form.get('email'):
            err.email = 'Please input email'
        else:
            emails = form['email'].replace(' ', '').split(';')
            for e in emails:
                if not is_email(e):
                    err.email = 'Email not valid, email=%s' % e
                elif e not in user.email and User.count(dict(email=e, deleted=False)):
                    err.email = "email %s already be used!" % e

        if not form.get('name'):
            err.name = 'Pleast input your name'
        elif form.get('name') != user.account and User.count(dict(account=form.get('name'), deleted=False)):
            err.name = 'name already be used!'

        if not form.get('password'):
            err.password = '******'
        elif form.get('password') != user.password and not is_valid_password(form.get('password')):
            err.password = '******'
        if not err:
            user = User._update_account(form.get('user_id'), **dict(
                email=form.get('email').replace(' ', '').split(';'),
                password=form.get('password'),
                account=form.get('name'),
                skype_id=form.get('skype_id'),
                phone=form.get('phone'),
                role_id=Role.affiliate()._id
            ))
            Affiliate._update(form.get('_id'), **form)
        self.render(err)
Example #2
0
    def post(self):
        err = JsOb()
        form = self.json

        if not form.email:
            err.email = 'Please input email'
        else:
            emails = form.email.replace(' ', '').split(',')
            for e in emails:
                if not is_email(e):
                    err.email = 'Email not valid, email=%s' % e
                elif User.count(dict(email=e, deleted=False)):
                    err.email = "email %s already in use" % e

        if not form.account:
            err.account = 'Pleast input your account'

        if not form.password:
            err.password = '******'
        elif not is_valid_password(form.password):
            err.password = '******'

        kw = dict(email=emails,
                  password=form.password,
                  account=form.account,
                  role_id=form.role_id,
                  skype_id=form.skype_id,
                  phone=form.phone)

        if not err:
            user = User._create(**kw)

        self.render(err)
Example #3
0
    def get(self):
        status = self.get_argument('status', '')
        limit = int(self.get_argument('limit', '100'))
        page = int(self.get_argument('page', '1'))
        skip = (page - 1) * limit

        ads = Advertisers.find(dict(
            status={"$ne": '0'} if not status or status == '0' else status),
                               limit=limit,
                               skip=skip)
        ads_count = Advertisers.count(dict(
            status={"$ne": '0'} if not status or status == '0' else status),
                                      limit=limit,
                                      skip=skip)
        for ad in ads:
            if ad.user_id:
                # offer_count = Offers.count(dict(advertiser=str(ad.user_id)))
                user = User._get(ad.user_id)
                bd = User._get(ad.account_manager)
                ad.account_manager = bd.account
                if ad.pm:
                    pm = User._get(ad.pm)
                    ad.pm = pm.account
                else:
                    ad.pm = ''
                ad['name'] = user.account
                ad['email'] = user.email
                ad['skype_id'] = user.skype_id
                ad._id = user._id
                ad.status = 'Active' if ad.status == '1' else 'Pending'
                # ad.offer_count = offer_count

        self.finish(dict(ads=ads, ads_count=ads_count))
Example #4
0
    def post(self):
        status = self.get_argument('status', '')
        page = int(self.get_argument('page', '1'))
        limit = int(self.get_argument('limit', '100'))
        skip = (page - 1) * limit

        affs = Affiliate.find(
            dict(
                status={"$ne": '0'} if not status or status == '0' else status,
                # account_manager=int(self.current_user_id) if not self.current_user.is_admin else {'$ne': ''}
            ),
            limit=limit,
            skip=skip)
        for aff in affs:
            aff.status = 'Active' if aff.status == '1' else 'Pending'
            user = User._get(aff.user_id)
            if aff.account_manager:
                account_manager = User._get(aff.account_manager)
                aff.account_manager = account_manager.account
            aff['name'] = user.account
            aff['email'] = user.email
            aff['password'] = user.password
            aff['_id'] = user._id
            aff['skype_id'] = user.skype_id
            aff['phone'] = user.phone
            aff['offer_count'] = OAffiliate.count(
                dict(affiliate_id=int(aff._id)))
        affs_count = Affiliate.count(
            dict(
                status={"$ne": '0'} if not status or status == '0' else status,
                # account_manager=int(self.current_user_id) if not self.current_user.is_admin else {'$ne': ''}
            ))

        self.finish(dict(affs=affs, affs_count=affs_count))
Example #5
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 #6
0
    def post(self):
        err = JsOb()
        name = self.json.name
        if not name:
            err.name = u'Advertiser name can\'t be empty!'
        elif User.count(dict(account=name)):
            err.name = u'The name has been used!'
        emails = self.json.email
        if not emails:
            err.email = u'email can\'t be empty!'
        else:
            emails = emails.replace(' ', '').split(',')
            for e in emails:
                if not is_email(e):
                    err.email = u'Email not valid, email=%s' % e
                elif User.count(dict(email=e, deleted=False)):
                    err.email = u"email %s already be used!" % e

        password = self.json.password
        if not is_valid_password(password):
            err.password = u'The password not Valid!'
        skype_id = self.json.skype_id
        country = self.json.country
        account_manager = self.json.account_manager
        if not account_manager:
            err.account_manager = u'BD must selected!'
        pm = self.json.pm
        if not pm:
            err.pm = u'PM must selected!'
        status = self.json.status
        white_list = self.json.white_list
        white_list = white_list.split(',') if white_list else None

        if not err:
            user = User._create(**dict(email=emails,
                                       password=password,
                                       account=name,
                                       role_id=Role.advertiser()._id,
                                       skype_id=skype_id))

            kw = dict(
                user_id=user._id,
                country=country,
                account_manager=int(account_manager)
                if account_manager else None,
                pm=int(pm) if pm else None,
                offer_count=0,
                white_list=white_list,
                status=status,
            )
            advertiser = Advertisers._save(**kw)
            self.finish(dict(advertiser_id=user._id, err=False))
        else:
            self.render(err)
Example #7
0
    def post(self, ad_id):
        err = JsOb()
        content = self.json
        ad = User.find_one(dict(_id=int(content.user_id)))
        if not content.name:
            err.name = u'Advertiser name can\'t be empty!'
        elif content.name != ad.account and User.count(
                dict(account=content.name)):
            err.name = u'The name has been used!'

        if not content.email:
            err.email = u'email can\'t be empty!'
        else:
            emails = content.email.replace(' ', '').split(',')
            for e in emails:
                if not is_email(e):
                    err.email = u'Email not valid, email=%s' % e
                elif e not in ad.email and User.count(
                        dict(email=e, deleted=False)):
                    err.email = u"email %s already be used!" % e

        if content.password != ad.password and not is_valid_password(
                content.password):
            err.password = u'The password not Valid!'

        if not content.account_manager:
            err.bd = u'BD must selected!'

        if not content.pm:
            err.pm = u'PM must selected!'

        if not err:
            user = User._update(
                content.user_id,
                **dict(email=emails,
                       password=content.password,
                       account=content.name,
                       skype_id=content.skype_id,
                       role_id=Role.advertiser()._id))

            kw = dict(
                country=content.country,
                account_manager=int(content.account_manager)
                if content.account_manager else None,
                pm=int(content.pm) if content.pm else None,
                white_list=content.white_list.split(',')
                if content.white_list else None,
                status=content.status,
            )

            advertiser = Advertisers._update(ad_id, **kw)
            self.finish(dict(advertiser_id=user._id, err=False))
        else:
            self.render(err)
Example #8
0
    def get(self, aff_id):
        affiliate = Affiliate.find_one(dict(user_id=int(aff_id)))
        user = User._get(affiliate.user_id)
        spec = dict(deleted=False, role_id=Role.am()._id)
        account_managers = User.find(spec)
        affiliate['account'] = user.account
        affiliate['email'] = user.email
        affiliate['skype_id'] = user.skype_id
        affiliate['phone'] = user.phone
        affiliate['password'] = user.password

        self.render(account_managers=account_managers,
                    affiliate=affiliate,
                    invoice_frequency=InvoiceFrequency)
Example #9
0
    def get(self, ad_id):
        advertiser = Advertisers.find_one(dict(user_id=int(ad_id)))
        white_list = advertiser.white_list
        advertiser.white_list = ','.join(white_list) if white_list else ''
        user = User._get(advertiser.user_id)
        spec = dict(deleted=False, role_id=Role.bd()._id)
        bds = User.find(spec)
        pms = User.find(dict(role_id=Role.pm()._id), deleted=False)
        if user:
            advertiser['name'] = user.account
            advertiser['email'] = ','.join(user.email)
            advertiser['skype_id'] = user.skype_id
            advertiser['password'] = user.password

        self.render(account_managers=bds, pms=pms, advertiser=advertiser)
Example #10
0
    def post(self):
        err = JsOb()
        if not self.json.email:
            err.email = 'Please input email'
        elif not is_email(self.json.email):
            err.email = 'Email not valid'
        if not self.json.password:
            err.password = '******'
        if not self.json.captcha_code:
            err.captcha_code = 'Please input captcha code'
        elif not captcha_verify(self.json.captcha_key, self.json.captcha_code):
            err.captcha_code = 'captcha code incorrect'

        if not err:
            try:
                user = User.verify(self.json.email, self.json.password)
                if user:
                    affiliate = Affiliate.find_one(dict(user_id=int(user._id)))
                    if affiliate:
                        if affiliate.status == '1':
                            self._session_new(self.json.email, user._id)
                            user.last_login = DateTime().current_time
                            user.save()
                        else:
                            err.application = 'The Account is Approving....'
                    else:
                        err.email = 'Affiliate not found, Please call the manager!'
            except UserNotFoundError:
                err.email = "email not found"
            except PasswordNotMatchError:
                err.password = "******"

        self.render(err)
Example #11
0
 def get(self):
     advertiser_extends = Advertisers.find(dict(status='1'))
     ads = User.find(
         dict(_id={'$in': [int(ad.user_id) for ad in advertiser_extends]},
              deleted=False))
     cat = Category._query()
     self.render(ads=ads, cat=cat, countries=c().countries)
Example #12
0
    def send_email(self, pause_date, offer_id):
        offer = Offers.find_one(dict(_id=int(offer_id)))
        offer_affiliate = OAffiliate.find(
            dict(offer_id=int(offer_id), status='1'), dict(affiliate_id=1))
        affiliate_uses = User.find(
            dict(_id={
                "$in":
                [int(off_aff.affiliate_id) for off_aff in offer_affiliate]
            }), dict(email=1))

        emails = map(lambda user: user.email, affiliate_uses)
        if not emails:
            return False
        recivers = reduce(lambda email_1, email_2: email_1.extend(email_2),
                          emails, [])
        content = dict(
            user_id=self.current_user_id,
            model_id=0,
            receiver=recivers,
            message=u'The offer named {offer} will be paused on {pause_date}'.
            format(offer=offer.title, pause_date=pause_date),
            subject=u'Leadhug offer paused notification',
            sender=self.current_user.account)
        EMail._create(**content)
        return True
Example #13
0
    def post(self):
        err = JsOb()
        if not self.json.email:
            err.email = 'Please input email'
        elif not is_email(self.json.email):
            err.email = 'Email not valid'
        if not self.json.password:
            err.password = '******'
        if not self.json.captcha_code:
            err.captcha_code = 'Please input captcha code'
        elif not captcha_verify(self.json.captcha_key, self.json.captcha_code):
            err.captcha_code = 'captcha code incorrect'

        if not err:
            try:
                user = User.verify(self.json.email, self.json.password)
                if user:
                    if user._role == 'Affiliate' or user._role == 'Advertiser':
                        err.email = u'You don\'t have a login permissions!'
                    else:
                        self._session_new(self.json.email, user._id)
                        user.last_login = DateTime().current_time
                        user.save()
            except UserNotFoundError:
                err.email = "email not found"
            except PasswordNotMatchError:
                err.password = "******"

        self.render(err)
Example #14
0
 def post(self):
     password = self.json.password
     _password = User.encrypt_pwd(self.json.password)
     if self.current_user.password != _password:
         res = u'Password Not Right!'
     else:
         res = u'Ok!'
     self.finish(dict(res=res))
Example #15
0
    def post(self, aff_id):
        affiliate_edit = Affiliate.find_one(dict(_id=int(aff_id)))
        user_edit = User._get(affiliate_edit.user_id)
        form = loads(self.request.body)
        err = {}
        if not form.get('email'):
            err['email'] = 'Please input email'
        else:
            emails = form['email'].replace(' ', '').split(',')
            for e in emails:
                if not is_email(e):
                    err['email'] = 'Email not valid, email=%s' % e
                elif e not in user_edit.email and User.count(
                        dict(email=e, deleted=False)):
                    err['email'] = "email %s already be used!" % e

        if not form.get('account'):
            err['account'] = 'Pleast input your account'
        elif form.get('account') != user_edit.account and User.count(
                dict(account=form.get('account'), deleted=False)):
            err['account'] = 'Account already be used!'

        if not form.get('password'):
            err['password'] = '******'
        elif form.get(
                'password') != user_edit.password and not is_valid_password(
                    form.get('password')):
            err['password'] = '******'

        if not form.get('account_manager') and form.get('status') != '0':
            err['account_manager'] = 'Please select Account Manager!'

        if not err:
            kw = dict(
                email=emails,
                password=form.get('password'),
                account=form.get('account'),
                role_id=Role.affiliate()._id,
                skype_id=form.get('skype_id'),
                phone=form.get('phone'),
            )
            user = User._update(user_edit._id, **kw)
            aff = Affiliate._update(aff_id, **form)

        self.finish(dict(err=err if err else False))
Example #16
0
    def post(self):
        err = JsOb()
        user_id = self.json.user_id

        if not user_id:
            err.user_error = u'user_id can\'t be empty!'
            self.render(err)
        if not err:
            user = User._delete(user_id)
            self.finish(dict(user=user))
Example #17
0
 def post(self):
     email = self.get_argument('email')
     password = self.get_argument('password')
     user = User.find_one(dict(email=email, password=password))
     if user:
         affiliate = Affiliate.find_one(dict(user_id=int(user._id)))
         if affiliate:
             if affiliate.status == '1':
                 self._session_new(email, user._id)
                 self.redirect('/report')
Example #18
0
 def get_current_user(self):
     current_user_id = self.current_user_id
     if current_user_id:
         # user = Ob.ob_get(current_user_id)
         user = User.find_one(dict(_id=current_user_id, deleted=False))
         if user is not None:
             return user
         self.clear_cookie(self._USER_COOKIE_NAME, domain="." + HOST)
         self.current_user_id = 0
     o = UserDict()
     return o
Example #19
0
 def get(self, ad_id):
     ad = Advertisers.find_one(dict(user_id=int(ad_id)))
     ad_user = User.find_one(dict(_id=int(ad_id)))
     if ad_user:
         ad['_id'] = ad_user._id
         ad['name'] = ad_user.account
         ad['email'] = ';'.join(ad_user.email)
         ad['skype_id'] = ad_user.skype_id
         bd = User.find_one(dict(_id=ad.account_manager))
         ad['bd'] = bd.account if bd else ''
         pm = User.find_one(dict(_id=ad.pm))
         ad['pm'] = pm.account if pm else ''
         offers_count = Offers.count(dict(advertiser_id=ad_user._id))
         ad['offers_count'] = offers_count
         status_map = {'0': 'Deleted', '1': 'Active', '2': 'Paused'}
         ad['status'] = status_map.get(ad.status)
         ad['white_list'] = ','.join(ad.white_list) if ad.white_list else ''
         self.render(advertiser=ad)
     else:
         self.write('The advertiser not exist!')
Example #20
0
 def get(self, offer_id):
     advertiser_extends = Advertisers.find(dict(status={"$ne": '0'}))
     ads = User.find(
         dict(_id={'$in': [int(ad.user_id) for ad in advertiser_extends]},
              deleted=False))
     cat = Category._query()
     offer = Offers.find_one(dict(_id=int(offer_id)))
     self.render(cat=cat,
                 ads=ads,
                 offer_id=offer_id,
                 offer=offer,
                 countries=c().countries)
Example #21
0
 def get(self):
     user_id = int(self.current_user_id)
     account = Affiliate.find_one(dict(user_id=user_id))
     user = User.find_one(dict(_id=user_id))
     account['name'] = user.account
     account['email'] = ';'.join(user.email)
     account['password'] = user.password
     account['phone'] = user.phone
     account['createdTime'] = user.createdTime
     account['last_login'] = user.last_login
     account['skype_id'] = user.skype_id
     self.render(account=account)
Example #22
0
    def get(self):
        offer_spce = dict(status={"$ne": 0}, is_api={"$ne": True})
        offers = Offers.find(offer_spce, dict(_id=1, title=1))

        affiliate_spec = dict(status={"$ne": 0})
        affiliates = Affiliate.find(affiliate_spec, dict(user_id=1))
        for aff in affiliates:
            user = User.find_one(dict(_id=int(aff.user_id)),
                                 dict(_id=1, account=1))
            if not user:
                continue
            aff['_id'] = user._id
            aff['name'] = user.account

        advertiser_spec = dict(status={"$ne": 0})
        advertisers = Advertisers.find(advertiser_spec, dict(user_id=1))
        for ad in advertisers:
            user = User.find_one(dict(_id=int(ad.user_id)),
                                 dict(_id=1, account=1))
            if not user:
                continue
            ad['_id'] = user._id
            ad['name'] = user.account

        categories = Category.find(dict(status={"$ne": 0}), dict(_id=1,
                                                                 name=1))

        ams = User.find(dict(role_id=Role.am()._id, deleted=False),
                        dict(_id=1, account=1, role_id=1))
        ams = [am for am in ams if am.role_id and am._role == 'AM']
        bds = User.find(dict(role_id=Role.bd()._id, deleted=False),
                        dict(_id=1, account=1, role_id=1))
        bds = [bd for bd in bds if bd.role_id and bd._role == 'BD']
        self.finish(
            dict(offers=offers,
                 affiliates=affiliates,
                 advertisers=advertisers,
                 categories=categories,
                 ams=ams,
                 bds=bds))
Example #23
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 #24
0
 def display_am(doc):
     if doc.get('affiliate_name'):
         affiliate_id = doc.get('affiliate_id')
         doc['AM'] = ''
         if affiliate_id:
             affiliate = Affiliate.find_one(
                 dict(user_id=int(affiliate_id)))
             if affiliate and affiliate.account_manager:
                 am = User.find_one(
                     dict(_id=int(affiliate.account_manager)))
                 doc['AM'] = am.account
     if doc.get('advertisers_name'):
         advertiser_id = doc.get('advertiser_id')
         doc['BD'] = ''
         if advertiser_id:
             advertiser = Advertisers.find_one(
                 dict(user_id=int(advertiser_id)))
             if advertiser and advertiser.account_manager:
                 bd = User.find_one(
                     dict(_id=int(advertiser.account_manager)))
                 doc['BD'] = bd.account
     return doc
Example #25
0
    def post(self):
        err = JsOb()
        user_id = self.json._id
        user_edit = User._get(user_id)
        if not self.json.account:
            err.account = u'Account not be empty!'
        elif self.json.account != user_edit.account and User.count(
                dict(account=self.json.account, deleted=False)):
            err.account = u'Account already in use!'

        if not self.json.email:
            err.email = u'Email not be empty!'
        else:
            emails = self.json.email.replace(' ', '').split(',')
            for e in emails:
                if not is_email(e):
                    err.email = 'Email not valid, email=%s' % e
                elif e not in user_edit.email and User.count(
                        dict(email=e, deleted=False)):
                    err.email = "email %s already in use" % e

        if self.json.password:
            if self.json.password != user_edit.password and not is_valid_password(
                    self.json.password):
                err.password = u'password not valid!'

        if not err:
            content = dict(account=self.json.account,
                           role_id=self.json.role_id,
                           email=emails,
                           password=self.json.password,
                           skype_id=self.json.skype_id,
                           phone=self.json.phone)
            res = User._update(user_id, **content)
            if not res:
                err.update = u'update user:{} failure'.format(user_id)

        self.render(err)
Example #26
0
    def post(self):
        form = loads(self.request.body)
        err = {}
        if not form.get('email'):
            err['email'] = 'Please input email'
        else:
            emails = form['email'].replace(' ', '').split(',')
            for e in emails:
                if not is_email(e):
                    err['email'] = 'Email not valid, email=%s' % e
                elif User.count(dict(email=e, deleted=False)):
                    err['email'] = "email %s already be used!" % e

        if not form.get('account'):
            err['account'] = 'Pleast input your account'
        elif User.count(dict(account=form.get('account'), deleted=False)):
            err['account'] = 'Account already be used!'

        if not form.get('password'):
            err['password'] = '******'
        elif not is_valid_password(form.get('password')):
            err['password'] = '******'

        if not form.get('account_manager'):
            err['account_manager'] = 'Please select Account Manager!'

        if not err:
            kw = dict(email=emails,
                      password=form.get('password'),
                      account=form.get('account'),
                      role_id=Role.affiliate()._id,
                      skype_id=form.get('skype_id'),
                      phone=form.get('phone'))
            user = User._create(**kw)
            form['user_id'] = user._id
            aff = Affiliate._save(**form)

        self.finish(dict(err=err if err else False))
Example #27
0
 def get(self):
     user_id = self.current_user_id
     affiliate = Affiliate.find_one(dict(user_id=int(user_id)))
     user = User.find_one(dict(_id=int(affiliate.account_manager)))
     lastest_offers = Offers.sort_limit(
         [('_id', -1)], 10, dict(status={'$ne': '0'}, is_api={'$ne': True}))
     deloffers = []
     for offer in lastest_offers:
         off_aff = OfferAffiliate.find_one(
             dict(offer_id=int(offer._id), affiliate_id=user_id, deleted=False))
         if off_aff:
             if off_aff.payout:
                 offer.payment = off_aff.payout
             if offer.access_status == '0' and off_aff.status != '1':
                 deloffers.append(offer)
         else:
             if offer.access_status == '0':
                 deloffers.append(offer)
     for i in deloffers:
         lastest_offers.remove(i)
     offer_infos = OfferInfo.sort_limit(
         [('amount', -1)], 10, dict(affiliate_id=user_id))
     # feature offers
     condition = []
     for i in offer_infos:
         condition.append({'_id': i.offer_id})
     if condition:
         high_income_offers = Offers.find(
             {'$or': condition, 'status': {'$ne': '0'}, 'is_api': {'$ne': True}})
         deloffers = []
         for offer in high_income_offers:
             off_aff = OfferAffiliate.find_one(
                 dict(offer_id=int(offer._id), affiliate_id=user_id, deleted=False))
             if off_aff:
                 if off_aff.payout:
                     offer.payment = off_aff.payout
                 if offer.access_status == '0' and off_aff.status != '1':
                     deloffers.append(offer)
             else:
                 if offer.access_status == '0':
                     deloffers.append(offer)
         for i in deloffers:
             high_income_offers.remove(i)
     else:
         high_income_offers = []
     self.render(
         account_manager=user,
         lastest_offers=lastest_offers,
         high_income_offers=high_income_offers,
     )
Example #28
0
def data_init():
    _t = DateTime()
    for r in ['AM', 'Affiliate', 'Advertiser', 'BD', 'PM']:
        role = Role(
            dict(_id=gid(GidKey.role_key),
                 name=r,
                 permission=[],
                 createdTime=_t.current_time,
                 last_update=_t.current_time,
                 deleted=False))
        role.save()

    user = User(
        dict(_id=gid(GidKey.user_key),
             account='admin',
             email=['*****@*****.**'],
             password=User.encrypt_pwd(u'chizicheng521'),
             role_id='',
             is_admin=True,
             createdTime=_t.current_time,
             last_update=_t.current_time,
             last_login=_t.current_time,
             deleted=False))
    user.save()
Example #29
0
    def post(self):
        err = JsOb()
        form = self.json
        if not form.new_password:
            err.password = u'Please input password'
        elif not is_valid_password(form.new_password):
            err.password = u'Password not valid'
        new_password = User.encrypt_pwd(self.json.new_password)

        if not err:
            self.current_user.password = new_password
            self.current_user._id = int(self.current_user_id)
            self.current_user.save()

        self.render(err)
Example #30
0
    def post(self):
        limit = int(self.json.limit)
        page = int(self.json.page)
        if self.current_user.is_admin:
            users = User.find({"deleted": False})
        else:
            users = [self.current_user]
        new_users = []
        for user in users:
            if user._role != 'Affiliate' and user._role != 'Advertiser':
                user['role'] = user._role
                new_users.append(user)

        users_count = len(new_users)
        start = (page - 1) * limit
        end = start + limit
        result = new_users[start:end]
        self.finish(dict(users=result, users_count=users_count))