Exemplo n.º 1
0
    def save(self, commit=True):
        logger.info('Ensuring the LawyerProfile Exists')

        data = self.cleaned_data

        firm_name = data.pop('firm_name')

        # @TODO should be in the clean_photo method
        hidden_photo = self.cleaned_data.get('hidden_photo', None)
        if type(hidden_photo) is int:
            try:
                data['photo'] = UploadedFile.objects.get(pk=hidden_photo)
            except UploadedFile.DoesNotExist:
                data['photo'] = None


        offices = []
        # dont pop these as we need them for local storage in lawyer
        offices.append(data.get('practice_location_1', None))
        offices.append(data.get('practice_location_2', None))

        lawyer_service = EnsureLawyerService(user=self.user, firm_name=firm_name, offices=offices, form=self, **data)
        lawyer_service.process()

        self.delete_cookies()
        # clear the nav cache for the user
        cache.delete(make_template_fragment_key("user", ["mugshot", self.request.user.pk]))

        logger.info('Complete: Ensuring the LawyerProfile Exists')
Exemplo n.º 2
0
    def import_csv(self, csv_file):
        """
        First name, Last name, Firm , Title, Angelist URL, email, City/Location,phone,LinkedIn,Facebook,Twitter,Other start-ups advised
        """
        with open(csv_file, 'rb') as csv_file:
            print("starting csv")
            dialect = csv.Sniffer().sniff(csv_file.read(1024))
            csv_file.seek(0)

            for i, r in enumerate(csv.reader(csv_file, dialect)):
                # skip title row
                if i > 0:
                    # get nice names
                    for k,v in enumerate(r):
                        r[k] = smart_unicode(v)

                    username = slugify(u'%s-%s'% (r[0], r[1],))

                    try:
                        user, user_is_new = User.objects.get_or_create(username=username, first_name=r[0], last_name=r[1], email=r[5])
                    except IntegrityError:
                        username = slugify(u'%s-%s%s'% (r[0], r[1], r[5],))
                        user, user_is_new = User.objects.get_or_create(username=username, first_name=r[0], last_name=r[1], email=r[5])
    
                    firm_name = r[2]
                    offices = r[6]

                    lawyer_service = EnsureLawyerService(user=user, firm_name=firm_name, offices=[offices])
                    lawyer_service.process()
Exemplo n.º 3
0
    def save(self, commit=True):
        user = self.user

        if commit is True:
            data = self.cleaned_data.copy()

            if self.user.profile.is_lawyer:
                lawyer_service = EnsureLawyerService(user=self.user, firm_name=data.get('company_name'), offices=[], form=self, **data)
                lawyer_service.process()

            elif self.user.profile.is_customer:
                customer_service = EnsureCustomerService(user=user, **data)
                customer = customer_service.process()

                company_service = EnsureCompanyService(name=data.pop('company_name'), customer=customer, **data)
                company_service.process()

        return user
Exemplo n.º 4
0
    def get_form(self, form_class):
        """
        Returns an instance of the form to be used in this view.
        """
        kwargs = self.get_form_kwargs()
        kwargs.update({'request': self.request}) # add the request to the form

        user = self.request.user
        lawyer_service = EnsureLawyerService(user=user)
        lawyer_service.process()
        lawyer = self.lawyer = lawyer_service.lawyer
        firm = lawyer_service.firm

        companies_advised = lawyer.data.get('companies_advised', [])

        kwargs.update({'initial': {
            'first_name': user.first_name,
            'last_name': user.last_name,
            'email': user.email,

            'role': lawyer.role,
            'phone': lawyer.phone if lawyer.phone not in [None,'None'] else '',

            'firm_name': getattr(firm, 'name', None),
            'practice_location_1': lawyer.data.get('practice_location_1', None),
            'practice_location_2': lawyer.data.get('practice_location_2', None),

            'years_practiced': lawyer.years_practiced,
            'summary': lawyer.summary,
            'bio': lawyer.bio,
            'if_i_wasnt_a_lawyer': lawyer.data.get('if_i_wasnt_a_lawyer', None),
            'companies_advised': json.dumps(companies_advised),

            'photo': lawyer.profile_photo,
            'twitter': lawyer.data.get('twitter',''),

            'linkedin': lawyer.data.get('linkedin',''),
            'agree_tandc': lawyer.data.get('agree_tandc', None),
        }})
        return form_class(**kwargs)
Exemplo n.º 5
0
def create_glynt_profile(profile, is_new):
    """ function used to create the appropriate glynt profile type
    for a user signing in """
    logger.info('create_glynt_profile for User %s' % profile.user.pk)
    user = profile.user

    logger.info('User is of class %s' % profile.user_class)

    if not is_new:
        logger.info('create_glynt_profile profile is not new User %s' % profile.user.pk)
    else:
        if profile.is_customer:
            logger.info('Creating Customer Profile for User %s' % user.username)
            customer_service = EnsureCustomerService(user=user)
            customer_service.process()

        elif profile.is_lawyer:
            logger.info('Creating Lawyer Profile for User %s' % user.username)
            lawyer_service = EnsureLawyerService(user=user)
            lawyer_service.process()

        else:
            raise Exception('Could not identify user class')