Пример #1
0
def filter_public_fields(survey):
    public_fields = [
        '_id', 'course_id', 'user_id', 'title', 'content', 'create_at'
    ]
    with no_auto_dereference(Survey):
        survey = dbutils.filter_fields(survey, public_fields)
    survey['survey_id'] = str(survey['_id'])
    del survey['_id']
    survey['course_id'] = str(survey['course_id'])
    survey['created_by'] = str(survey['user_id'])
    del survey['user_id']
    survey['create_at'] = utils.get_timestamp(survey['create_at'])
    return survey
Пример #2
0
def filter_public_fields(user):
    public_fields = [
        '_id', 'username', 'last_name', 'first_name', 'email', 'birthday',
        'type', 'create_at'
    ]
    user = dbutils.filter_fields(user, public_fields)
    user['user_id'] = str(user['_id'])
    del user['_id']
    user['birthday_year'] = user['birthday'].year
    user['birthday_month'] = user['birthday'].month
    user['birthday_day'] = user['birthday'].day
    del user['birthday']
    user['create_at'] = get_timestamp(user['create_at'])
    return user
Пример #3
0
def filter_public_fields(survey_response):
    public_fields = [
        '_id', 'user_id', 'course_id', 'survey_id', 'content', 'create_at'
    ]
    survey_response = dbutils.filter_fields(survey_response, public_fields)
    survey_response['survey_response_id'] = str(survey_response['_id'])
    del survey_response['_id']
    survey_response['student_info'] = filter_user_fields(
        survey_response['user_id'])
    del survey_response['user_id']
    survey_response['course_id'] = str(survey_response['course_id']._id)
    survey_response['survey_id'] = str(survey_response['survey_id']._id)
    survey_response['create_at'] = utils.get_timestamp(
        survey_response['create_at'])
    return survey_response
Пример #4
0
def filter_public_fields(announcement):
    public_fields = [
        '_id',
        'user_id',
        'course_id',
        'title',
        'content',
        'create_at'
    ]
    announcement = dbutils.filter_fields(announcement, public_fields)
    announcement['announcement_id'] = str(announcement['_id'])
    del announcement['_id']
    announcement['teacher_info'] = filter_user_fields(announcement['user_id'])
    del announcement['user_id']
    announcement['course_id'] = str(announcement['course_id']._id)
    announcement['create_at'] = utils.get_timestamp(announcement['create_at'])
    return announcement
Пример #5
0
def filter_public_fields(homework):
    public_fields = [
        '_id',
        'course_id',
        'title',
        'content',
        'deadline',
        'create_at'
    ]
    with no_auto_dereference(Homework):
        homework = dbutils.filter_fields(homework, public_fields)
    homework['id'] = str(homework['_id'])
    del homework['_id']
    homework['course_id'] = str(homework['course_id'])
    homework['deadline'] = utils.get_timestamp(homework['deadline'])
    homework['create_at'] = utils.get_timestamp(homework['create_at'])
    return homework