# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():
# 
# Path: mass_flask_core/models/user.py
# class User(db.Document, UserMixin):
#     def is_authenticated(self):
#         return True
# 
#     username = StringField(min_length=3, max_length=50, unique=True, required=True)
#     password_hash = StringField(min_length=5, max_length=200)
#     user_level = UserLevelField(default=UserLevel.USER_LEVEL_USER, required=True)
# 
#     def set_password(self, password):
#         self.password_hash = generate_password_hash(password)
# 
#     def check_password(self, password):
#         return check_password_hash(self.password_hash, password)
# 
#     def get_id(self):
#         return str(self.id)
# 
#     @staticmethod
#     def user_loader(**kwargs):
#         if 'username' in kwargs and 'password' in kwargs:
#             user = User.objects(username=kwargs['username']).first()
#             if user and user.check_password(kwargs['password']):
#                 return user
#             else:
#                 return None
#         elif 'id' in kwargs and kwargs['id']:
#             return User.objects(id=ObjectId(kwargs['id'])).first()
#         else:
#             raise RuntimeError('This access method is not supported by the user loader.')
# 
# Path: mass_flask_core/utils/time_functions.py
# class TimeFunctions:
#     @staticmethod
#     def get_timestamp():
#         # We remove the microsecond part of the timestamp here since mongoengine can not handle it correctly and test cases fail due to the lost precision
#         return datetime.now(utc).replace(microsecond=0)


from mongoengine import StringField, DateTimeField, ReferenceField, EmbeddedDocumentField, ListField
from mass_flask_config.app import db
from .user import User
from mass_flask_core.utils import TimeFunctions


class Comment(db.EmbeddedDocument):
    comment = StringField(max_length=1000, verbose_name='Comment', help_text='Leave a comment', required=True)
    post_date = DateTimeField(default=TimeFunctions.get_timestamp, required=True)

# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():
# 
# Path: mass_flask_core/models/user.py
# class User(db.Document, UserMixin):
#     def is_authenticated(self):
#         return True
# 
#     username = StringField(min_length=3, max_length=50, unique=True, required=True)
#     password_hash = StringField(min_length=5, max_length=200)
#     user_level = UserLevelField(default=UserLevel.USER_LEVEL_USER, required=True)
# 
#     def set_password(self, password):
#         self.password_hash = generate_password_hash(password)
# 
#     def check_password(self, password):
#         return check_password_hash(self.password_hash, password)
# 
#     def get_id(self):
#         return str(self.id)
# 
#     @staticmethod
#     def user_loader(**kwargs):
#         if 'username' in kwargs and 'password' in kwargs:
#             user = User.objects(username=kwargs['username']).first()
#             if user and user.check_password(kwargs['password']):
#                 return user
#             else:
#                 return None
#         elif 'id' in kwargs and kwargs['id']:
#             return User.objects(id=ObjectId(kwargs['id'])).first()
#         else:
#             raise RuntimeError('This access method is not supported by the user loader.')
# 
# Path: mass_flask_core/utils/time_functions.py
# class TimeFunctions:
#     @staticmethod
#     def get_timestamp():
#         # We remove the microsecond part of the timestamp here since mongoengine can not handle it correctly and test cases fail due to the lost precision
#         return datetime.now(utc).replace(microsecond=0)


# Path: mass_flask_core/models/comment.py
from mongoengine import StringField, DateTimeField, ReferenceField, EmbeddedDocumentField, ListField
from mass_flask_config.app import db
from .user import User
from mass_flask_core.utils import TimeFunctions



class Comment(db.EmbeddedDocument):
    comment = StringField(max_length=1000, verbose_name='Comment', help_text='Leave a comment', required=True)
    post_date = DateTimeField(default=TimeFunctions.get_timestamp, required=True)

    user = ReferenceField(User, required=True)