Ejemplo n.º 1
0
Archivo: user.py Proyecto: markblog/h5
 def verify_auth_token(token):
     s = Serializer(current_app.config['SECRET_KEY'])
     try:
         data = s.loads(token)
         refresh_token_or_not = True if now() + 600 >= data.get('expire_time') else False
     except:
         return None, None
     return User.query.get(data['id']), refresh_token_or_not
Ejemplo n.º 2
0
 def get(self):
     # to get the latest date
     page = request.args.get('page', default=1, type=int)
     page_size = request.args.get('page_size', default=7, type=int)
     date = request.args.get('date', default=now(), type=int)
     date = int_to_timestamp(date)
     meetings = meeting_services.m_get_meetings_by_page_and_attendance_after_date(
         date, page, page_size)
     return meetings
Ejemplo n.º 3
0
    def get(self, entity_id):

        res = {}
        structure, lowest_level, date_key = asset_services.m_is_lowest_level(
            entity_id)
        res['metricData'] = asset_services.m_get_metrics_data_of_structure(
            entity_id, date_key).to_dict()
        if structure.level == lowest_level:
            res['cardInfo'] = meeting_services.m_get_first_upcoming_meeting_by_entity_id(
                entity_id, int_to_timestamp(now()))
            res['type'] = 'meeting'
        else:
            res['cardInfo'] = asset_services.m_top3_holding_funds(
                entity_id, lowest_level, date_key).to_dict()
            res['type'] = 'top3'
        res['insights'] = chart_services.m_chart_insight(entity_id)

        return res
Ejemplo n.º 4
0
 def generate_auth_token(self, expiration=3600 * 24):
     s = Serializer(current_app.config['SECRET_KEY'], expires_in=expiration)
     return s.dumps({
         'id': self.id,
         'expire_time': now() + expiration
     }).decode('utf-8')