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
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
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)