def sendNotificationToMinistry(date):
    """
    send a notification to the ministry stating
    all questions that are approaching the deadline
    """
    text = translate("notification_email_to_ministry_question_pending_response",
                     target_language="en",
                     domain="bungeni",
                     default="Questions pending responses.")
    ministries = _getAllMinistries(date)
    for ministry in ministries:
        questions = _getQuestionsPendingResponse(date, ministry)
        text = translate("notification_email_to_ministry_question_pending_response",
                     target_language="en",
                     domain="bungeni",
                     default="Questions assigned to the ministry pending responses.")
        if questions: 
            text = "%s\n%s: \n" % (text, ministry.full_name) + \
                "\n".join([ question.subject for question in questions ])
            emails = [ utils.formatted_user_email(minister)
                for minister in dbutils.get_ministers(ministry) ]
            msg = MIMEText(text)
            msg["Subject"] = "Questions pending response"
            msg["From"] = prefs.getClerksOfficeEmail()
            msg["To"] = " ,".join(emails)
            print msg
            # !+SENDMAIL(ah,18-03-2010)
            #Mail sending is commented out 
            dispatch(msg)
def sendNotificationToMP(date):
    """
    send a mail to the MP asking the question that the deadline 
    of the question is aproaching
    """
    status = u"Question pending response" #q_state.response_pending
    text = translate('notification_email_to_mp_question_pending_response',
                     target_language='en',
                     domain='bungeni.core',
                     default="Questions pending responses.")
    session = Session()
    qfilter=sql.and_(
                (domain.Question.ministry_submit_date < date ),
                (domain.Question.status == status),
                )
    questions = session.query(domain.Question).filter(qfilter).all()
    for question in questions:
        mailto = _getMemberOfParliamentEmail(question)
        if mailto and question.receive_notification:
            msg = MIMEText(text)
            msg['Subject'] = u'Questions pending response'
            msg['From'] = prefs.getAdministratorsEmail()
            msg['To'] =  mailto
            text = text + '\n' + question.subject + '\n'
            print msg
            # !+SENDMAIL(ah,18-03-2010)
            #Mail sending is commented out below
            dispatch(msg)
 def __call__(self, context):
     if not self.condition(context):
         return # do not notify
     # lang, translated subject/body 
     lang = capi.default_language
     # !+DEFAULT(mr, apr-2011) breaks notification tests out of context
     subject = translate(self.subject, target_language=lang,
         # pick subject default value off self.__init__
         #default=self.__init__.func_defaults[1]
     )
     body = translate(self.body, target_language=lang, 
         # pick body default value off self.__init__
         #default=self.__init__.func_defaults[4]
     )
     # evaluation locals namespace
     locals = {
         "item": TemplateNamespaceItem(context, lang)
     }
     # set/retrieve the template for each templated value, and evoque --
     # all translatable template sources are translated **prior** to 
     # setting/retrieving
     msg = MIMEText(st(body).evoque(locals))
     msg["Subject"] = st(subject).evoque(locals)
     msg["From"] = st(self.from_).evoque(locals)
     msg["To"] = st(self.to).evoque(locals)
     dispatch(msg)
def sendNotificationToClerksOffice(date):
    """
    send a mail to the clerks office with
    stating all questions per ministry that
    are approaching the deadline
    """
    text = translate('notification_email_to_clerk_question_pending_response',
                     target_language='en',
                     domain='bungeni.core',
                     default="Questions pending responses.")
    ministries = _getAllMinistries(date)
    for ministry in ministries:
        questions = _getQuestionsPendingResponse(date, ministry)
        if questions:
            text = text + '\n' + ministry.full_name +': \n'
        for question in questions:
            text = text + question.subject + '\n'
    
    msg = MIMEText(text)
    
    msg['Subject'] = u'Questions pending response'
    msg['From'] = prefs.getAdministratorsEmail()
    msg['To'] = prefs.getClerksOfficeEmail()
    print msg
    # !+SENDMAIL(ah,18-03-2010)
    #Mail sending is commented out below
    dispatch(msg)
Exemple #5
0
def sendNotificationToMP(date):
    """
    send a mail to the MP asking the question that the deadline 
    of the question is aproaching
    """
    status = u"Question pending response"  #q_state.response_pending
    text = translate('notification_email_to_mp_question_pending_response',
                     target_language='en',
                     domain='bungeni.core',
                     default="Questions pending responses.")
    session = Session()
    qfilter = sql.and_(
        (domain.Question.ministry_submit_date < date),
        (domain.Question.status == status),
    )
    questions = session.query(domain.Question).filter(qfilter).all()
    for question in questions:
        mailto = _getMemberOfParliamentEmail(question)
        if mailto and True:  #!+NOTIFICATION_SETTINGS = True
            msg = MIMEText(text)
            msg['Subject'] = u'Questions pending response'
            msg['From'] = prefs.getAdministratorsEmail()
            msg['To'] = mailto
            text = text + '\n' + question.subject + '\n'
            print msg
            # !+SENDMAIL(ah,18-03-2010)
            #Mail sending is commented out below
            dispatch(msg)
Exemple #6
0
def sendNotificationToMinistry(date):
    """
    send a notification to the ministry stating
    all questions that are approaching the deadline
    """
    text = translate(
        "notification_email_to_ministry_question_pending_response",
        target_language="en",
        domain="bungeni",
        default="Questions pending responses.")
    ministries = _getAllMinistries(date)
    for ministry in ministries:
        questions = _getQuestionsPendingResponse(date, ministry)
        text = translate(
            "notification_email_to_ministry_question_pending_response",
            target_language="en",
            domain="bungeni",
            default="Questions assigned to the ministry pending responses.")
        if questions:
            text = "%s\n%s: \n" % (text, ministry.full_name) + \
                "\n".join([ question.subject for question in questions ])
            emails = [
                utils.formatted_user_email(minister)
                for minister in dbutils.get_ministers(ministry)
            ]
            msg = MIMEText(text)
            msg["Subject"] = "Questions pending response"
            msg["From"] = prefs.getClerksOfficeEmail()
            msg["To"] = " ,".join(emails)
            print msg
            # !+SENDMAIL(ah,18-03-2010)
            #Mail sending is commented out
            dispatch(msg)
Exemple #7
0
def sendNotificationToClerksOffice(date):
    """
    send a mail to the clerks office with
    stating all questions per ministry that
    are approaching the deadline
    """
    text = translate('notification_email_to_clerk_question_pending_response',
                     target_language='en',
                     domain='bungeni.core',
                     default="Questions pending responses.")
    ministries = _getAllMinistries(date)
    for ministry in ministries:
        questions = _getQuestionsPendingResponse(date, ministry)
        if questions:
            text = text + '\n' + ministry.full_name + ': \n'
        for question in questions:
            text = text + question.subject + '\n'

    msg = MIMEText(text)

    msg['Subject'] = u'Questions pending response'
    msg['From'] = prefs.getAdministratorsEmail()
    msg['To'] = prefs.getClerksOfficeEmail()
    print msg
    # !+SENDMAIL(ah,18-03-2010)
    #Mail sending is commented out below
    dispatch(msg)
Exemple #8
0
    def __call__(self):
        text = translate(self.body)
        msg = MIMEText(text)

        msg['Subject'] = self.subject
        msg['From'] = self.from_address
        msg['To'] = self.recipient_address

        dispatch(msg)
    def __call__(self):
        text = translate(self.body)
        msg = MIMEText(text)

        msg['Subject'] = self.subject
        msg['From'] = self.from_address
        msg['To'] = self.recipient_address

        dispatch(msg)