Exemplo n.º 1
0
    def patch(self):
        """Update settings with payload.
        method follows the rfc5789 PATCH and rfc7396 Merge patch
        specifications, + 'current_state' caliopen's specs.
        stored messages are modified according to the fields within the
        payload, ie payload fields squash existing db fields, no other
        modification done. If message doesn't existing, response is 404.
        If payload fields are not conform to the message db schema, response is
        422 (Unprocessable Entity).
        Successful response is 204, without a body.
        """
        patch = self.request.json

        settings = ObjectSettings(self.user)
        error = settings.apply_patch(patch, db=True)
        if error is not None:
            raise MergePatchError(error)

        return Response(None, 204)
Exemplo n.º 2
0
def setup_settings(user, settings):
    """Create settings related to user."""
    # XXX set correct values

    settings = {
        'user_id': user.user_id,
        'default_locale': settings.default_locale,
        'message_display_format': settings.message_display_format,
        'contact_display_order': settings.contact_display_order,
        'contact_display_format': settings.contact_display_format,
        'notification_enabled': settings.notification_enabled,
        'notification_message_preview': settings.notification_message_preview,
        'notification_sound_enabled': settings.notification_sound_enabled,
        'notification_delay_disappear': settings.notification_delay_disappear,
    }

    obj = ObjectSettings(user)
    obj.unmarshall_dict(settings)
    obj.marshall_db()
    obj.save_db()
    return True