コード例 #1
0
def put_event(event_id):
    post_data = request.get_json()
    user_id = Helps.get_user_id_from_headers()
    event_own_id = list(map(int, event_id.split('_')))
    user_id_of_event = MySql.get_user_id_of_event(event_own_id[0])

    if user_id_of_event == user_id and event_own_id[1] == 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, event_own_id[0]):
            try:
                MySql.update_event(event_own_id[0], local_start_date, local_end_date, post_data['text'])
                MySql.save_to_db()
            except IndentationError:
                MySql.rollback()
                return {"action": "error", "message": "ERROR: Insert database error"}
            if Helps.insert_data_child(post_data, list_type, event_id=post_data['id_old']):
                return {"action": "success", "tid": post_data['id'], "message": "UPDATED"}
            else:
                return {"action": "error", "message": "ERROR: Insert database error"}
        else:
            return {"action": "error", "message": "ERROR: The device has been used"}
    return {"action": "error", "message": "Failed to update other people's events"}
コード例 #2
0
def delete_event(event_id):
    user_id = Helps.get_user_id_from_headers()
    event_own_id = list(map(int, event_id.split('_')))
    user_id_of_event = MySql.get_user_id_of_event(event_own_id[0])

    if user_id_of_event is None:
        return {"action": "success", "message": "DELETED"}

    if user_id_of_event == user_id and event_own_id[1] == user_id:
        for a in MySql.get_devices_by_event_id(event_own_id[0]):
            MySql.remove_from_db(a)
        for b in MySql.get_users_by_event_id(event_own_id[0]):
            MySql.remove_from_db(b)
        ev = MySql.get_event_by_id(event_own_id[0])
        MySql.remove_from_db(ev)
        MySql.save_to_db()
        return {"action": "success", "message": "DELETED"}
    if user_id_of_event != user_id and user_id == event_own_id[1]:
        a = MySql.get_event_user_by_event_member(event_own_id[0], user_id)
        MySql.remove_from_db(a)
        MySql.save_to_db()
        return {"action": "success", "message": "DELETED"}
    return {
        "action": "error",
        "message": "Failed to delete other people's events"
    }
コード例 #3
0
def delete_event(event_id):
    user_id = Helps.get_user_id_from_headers()
    event_own_device = list(map(int, event_id.split('_')))
    user_id_of_event = MySql.get_user_id_of_event(event_own_device[0])

    if user_id_of_event is None:
        return {"action": "success", "message": "DELETED"}

    if event_own_device[1] == user_id:
        event_device = MySql.get_event_device_by_id(event_own_device[2])
        MySql.remove_from_db(event_device)
        MySql.save_to_db()
        return {"action": "success", "message": "DELETED"}
    return {"action": "error", "message": "Failed to delete other people's events"}
コード例 #4
0
ファイル: my_calendar.py プロジェクト: duytanfit/scheduler
def delete_event(event_id):
    user_id = Helps.get_user_id_from_headers()
    user_id_of_ev = MySql.get_user_id_of_event(event_id)
    if user_id_of_ev is None:
        return {"action": "success", "message": "DELETED"}

    if user_id_of_ev == user_id:
        for a in MySql.get_devices_by_event_id(event_id):
            MySql.remove_from_db(a)
        for b in MySql.get_users_by_event_id(event_id):
            MySql.remove_from_db(b)
        ev = MySql.get_event_by_id(event_id)
        MySql.remove_from_db(ev)
        MySql.save_to_db()
        return {"action": "success", "message": "DELETED"}
    else:
        a = MySql.get_event_user_by_event_member(event_id, user_id)
        MySql.remove_from_db(a)
        MySql.save_to_db()
        return {"action": "success", "message": "DELETED"}