Ejemplo n.º 1
0
    def setUp(self):
        from naaya.core.zope2util import getExtConfiguration as getConfiguration
        from Products.Naaya.NySite import NySite

        self.config = getConfiguration()
        self.config_patch = patch.object(self.config, 'environment', {},
                                         create=True)
        self.config_patch.start()

        self.environ_patch = patch.dict(os.environ)
        self.environ_patch.start()

        self.portal = NySite('test-site')
Ejemplo n.º 2
0
    def setUp(self):
        from naaya.core.zope2util import getExtConfiguration as getConfiguration
        from Products.Naaya.NySite import NySite

        self.config = getConfiguration()
        self.config_patch = patch.object(self.config,
                                         'environment', {},
                                         create=True)
        self.config_patch.start()

        self.environ_patch = patch.dict(os.environ)
        self.environ_patch.start()

        self.portal = NySite('test-site')
Ejemplo n.º 3
0
    def setUp(self):
        from naaya.core.zope2util import getExtConfiguration as getConfiguration
        from Products.Naaya.NySite import NySite

        self.config = getConfiguration()
        self.config_patch = patch.object(self.config, 'environment', {},
                                         create=True)
        self.config_patch.start()

        self.environ_patch = patch.dict(os.environ)
        self.environ_patch.start()

        self.portal = NySite('test')
        self.portal.portal_email = EmailTool('id_email_tool', 'Test email tool')

        self.TMP_FOLDER = tempfile.mkdtemp()
Ejemplo n.º 4
0
    def setUp(self):
        from naaya.core.zope2util import getExtConfiguration as getConfiguration
        from Products.Naaya.NySite import NySite

        self.config = getConfiguration()
        self.config_patch = patch.object(self.config,
                                         'environment', {},
                                         create=True)
        self.config_patch.start()

        self.environ_patch = patch.dict(os.environ)
        self.environ_patch.start()

        self.portal = NySite('test')
        self.portal.portal_email = EmailTool('id_email_tool',
                                             'Test email tool')

        self.TMP_FOLDER = tempfile.mkdtemp()
Ejemplo n.º 5
0
def AdminAPIKeysStatus(context, request):
    """
    Check if API keys exists and are valid
    """
    conf = getConfiguration()

    #Akismet
    api_keys = {'akismet': {'key': '', 'valid': False}}

    akismet_api_key = getattr(conf, 'environment',
                              {}).get('AKISMET_API_KEY', '')
    valid = False
    if akismet_api_key:
        valid = akismet.verify_key(akismet_api_key, context.getSitePath())

    api_keys['akismet'] = {
        'title': 'Akismet',
        'description': 'Filters comments and track-back spam',
        'key': akismet_api_key,
        'valid': valid,
        'change_link': None
    }

    google_client_id = getattr(conf, 'environment',
                               {}).get('GOOGLE_AUTH_CLIENT_ID', '')
    valid = False
    if google_client_id:
        valid = True

    api_keys['google_client_id'] = {
        'title': 'Google Authentication Client ID',
        'description': 'Google Authentication Client ID',
        'key': None,
        'valid': valid,
        'change_link': None
    }

    google_client_secret = getattr(conf, 'environment',
                                   {}).get('GOOGLE_AUTH_CLIENT_SECRET', '')
    valid = False
    if google_client_secret:
        valid = True

    api_keys['google_client_secret'] = {
        'title': 'Google Authentication Client Secret Key',
        'description': 'Google Authentication Client Secret Key',
        'key': None,
        'valid': valid,
        'change_link': None
    }

    master_ga_id = getattr(conf, 'environment', {}).get('GA_ID', '')
    valid = False
    if master_ga_id:
        valid = True

    api_keys['master_ga_id'] = {
        'title': 'Google Analytics primary tracking code',
        'description':
        'The GA web property of the master profile (the profile of the top-level domain)',
        'key': master_ga_id,
        'valid': valid,
        'change_link': None
    }

    ga_domain_name = getattr(conf, 'environment', {}).get('GA_DOMAIN_NAME', '')
    valid = False
    if ga_domain_name:
        valid = True

    api_keys['ga_domain_name'] = {
        'title': 'Google Analytics domain name',
        'description': 'Sets the domain name to the top-level domain for '
        'the portal',
        'key': ga_domain_name,
        'valid': valid,
        'change_link': None
    }

    #Google Analytics
    ga_id = getattr(context.portal_statistics, 'ga_id', '')
    valid = False
    if ga_id:
        valid = True

    api_keys['ga_id'] = {
        'title': 'Google Analytics portal tracking code',
        'description':
        'Allows Google to access your website traffic data and saves data in portal profile of GA.',
        'key': ga_id,
        'valid': valid,
        'change_link': '/portal_statistics/admin_verify'
    }

    #reCaptcha
    recaptcha_private_key = context.get_recaptcha_private_key()
    valid = False
    if recaptcha_private_key:
        valid = True

    api_keys['recaptcha_private_key'] = {
        'title': 'reCaptcha private key',
        'description': 'reCaptcha private key for CAPTCHA verification',
        'key': recaptcha_private_key,
        'valid': valid,
        'change_link': '/admin_properties_html'
    }

    recaptcha_public_key = context.get_recaptcha_public_key()
    valid = False
    if recaptcha_public_key:
        valid = True

    api_keys['recaptcha_public_key'] = {
        'title': 'reCaptcha public key',
        'description': 'reCaptcha public key for CAPTCHA verification',
        'key': recaptcha_public_key,
        'valid': valid,
        'change_link': '/admin_properties_html'
    }

    options = {
        'here': context,
        'api_keys': api_keys,
    }

    return tmpl.__of__(context)(**options)
Ejemplo n.º 6
0
from OFS.Folder import Folder

from Products.NaayaBase.events import NyCommentAddEvent
from Products.NaayaCore.FormsTool.NaayaTemplate import NaayaPageTemplateFile
from constants import *
from Products.NaayaCore.managers.utils import utils
import interfaces
import akismet
from akismet import AkismetError
from unidecode import unidecode
from naaya.core.utils import cleanup_message, is_ajax, str2bool
from naaya.core.zope2util import json_response, ofs_path

akismet.USERAGENT = "MyApplication/MyVersion"

configuration = getConfiguration()
environment = getattr(configuration, 'environment', {})
has_api_key = 'AKISMET_API_KEY' in environment

if has_api_key:
    akismet_api_key = environment.get('AKISMET_API_KEY', '')


@adapter(interfaces.INyCommentable, IObjectEvent)
def handleComentedObject(ob, event):
    if IObjectAddedEvent.providedBy(event):
        catalog_comments(ob)
    elif IObjectMovedEvent.providedBy(event):
        if event.newParent is not None:
            catalog_comments(ob)
    elif IObjectWillBeMovedEvent.providedBy(event):
Ejemplo n.º 7
0
from OFS.Folder import Folder

from Products.NaayaBase.events import NyCommentAddEvent
from Products.NaayaCore.FormsTool.NaayaTemplate import NaayaPageTemplateFile
from constants import *
from Products.NaayaCore.managers.utils import utils
import interfaces
import akismet
from akismet import AkismetError
from unidecode import unidecode
from naaya.core.utils import cleanup_message, is_ajax, str2bool
from naaya.core.zope2util import json_response, ofs_path

akismet.USERAGENT = "MyApplication/MyVersion"

configuration = getConfiguration()
environment = getattr(configuration, 'environment', {})
has_api_key = 'AKISMET_API_KEY' in environment

if has_api_key:
    akismet_api_key = environment.get('AKISMET_API_KEY', '')


@adapter(interfaces.INyCommentable, IObjectEvent)
def handleComentedObject(ob, event):
    if IObjectAddedEvent.providedBy(event):
        catalog_comments(ob)
    elif IObjectMovedEvent.providedBy(event):
        if event.newParent is not None:
            catalog_comments(ob)
    elif IObjectWillBeMovedEvent.providedBy(event):