Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _createFromForm(self):
- """Creates a new connection based on the data inserted in the form.
- Returns:
- a newly created Connection entity or None
- """
- assert isSet(self.data.organization)
- connection_form = ConnectionForm(self.data, self.data.POST)
- if not connection_form.is_valid():
- return None
- assert isSet(self.data.connected_user)
- assert self.data.connected_user
- # create a new connection entity
- connection_form.cleaned_data['organization'] = self.data.organization
- connection_form.cleaned_data['user_action'] = 'pending'
- connection_form.cleaned_data['org_action'] = 'accepted'
- def create_invite_txn(user):
- connection = connection_form.create(commit=True, parent=user)
- # TODO(dcrodman): Make this work for connections
- #context = notifications.inviteContext(self.data, connection)
- #sub_txn = mailer.getSpawnMailTaskTxn(context, parent=connection)
- #sub_txn()
- return connection
- for user in self.data.connected_user:
- connection_form.instance = None
- connection_form.cleaned_data['user'] = user
- db.run_in_transaction(create_invite_txn, user)
- return True
Advertisement
Add Comment
Please, Sign In to add comment