def handle(self, *args, **options): organization=[ {'name':'Рога и копыта','site':'','location':'Черноморск','adress':'unknown','zip_code':'420075'}, {'name':'Рога и копыта','site':'','location':'Черноморск','adress':'unknown','zip_code':'420075'} ] for org in organization: org_inst=Organization(**org) org_inst.full_clean() org_inst.save()
def handle(self, *args, **options): organizations = [ {'name': 'Skyparkcdn', 'region': 'Пермь', 'tax_id': 123456, 'site': 'https://www.skyparkcdn.com/'}, {'name': 'ООО Транио', 'region': 'москва', 'tax_id': 666122, 'site': 'https://www.tranio.ru/'}, {'name': 'GeekBrains', 'region': 'Москва', 'tax_id': 123456, 'site': 'geekbrains.ru'}, ] works = [ {'organization': 'Skyparkcdn', 'position': 'Программист-разработчик', 'duties': 'Разработка серверной(nodejs) и клиентской(angularJS) частей веб-сервисов.Написание ' 'микро-сервисов для работы с MongoDB (REST архитектура).Верстка по предоставленным ' 'макетам (Bootstrap)', 'period': 6}, {'organization': 'ООО Транио', 'position': 'Программист Python', 'duties': 'Доработка функциональности сайта. Backend разработка - Django,Frontend - javascript и ' 'верстка по предоставленным шаблонам.', 'period': 4}, {'organization': 'GeekBrains', 'position': 'teacher', 'duties': 'Подготовка и преподавание курсов python/django', 'period': 12}, ] hobbies = [ {'name': 'tourism'}, {'name': 'programming'}, ] studies = [ {'type': 'school', 'number': 36, 'study_from': date(1989, 9, 1), 'study_to': date(1997, 6, 1)}, {'type': 'lyceum', 'number': 84, 'study_from': date(1997, 9, 1), 'study_to': date(2000, 6, 1)}, {'type': 'university', 'number': 0, 'study_from': date(2000, 9, 1), 'study_to': date(2005, 8, 1)}, ] for organization in organizations: organization = Organization(**organization) organization.save() for work in works: org_name = work["organization"] # Получаем организацию по имени organization = Organization.objects.get(name=org_name) # Заменяем название организации объектом work['organization'] = organization work = Work(**work) work.save() for hobby in hobbies: hobby = Hobby(**hobby) hobby.save() for study in studies: study = Study(**study) study.save()
def handle_noargs(self, **options): organizations = [ {'name': 'ООО "СтройКопай"', 'region': 'Москва', 'tax_id': 123456, 'site': 'build_dig.com'}, {'name': 'ИП "Иванушка"', 'region': 'Подмосковье', 'tax_id': 666122, 'site': ''}, {'name': 'GeekBrains', 'region': 'Москва', 'tax_id': 123456, 'site': 'geekbrains.ru'}, ] works = [ {'organization': 'ООО "СтройКопай"', 'position': 'digger', 'duties': 'В основном копал...', 'period': 6}, {'organization': 'ИП "Иванушка"', 'position': 'assistant', 'duties': '...', 'period': 4}, {'organization': 'GeekBrains', 'position': 'teacher', 'duties': 'Пдготовка и преподавание курсов python/django', 'period': 12}, ] hobbies = [ {'name': 'tourism'}, {'name': 'programming'}, {'name': 'digging -)'}, ] studies = [ {'type': 'school', 'number': 36, 'study_from': date(1990, 9, 1), 'study_to': date(1998, 6, 1)}, {'type': 'lyceum', 'number': 66, 'study_from': date(1998, 9, 1), 'study_to': date(2001, 6, 1)}, {'type': 'university', 'number': 0, 'study_from': date(2001, 9, 1), 'study_to': date(2006, 8, 1)}, ] for organization in organizations: organization = Organization(**organization) organization.save() for work in works: org_name = work["organization"] # Получаем организацию по имени organization = Organization.objects.get(name=org_name) # Заменяем название организации объектом work['organization'] = organization work = Work(**work) work.save() for hobby in hobbies: hobby = Hobby(**hobby) hobby.save() for study in studies: study = Study(**study) study.save()
def organization(self, libobject: JSON, organization: Organization) -> Organization: type_name = libobject.get("organizationType") # E.g. Leipzig sets organizationType: "Gremium" and classification: "Fraktion" for factions, # so we give priority to classification if libobject.get("classification") in self.utils.organization_classification: type_name = libobject["classification"] type_id = self.utils.organization_classification.get(type_name) if type_id: orgtype = OrganizationType.objects.get(id=type_id) else: orgtype, _ = OrganizationType.objects.get_or_create( name=libobject.get("organizationType") ) organization.organization_type = orgtype if libobject.get("body"): # If we really have a case with an extra body then this should error because then we need some extra handling organization.body = Body.by_oparl_id(libobject["body"]) else: organization.body = self.default_body organization.start = self.utils.parse_date(libobject.get("startDate")) organization.end = self.utils.parse_date(libobject.get("endDate")) organization.location = self.retrieve(Location, libobject.get("location")) if organization.name == organization.short_name and type_name: pattern = "[- ]?" + re.escape(type_name) + "[ ]?" organization.short_name = re.sub( pattern, "", organization.short_name, flags=re.I ) return organization
def test_organization(self): # Body is mandatory for organization self.converter.import_anything("https://oparl.example.org/body/1") self.converter.ensure_organization_type() organization = Organization() data = self.api_data["https://oparl.example.org/organization/34"] self.converter.organization(data, organization) self.assertEqual(organization.start, date(2012, 7, 17)) self.assertEqual(organization.end, None) self.assertEqual(organization.body.short_name, "Köln") self.assertTrue( organization.location.description.startswith("Rathaus")) self.assertEqual(organization.color, None) self.assertEqual(organization.logo, None) self.assertEqual(organization.organization_type.name, "committee")
def test_organization_normalization(self): """ Test for the normalization which was mainly built for cc-egov """ # Body is mandatory for organization self.converter.import_anything("https://oparl.example.org/body/1") self.converter.ensure_organization_type() organization = Organization() data = { "id": "https://oparl.example.org/organization/34", "type": "https://schema.oparl.org/1.1/Organization", "body": "https://oparl.example.org/body/1", "name": "Freibier-Fraktion", "organizationType": "Gremium", "classification": "Fraktion", } self.converter.init_base(data, organization) self.converter.organization(data, organization) self.assertEqual(organization.name, "Freibier-Fraktion") self.assertEqual(organization.short_name, "Freibier") self.assertEqual(organization.organization_type_id, 1)
def add_missing_associations(self): logging.info("Adding missing meeting <-> persons associations") for meeting_id, person_ids in self.meeting_person_queue.items(): meeting = Meeting.by_oparl_id(meeting_id) meeting.persons = [ Person.by_oparl_id(person_id) for person_id in person_ids ] meeting.save() logging.info("Adding missing agenda item <-> paper associations") for item_id, paper_id in self.agenda_item_paper_queue.items(): item = AgendaItem.objects_with_deleted.get(oparl_id=item_id) item.paper = Paper.objects_with_deleted.filter( oparl_id=paper_id).first() if not item.paper: message = "Missing Paper: {}, ({})".format(paper_id, item_id) self.errorlist.append(message) item.save() logging.info("Adding missing memberships") for organization, libobject in self.membership_queue: self.membership(organization, libobject) logging.info("Adding missing papper to consultations") for consultation, paper in self.consultation_paper_queue: consultation.paper = Paper.by_oparl_id(paper) consultation.save() logging.info("Adding missing meetings to consultations") for consultation, meeting in self.consultation_meeting_queue: consultation.meeting = Meeting.by_oparl_id(meeting) consultation.save() logging.info("Adding missing organizations to papers") for paper, organization_url in self.paper_organization_queue: paper.organizations.add(Organization.by_oparl_id(organization_url))
def handle(self, *args, **options): organization = [{ 'name': 'Рога и копыта', 'site': '', 'location': 'Черноморск', 'adress': 'unknown', 'zip_code': '420075' }, { 'name': 'Рога и копыта', 'site': '', 'location': 'Черноморск', 'adress': 'unknown', 'zip_code': '420075' }] for org in organization: org_inst = Organization(**org) org_inst.full_clean() org_inst.save()
def handle(self, *args, **options): organizations = [ { 'name': 'ПГНИУ', 'image_path': 'images/work/university.png', 'site': 'https://ru.wikipedia.org/wiki/Пермский_государственный_университет' }, { 'name': 'ЗАО Прогноз', 'image_path': 'images/work/prognoz.jpeg', 'site': 'http://www.prognoz.ru/' }, ] works = [ { 'organization': 'ПГНИУ', 'position': 'Администратор', 'duties': 'Поддержка серверов' }, { 'organization': 'ЗАО Прогноз', 'position': 'Программист', 'duties': 'Написание кода' }, ] studies = [ { 'name': 'Гимназия №17', 'image_path': 'images/study/school.jpg', 'site': 'https://ru.wikipedia.org/wiki/Гимназия_№_17_(Пермь)' }, { 'name': 'ПГНИУ', 'image_path': 'images/study/university.png', 'site': 'https://ru.wikipedia.org/wiki/Пермский_государственный_университет' }, { 'name': 'GeekBrains.ru', 'image_path': 'images/study/gb.png', 'site': 'https://geekbrains.ru/' }, ] skills = [ { 'text': 'Математика во всех ее проявлениях, все таки магистратуру мехмата осилил' }, { 'text': 'Нейросети. Люблю нейросети.' }, { 'text': 'ООП, куда же без него' }, { 'text': 'Алгоритмическое мышление - есть' }, { 'text': 'HTML5/CSS3 - ну, учил :)' }, { 'text': 'JavaScript - совсем поверхностно :(' }, { 'text': 'С# - тут намного лучше' }, { 'text': 'SQL - \"могу писать сложные запросы\"' }, { 'text': 'Проектирование приложений' }, { 'text': 'Проектирование баз данных', }, { 'text': 'Python' }, { 'text': 'Git, Jira, TFS, Redmine' }, ] hobbies = [ { 'text': 'Из айтишного: ИИ, big data, deep machine learning, распознавание текста и образов' }, { 'text': 'Моделизм (клеить и пытаться красить)' }, { 'text': 'Стрельба из лука и страйкбол (сейчас уже реже)' }, { 'text': 'PS4 вечерком, поиграть в РПГ или какой-нибудь Dark Souls' }, { 'text': 'Dungeons & Dragons в роли мастера и игрока' }, ] Organization.objects.all().delete() Work.objects.all().delete() Hobby.objects.all().delete() Study.objects.all().delete() Skill.objects.all().delete() for organization in organizations: organization = Organization(**organization) organization.save() for work in works: org_name = work["organization"] # Получаем организацию по имени organization = Organization.objects.get(name=org_name) # Заменяем название организации объектом work['organization'] = organization work = Work(**work) work.save() for hobby in hobbies: hobby = Hobby(**hobby) hobby.save() for study in studies: study = Study(**study) study.save() for skill in skills: skill = Skill(**skill) skill.save()
def handle(self, *args, **option): organizations = [{ 'name': 'Организация1', 'phone_number': '+7-999-123-456', 'region': 'г. Москва', 'site': '/org1' }, { 'name': 'Организация2', 'phone_number': '+7-999-123-654', 'region': 'г. Красноярск', 'site': '/org2' }] works = [{ 'organization': 'Организация1', 'post': 'Рыбочий', 'desc': 'работал', 'period': 2 }, { 'organization': 'Организация1', 'post': 'Рыбочий', 'desc': 'работал', 'period': 4 }, { 'organization': 'Организация2', 'post': 'Рыбочий', 'desc': 'работал', 'period': 3 }] hobbies = [{ 'name': 'Автомобили', 'year': '2008' }, { 'name': 'Путешествия', 'year': '2011' }] studies = [{ 'name': 'Сибирский федеральный университет', 'spec': 'Программная инженерия' }, { 'name': 'GeekBrains', 'spec': 'Web-разработчик python/django' }] Organization.objects.all().delete() for organization in organizations: organization = Organization(**organization) organization.save() Work.objects.all().delete() for work in works: org_name = work["organization"] # Получаем организацию по имени organization = Organization.objects.get(name=org_name) # Заменяем название организации объектом work['organization'] = organization work = Work(**work) work.save() Hobby.objects.all().delete() for hobby in hobbies: hobby = Hobby(**hobby) hobby.save() Study.objects.all().delete() for study in studies: study = Study(**study) study.save() print('Команда выполнена')
def handle(self, *args, **options): organizations = [ { 'name': 'WebDev1', 'region': 'Урал', 'tax_id': 123456, 'site': 'webdev1.local' }, { 'name': 'WebDev2', 'region': 'Урал', 'tax_id': 654321, 'site': 'webdev2.local' }, { 'name': 'GeekBrains', 'region': 'Москва', 'tax_id': 123456, 'site': 'geekbrains.ru' }, ] works = [ { 'organization': 'WebDev1', 'position': 'Программист-разработчик', 'duties': 'Разработка веб-сервисов.Написание ' 'кода.Верстка по предоставленным ' 'макетам (Bootstrap)', 'period': 12 }, { 'organization': 'WebDev2', 'position': 'Программист Python', 'duties': 'Доработка функциональности сайта.' 'Верстка по предоставленным шаблонам.', 'period': 6 }, { 'organization': 'GeekBrains', 'position': 'Преподаватель', 'duties': 'Подготовка и преподавание курсов', 'period': 18 }, ] hobbies = [ { 'name': 'сноуборд' }, { 'name': 'фотография' }, ] studies = [ { 'type': 'school', 'number': 111, 'study_from': date(1987, 9, 1), 'study_to': date(1995, 6, 1) }, { 'type': 'lyceum', 'number': 222, 'study_from': date(1995, 9, 1), 'study_to': date(1997, 6, 1) }, { 'type': 'university', 'number': 0, 'study_from': date(1997, 9, 1), 'study_to': date(2002, 8, 1) }, ] Organization.objects.all().delete() for organization in organizations: organization = Organization(**organization) organization.save() Work.objects.all().delete() for work in works: org_name = work["organization"] # Получаем организацию по имени organization = Organization.objects.get(name=org_name) # Заменяем название организации объектом work['organization'] = organization work = Work(**work) work.save() Hobby.objects.all().delete() for hobby in hobbies: hobby = Hobby(**hobby) hobby.save() Study.objects.all().delete() for study in studies: study = Study(**study) study.save()