def post(self): print('GroupAddAPI\n\n') parser = reqparse.RequestParser() parser.add_argument('config', type=dict, location='json', required=True) args = parser.parse_args() newGroupName = args.config['groupName'] myPath = os.path.dirname(os.path.abspath(__file__)) groupDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-5]), "database\\groupdb") newGroupPath = os.path.join(groupDBRootPath, newGroupName+".json") Group.create(name=newGroupName, groupPath=newGroupPath).commit() defaultGraph=\ { "graph":{ "nodes":[], "edges":[], } } with open(newGroupPath, 'w') as groupJsonFile : json.dump(defaultGraph, groupJsonFile) return '', status.HTTP_200_OK
def show_student_analytics_window(self): group = Group() ls_name = group.show_name(self.session) self.choice_group_ui.comboBox.clear() self.choice_group_ui.comboBox.addItems(ls_name) self.choice_analytics_window.hide() self.choice_group_ui.update(self.dark_theme) self.choice_group_window.show()
def show_group_window(self): group = Group() ls_all = group.show_all(self.session) ls_all = np.array(ls_all) self.group_ui.tableWidget = set_items_to_table( self.group_ui.tableWidget, ls_all, DARK_THEME=self.dark_theme) self.group_ui.update(self.dark_theme) self.group_ui.tableWidget.resizeColumnsToContents() self.group_window.show()
def update(self): number = self.lineEdit.text() specialty: str = self.comboBox.currentText() group = Group() group.update(self.session, self.update_value, number, specialty) self.table.setItem(self.row, 0, QtWidgets.QTableWidgetItem(specialty)) self.table.setItem(self.row, 1, QtWidgets.QTableWidgetItem(number)) self.update_group_window.close()
def show_analytics_window(self): group = Group() ls_name = group.show_name(self.session) discipline = Discipline d_name = discipline.show_name(self.session) self.choice_discipline_ui.comboBox.clear() self.choice_discipline_ui.comboBox.addItems(d_name) self.choice_discipline_window.show() self.choice_discipline_ui.update(self.dark_theme) self.choice_analytics_window.hide()
def show_grade_window(self): group = Group() ls_name = group.show_name(self.session) self.grade_ui.comboBox_2.clear() self.grade_ui.comboBox_2.addItems(ls_name) discipline = Discipline d_name = discipline.show_name(self.session) self.grade_ui.comboBox.clear() self.grade_ui.comboBox.addItems(d_name) self.grade_ui.update(self.dark_theme) self.grade_window.show()
def add_group(self): number = self.lineEdit.text() specialty: str = self.comboBox.currentText() group = Group() group.add(self.session, number, specialty) row = self.table.rowCount() self.table.setRowCount(row + 1) self.table.setItem(row, 0, QtWidgets.QTableWidgetItem(specialty)) self.table.setItem(row, 1, QtWidgets.QTableWidgetItem(number)) self.combo.addItem(number) self.comboBox.clear() self.lineEdit.clear() self.add_group_window.close()
def delete(self): items = self.tableWidget.selectedItems() for i in items: row = self.tableWidget.row(i) number = self.tableWidget.item(row, 1).text() group = Group() group.delete(self.session, number) self.tableWidget.removeRow(row) self.combo.clear() ls_name = group.show_name(self.session) self.combo.addItems(ls_name)
def next_page(self): choice = self.comboBox.currentText() if choice == 'По группам': self.choice_discipline_group_ui.discipline = self.discipline self.choice_discipline_group_ui.update(self.dark_theme) self.choice_discipline_group_window.show() else: group = Group() ls_name = group.show_name(self.session) self.choice_discipline_student_group_ui.comboBox.clear() self.choice_discipline_student_group_ui.comboBox.addItems(ls_name) self.choice_discipline_student_group_ui.discipline = self.discipline self.choice_discipline_student_group_ui.update(self.dark_theme) self.choice_discipline_student_group_window.show() self.choice_discipline_group_or_student_window.hide()
def create_group(): if requires_scope('sms:write'): body = request.get_json() assert 'group_name' in body session = session_creator() session.add(Group(group_name=body['group_name'])) session.commit() session.close() return 'ok' raise AuthError( { "code": "Unauthorized", "description": "You don't have access to this resource" }, 403)
def sync_slack_groups(): """Adds groups from Slack into the database, if they do not already exist. """ client = slack.SlackClient(token.get_slack_token()) slack_usergroups = client.get_usergroups_list() groups = query.get_slack_groups() missing_ids = utils.get_missing_group_ids(slack_usergroups, groups) for usergroup in slack_usergroups: if usergroup.slack_id in missing_ids: name = usergroup.name slack_group_id = usergroup.slack_id if name and slack_group_id: group = Group(name, slack_group_id, 1) query.add_group(group)
def load_data(): from db.models import (User, UserEmail, UserPermission, Role, Permission, Group, GroupMember, GroupPermission) from db.models.utils import Session session = Session() dev_role = Role(name='PYTHON_DEV') intellij_ide = Permission(name='pycharm') session.add_all([dev_role, intellij_ide]) session.commit() prem = User( first_name='Premkumar', last_name='Chalmeti', username='******', avatar='https://avatars0.githubusercontent.com/u/22867776', bio= 'Software Craftsman | Python | Django | Elasticsearch | VueJS | AWS', role=dev_role.id, password='******') session.add(prem) session.commit() emails = UserEmail(user_id=prem.id, primary_email='*****@*****.**') user_rights = UserPermission(role_id=dev_role.id, permission_id=intellij_ide.id) session.add_all([emails, user_rights]) session.commit() devops = Group(name='DevOps Team') aws_permission = Permission(name='AWS_ACCOUNT') session.add_all([devops, aws_permission]) session.commit() devops_member = GroupMember(group_id=devops.id, user_id=prem.id) group_rights = GroupPermission(group_id=devops.id, permission_id=aws_permission.id) session.add_all([devops_member, group_rights]) session.commit()
def parser_moodle(address, login, password, session) -> int: # address = 'https://cp29191-wordpress-8.tw1.ru' # login = "******" # password = "******" login_address = address + "/login/index.php" chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--ignore-certificate-errors") driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options) try: driver.get(login_address) username = driver.find_element_by_id('username') username.click() username.send_keys(login) password_ = driver.find_element_by_id("password") password_.click() password_.send_keys(password) submit = driver.find_element_by_id("loginbtn") submit.click() time.sleep(1) number_course = 0 while number_course != -1: courses = driver.find_elements_by_class_name( 'list-group-item-action') flag = 0 this_number_course = 0 flag_number_course = 0 for course in courses: if flag == 1 and this_number_course == number_course: # Синхронизация дисциплин c = course c.click() title = driver.title name_course = title.split('Курс: ')[1] d = Discipline() discipline = d.all(session) flag_d = 0 for d in discipline: if d.name == name_course: flag_d = 1 break if not flag_d: d.add(session, discipline) driver.find_element_by_partial_link_text( "Участники").click() time.sleep(5) # Синхронизация групп и студентов i = 0 flag_e = 0 id_template = "user-index-participants-4_r" while flag_e == 0: try: id = id_template + str(i) tr = driver.find_element_by_id(id) i += 1 name = tr.find_elements_by_class_name('c1') name = name[0].text role = tr.find_elements_by_class_name('c3') role = role[0].text group = tr.find_elements_by_class_name('c4') group = group[0].text if role == 'Студент': g = Group() g_names = g.show_name(session) g_flag = 0 for g_name in g_names: if g_name == group: g_flag = 1 break if g_flag == 0: g.add(session, group, 'Информационная безопасность') s = Student() s_names = s.all(session, group) s_flag = 0 for s_name in s_names: if s_name == name: s_flag = 1 break if s_flag == 0: record_book = randint(100000, 999999) s.add(session, name, record_book, group) except: flag_e = 1 driver.back() time.sleep(3) driver.back() time.sleep(3) number_course += 1 flag_number_course = 1 break elif flag == 1: this_number_course += 1 if course.text == "Личные файлы": flag = 1 if flag_number_course == 0: number_course = -1 driver.close() return 0 except: driver.close() return 1
def show_group_choice_window(self): group = Group() ls_name = group.show_name(self.session) self.group_choice_ui.comboBox.addItems(ls_name) self.group_choice_ui.update(self.dark_theme) self.group_choice_window.show()
def find_or_create_group(slug: str, author_name: str) -> Group: group = db.query(Group).filter(Group.slug == slug).first() if not group: group = Group(slug=slug) group.author = find_or_create_author(author_name) return group
import json myPath = os.path.dirname(os.path.abspath(__file__)) modelDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-1]), "database\\modeldb") modelDBJsonList = os.listdir(modelDBRootPath) for JsonName in modelDBJsonList: Neuron.create(name=JsonName.split('.')[0], modelPath=os.path.join(modelDBRootPath, JsonName)) groupDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-1]), "database\\groupdb") groupDBJsonList = os.listdir(groupDBRootPath) for JsonName in groupDBJsonList: Group.create(name=JsonName.split('.')[0], groupPath=os.path.join(groupDBRootPath, JsonName)) networkDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-1]), "database\\networkdb") networkDBJsonList = os.listdir(networkDBRootPath) for JsonName in networkDBJsonList: Network.create(name=JsonName.split('.')[0], networkPath=os.path.join(networkDBRootPath, JsonName)) initialGraphs = [ { "name": "e^x-1", "parameter": { 0: { "id": 0, "name": "x^5",