Ejemplo n.º 1
0
def get_schema_of_prj(id_prj):
	try:
		schema_of_prj = {
			"error": "success",
			"timestamp": datetime.timestamp(datetime.now()),
			"data": dict()
		}
		project_pms = dbase.get_pms_for_prj(id_prj)
		project_devs = dbase.get_devs_for_prj(id_prj)
		projects_dict = {
			"id": id_prj,
			"name": dbase.get_name_project(id_prj),
			"pms": list(),
			"developers": list()
		}
		for pm in project_pms:
			projects_dict["pms"].append({
				"id": pm[0],
				"name": dbase.get_name_pm(pm[0]),
				"telegram": dbase.get_username_of_tg(dbase.get_pm_tgid(pm[0]))[0],
			})
		for dev in project_devs:
			projects_dict["developers"].append({
				"id": dev[0],
				"name": dbase.get_name_resource(dev[0]),
				"telegram": dbase.get_username_of_tg(dbase.get_dev_tgid(dev[0]))[0]
			})
		schema_of_prj["data"] = projects_dict
		return schema_of_prj
	except:
		return False
Ejemplo n.º 2
0
def get_list_pms():
	schema_of_pms = {
		"error": "success",
		"timestamp": datetime.timestamp(datetime.now()),
		"total": 0,
		"offset": 0,
		"perPage": 0,
		"data": list()
	}
	list_of_id_pms = dbase.get_list_of_id_pms()
	for id_pm in list_of_id_pms:
		pm_projects = dbase.get_prjs_for_idpm(id_pm)
		projects_list = list()
		for prj in pm_projects:
			projects_list.append({
				"id": prj[0],
				"name": dbase.get_name_project(prj[0])
			})
		dict_for_pm = {
			"name": dbase.get_name_pm(id_pm),
			"telegram": dbase.get_username_of_tg(dbase.get_pm_tgid(id_pm))[0],
			"projects": projects_list
		}
		schema_of_pms["data"].append(dict_for_pm)
	return Response(json.dumps(schema_of_pms, ensure_ascii=False), mimetype='application/json')
Ejemplo n.º 3
0
def get_list_prjs():
	schema_of_prjs = {
		"error": "success",
		"timestamp": datetime.timestamp(datetime.now()),
		"total": 0,
		"offset": 0,
		"perPage": 0,
		"data": list()
	}
	list_of_id_prjs = dbase.get_list_of_id_prjs()
	for id_prj in list_of_id_prjs:
		project_pms = dbase.get_pms_for_prj(id_prj)
		project_devs = dbase.get_devs_for_prj(id_prj)
		projects_dict = {
			"id": id_prj,
			"name": dbase.get_name_project(id_prj),
			"pms": list(),
			"developers": list()
		}
		for pm in project_pms:
			projects_dict["pms"].append({
				"id": pm[0],
				"name": dbase.get_name_pm(pm[0]),
				"telegram": dbase.get_username_of_tg(dbase.get_pm_tgid(pm[0]))[0],
			})
		for dev in project_devs:
			projects_dict["developers"].append({
				"id": dev[0],
				"name": dbase.get_name_resource(dev[0]),
				"telegram": dbase.get_username_of_tg(dbase.get_dev_tgid(dev[0]))[0]
			})
		schema_of_prjs["data"].append(projects_dict)
	return Response(json.dumps(schema_of_prjs, ensure_ascii=False), mimetype='application/json')
Ejemplo n.º 4
0
def get_timelog_dev(id_dev):
	if request.method == 'GET':
		if dbase.get_schedule_dev(id_dev):
			schema_of_timelog_dev = {
				"error": "string",
				"timestamp": 1559751301818,
				"total": 0,
				"offset": 0,
				"perPage": 0,
				"data": list()
			}
			list_of_schedule = dbase.get_schedule_dev(id_dev)
			for schedule in list_of_schedule:
				split_schedule = schedule[0].split('/')
				date_ts = datetime(int(split_schedule[2]), int(split_schedule[1]), int(split_schedule[0]))
				dict_of_schedule = {
					"date": int(datetime.timestamp(date_ts)),
					"project": dbase.get_name_project(schedule[1]),
					"hours": schedule[2]
				}
				schema_of_timelog_dev["data"].append(dict_of_schedule)
		else:
			abort(make_response(jsonify({
				"error": "invalid_request",
				"error_description": "Unauthorized"
			}), 401))
		return Response(json.dumps(schema_of_timelog_dev, ensure_ascii=False), mimetype='application/json')

	elif request.method == 'PUT':
		try:
			date_ts = datetime.fromtimestamp(request.json["date"])
			date_str = f'{int(date_ts.day)}/{int(date_ts.month)}/{int(date_ts.year)}'
			print(request.json["date"], date_str, request.json["project"], request.json["hours"])
			dbase.update_schedule_for_dev(id_dev, date_str, request.json["project"], request.json["hours"])
			response_json = {
				"error": "success",
				"timestamp": datetime.timestamp(datetime.now()),
				"data": {
					"message": "ok"
				}
			}
		except:
			abort(make_response(jsonify({
				"error": "invalid_request",
				"error_description": "Unauthorized"
			}), 401))

		return Response(json.dumps(response_json, ensure_ascii=False), mimetype='application/json')
Ejemplo n.º 5
0
def prj_button(user_id, soldate):
    prj = dbase.check_prj(user_id, soldate)
    print(prj)
    markup = InlineKeyboardMarkup()
    row = []
    for have in prj:
        row.append(
            types.InlineKeyboardButton(dbase.get_name_project(have[0]),
                                       callback_data="tap-project" +
                                       str(have[0])))
    markup.row(*row)
    row = []
    row.append(
        types.InlineKeyboardButton("↩️", callback_data="back_to_calendar"))
    markup.row(*row)
    return markup
Ejemplo n.º 6
0
def update_schedule(message, id_prj):
	bot.delete_message(message.chat.id, message.message_id)
	id_dev = dict_dev[message.chat.id]
	tg_id_dev = dbase.get_dev_tgid(id_dev)
	id_prj_from = dict_from_prj[message.chat.id]
	sendhours = totalhours[message.chat.id]
	id_to_pm = dict_to_pm[message.chat.id]
	tg_id_to_pm = dbase.get_pm_tgid(id_to_pm)
	id_from_pm = dbase.get_pm_sqlid(message.chat.id)
	mydate = dict_for_schedule[message.chat.id]
	dbase.update_base(message, mydate, int(id_prj), id_dev, id_prj_from, sendhours, id_to_pm)
	bot.send_message(message.chat.id, 'Ресурс передан!!',
					 reply_markup=markup.back_to_main_menu())
	bot.send_message(tg_id_dev, 'Ваше расписание на 📆' + mydate + ' сменилось\n'
								'ПМ:👨‍🎨{} сместил ⏳{}ч. Вас с проекта #{} на проект #{}\n'
								'Проверьте свое расписание!!!'.format(dbase.get_name_pm(id_from_pm), sendhours, dbase.get_name_project(id_prj_from), dbase.get_name_project(int(id_prj))))
	bot.send_message(tg_id_to_pm,	"Ваше расписание на {} сменилось\n"
									"ПМ:👨‍🎨{} передал Вам на ⏳{}ч. 👨‍💻:{} на проект #{}\n"
									"Проверьте свое расписание!!!".format(mydate, dbase.get_name_pm(id_from_pm), dbase.get_name_resource(id_dev),
																		  sendhours, dbase.get_name_project(id_prj)))
Ejemplo n.º 7
0
def get_list_markups_of_projects_for_pm(user_id, list_of_prj_id):
    markup = InlineKeyboardMarkup()
    i = 0
    row = []
    for id_prj in list_of_prj_id:
        row.append(
            types.InlineKeyboardButton(
                dbase.get_name_project(id_prj),
                callback_data="solution_amount_of_hours" + str(id_prj)))
        i += 1
        if i % 2 == 0:
            markup.row(*row)
            row = []
    if i % 2 != 0:
        markup.row(*row)
    row = []
    row.append(
        types.InlineKeyboardButton(
            "↩️", callback_data="back_to_resource_for_distribute"))
    markup.row(*row)
    return (markup)
Ejemplo n.º 8
0
def get_list_prj(user_id, pm_prjs):
    print(pm_prjs)
    markup = InlineKeyboardMarkup()
    i = 0
    row = []
    for pm in pm_prjs:
        prj = dbase.get_name_project(pm[0])
        row.append(
            types.InlineKeyboardButton(prj,
                                       callback_data="update_schedule" +
                                       str(pm[0])))
        i += 1
        if i % 2 == 0:
            markup.row(*row)
            row = []
    if i % 2 != 0:
        markup.row(*row)
    row = []
    row.append(
        types.InlineKeyboardButton("↩️", callback_data="back_to_what_prj"))
    markup.row(*row)
    return markup
Ejemplo n.º 9
0
def get_schema_of_pm(id_pm):
	try:
		schema_of_pm = {
			"error": "success",
			"timestamp": datetime.timestamp(datetime.now()),
			"data": dict()
		}
		pm_projects = dbase.get_prjs_for_idpm(id_pm)
		projects_list = list()
		for prj in pm_projects:
			projects_list.append({
				"id": prj[0],
				"name": dbase.get_name_project(prj[0])
			})
		data = {
			"name": dbase.get_name_pm(id_pm),
			"telegram": dbase.get_username_of_tg(dbase.get_pm_tgid(id_pm))[0],
			"projects": projects_list
		}
		schema_of_pm["data"] = data
	except:
		return False
	return schema_of_pm
Ejemplo n.º 10
0
def get_schema_of_dev(id_dev):
	try:
		schema_of_dev = {
			"error": "success",
			"timestamp": datetime.timestamp(datetime.now()),
			"data": dict()
		}
		dev_projects = dbase.get_prjs_for_dev(id_dev)
		projects_list = list()
		for prj in dev_projects:
			projects_list.append({
				"id": prj[0],
				"name": dbase.get_name_project(prj[0])
			})
		data = {
			"name": dbase.get_name_resource(id_dev),
			"telegram": dbase.get_username_of_tg(dbase.get_dev_tgid(id_dev))[0],
			"projects": projects_list
		}
		schema_of_dev["data"] = data
	except:
		return False
	return schema_of_dev
Ejemplo n.º 11
0
def update_schedule_for_distribute(message):
	# bot.delete_message(message.chat.id, message.message_id)
	id_from_pm = dbase.get_pm_sqlid(message.chat.id)
	id_dev = dict_distribute_dev[message.chat.id]
	tg_id_dev = dbase.get_dev_tgid(id_dev)
	id_prj = dict_distribute_prj[message.chat.id]
	usehours = dict_distribute_hours[message.chat.id]
	usedate = dict_distribute_date[message.chat.id]
	dbase.update_base_distribute(message, usedate, id_prj, id_dev, usehours)
	bot.send_message(tg_id_dev, "У вас новая задача на 📆{}\n"
								"ПМ:👨‍🎨{} добавил Вам ⏳{}ч. на проект #{}\n"
								"Проверьте свое расписание!!!".format(usedate, dbase.get_name_pm(id_from_pm), usehours, dbase.get_name_project(id_prj)))
	bot.send_message(message.chat.id, 'Задача поставлена!!!',
					 reply_markup=markup.back_to_main_menu())