Ejemplo n.º 1
0
  def testNotificationSettingsCreated(self):
    """Tests that notification settings is created properly if data is valid."""
    notification_settings = profile_logic.createtNotificationSettings(
        TEST_NOTIFICATION_SETTINGS_PROPERTIES)

    # check properties
    self.assertEqual(
        notification_settings.to_dict(), TEST_NOTIFICATION_SETTINGS_PROPERTIES)
Ejemplo n.º 2
0
  def post(self, data, check, mutator):
    """See base.RequestHandler.post for specification."""
    form = NotificationSettingsForm(data=data.POST)
    if form.is_valid():
      properties = form.getNotificationSettingsProperties()
      profile_properties = {
          profile_model.Profile.notification_settings._name:
              profile_logic.createtNotificationSettings(properties)
          }

      result = profile_logic.editProfile(
          data.ndb_profile.key, profile_properties)
      if not result:
        raise exception.BadRequest(message=result.extra)
      else:
        url = self.linker.program(
            data.program, self.url_names.PROFILE_NOTIFICATION_SETTINGS)
      return http.HttpResponseRedirect(url)
    else:
      # TODO(nathaniel): problematic self-call.
      return self.get(data, check, mutator)