# Path: apis/helpers.py
# def split_datetime(datetime, date_format="YYYY-MM-DD", time_format="HH:MM"):
#     '''
#     :param datetime: datetime object
#     :return: date str and time str ex: 2017-03-02, 12:09
#     '''
#     tzinfo = tz.gettz('Asia/Shanghai')
#     adatetime = arrow.Arrow.fromdate(datetime).to(tzinfo)
#     return adatetime.format(date_format), adatetime.format(time_format)
# 
# Path: apis/models/oauth.py
# class Account(Document):
# 
#     '''
#     帐号
#     :param _id: account ID
#     :param username: 用户ID
#     :param created_time: 创建时间
#     :param password: 密码
#     :param authentications: 认证信息 {'wxapp': 'openid', 'mobile': 'mobile_num'}
#     :param status: 状态(active|发布|forbidden)
#     '''
# 
#     meta = {
#         'collection': 'account',
#         'indexes': [
#             '$username',  # text index
#         ]
#     }
# 
#     id = ObjectIdField(primary_key=True, required=True)
#     nickname = StringField(required=True)
#     avatar = StringField(required=True)
#     username = StringField()
#     password = StringField()
#     authentications = EmbeddedDocumentField(Authentications)
#     created_time = DateTimeField(default=datetime.utcnow())
#     updated_time = DateTimeField()
# 
#     @classmethod
#     def get_by_wxapp(cls, openid):
#         account = cls.objects(authentications__wxapp=openid).first()
#         return account


from datetime import datetime
from weixin.helper import smart_str
from mongoengine import EmbeddedDocument, Document
from mongoengine.fields import (StringField, DateTimeField,
                                ObjectIdField, DictField, IntField,
                                ListField, ReferenceField,
                                BooleanField)
from apis.helpers import split_datetime
from apis.models.oauth import Account
            ('creator_id', 'status', '-created_time'),
            ('is_sticky', 'status', '-order_score'),
            ('is_digest', 'status', '-order_score'),
            ('status', '-participate_number')
        ]
    }

    @property
    def creator(self):
        account = Account.objects(id=self.creator_id).first()
        return account

    def get_start_time_value(self):
        if self.start_time:
            date_start, time_start = split_datetime(self.start_time)
            return date_start, time_start
        return None, None

    @property
    def time_start(self):
        _, time_start = self.get_start_time_value()
        return time_start

    @property
    def date_start(self):
        date_start, _ = self.get_start_time_value()
        return date_start

    def get_end_time_value(self):
        if self.end_time:

# Path: apis/helpers.py
# def split_datetime(datetime, date_format="YYYY-MM-DD", time_format="HH:MM"):
#     '''
#     :param datetime: datetime object
#     :return: date str and time str ex: 2017-03-02, 12:09
#     '''
#     tzinfo = tz.gettz('Asia/Shanghai')
#     adatetime = arrow.Arrow.fromdate(datetime).to(tzinfo)
#     return adatetime.format(date_format), adatetime.format(time_format)
# 
# Path: apis/models/oauth.py
# class Account(Document):
# 
#     '''
#     帐号
#     :param _id: account ID
#     :param username: 用户ID
#     :param created_time: 创建时间
#     :param password: 密码
#     :param authentications: 认证信息 {'wxapp': 'openid', 'mobile': 'mobile_num'}
#     :param status: 状态(active|发布|forbidden)
#     '''
# 
#     meta = {
#         'collection': 'account',
#         'indexes': [
#             '$username',  # text index
#         ]
#     }
# 
#     id = ObjectIdField(primary_key=True, required=True)
#     nickname = StringField(required=True)
#     avatar = StringField(required=True)
#     username = StringField()
#     password = StringField()
#     authentications = EmbeddedDocumentField(Authentications)
#     created_time = DateTimeField(default=datetime.utcnow())
#     updated_time = DateTimeField()
# 
#     @classmethod
#     def get_by_wxapp(cls, openid):
#         account = cls.objects(authentications__wxapp=openid).first()
#         return account


# Path: apis/models/test.py
from datetime import datetime
from weixin.helper import smart_str
from mongoengine import EmbeddedDocument, Document
from mongoengine.fields import (StringField, DateTimeField,
                                ObjectIdField, DictField, IntField,
                                ListField, ReferenceField,
                                BooleanField)
from apis.helpers import split_datetime
from apis.models.oauth import Account

            ('creator_id', 'status', '-created_time'),
            ('is_sticky', 'status', '-order_score'),
            ('is_digest', 'status', '-order_score'),
            ('status', '-participate_number')
        ]
    }

    @property
    def creator(self):
        account = Account.objects(id=self.creator_id).first()
        return account

    def get_start_time_value(self):
        if self.start_time:
            date_start, time_start = split_datetime(self.start_time)
            return date_start, time_start
        return None, None

    @property
    def time_start(self):
        _, time_start = self.get_start_time_value()
        return time_start

    @property
    def date_start(self):
        date_start, _ = self.get_start_time_value()
        return date_start

    def get_end_time_value(self):
        if self.end_time:

            date_end, time_end = split_datetime(self.end_time)