예제 #1
0
파일: forms.py 프로젝트: shawiz/idlebook
 def save(self, facebook_data):
     new_user = User.objects.create(
         username=self.cleaned_data['email'],
         email=self.cleaned_data['email']
     )
     new_user.first_name = facebook_data['first_name']
     new_user.last_name = facebook_data['last_name']
     
     new_user.save()
     new_user.set_unusable_password()
     new_username = int(new_user.id) + 1000000
             
     # set network for the user after registration
     # todo: make it universal for all universities using email pattern        
     network = Network.objects.get(id=1)
     
     profile = UserProfile(
         user=new_user,
         username=new_username,
         network=network
     )
     profile.save()
     
     wallet = Wallet(user=new_user)
     wallet.save()
     
     notif_setting = NotificationSettings(user=new_user)
     notif_setting.save()
             
     # send email confirmation
     EmailConfirmation.objects.send_confirmation(self.cleaned_data['email'], profile)
     
     return new_user
예제 #2
0
 def add_to_wallet(self, data):
     """
     Encapsulates the saving into the wallet
     return: wallet saved row
     """
     rec = Wallet(**data)
     rec.save()
     self.log.info('Added to wallet: %s', rec)
     return rec
예제 #3
0
파일: run.py 프로젝트: gibegod/bc-romantic
def account():
    wallets = Wallet.get_by_idowner(current_user.id)
    form = WalletForm()
    if form.validate_on_submit():
        name = form.name.data
        key = form.key.data
        wallet = Wallet(name=name, owner_id=current_user.id, key = key)
        wallet.save()
        return redirect(url_for('account'))
    return render_template('myaccount.html', wallets=wallets, form=form)