Ejemplo n.º 1
0
    def acceptInviteGet(self, request, context, params, request_entity,
                        **kwargs):
        """Handles the GET request concerning the creation of a Role via an
    invite.

    Args:
      request: the standard Django HTTP request object
      context: dictionary containing the context for this view
      params: a dict with params for this View
      request_entity: Request that is being accepted
      kwargs: contains the ID for the Request entity
    """

        # create the form using the scope_path and link_id from kwargs
        # as initial value
        fields = {
            'link_id': request_entity.user.link_id,
            'scope_path': request_entity.group.key().id_or_name()
        }

        fields.update(
            role_logic.getSuggestedInitialProperties(request_entity.user))

        form = params['invited_create_form'](initial=fields)
        # construct the appropriate response
        return super(View, self)._constructResponse(request,
                                                    entity=None,
                                                    context=context,
                                                    form=form,
                                                    params=params)
Ejemplo n.º 2
0
  def acceptInviteGet(self, request, context, params, request_entity,
                      **kwargs):
    """Handles the GET request concerning the creation of a Role via an
    invite.

    Args:
      request: the standard Django HTTP request object
      context: dictionary containing the context for this view
      params: a dict with params for this View
      request_entity: Request that is being accepted
      kwargs: contains the ID for the Request entity
    """

    # create the form using the scope_path and link_id from kwargs 
    # as initial value
    fields = {'link_id': request_entity.user.link_id,
              'scope_path': request_entity.group.key().id_or_name()}

    fields.update(role_logic.getSuggestedInitialProperties(
        request_entity.user))

    form = params['invited_create_form'](initial=fields)
    # construct the appropriate response
    return super(View, self)._constructResponse(request, entity=None,
        context=context, form=form, params=params)
Ejemplo n.º 3
0
 def testGetSuggestedInitialProperties(self):
   """Test that correct properties are retrieved.
   """
   role, properties = self.createRole(self.user)
   initial_properties = role_logic.getSuggestedInitialProperties(self.user)
   for key, value in properties.iteritems():
     if key in initial_properties:
       self.assertEqual(value, initial_properties[key])
Ejemplo n.º 4
0
 def testGetSuggestedInitialProperties(self):
     """Test that correct properties are retrieved.
 """
     role, properties = self.createRole(self.user)
     initial_properties = role_logic.getSuggestedInitialProperties(
         self.user)
     for key, value in properties.iteritems():
         if key in initial_properties:
             self.assertEqual(value, initial_properties[key])
Ejemplo n.º 5
0
  def acceptInvitationGet(self, request, context, params, form, **kwargs):
    """Handles the GET request concerning the creation of a Role
    via an invitation.
    """

    # create the form using the scope_path and link_id from request_entity 
    # as initial value
    fields = {
        'link_id': request_entity.user.link_id,
        'scope_path': request_entity.group.key().id_or_name()
        }

    fields.update(role_logic.getSuggestedInitialProperties(
        request_entity.user))

    form = form(initial=fields)

    # construct the appropriate response
    return super(View, self)._constructResponse(request, entity=None,
        context=context, form=form, params=params)
Ejemplo n.º 6
0
    def acceptInvitationGet(self, request, context, params, form, **kwargs):
        """Handles the GET request concerning the creation of a Role
    via an invitation.
    """

        # create the form using the scope_path and link_id from request_entity
        # as initial value
        fields = {
            'link_id': request_entity.user.link_id,
            'scope_path': request_entity.group.key().id_or_name()
        }

        fields.update(
            role_logic.getSuggestedInitialProperties(request_entity.user))

        form = form(initial=fields)

        # construct the appropriate response
        return super(View, self)._constructResponse(request,
                                                    entity=None,
                                                    context=context,
                                                    form=form,
                                                    params=params)
Ejemplo n.º 7
0
 def testGetSuggestedInitialPropertiesWithoutAnyRoles(self):
   """Test that an empty dict is returned when the user has no roles.
   """
   properties = role_logic.getSuggestedInitialProperties(self.user)
   self.assertEqual(properties, {})
Ejemplo n.º 8
0
 def testGetSuggestedInitialPropertiesWithoutAnyRoles(self):
     """Test that an empty dict is returned when the user has no roles.
 """
     properties = role_logic.getSuggestedInitialProperties(self.user)
     self.assertEqual(properties, {})