コード例 #1
0
ファイル: my_calendar.py プロジェクト: duytanfit/scheduler
def insert_event():
    post_data = request.get_json()
    user_id = Helps.get_user_id_from_headers()
    department_id = MySql.get_department_of_user(user_id)

    local_start_date = Helps.format_time(post_data.get('start_date'))
    local_end_date = Helps.format_time(post_data.get('end_date'))
    list_type = MySql.get_all_type()

    if Helps.is_check_device_Invalid(post_data, list_type, local_start_date,
                                     local_end_date):
        try:
            event = Event(local_start_date, local_end_date,
                          post_data.get('text'), user_id, department_id)
            MySql.save_to_db(event)
        except IndentationError:
            MySql.rollback()
            return {
                "action": "error",
                "message": "ERROR: Insert database error"
            }
        if Helps.insert_data_child(post_data, list_type, event=event):
            return {
                "action": "success",
                "tid": event.id,
                "message": "Inserted"
            }
        else:
            return {
                "action": "error",
                "message": "ERROR: Insert database error"
            }
    return {"action": "error", "message": "ERROR: The device has been used"}
コード例 #2
0
ファイル: my_calendar.py プロジェクト: duytanfit/scheduler
def get_events():
    user_id = Helps.get_user_id_from_headers()
    department_id = MySql.get_department_of_user(user_id)
    '''xu li light box'''
    data = Helps.config_lightbox(user_id, department_id)
    '''xu li event cua user'''
    list_event = Helps.config_event(user_id)
    return jsonify({'data': list_event, 'collections': data})
コード例 #3
0
def get_events():
    user_id = Helps.get_user_id_from_headers()
    department_id = MySql.get_department_of_user(user_id)

    data_color = Helps.random_color_user(user_id, department_id)
    data = Helps.config_lightbox(user_id, department_id)
    list_event = Helps.config_event_for_department(data_color, department_id)
    return jsonify({'data': list_event, 'collections': data})
コード例 #4
0
def find_list():
    user_id = Helps.get_user_id_from_headers()
    department_id = MySql.get_department_of_user(user_id)
    a = list(map(int, request.get_json()['list_user'].split(',')))

    data_color = Helps.random_color_search(a)
    data = Helps.config_lightbox(user_id, department_id)
    list_event = Helps.config_event_for_search(data_color, a)
    return jsonify({'data': list_event, 'collections': data})