def add_anonymous_subscription(self, **kw):
        """ Handle anonymous users """
        self._validate_subscription(anonymous=True, **kw)
        subscription = AnonymousSubscription(**kw)
        # Add to temporary container
        self.pending_anonymous_subscriptions.append(subscription)

        # Send email
        email_tool = self.getSite().getEmailTool()
        email_from = email_tool.get_addr_from()
        email_template = EmailPageTemplateFile(
            'emailpt/confirm.zpt', globals())
        email_data = email_template.render_email(
            **{'key': subscription.key, 'here': self})
        email_to = subscription.email
        email_tool.sendEmail(email_data['body_text'], email_to, email_from,
                             email_data['subject'])
    def add_anonymous_subscription(self, **kw):
        """ Handle anonymous users """
        self._validate_subscription(anonymous=True, **kw)
        subscription = AnonymousSubscription(**kw)
        # Add to temporary container
        self.pending_anonymous_subscriptions.append(subscription)

        # Send email
        email_tool = self.getSite().getEmailTool()
        email_from = email_tool.get_addr_from()
        email_template = EmailPageTemplateFile(
            'emailpt/confirm.zpt', globals())
        email_data = email_template.render_email(
            **{'key': subscription.key, 'here': self})
        email_to = subscription.email
        email_tool.sendEmail(email_data['body_text'], email_to, email_from,
                             email_data['subject'])
          '_module': sys.modules[__name__],
          'icon': os.path.join(os.path.dirname(__file__), 'www',
                               'NyMunicipality.gif'),
          'on_install': setupContentType,
          'additional_style': AdditionalStyle('www/municipality.css',
                                              globals()),
          '_misc': {
              'NyMunicipality.gif': ImageFile('www/NyMunicipality.gif',
                                              globals()),
              'NyMunicipality_marked.gif': ImageFile(
                  'www/NyMunicipality_marked.gif', globals()),
              },
          }

email_templates = {
    'email_when_unapproved_to_maintainer': EmailPageTemplateFile(
        'templates/email_when_unapproved_to_maintainer.zpt', globals()),
}


def municipality_add_html(self, REQUEST=None, RESPONSE=None):
    """ """
    from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype
    form_helper = get_schema_helper_for_metatype(self, METATYPE_OBJECT)
    return self.getFormsTool().getContent(
        {'here': self, 'kind': METATYPE_OBJECT, 'action': 'addNyMunicipality',
         'form_helper': form_helper}, 'municipality_add')


def _create_NyMunicipality_object(parent, id, title, contributor):
    id = make_id(parent, id=id, title=title, prefix='municipality')
    ob = NyMunicipality(id, title, contributor)
from naaya.core.zope2util import ofs_path
from naaya.core.zope2util import folder_manage_main_plus
from naaya.core.exceptions import i18n_exception

from interfaces import ISubscriptionContainer
from interfaces import ISubscriptionTarget
from containers import SubscriptionContainer  # Keep for backward compatibility
from containers import AnonymousSubscription, AccountSubscription

from Products.NaayaCore.NotificationTool import utils

notif_logger = logging.getLogger('naaya.core.notif')

email_templates = {
    'maintainer':
    EmailPageTemplateFile('emailpt/maintainer.zpt', globals()),
    'administrative':
    EmailPageTemplateFile('emailpt/administrative.zpt', globals()),
    'instant':
    EmailPageTemplateFile('emailpt/instant.zpt', globals()),
    'daily':
    EmailPageTemplateFile('emailpt/daily.zpt', globals()),
    'weekly':
    EmailPageTemplateFile('emailpt/weekly.zpt', globals()),
    'monthly':
    EmailPageTemplateFile('emailpt/monthly.zpt', globals()),
    'account_modified':
    EmailPageTemplateFile('emailpt/account_modified.zpt', globals()),
}

Beispiel #5
0

def set_response_attachment(RESPONSE, filename, content_type, length=None):
    RESPONSE.setHeader('Content-Type', content_type)
    if length is not None:
        RESPONSE.setHeader('Content-Length', length)
    RESPONSE.setHeader('Pragma', 'public')
    RESPONSE.setHeader('Cache-Control', 'max-age=0')
    RESPONSE.setHeader(
        'Content-Disposition',
        "attachment; filename*=UTF-8''%s" % urllib.quote(filename))


email_templates = {
    'email_to_owner':
    EmailPageTemplateFile('templates/email_survey_answer_to_owner.zpt',
                          globals()),
    'email_to_respondent':
    EmailPageTemplateFile('templates/email_survey_answer_to_respondent.zpt',
                          globals()),
    'email_to_unauthenticated':
    EmailPageTemplateFile(
        'templates/email_survey_answer_to_unauthenticated.zpt', globals()),
}


class SurveyQuestionnaire(NyRoleManager, NyAttributes, questionnaire_item,
                          NyContainer):
    """ """
    meta_type = "Naaya Survey Questionnaire"
    meta_label = "Survey Instance"
    icon = 'misc_/NaayaSurvey/NySurveyQuestionnaire.gif'
Beispiel #6
0
from datetime import timedelta

from Products.NaayaCore.EmailTool.EmailPageTemplate import EmailPageTemplateFile
from naaya.core.zope2util import path_in_site

import constants
import utils
from interfaces import ISubscriptionContainer

csv_email_template = EmailPageTemplateFile('emailpt/csv_import.zpt', globals())
zip_email_template = EmailPageTemplateFile('emailpt/zip_import.zpt', globals())

def check_skip_notifications(subscriber):
    def wrapper(event):
        """This session key will be set for admins that don't want to notify
        users with their bulk modifications updates.
        Also check if the object is approved.

        """

        if (hasattr(event.context, 'REQUEST') and
            hasattr(event.context.REQUEST, 'SESSION') and
            event.context.REQUEST.SESSION.get('skip_notifications', False) is
            True):
            return
        return subscriber(event)
    return wrapper

@check_skip_notifications
def handle_object_approved(event):
    """ Called when an object has been approved """
Beispiel #7
0
from datetime import datetime

from zope.interface import Interface, implements
from zope.event import notify
from OFS.SimpleItem import SimpleItem
from Products.Five.browser import BrowserView

from Products.NaayaCore.managers.utils import genObjectId
from naaya.groupware.groupware_site import manage_addGroupwareSite
from Products.NaayaCore.EmailTool.EmailPageTemplate import EmailPageTemplateFile
from naaya.core.zope2util import get_zope_env

NETWORK_NAME = get_zope_env('NETWORK_NAME', 'Eionet')
approved_mail = EmailPageTemplateFile('emailpt/approved_application.zpt',
                                      globals())
rejected_mail = EmailPageTemplateFile('emailpt/rejected_application.zpt',
                                      globals())


def make_unicode(s):
    if isinstance(s, unicode):
        return s
    try:
        return s.decode('utf-8')
    except:
        return s.decode('latin-1')


class IGWApplication(Interface):
    """Interface for the GWApplication class
    """
Beispiel #8
0
    def logout_html(self, REQUEST=None, RESPONSE=None):
        """ """
        return REQUEST.RESPONSE.redirect(self.getSite().absolute_url() +
                                         '/login/logout')

    security.declarePublic('inside_meeting')

    def check_inside_meeting(self, came_from=None):
        """ """
        if came_from:
            o = urlparse(came_from.replace('/index_html', ''))
            if o.path:
                location_obj = self.unrestrictedTraverse(o.path, None)
                return _inside_meeting(location_obj)

    request_ig_access_emailpt = EmailPageTemplateFile(
        'zpt/emailpt/request_ig_access.zpt', globals())
    request_rejected_emailpt = EmailPageTemplateFile(
        'zpt/emailpt/request_rejected.zpt', globals())

    review_ig_request_html = nptf('zpt/review_ig_request', globals(),
                                  'naaya.groupware.review_ig_request')
    request_ig_access_html = nptf('zpt/request_ig_access', globals(),
                                  'naaya.groupware.request_ig_access')
    relinquish_membership_html = nptf('zpt/relinquish_membership', globals(),
                                      'naaya.groupware.relinquish_membership')

    _admin_webex_mail = nptf('skel/forms/site_admin_webex_mail', globals(),
                             'naaya.groupware.site_admin_webex_mail')

    member_search = MemberSearch(id='member_search')
from naaya.core.zope2util import path_in_site
from naaya.core.zope2util import relative_object_path
from naaya.core.zope2util import ofs_path
from naaya.core.zope2util import folder_manage_main_plus
from naaya.core.exceptions import i18n_exception

from interfaces import ISubscriptionContainer
from interfaces import ISubscriptionTarget
from containers import (SubscriptionContainer, AccountSubscription,
                        AnonymousSubscription)
import utils

notif_logger = logging.getLogger('naaya.core.notif')

email_templates = {
    'maintainer': EmailPageTemplateFile('emailpt/maintainer.zpt',
                                            globals()),
    'administrative': EmailPageTemplateFile('emailpt/administrative.zpt',
                                            globals()),
    'instant': EmailPageTemplateFile('emailpt/instant.zpt', globals()),
    'daily': EmailPageTemplateFile('emailpt/daily.zpt', globals()),
    'weekly': EmailPageTemplateFile('emailpt/weekly.zpt', globals()),
    'monthly': EmailPageTemplateFile('emailpt/monthly.zpt', globals()),
}

def manage_addNotificationTool(self, REQUEST=None):
    """ """
    ob = NotificationTool(core_constants.ID_NOTIFICATIONTOOL,
                          core_constants.TITLE_NOTIFICATIONTOOL)
    self._setObject(core_constants.ID_NOTIFICATIONTOOL, ob)

    if REQUEST is not None:
Beispiel #10
0
from persistent import Persistent
from BTrees.OOBTree import OOBTree as BTree
from OFS.SimpleItem import SimpleItem
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass

from Products.NaayaCore.FormsTool.NaayaTemplate import NaayaPageTemplateFile
from Products.NaayaCore.EmailTool.EmailPageTemplate import \
     EmailPageTemplateFile
from naaya.core.exceptions import i18n_exception
from naaya.core.zope2util import physical_path

log = logging.getLogger('naaya.core.auth.recover_password')

email_template = EmailPageTemplateFile('emailpt/recover_password.zpt',
                                       globals())

TOKEN_SYMBOL = string.ascii_letters + string.digits
BAD_TOKEN_MSG = ("Your password change link is invalid - it probably expired."
                 " Please try again.")


class TokenData(Persistent):
    def __init__(self, user_id):
        self.user_id = user_id
        self.create_time = datetime.now()


class RecoverPassword(SimpleItem):
    """ multi-step process to reset a user's password """
Beispiel #11
0
                                       'correct them and try again.'])
                formerrors = dict(e.errors)

        else:
            formdata = dict( (key, '') for key in keys )

        return self._create_html(formdata=formdata, formerrors=formerrors,
                                 **extra_opts)

    def _create_invitation(self, **invite_args):
        key = random_key()
        invitation = Invitation(key=key, **invite_args)
        self._invites.insert(key, invitation)
        return key

    _invite_email = EmailPageTemplateFile('zpt/invitations_email.zpt', globals())
    def _send_invitation(self, name, email, organization, notes, message,
                         inviter_userid, inviter_name,
                         web_form=False, preview=False):
        errors = []
        if not name:
            errors.append(('name', ValueError('Name is mandatory')))
        if not email:
            errors.append(('email', ValueError('Email is mandatory')))

        if errors:
            if web_form:
                raise FormError(errors)
            else:
                raise errors[0][1]
Beispiel #12
0
from persistent.mapping import PersistentMapping
from zope.interface import Interface, implements
from OFS.Folder import Folder
from application_item import IGWApplication, GWApplication
from Products.Five.browser import BrowserView
from Products.NaayaCore.managers.utils import genObjectId, genRandomId
from Products.NaayaCore.EmailTool.EmailTool import EmailTool
from Products.NaayaCore.EmailTool.EmailPageTemplate import EmailPageTemplateFile
from application_item import make_unicode

from naaya.groupware.constants import GROUPWARE_META_ID

new_application_mail = EmailPageTemplateFile('emailpt/new_application.zpt',
                                             globals())


class IGWApplications(Interface):
    """Interface for the GWApplications class
    """


class GWApplications(Folder):

    implements(IGWApplications)
    email_sender = EmailTool('email_sender', 'Applications email sender')
    email_sender.mail_server_name = 'localhost'
    email_sender.mail_server_port = '25'

    _properties = (
        {
            'id': 'mail_from',