예제 #1
0
    def comment_spam_status(self, REQUEST):
        """
        Set comment spam status
        Status: True/False
        If it's an AJAX request return a message,
        else redirect user to the admin page
        """

        id_comment = REQUEST.form.get('id', '')
        status = str2bool(REQUEST.form.get('status', False))
        user = REQUEST.AUTHENTICATED_USER.getUserName()
        status_set = False
        translate = self.getPortalI18n().get_translation

        if self._set_comment_spam_status(id_comment, status):
            status_set = True

        if is_ajax(REQUEST):
            if status_set:
                return json_response({'status': 'success'}, REQUEST.RESPONSE)
            else:
                return json_response({'status': 'error',
                                      'message': translate(MESSAGE_ERROROCCURRED)},
                                    REQUEST.RESPONSE)
        else:
            if status_set:
                self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate())
            else:
                self.setSessionErrorsTrans(MESSAGE_ERROROCCURRED)
            return REQUEST.RESPONSE.redirect('%s/index_html' % self.absolute_url())

        return False
예제 #2
0
    def comment_spam_status(self, REQUEST):
        """
        Set comment spam status
        Status: True/False
        If it's an AJAX request return a message,
        else redirect user to the admin page
        """

        id_comment = REQUEST.form.get('id', '')
        status = str2bool(REQUEST.form.get('status', False))
        status_set = False
        translate = self.getPortalI18n().get_translation

        if self._set_comment_spam_status(id_comment, status):
            status_set = True

        if is_ajax(REQUEST):
            if status_set:
                return json_response({'status': 'success'}, REQUEST.RESPONSE)
            else:
                return json_response(
                    {
                        'status': 'error',
                        'message': translate(MESSAGE_ERROROCCURRED)
                    }, REQUEST.RESPONSE)
        else:
            if status_set:
                self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES,
                                         date=self.utGetTodayDate())
            else:
                self.setSessionErrorsTrans(MESSAGE_ERROROCCURRED)
            return REQUEST.RESPONSE.redirect('%s/index_html' %
                                             self.absolute_url())

        return False
예제 #3
0
    def getProfiles(self, account, REQUEST=None):
        """ """
        resp_json = self._api_get('management/accounts/%s/webproperties'
                                  % account)
        data = {'profiles': [{'code': i['id'], 'name': i['name']}
                             for i in resp_json['items']]}

        if REQUEST is not None:
            return json_response(data, REQUEST.RESPONSE)
        else:
            return data
예제 #4
0
    def getProfiles(self, account, REQUEST=None):
        """ """
        resp_json = self._api_get('management/accounts/%s/webproperties' %
                                  account)
        data = {
            'profiles': [{
                'code': i['id'],
                'name': i['name']
            } for i in resp_json['items']]
        }

        if REQUEST is not None:
            return json_response(data, REQUEST.RESPONSE)
        else:
            return data
예제 #5
0
    def upload_maintopic_temp_image(self, REQUEST):
        """ """
        temp_folder = self.getSite().temp_folder
        file = REQUEST.form.get("upload_file", None)
        if file is None:
            return json_response({'error': "no file"}, REQUEST.RESPONSE)

        id = make_id(temp_folder)
        manage_addImage(temp_folder, id, file=file)
        ob = getattr(temp_folder, id)

        skin = self.getLayoutTool().getCurrentSkin()
        image_size = map(int, skin.main_section_image_size.split("x"))

        try:
            data = crop_image(ob, image_size)
        except AssertionError, e:
            data = {"error": str(e)}
예제 #6
0
    def comment_del(self, REQUEST):
        """
        Delete a comment.
        """

        id_comment = REQUEST.form.get('id', '')
        user = REQUEST.AUTHENTICATED_USER.getUserName()

        self._comment_del(id_comment)

        auth_tool = self.getAuthenticationTool()
        auth_tool.changeLastPost(user)

        if is_ajax(REQUEST):
            return json_response({'status': 'success'}, REQUEST.RESPONSE)
        else:
            self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate())
            return REQUEST.RESPONSE.redirect('%s/index_html' % self.absolute_url())
예제 #7
0
    def upload_maintopic_temp_image(self, REQUEST):
        """ """
        temp_folder = self.getSite().temp_folder
        file = REQUEST.form.get("upload_file", None)
        if file is None:
            return json_response({'error': "no file"}, REQUEST.RESPONSE)

        filename = file.filename
        id = make_id(temp_folder, id=filename)
        manage_addImage(temp_folder, id, file=file)
        ob = getattr(temp_folder, id)

        skin = self.getLayoutTool().getCurrentSkin()
        image_size = map(int, skin.main_section_image_size.split("x"))

        try:
            data = crop_image(ob, image_size)
        except AssertionError, e:
            data = {"error": str(e)}
예제 #8
0
    def comment_del(self, REQUEST):
        """
        Delete a comment.
        """

        id_comment = REQUEST.form.get('id', '')
        user = REQUEST.AUTHENTICATED_USER.getUserName()

        self._comment_del(id_comment)

        auth_tool = self.getAuthenticationTool()
        auth_tool.changeLastPost(user)

        if is_ajax(REQUEST):
            return json_response({'status': 'success'}, REQUEST.RESPONSE)
        else:
            self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES,
                                     date=self.utGetTodayDate())
            return REQUEST.RESPONSE.redirect('%s/index_html' %
                                             self.absolute_url())
예제 #9
0
        if file is None:
            return json_response({'error': "no file"}, REQUEST.RESPONSE)

        id = make_id(temp_folder)
        manage_addImage(temp_folder, id, file=file)
        ob = getattr(temp_folder, id)

        skin = self.getLayoutTool().getCurrentSkin()
        image_size = map(int, skin.main_section_image_size.split("x"))

        try:
            data = crop_image(ob, image_size)
        except AssertionError, e:
            data = {"error": str(e)}

        return json_response(data, REQUEST.RESPONSE)

    security.declareProtected(PERMISSION_PUBLISH_OBJECTS,
                              'upload_slider_temp_image')

    def upload_slider_temp_image(self, REQUEST):
        """ """
        temp_folder = self.getSite().temp_folder
        file = REQUEST.form.get("upload_file", None)
        if file is None:
            return json_response({'error': "no file"}, REQUEST.RESPONSE)

        id = make_id(temp_folder)
        manage_addImage(temp_folder, id, file=file)
        ob = getattr(temp_folder, id)
예제 #10
0
            return json_response({'error': "no file"}, REQUEST.RESPONSE)

        filename = file.filename
        id = make_id(temp_folder, id=filename)
        manage_addImage(temp_folder, id, file=file)
        ob = getattr(temp_folder, id)

        skin = self.getLayoutTool().getCurrentSkin()
        image_size = map(int, skin.main_section_image_size.split("x"))

        try:
            data = crop_image(ob, image_size)
        except AssertionError, e:
            data = {"error": str(e)}

        return json_response(data, REQUEST.RESPONSE)

    security.declareProtected(PERMISSION_PUBLISH_OBJECTS,
                              'upload_slider_temp_image')

    def upload_slider_temp_image(self, REQUEST):
        """ """
        temp_folder = self.getSite().temp_folder
        file = REQUEST.form.get("upload_file", None)
        if file is None:
            return json_response({'error': "no file"}, REQUEST.RESPONSE)

        filename = file.filename
        id = make_id(temp_folder, id=filename)
        manage_addImage(temp_folder, id, file=file)
        ob = getattr(temp_folder, id)