예제 #1
0
파일: views.py 프로젝트: rosscdh/glynt
    def get_form(self, form_class):
        kwargs = self.get_form_kwargs()
        kwargs.update({'request': self.request})  # add the request to the form
        user = self.request.user

        customer_service = EnsureCustomerService(user=user)
        self.customer = customer_service.process()

        # get the startup
        startup = self.customer.primary_company

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

            'photo': self.customer.profile_photo,

            'company_name': startup,
            'website': startup.website,
            'summary': startup.summary,

            'agree_tandc': self.customer.data.get('agree_tandc', False),
        }})
        return form_class(**kwargs)
예제 #2
0
    def process(self):
        customer_service = EnsureCustomerService(user=self.user, **self.data)
        self.customer = customer_service.process()

        startup_service = EnsureCompanyService(name=self.startup_name, customer=self.customer, **self.data)
        self.startup = startup_service.process()

        project, is_new = self.save_project()

        self.notify(self.project, is_new)

        return self.project
예제 #3
0
파일: forms.py 프로젝트: rosscdh/glynt
    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
예제 #4
0
파일: forms.py 프로젝트: rosscdh/glynt
    def save(self, commit=True):
        data = self.cleaned_data

        #self.user
        logger.info('CustomerProfileSetupForm Starting')

        # @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

        customer_service = EnsureCustomerService(user=self.user, **data)
        customer = customer_service.process()

        if self.user.profile.is_customer:
            company_service = EnsureCompanyService(name=data.get('company_name'), customer=customer, **data)
            company_service.process()
예제 #5
0
파일: models.py 프로젝트: rosscdh/glynt
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')