Esempio n. 1
0
def getAccount():
    args = []
    words = queryHotWord()
    logger.info("同步【更新公众号】 热词数量:" + str(len(words)))
    for word in words:
        for i in range(1, 11):
            args.append([word[1], i, word[2]])
    Account.run(args)
    logger.info("同步【更新公众号】 热词数量:结束")
Esempio n. 2
0
 def inject(self, acc):
     """Inject an account object into the dialoge and turn off signals
     from name and number fields whil we edit<br>
     'acc': Account object, supplied by signal
     """
     Account.inject(self, acc)
     self._accObj= acc.copyOfAccount() # Make a new objet for editing
     self.blockSomeSignals(1)
     self.wLineMode.setPixmap(self.imgEdit) #name field is in edit mode
Esempio n. 3
0
 def inject(self, acc):
     """Get the account object from an other dialogue.<br>
     'acc': Account object supplied with signal
     """
     Account.inject(self, acc) # do the basefunction, and then some...
     self._accObj= acc.copyOfAccount()
     self.wAccNum.setText(acc.num)
     self.wAccName.setText(acc.name)
     self.wVat.setCurrentItem(int(acc.defVat))
     self.wBudget.setText(Model.Global.intToMoney(acc.budget))
Esempio n. 4
0
 def __init__(self,parent = None,name = None,modal = 0,fl = 0):
     """Set up New specific fields and signal connections.<br>
     'parent', 'name', 'modal', 'fl': As usual
     """
     Account.__init__(self,parent,name,modal,fl)
     self.setCaption(self.tr('Account new'))
     self.wNew.setText(self.tr('Clear'))
     self.wSave.setEnabled(1)
     #Enable inject in case we want to base the new account on an old
     QObject.connect(parent,PYSIGNAL('accountSelected'), self.inject)
     self.wLineMode.setPixmap(self.imgEdit) #We are not grepping
Esempio n. 5
0
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        """Set up delete specific fields and signal connections.<br>
        'parent', 'name', 'modal', 'fl': As usual
        """
        Account.__init__(self,parent,name,modal,fl)
        self.setCaption(self.tr('Account delete'))
        self.wNew.hide() #not useful for a delete action
        self.wSave.setText(self.tr('Delete')) # more appropriate

        self.wSave.setEnabled(0)
        self.hideAndSuch()    
        QObject.connect(parent,PYSIGNAL('accountSelected'), self.inject)
        QObject.connect(self.wAccName, SIGNAL('textChanged(const QString &)'),
                        self.nameGrep)
        QObject.connect(self.wAccName, SIGNAL('lostFocus()'), self.nameLostFocus)
        QObject.connect(self.wAccNum, SIGNAL('textChanged(const QString &)'),
                        self.accNumChanged)
Esempio n. 6
0
 def __init__(self,parent = None,name = None,modal = 0,fl = 0):
     """Set up Edit specific fields and signal connections.<br>
     'parent', 'name', 'modal', 'fl': As usual
     """
     Account.__init__(self,parent,name,modal,fl)
     self.setCaption(self.tr('Account edit'))
     self.initCombo()
     self.wNew.setText(self.tr('Clear'))
     self.wSave.setEnabled(0)
     #Set up signal slot relations
     QObject.connect(parent,PYSIGNAL('accountSelected'), self.inject)
     QObject.connect(self.wAccName, SIGNAL('textChanged(const QString &)'),
                     self.nameGrep)
     QObject.connect(self.wAccName, SIGNAL('lostFocus()'),
                     self.nameLostFocus)
     QObject.connect(self.wAccNum, SIGNAL('textChanged(const QString &)'),
                     self.accNumChanged)
     self.wSave.setEnabled(0)
Esempio n. 7
0
def getArtByAccount():
    args = []
    rows = Account.getAllAccount()
    logger.info("同步【公众号文章】 公众号数:" + str(len(rows)))
    for row in rows:
        for i in range(1, 2):
            args.append([row[3], row[4], i, row[2]])
    Article.run(args)
    logger.info("同步【公众号文章】 结束")
Esempio n. 8
0
 def register_with_google(self, json_data):
     google_response = urllib.request.urlopen(
         "https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=" +
         json_data["access_token"]).read()
     google_response_json = json.loads(google_response.decode("UTF-8"))
     google_profile_response_json = json.loads(
         urllib.request.urlopen(
             "https://www.googleapis.com/oauth2/v3/userinfo?access_token=" +
             json_data["access_token"]).read().decode('utf-8').replace(
                 '\n', ''))
     account = Account.query.filter_by(
         email=google_response_json['email']).first()
     if account:
         return {
             "status": "failed",
             "message": get_request_message(request, "EXISTENT_ACCOUNT")
         }, 409
     if (json_data["is_artist"]):
         artist = Artist.query.filter_by(
             artistic_name=json_data["artistic_name"]).first()
         if artist:
             return {
                 "status": "failed",
                 "message": get_request_message(request, "EXISTENT_ARTIST")
             }, 409
     account = Account(
         email=google_response_json['email'],
         password=hashlib.sha512(
             "googleaccountpass_OXI8SV7E".encode()).hexdigest(),
         name=google_profile_response_json['given_name'],
         last_name=google_profile_response_json['family_name'],
         creation_date=date.today().strftime("%Y/%m/%d"))
     database.session.add(account)
     database.session.commit()
     result = account_schema.dump(account).data
     if (json_data["is_artist"]):
         artist = Artist(result["account_id"], json_data["artistic_name"])
         database.session.add(artist)
         database.session.commit()
     return {"status": "success", "data": result}, 201
Esempio n. 9
0
    def post(self):
        current_app.logger.info('Processing Account POST')
        json_data = request.get_json(force=True)
        if not json_data:
            current_app.logger.error('No input data given to Account POST')
            return {'message': 'No input data provided', 'error': 'true'}, 400
        # Validate and deserialize input
        data, errors = account_schema.load(json_data)
        if errors:
            current_app.logger.error('Bad data given to Account POST')
            return errors, 422
        # account = Account.query.filter_by(name=data['name']).first()
        # if account:
        #     return {'message': 'Account already exists', 'error': 'true'}, 400
        account = Account(name=json_data['name'],
                          plan_level=json_data['plan_level'])

        db.session.add(account)
        db.session.commit()

        result = account_schema.dump(account).data

        current_app.logger.info('Successful Account POST')
        return {"status": 'success', 'data': result}, 201
Esempio n. 10
0
 def post(self, request_type, method=None):
     json_data = request.get_json()
     if not json_data:
         return {
             "status": "failed",
             "message": get_request_message(request,
                                            "NO_INPUT_DATA_PROVIDED")
         }, 400
     if request_type == "login":
         if method and method == "google":
             return self.login_with_google(json_data)
         account = Account.query.filter_by(
             email=json_data["email"],
             password=hashlib.sha512(
                 json_data["password"].encode()).hexdigest()).first()
         if not account:
             return {
                 "status": "failed",
                 'message': get_request_message(request,
                                                "NON_EXISTENT_ACCOUNT")
             }, 422
         access_token = jwt.encode(
             {
                 "account_id": account.account_id,
                 "exp":
                 datetime.datetime.utcnow() + datetime.timedelta(hours=1)
             }, config.SECRET_KEY)
         return {
             "status": "success",
             "data": account_schema.dump(account).data,
             "access_token": access_token.decode("UTF-8")
         }, 200
     elif request_type == "register":
         if method and method == "google":
             return self.register_with_google(json_data)
         data, errors = account_schema.load(json_data)
         if errors:
             return errors, 422
         account = Account.query.filter_by(email=data['email']).first()
         if account:
             return {
                 "status": "failed",
                 'message': get_request_message(request, "EXISTENT_ACCOUNT")
             }, 409
         if (json_data["is_artist"]):
             artist = Artist.query.filter_by(
                 artistic_name=json_data["artistic_name"]).first()
             if artist:
                 return {
                     "status": "failed",
                     'message': get_request_message(request,
                                                    "EXISTENT_ARTIST")
                 }, 409
         account = Account(email=data['email'],
                           password=hashlib.sha512(
                               data['password'].encode()).hexdigest(),
                           name=data['name'],
                           last_name=data['last_name'],
                           creation_date=date.today().strftime("%Y/%m/%d"))
         database.session.add(account)
         database.session.commit()
         result = account_schema.dump(account).data
         if (json_data["is_artist"]):
             artist = Artist(result["account_id"],
                             json_data["artistic_name"])
             database.session.add(artist)
             database.session.commit()
         return {"status": "success", "data": result}, 201
     else:
         return {
             "status": "failed",
             "message": get_request_message(request,
                                            "INVALID_REQUEST_PROVIDED")
         }, 400