Advertisement
Guest User

request.py

a guest
Jun 11th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1.   def _createFromForm(self):
  2.     """Creates a new request based on the data inserted in the form.
  3.  
  4.    Returns:
  5.      a newly created Request entity or None
  6.    """
  7.     assert isSet(self.data.organization)
  8.  
  9.     connection_form = ConnectionForm(
  10.         data=self.data.POST)
  11.  
  12.     if not connection_form.is_valid():
  13.       return None
  14.  
  15.     # create a new invitation entity
  16.     connection_form.cleaned_data['user'] = self.data.user
  17.     connection_form.cleaned_data['organization'] = self.data.organization
  18.     connection_form.cleaned_data['role'] = 'mentor'
  19.     connection_form.cleaned_data['user_action'] = 'accepted'
  20.     connection_form.cleaned_data['org_action'] = 'pending'
  21.  
  22.     # alert the org admins that a new request has been submitted
  23.     q = GSoCProfile.all().filter('org_admin_for', self.data.organization)
  24.     q = q.filter('status', 'active').filter('notify_new_requests', True)
  25.     admins = q.fetch(1000)
  26.     admin_emails = [i.email for i in admins]
  27.  
  28.     def create_connection_txn():
  29.       conn = connection_form.create(commit=True, parent=self.data.user)
  30.       # TODO(dcrodman): Add inviteContext function & fix notifications for conns
  31.       # context = notifications.requestContext(self.data, request, admin_emails)
  32.       # sub_txn = mailer.getSpawnMailTaskTxn(context, parent=request)
  33.       # sub_txn()
  34.       return conn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement