class ProjectCompleteResource(resources.ModelResource): site = fields.Field(column_name='site', attribute='site', widget=ManyToManyWidget(SiteProfile, 'name')) stakeholder = fields.Field(column_name='stakeholder', attribute='stakeholder', widget=ManyToManyWidget(Stakeholder, 'name')) workflowlevel1 = fields.Field(column_name='program', attribute='program', widget=ForeignKeyWidget( WorkflowLevel1, 'name')) sector = fields.Field(column_name='sector', attribute='sector', widget=ForeignKeyWidget(Sector, 'sector')) project_type = fields.Field(column_name='project_type', attribute='project_type', widget=ForeignKeyWidget(ProjectType, 'name')) office = fields.Field(column_name='office', attribute='office', widget=ForeignKeyWidget(Office, 'code')) estimated_by = fields.Field(column_name='estimated_by', attribute='estimated_by', widget=ForeignKeyWidget(TolaUser, 'name')) approved_by = fields.Field(column_name='approved_by', attribute='approved_by', widget=ForeignKeyWidget(TolaUser, 'name')) class Meta: model = WorkflowLevel2
class ProjectAgreementResource(resources.ModelResource): site = fields.Field(column_name='site', attribute='site', widget=ManyToManyWidget(SiteProfile, 'name')) capacity = fields.Field(column_name='capacity', attribute='capacity', widget=ManyToManyWidget(Capacity, 'capacity')) evaluate = fields.Field(column_name='evaluate', attribute='evaluate', widget=ManyToManyWidget(Evaluate, 'evaluate')) stakeholder = fields.Field(column_name='stakeholder', attribute='stakeholder', widget=ManyToManyWidget(Stakeholder, 'name')) program = fields.Field(column_name='program', attribute='program', widget=ForeignKeyWidget(Program, 'name')) sector = fields.Field(column_name='sector', attribute='sector', widget=ForeignKeyWidget(Sector, 'sector')) project_type = fields.Field(column_name='project_type', attribute='project_type', widget=ForeignKeyWidget(ProjectType, 'name')) office = fields.Field(column_name='office', attribute='office', widget=ForeignKeyWidget(Office, 'code')) estimated_by = fields.Field(column_name='estimated_by', attribute='estimated_by', widget=ForeignKeyWidget(TolaUser, 'name')) approved_by = fields.Field(column_name='approved_by', attribute='approved_by', widget=ForeignKeyWidget(TolaUser, 'name')) class Meta: model = ProjectAgreement
class IndicatorResource(resources.ModelResource): indicator_type = ManyToManyWidget(IndicatorType, separator=" | ", field="indicator_type") objective = ManyToManyWidget(Objective, separator=" | ", field="objective"), strategic_objective = ManyToManyWidget(StrategicObjective, separator=" | ", field="strategic_objective") level = ManyToManyWidget(Level, separator=" | ", field="level") reporting_frequency = fields.Field(column_name='reporting_frequency', attribute='reporting_frequency', widget=ForeignKeyWidget( ReportingFrequency, 'frequency')) sector = fields.Field(column_name='sector', attribute='sector', widget=ForeignKeyWidget(Sector, 'sector')) program = ManyToManyWidget(Program, separator=" | ", field="name") class Meta: model = Indicator fields = ('id','indicator_type','level','objective','strategic_objective','name','number',\ 'source','definition','baseline','lop_target','means_of_verification','data_collection_method','responsible_person',\ 'method_of_analysis','information_use','reporting_frequency','comments','disaggregation','sector',\ 'program','key_performance_indicator')
class EventResource(resources.ModelResource): activity = Field(column_name="activity", attribute="activity", widget=ForeignKeyWidget(Activity, "id")) organization = Field(column_name="organization", attribute="organization", widget=ForeignKeyWidget(Organization, "id")) registered = Field(column_name="registered", attribute="registered", widget=ManyToManyWidget(CustomUser)) presents = Field(column_name="presents", attribute="presents", widget=ManyToManyWidget(CustomUser)) organizers = Field(column_name="organizers", attribute="organizers", widget=ManyToManyWidget(CustomUser)) location = Field(column_name="location", attribute="location", widget=ForeignKeyWidget(Place, "id")) conditions = Field(column_name="conditions", attribute="conditions", widget=ManyToManyWidget(Condition)) class Meta: model = Event
class IndicatorResource(resources.ModelResource): indicator_type = ManyToManyWidget(IndicatorType, separator=" | ", field="indicator_type") objective = ManyToManyWidget(Objective, separator=" | ", field="objective"), strategic_objective = ManyToManyWidget(StrategicObjective, separator=" | ", field="strategic_objective") level = ManyToManyWidget(Level, separator=" | ", field="level") reporting_frequency = fields.Field(column_name='reporting_frequency', attribute='reporting_frequency', widget=ForeignKeyWidget( Frequency, 'frequency')) sector = fields.Field(column_name='sector', attribute='sector', widget=ForeignKeyWidget(Sector, 'sector')) workflowlevel1 = ManyToManyWidget(WorkflowLevel1, separator=" | ", field="name") class Meta: model = Indicator fields = ('id','indicator_key','indicator_type','level','objective','strategic_objective','name','number',\ 'source','definition', 'justification', 'unit_of_measure', 'baseline','lop_target', 'rationale_for_target', 'means_of_verification','data_collection_method', 'data_collection_frequency', 'data_points', 'responsible_person',\ 'method_of_analysis','information_use','reporting_frequency', 'quality_assurance', 'data_issues', 'indicator_changes', 'comments','disaggregation','sector',\ 'workflowlevel1','key_performance_indicator')
class BookResource(resources.ModelResource): book_category = Field(attribute='book_category', widget=ManyToManyWidget(Category, field='category_name'), column_name='Category') book_author = Field(attribute='book_author', widget=ManyToManyWidget(Author), column_name='Author') isbn = Field(attribute='isbn', column_name='ISBN') title = Field(attribute='title', column_name='Title') average_rating = Field(attribute='average_rating', column_name='Average rating') class Meta: model = Book fields = ('isbn', 'title', 'book_author', 'book_category', 'average_rating') export_order = fields def dehydrate_book_author(self, book): authors = [ '{} {}'.format(author.name, author.surname) for author in book.book_author.all() ] return ','.join(authors)
class MedicalExpertResource(resources.ModelResource): degree = fields.Field(column_name='degree', attribute='degree', widget=ForeignKeyWidget(helper_models.Degree, field='name')) last_changed_by = fields.Field(column_name='last_changed_by', attribute='last_changed_by', widget=ForeignKeyWidget(User, field='username')) profession = fields.Field(column_name='profession', attribute='profession', widget=ForeignKeyWidget(helper_models.Profession, field='name')) career_stage = fields.Field(column_name='career_stage', attribute='career_stage', widget=ForeignKeyWidget( helper_models.CareerStage, field='name')) gender = fields.Field(column_name='gender', attribute='gender', widget=ForeignKeyWidget(helper_models.PersonGender, field='name')) specialties = fields.Field(column_name='specialties', attribute='specialties', widget=ManyToManyWidget( helper_models.MedicalExpertise, separator='|', field='name')) therapeutic_areas = fields.Field(column_name='therapeutic_areas', attribute='therapeutic_areas', widget=ManyToManyWidget( helper_models.TherapeuticArea, separator='|', field='name')) country = fields.Field(column_name='country', attribute='country', widget=ForeignKeyWidget(helper_models.Country, field='name')) combined_name = fields.Field(column_name='combined_name', attribute='combined_name') similar_matches_rules = [ (['first_name'], 0.7), (['last_name'], 0.7), ] similar_matches_rules_full_match_search = [ (['last_name'], 0.7), ] class Meta: model = MedicalExpert exclude = ('id', ) import_id_fields = ('oid', )
class HabilitationRequestResource(resources.ModelResource): created_at = Field(attribute="created_at", column_name="Date d'ajout") organisation__data_pass_id = Field(attribute="organisation__data_pass_id", column_name="N° de la demande Datapass") organisation__name = Field(attribute="organisation__name", column_name="Nom de la structure") organisation__type__name = Field(attribute="organisation__type__name", column_name="Type de structure") responsable__last_name = Field( attribute="organisation__responsables", column_name="Responsable Aidants Connect (Nom)", widget=ManyToManyWidget(Aidant, field="last_name", separator="\n"), ) responsable__first_name = Field( attribute="organisation__responsables", column_name="Responsable Aidants Connect (Prénom)", widget=ManyToManyWidget(Aidant, field="first_name", separator="\n"), ) responsable__profession = Field( attribute="organisation__responsables", column_name="Intitulé de poste du responsable Aidants Connect", widget=ManyToManyWidget(Aidant, field="profession", separator="\n"), ) reponsable__email = Field( attribute="organisation__responsables", column_name="Responsable Aidants Connect (adresse mail)", widget=ManyToManyWidget(Aidant, field="email", separator="\n"), ) responsable__phone = Field( attribute="organisation__responsables", column_name="Téléphone responsable Aidants Connect", widget=ManyToManyWidget(Aidant, field="phone", separator="\n"), ) last_name = Field(attribute="last_name", column_name="Nom de l'aidant à former") first_name = Field(attribute="first_name", column_name="Prénom de l'aidant à former") email = Field(attribute="email", column_name="Adresse e-mail de l'aidant à former") profession = Field(attribute="profession", column_name="Intitulé de poste de l'aidant à former") organisation__address = Field(attribute="organisation__address", column_name="Adresse Postale") organisation__zipcode = Field(attribute="organisation__zipcode", column_name="Code Postal") organisation__city = Field(attribute="", column_name="Ville") organisation__departement = Field(attribute="", column_name="Département") organisation__region = Field(attribute="", column_name="Région") class Meta: model = HabilitationRequest fields = set()
class HousingResource(resources.ModelResource): orphan_children_names = fields.Field( column_name = 'Orphan Children', attribute = 'orphan_children_names', widget = ManyToManyWidget(Orphan, separator=',', field='person') ) members = fields.Field( column_name = 'Family Members', attribute = 'members', widget = ManyToManyWidget(Person, separator=',', field='name') ) old_aged_person_names = fields.Field( column_name = 'Old Aged Person Names', attribute = 'old_aged_person_names', widget = ManyToManyWidget(OldAgedPerson, separator=',', field='person') ) differently_able_person_names = fields.Field( column_name = 'Differetly Able Person Names', attribute = 'differently_able_person_available_names', widget = ManyToManyWidget(DifferentlyAblePerson, separator=',', field='person') ) haji_person = fields.Field( column_name = 'Hajis', attribute = 'haji_name', widget = ManyToManyWidget(Haji, separator=',', field='person') ) class Meta: model = Housing fields = ( 'head_of_family', 'house_no', 'members', 'homested_area', 'type_of_house', 'ownership', 'no_of_rooms', 'fuel_for_cooking', 'access_to_electricity', 'water_source', 'water_availability', 'toilet_facility', 'bath_facility', 'sewage_disposal_facility', 'no_of_years_stayed_here', 'ever_lived_in_another_place', 'family_type', 'orphan_children_available', 'orphan_children_names', 'differently_able_person_available', 'differently_able_person_names', 'old_aged_person_available', 'old_aged_person_names', 'haji_available', 'haji_person', 'priority_household', 'nation_food_security_act', 'housing_schemes', 'specify_housing_schemes', 'old_aged_pension_scheme', 'specify_old_aged_pension_scheme', 'other_schemes', 'specify_other_schemes', ) export_order = ( 'head_of_family', 'house_no', 'members', 'homested_area', 'type_of_house', 'ownership', 'no_of_rooms', 'fuel_for_cooking', 'access_to_electricity', 'water_source', 'water_availability', 'toilet_facility', 'bath_facility', 'sewage_disposal_facility', 'no_of_years_stayed_here', 'ever_lived_in_another_place', 'family_type', 'orphan_children_available', 'orphan_children_names', 'differently_able_person_available', 'differently_able_person_names', 'old_aged_person_available', 'old_aged_person_names', 'haji_available', 'haji_person', 'priority_household', 'nation_food_security_act', 'housing_schemes', 'specify_housing_schemes', 'old_aged_pension_scheme', 'specify_old_aged_pension_scheme', 'other_schemes', 'specify_other_schemes', )
class EmployeeResource(resources.ModelResource): formats = DEFAULT_FORMATS user = fields.Field(column_name='user', attribute='user', widget=ForeignKeyWidget(User, field ='username')) department = fields.Field(column_name='department', attribute='department', widget=ForeignKeyWidget(Department, field ='title')) # organization = fields.Field(column_name='organization', attribute='organization', # widget=ForeignKeyWidget(Organization, field ='title')) parent = fields.Field(column_name='reporting to', attribute='parent', widget=ForeignKeyWidget(Employee, field ='name')) roles = fields.Field(column_name='roles', attribute='roles', widget=ManyToManyWidget(Role, field ='title')) class Meta: model = Employee skip_unchanged = True report_skipped = True import_id_fields = ('user',) fields = ('name','user','department','roles','parent',) export_order = ('name','user','department','roles','parent',)
class StudentResource(resources.ModelResource): qualification = fields.Field( attribute='qualification', column_name='qualification', widget=ForeignKeyWidget(Qualification, 'code')) units = fields.Field( attribute='units', column_name='units', widget=ManyToManyWidget(Unit,field='code')) past_units = fields.Field( attribute='past_units', column_name='past_units', widget=ManyToManyWidget(Unit, field='code')) class Meta: model = Student
class QuestionResource(resources.ModelResource): """ """ category = fields.Field( column_name="category", attribute="category", widget=ForeignKeyWidget(Category, field="name"), ) tags = fields.Field(column_name="tags", attribute="tags", widget=ManyToManyWidget(Tag, field="name")) def before_import_row(self, row, **kwargs): """ - Notion.so adds a BOM identifier before each line And setting from_encoding = 'utf-8-sig' in the QuestionAdmin does not work So we need to fix the 'id' column - Issue with BooleanFields because Notion exports Yes/No """ if "id" not in row: row["id"] = row["\ufeffid"] BOOLEAN_FIELDS = ["has_ordered_answers", "publish"] for boolean_field in BOOLEAN_FIELDS: row[boolean_field] = True if (row[boolean_field] == "Yes") else False def import_obj(self, instance, row, dry_run): """ Manually manage M2M column - tags in an existing instance: get the row's comma-seperated tags, get their ids, check if they are different than the instance, and finally set them to the instance - tags in a new instance: check that the tags exist """ self._m2m_updated = False # get tag_ids tag_ids = [] tags = row.get("tags") if tags: tags_split = tags.split(",") tag_ids = Tag.objects.get_ids_from_name_list(tags_split) # compare if instance.id: if list(instance.tags.values_list("id", flat=True)) != tag_ids: instance.tags.set(tag_ids) self._m2m_updated = True super(QuestionResource, self).import_obj(instance, row, dry_run) def skip_row(self, instance, original): """ Highlight row if M2M column was updated """ if self._m2m_updated: return False return super(QuestionResource, self).skip_row(instance, original) class Meta: model = Question skip_unchanged = True report_skipped = True
class CollectionVersionContentResource(BaseContentResource): """ Resource for import/export of ansible_collectionversion-content entities. """ tags = fields.Field( column_name="tags", attribute="tags", widget=ManyToManyWidget(Tag, field="name") ) def before_import_row(self, row, **kwargs): """ Finds and sets collection using name and namespace. Args: row (tablib.Dataset row): incoming import-row representing a single CollectionVersion. kwargs: args passed along from the import() call. """ col = Collection.objects.get(name=row["name"], namespace=row["namespace"]) row["collection"] = str(col.pk) def set_up_queryset(self): """ :return: CollectionVersion content specific to a specified repo-version. """ return CollectionVersion.objects.filter(pk__in=self.repo_version.content) class Meta: model = CollectionVersion import_id_fields = model.natural_key_fields()
class MacroResource(resources.ModelResource): # def before_import(self, dataset, using_transactions, dry_run, **kwargs): # dataset.insert_col(0, col=["", ] * dataset.height, header="id") # # def get_instance(self, instance_loader, row): # return False Type = fields.Field(column_name='Type', attribute='Type', widget=ForeignKeyWidget(Type, 'title')) Tags = fields.Field(column_name='Tags', attribute='Tags', widget=ManyToManyWidget(Tag, field='title')) Category = fields.Field(column_name='Category', attribute='Category', widget=ForeignKeyWidget(Category, 'title')) class Meta: model = Macro skip_unchanged = True report_skipped = True exclude = ('id', ) import_id_fields = ('Title', ) fields = ('Type', 'Tags', 'Category', 'Abbreviation', 'Title', 'Content')
class TeachertResource(resources.ModelResource): """Форма для создания таблиц импорта/экспорта преподавателя""" lastname = fields.Field( column_name='Фамилия', attribute='lastname', ) firstname = fields.Field( column_name='Имя', attribute='firstname', ) patronymic = fields.Field( column_name='Отчество', attribute='patronymic', ) slug = fields.Field( column_name='URL преподавателя', attribute='slug', ) discipline = fields.Field(column_name='Дисциплины', attribute='discipline', widget=ManyToManyWidget(Discipline, ', ', 'name')) class Meta: model = Teacher
class ProductResource(resources.ModelResource): id = fields.Field(attribute='id', column_name='Id товару') product_category = fields.Field(column_name='Категорія товарів', attribute='product_category', widget=ForeignKeyWidget( CategoryGoods, 'category')) product_name = fields.Field(attribute='product_name', column_name='Назва товару') is_active = fields.Field( attribute='is_active', column_name='Товар активний/неактивний (True/False)') compatible_product_brand = fields.Field( attribute='compatible_product_brand', column_name='Бренди сумісності', widget=ManyToManyWidget(BrandProducts)) description = fields.Field(attribute='description', column_name='Опис товару') technical_characteristic = fields.Field( attribute='technical_characteristic', column_name='Технічна характеристика') status_product = fields.Field(column_name='Статус товару', attribute='status_product', widget=ForeignKeyWidget( StatusGoods, 'status')) product_price = fields.Field(attribute='product_price', column_name='Ціна, Грн') product_discount = fields.Field(attribute='product_discount', column_name='Знижка, %') created = fields.Field(attribute='created', column_name='Дата створення') updated = fields.Field(attribute='updated', column_name='Дата оновлення') class Meta: model = Product
class StakeholderResource(resources.ModelResource): type = fields.Field(column_name='type', attribute='type', widget=ForeignKeyWidget(StakeholderType, 'name')) contact = fields.Field(column_name='contact', attribute='contact', widget=ManyToManyWidget(Contact, field='name')) country = fields.Field(column_name='country', attribute='country', widget=ForeignKeyWidget(Country, 'country')) sector = fields.Field(column_name='sector', attribute='sector', widget=ForeignKeyWidget(Sector, 'sector')) approved_by = fields.Field(column_name='approved_by', attribute='approved_by', widget=ForeignKeyWidget(TolaUser, 'name')) filled_by = fields.Field(column_name='filled_by', attribute='filled_by', widget=ForeignKeyWidget(TolaUser, 'name')) stakeholder_register = fields.Field(column_name='stakeholder_register', attribute='stakeholder_register') class Meta: model = Stakeholder def dehydrate_stakeholder_register(self, stakeholder): if stakeholder.stakeholder_register == 1: return 'True' if stakeholder.stakeholder_register == 0: return 'False'
class TrainingMatrixResource(resources.ModelResource): department = fields.Field(column_name='department', attribute='department', widget=ForeignKeyWidget(Department, 'department')) position = fields.Field(column_name='position', attribute='position', widget=ForeignKeyWidget(Position, 'position')) training = fields.Field(column_name='training', attribute='training', widget=ManyToManyWidget(Training, separator=',', field='title')) class Meta: model = TrainingMatrix exclude = ('id', ) import_id_fields = ( 'department', 'position', ) fields = ( 'department', 'position', 'job', )
class EventResource(resources.ModelResource): authorizer = fields.Field( column_name="authorizer", attribute="authorizer", widget=ForeignKeyWidget(Authorizer, "name"), ) tags = fields.Field( column_name="tags", attribute="tags", widget=ManyToManyWidget(Tag, field="name", separator="|"), ) class Meta: model = Event fields = ( "id", "published_on", "tags", "scope", "authorizer", "title", "authoritative_url", "media_type", ) export_order = ( "id", "published_on", "tags", "scope", "authorizer", "title", "authoritative_url", "media_type", ) skip_unchanged = True
class PackageResource(resources.ModelResource): memberships = fields.Field( column_name='memberships', attribute='exclusive_memberships', widget=ManyToManyWidget(Membership, ',', 'name'), ) class Meta: model = Package fields = ( 'id', 'name', 'details', 'price', 'reservations', 'memberships', 'available', ) export_order = ( 'id', 'name', 'details', 'price', 'reservations', 'memberships', 'available', )
class MembershipResource(resources.ModelResource): academic_levels = fields.Field( column_name='academic_levels', attribute='academic_levels', widget=ManyToManyWidget(AcademicLevel, ',', 'name'), ) class Meta: model = Membership fields = ( 'id', 'name', 'details', 'price', 'duration', 'academic_levels', 'available', ) export_order = ( 'id', 'name', 'details', 'price', 'duration', 'academic_levels', 'available', )
class ConferenceArticleResource(resources.ModelResource): facultyauthor = fields.Field(column_name='facultyauthor', widget=ManyToManyWidget(Faculty,'facultyname')) studentauthor = fields.Field(column_name='studentauthor', widget=ManyToManyWidget(Student,'sname')) rsauthor = fields.Field(column_name='rsauthor',widget=ManyToManyWidget(ResearchScholar, 'rsname')) def dehydrate_facultyauthor(self, conferencearticle): return ', '.join(map(str, conferencearticle.facultyauthor.all())) def dehydrate_studentauthor(self, conferencearticle): return ', '.join(map(str,conferencearticle.studentauthor.all())) def dehydrate_rsauthor(self, conferencearticle): return ', '.join(map(str,conferencearticle.rsauthor.all())) class Meta: model = ConferenceArticle fields = ('id','refformat','facultyauthor','studentauthor', 'rsauthor', 'ctitle','cname','presentedby', 'conferencecategory', 'cdateto', 'venue', 'country', 'csjr','csnip', 'cisbn', 'pubtojournalorbook', 'created_at', 'updated_at', 'created_by', 'updated_by') import_id_fields = ['id']
class ProductResourceAdmin(resources.ModelResource): markets = fields.Field(attribute='markets', column_name='markets', widget=ManyToManyWidget(Market, field='name')) class Meta: model = Product import_id_fields = 'code', exclude = 'id', 'updated', 'created', export_order = 'name', 'code', 'price', 'markets'
class JournalArticleResource(resources.ModelResource): facultyauthor = fields.Field(column_name='facultyauthor', widget=ManyToManyWidget(Faculty,'facultyname')) studentauthor = fields.Field(column_name='studentauthor', widget=ManyToManyWidget(Student,'sname')) rsauthor = fields.Field(column_name='rsauthor',widget=ManyToManyWidget(ResearchScholar, 'rsname')) def dehydrate_facultyauthor(self, journalarticle): return ', '.join(map(str, journalarticle.facultyauthor.all())) def dehydrate_studentauthor(self, journalarticle): return ', '.join(map(str,journalarticle.studentauthor.all())) def dehydrate_rsauthor(self, journalarticle): return ', '.join(map(str,journalarticle.rsauthor.all())) class Meta: model = JournalArticle fields = ('id','refformat', 'facultyauthor', 'studentauthor', 'rsauthor', 'jtitle', 'jname', 'jstatus_choice', 'jstatus', 'jpublishedon', 'jvolno', 'jissueno', 'jpageno', 'jtr', 'jsjr', 'jsnip', 'jissn', 'pubfromconf', 'created_at','updated_at','created_by','updated_by') import_id_fields=['id']
class CelebrityResource(resources.ModelResource): duties = fields.Field(attribute='duties', column_name='duties', widget=ManyToManyWidget(Duty, field='code', separator=',')) class Meta: model = Celebrity
class PublicationResource(resources.ModelResource): logo = publication__logo = 'uploads/2018/04/placeholder.png' targetGroups = fields.Field(column_name='targetGroups', attribute='targetGroups', widget=ManyToManyWidget( TargetGroup, ',', 'name')) class Meta: model = Publication import_id_fields = ('name', )
class OrganizationResource(resources.ModelResource): members = Field(column_name="members", attribute="members", widget=ManyToManyWidget(CustomUser)) volunteers = Field(column_name="volunteers", attribute="volunteers", widget=ManyToManyWidget(CustomUser)) visitors = Field(column_name="visitors", attribute="visitors", widget=ManyToManyWidget(CustomUser)) actives = Field(column_name="actives", attribute="actives", widget=ManyToManyWidget(CustomUser)) admins = Field(column_name="admins", attribute="admins", widget=ManyToManyWidget(CustomUser)) class Meta: model = Organization
class BaseAdvertisementResource(resources.ModelResource): eligible_program_branch = Field(attribute='eligible_program_branch', widget=ManyToManyWidget(ProgramAndBranch, field='name')) class Meta: abstract = True fields = ( 'company__name', 'designation', 'description', 'tentative_join_date', 'tentative_job_location', 'ctc', 'gross_salary', 'bonus', 'bond', 'bond_details', 'resume_required', 'resume_shortlist_criteria', 'aptitude_test_required', 'group_discussion_required', 'number_of_technical_interviews', 'number_of_technical_tests', 'number_of_hr_rounds', 'medical_test_required', 'min_gpa', 'number_of_members', 'other_details', ) export_order = ( 'company__name', 'designation', 'description', 'tentative_join_date', 'eligible_program_branch', 'min_gpa', 'tentative_job_location', 'ctc', 'gross_salary', 'bonus', 'bond', 'bond_details', 'resume_required', 'resume_shortlist_criteria', 'aptitude_test_required', 'group_discussion_required', 'number_of_technical_interviews', 'number_of_technical_tests', 'number_of_hr_rounds', 'medical_test_required', 'number_of_members', 'other_details', )
class VendorResource(ModelResource): """ Handles importting vendors """ types = Field(attribute="types", widget=ManyToManyWidget(model=Type, field="title")) subjects = Field(attribute="subjects", widget=ManyToManyWidget(model=Subject, field="title")) class Meta: model = Vendor import_id_fields = ("title", ) skip_unchanged = True report_skipped = True fields = ("title", "phone", "email", "website", "description", "subjects", "types", "address", "city", "state") def before_import(self, dataset, using_transactions, dry_run, **kwargs): # Lowercase headers to match field names if dataset.headers: dataset.headers = [ str(header).lower().strip() for header in dataset.headers ] def before_import_row(self, row, **kwargs): # Trim description whitespace try: row["description"] = row["description"].strip() except KeyError: pass # If city and state are provided separately, append them to the address # This will improve geocoder results later try: address = [row["address"]] if row["city"]: address.append(row["city"].strip()) if row["state"]: address.append(row["state"].strip()) row["address"] = ", ".join(address) except KeyError: pass
class EquipoResource(resources.ModelResource): #materiales = fields.Field(widget=ManyToManyWidget(Material)) materiales = fields.Field( widget=ManyToManyWidget(Material, field='idmaterial')) class Meta: model = Equipo skip_unchanged = False report_skipped = True exclude = ('id', ) import_id_fields = ('nombre', )