Beispiel #1
0
    def create_consultant(self, user, status, languages, industries, keywords,
                          exo_attributes, time_zone, coins, exo_areas,
                          created_by, last_activity):

        kwargs = {'coins': coins} if coins else {}
        if created_by is None:
            created_by = get_user_model().objects.filter(
                is_superuser=True).first()
        consultant = Consultant.objects.create_consultant(
            short_name=user.short_name,
            email=user.email,
            full_name=user.full_name,
            invite_user=created_by,
            registration_process=True,
            waiting_list=False,
            **kwargs)

        if last_activity:
            Member.objects.filter(user=consultant.user).update(
                modified=last_activity)

        self.update_consultant_status(consultant=consultant, status=status)

        for area in exo_areas:
            ConsultantExOArea.objects.create(
                consultant=consultant, exo_area=ExOArea.objects.get(name=area))

        for industry in industries:
            ConsultantIndustry.objects.create(
                consultant=consultant,
                level=find_tuple_values(settings.RELATION_INDUSTRIES_CHOICES,
                                        industry.get('level'))[0],
                industry=Industry.objects.get(name=industry.get('name')))

        for keyword in keywords:
            ConsultantKeyword.objects.create(
                consultant=consultant,
                level=find_tuple_values(settings.RELATION_KEYWORD_CHOICES,
                                        keyword.get('level'))[0],
                keyword=Keyword.objects.get(name=keyword.get('name')))

        # ExO attributes are created by default, so just update it
        for attr in exo_attributes:
            consultant_attribute = ConsultantExOAttribute.objects.get(
                consultant=consultant,
                exo_attribute=ExOAttribute.objects.get(
                    name=attr.get('attribute')))
            consultant_attribute.level = find_tuple_values(
                settings.RELATION_EXO_ATTRIBUTE_CHOICES, attr.get('level'))[0]
            consultant_attribute.save(update_fields=['level'])
        return consultant
    def create_project(self):
        category = find_tuple_values(
            settings.PROJECT_CH_CATEGORY,
            self.data.get('category', 'Transformation')
        )[0]
        generic_project = GenericProjectFactory(
            id=self.data.get('id'),
            uuid=self.data.get('uuid', uuid.uuid4()),
            name=self.data.get('name'),
            customer=self.data.get('customer'),
            duration=self.data.get('duration'),
            category=category,
            lapse=settings.PROJECT_LAPSE_PERIOD,
            start=self.data.get('start'),
            location=self.data.get('place').get('name'),
            place_id=self.data.get('place').get('place_id'),
        )

        user = self.data.get('created_by')
        if user and isinstance(user, Consultant):
            generic_project.created_by = user.user
        else:
            generic_project.created_by = user
        if self.data.get('template'):
            generic_project.template = self.data.get('template')
        generic_project.save()
        return generic_project
Beispiel #3
0
 def populate_streams(self, streams):
     for stream in streams:
         name = stream.get('name')
         code = find_tuple_values(settings.UTILS_STREAM_CH_TYPE, name)[0]
         new_stream = self.project.streams.create(name=name, code=code)
         for i in range(stream.get('num_team', 0)):
             self.project.teams.create(created_by=self.project.created_by,
                                       name='{} {}'.format(name, i),
                                       stream=new_stream)
    def update_internal_organization(self, user, internal_organization):
        organization, _ = InternalOrganization.objects.get_or_create(
            name=internal_organization.get('name'))
        status = find_tuple_values(settings.RELATION_ROLE_CH_STATUS,
                                   internal_organization.get('status'))[0]

        OrganizationUserRole.objects.get_or_create(
            user=user,
            organization=organization,
            position=internal_organization.get('position'),
            status=status)
Beispiel #5
0
    def create_object(self):
        status = find_tuple_values(
            settings.EXO_CERTIFICATION_COHORT_STATUS_CH_STATUSES,
            self.data.get('status'))[0]
        lang = find_tuple_values(settings.EXO_CERTIFICATION_COHORT_CH_LANGS,
                                 self.data.get('language'))[0]
        certification = ExOCertification.objects.get(
            level=self.data.get('certification'))

        return CertificationCohort.objects.create(
            certification=certification,
            uuid=self.data.get('uuid'),
            date=self.data.get('date'),
            seats=self.data.get('seats', 0),
            price=self.data.get('price'),
            currency=self.data.get('currency'),
            invoice_concept=self.data.get('invoice_concept'),
            language=lang,
            status=status,
        )
Beispiel #6
0
 def create_team(self, uuid, name, project, stream, coach, created_by,
                 zoom_id):
     return FakeTeamFactory(project=project.project_ptr,
                            uuid=uuid,
                            name=name,
                            stream=find_tuple_values(
                                settings.PROJECT_STREAM_CH_TYPE, stream)[0],
                            coach=coach,
                            created_by=created_by,
                            user_from=created_by,
                            zoom_id=zoom_id)
Beispiel #7
0
    def update_profile(self, profile, personal_mtp, mtp_mastery, availability):
        values = {}

        if personal_mtp:
            values.update({'personal_mtp': personal_mtp})

        if mtp_mastery:
            values.update({
                'mtp_mastery':
                find_tuple_values(
                    settings.CONSULTANT_SKILL_MTP_MASTERY_CHOICES,
                    mtp_mastery)[0]
            })

        if availability:
            values.update({
                'availability':
                find_tuple_values(settings.CONSULTANT_SKILL_AVAILABILITY,
                                  availability)[0]
            })

        ConsultantExOProfile.objects.filter(pk=profile.id).update(**values)
    def create_object(self):
        type = find_tuple_values(settings.EXO_CERTIFICATION_COUPON_CH_TYPES,
                                 self.data.get('type'))[0]

        certification = ExOCertification.objects.get(
            level=self.data.get('certification'))

        owner = self.data.get('owner', None)
        if owner:
            owner = owner.user

        return Coupon.objects.create(
            code=self.data.get('code'),
            certification=certification,
            expiry_date=self.data.get('expiry_date', None),
            max_uses=self.data.get('max_uses', 10),
            uses=self.data.get('uses', 0),
            discount=self.data.get('discount'),
            type=type,
            owner=owner,
            fixed_email=self.data.get('fixed_email', None),
            comment=self.data.get('comment', None),
        )