Beispiel #1
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')
Beispiel #2
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
Beispiel #3
0
def str_for_schedule_dev_message(id_dev, nowdate):
	stroka = '📆' + nowdate
	stroka += '\n👨‍💻' + dbase.get_name_resource(id_dev) + '\n' + '📌️' * 8
	list_of_pph = dbase.get_list_of_prj_hours(id_dev, nowdate)
	for ls in list_of_pph:
		stroka += dbase.get_str_for_info_for_dev(ls[0], ls[1], ls[2])
	return stroka
Beispiel #4
0
def get_list_devs():
	schema_of_devs = {
		"error": "success",
		"timestamp": datetime.timestamp(datetime.now()),
		"total": 0,
		"offset": 0,
		"perPage": 0,
		"data": list()
	}
	list_of_id_devs = dbase.get_list_of_id_devs()
	for id_dev in list_of_id_devs:
		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])
			})
		dict_for_dev = {
			"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_devs["data"].append(dict_for_dev)
	return Response(json.dumps(schema_of_devs, ensure_ascii=False), mimetype='application/json')
Beispiel #5
0
def rsr_button(user_id, soldate, id_prj):
    rsr = dbase.check_rsr(user_id, soldate, id_prj)
    print(rsr)
    markup = InlineKeyboardMarkup()
    row = []
    i = 0
    for have in rsr:
        row.append(
            types.InlineKeyboardButton(dbase.get_name_resource(have),
                                       callback_data="tap_resource" +
                                       str(have)))
    markup.row(*row)
    row = []
    row.append(
        types.InlineKeyboardButton("↩️", callback_data="back_to_tap_project"))
    markup.row(*row)
    return markup
Beispiel #6
0
def get_list_free_devs(user_id, list_devs):
    markup = InlineKeyboardMarkup()
    i = 0
    row = []
    for dev in list_devs:
        row.append(
            types.InlineKeyboardButton(dbase.get_name_resource(dev[0]) +
                                       ' ⏳ ' + str(dev[1]) + 'ч.',
                                       callback_data="ignore"))
        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_main"))
    markup.row(*row)
    return markup
Beispiel #7
0
def get_list_markups_of_resorces_for_pm(user_id, list_of_dev_name):
    markup = InlineKeyboardMarkup()
    i = 0
    row = []
    for dev in list_of_dev_name:
        row.append(
            types.InlineKeyboardButton(dbase.get_name_resource(dev),
                                       callback_data="distribute-resource" +
                                       str(dev)))
        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_calendar"))
    markup.row(*row)
    return (markup)
Beispiel #8
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
Beispiel #9
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)))