Example #1
0
    def save(self):
        new_user = User.objects.create_user(self.cleaned_data['email'],
                                            self.cleaned_data['email'],
                                            self.cleaned_data.get('password'))
        new_user.first_name = self.cleaned_data['first_name']
        new_user.last_name = self.cleaned_data['last_name']
        new_user.is_active = False
        new_user.save()

        #create the activation key
        salt = str(random.random())
        hash_salt = hashlib.sha224(salt).hexdigest()
        activation_key = hashlib.sha224(hash_salt +
                                        new_user.username).hexdigest()[:32]
        key_expires = datetime.datetime.today() + datetime.timedelta(days=1)

        key_obj = ActivationKey(user=new_user,
                                activation_key=activation_key,
                                key_expires=key_expires)
        key_obj.save()

        new_profile = UserProfile(user=new_user,
                                  account_type=UserProfile.ACCOUNT_VOLUNTEER)

        new_profile.save()

        return new_user
Example #2
0
    def save(self):
        new_user = User.objects.create_user(
            self.cleaned_data['primary_contact_email'],
            self.cleaned_data['primary_contact_email'],
            self.cleaned_data.get('password'))
        new_user.first_name = self.cleaned_data['primary_contact_first_name']
        new_user.last_name = self.cleaned_data['primary_contact_last_name']
        new_user.is_active = False
        new_user.save()

        salt = str(random.random())
        hash_salt = hashlib.sha224(salt).hexdigest()
        activation_key = hashlib.sha224(hash_salt +
                                        new_user.username).hexdigest()[:32]
        key_expires = datetime.datetime.today() + datetime.timedelta(days=1)

        key_obj = ActivationKey(user=new_user,
                                activation_key=activation_key,
                                key_expires=key_expires)
        key_obj.save()

        new_profile = UserProfile(
            user=new_user,
            account_type=UserProfile.ACCOUNT_ORGANIZATION,
            organization_name=self.cleaned_data['business_name'],
            organization_address=self.cleaned_data['business_address'],
            organization_city=self.cleaned_data['business_city'],
            organization_state=self.cleaned_data['business_state'],
            organization_postalzip=self.cleaned_data['business_zip'],
            organization_phone=self.cleaned_data['business_phone'])

        new_profile.save()
        print new_profile

        return new_user
Example #3
0
    def save(self):
        new_user = User.objects.create_user(self.cleaned_data['primary_contact_email'], self.cleaned_data['primary_contact_email'], self.cleaned_data.get('password'))
        new_user.first_name = self.cleaned_data['primary_contact_first_name']
        new_user.last_name = self.cleaned_data['primary_contact_last_name']
        new_user.is_active = False
        new_user.save()
        
        salt = str(random.random())
        hash_salt = hashlib.sha224(salt).hexdigest()
        activation_key = hashlib.sha224(hash_salt + new_user.username).hexdigest()[:32]
        key_expires = datetime.datetime.today() + datetime.timedelta(days=1)
        
        key_obj = ActivationKey(user=new_user,activation_key=activation_key,key_expires=key_expires)
        key_obj.save()

        new_profile = UserProfile(user=new_user,
                                  account_type=UserProfile.ACCOUNT_ORGANIZATION,
                                  organization_name=self.cleaned_data['business_name'],
                                  organization_address=self.cleaned_data['business_address'],
                                  organization_city=self.cleaned_data['business_city'],
                                  organization_state=self.cleaned_data['business_state'],
                                  organization_postalzip=self.cleaned_data['business_zip'],
                                  organization_phone=self.cleaned_data['business_phone']
                        )
            
        new_profile.save()
        print new_profile
        
        return new_user
Example #4
0
 def save(self):
     new_user = User.objects.create_user(self.cleaned_data['email'], self.cleaned_data['email'], self.cleaned_data.get('password'))
     new_user.first_name = self.cleaned_data['first_name']
     new_user.last_name = self.cleaned_data['last_name']
     new_user.is_active = False
     new_user.save()
     
     #create the activation key
     salt = str(random.random())
     hash_salt = hashlib.sha224(salt).hexdigest()
     activation_key = hashlib.sha224(hash_salt + new_user.username).hexdigest()[:32]
     key_expires = datetime.datetime.today() + datetime.timedelta(days=1)
     
     key_obj = ActivationKey(user=new_user,activation_key=activation_key,key_expires=key_expires)
     key_obj.save()
     
     new_profile = UserProfile(user=new_user,account_type=UserProfile.ACCOUNT_VOLUNTEER)
         
     new_profile.save()
     
     return new_user