Exemple #1
0
def rpc_campaign_message_new(handler, session, campaign_id, email_id, target_email, first_name, last_name, department_name=None):
	"""
	Record a message that has been sent as part of a campaign. These
	details can be retrieved later for value substitution in template
	pages.

	:param int campaign_id: The ID of the campaign.
	:param str email_id: The message id of the sent email.
	:param str target_email: The email address that the message was sent to.
	:param str first_name: The first name of the message's recipient.
	:param str last_name: The last name of the message's recipient.
	:param str department_name: The name of the company department that the message's recipient belongs to.
	"""
	department = None
	if department_name is not None:
		department = session.query(db_models.CompanyDepartment).filter_by(name=department_name).first()
		if department is None:
			department = db_models.CompanyDepartment(name=department_name)
			department.assert_session_has_permissions('c', handler.rpc_session)
			session.add(department)
			session.commit()
	message = db_models.Message()
	message.id = email_id
	message.campaign_id = campaign_id
	message.target_email = target_email
	message.first_name = first_name
	message.last_name = last_name
	if department is not None:
		message.company_department_id = department.id
	message.assert_session_has_permissions('c', handler.rpc_session)
	session.add(message)
	session.commit()
Exemple #2
0
    def rpc_campaign_message_new(self, campaign_id, email_id, target_email,
                                 company_name, first_name, last_name):
        """
		Record a message that has been sent as part of a campaign. These
		details can be retrieved later for value substitution in template
		pages.

		:param int campaign_id: The ID of the campaign.
		:param str email_id: The message id of the sent email.
		:param str target_email: The email address that the message was sent to.
		:param str company_name: The company name value for the message.
		:param str first_name: The first name of the message's recipient.
		:param str last_name: The last name of the message's recipient.
		"""
        session = db_manager.Session()
        message = db_models.Message()
        message.id = email_id
        message.campaign_id = campaign_id
        message.target_email = target_email
        message.company_name = company_name
        message.first_name = first_name
        message.last_name = last_name
        session.add(message)
        session.commit()
        session.close()
        return
Exemple #3
0
def _message_new(handler,
                 session,
                 campaign_id,
                 email_id,
                 target_email,
                 first_name,
                 last_name,
                 department_name=None):
    department = None
    if department_name is not None:
        department = session.query(db_models.CompanyDepartment).filter_by(
            name=department_name).first()
        if department is None:
            department = db_models.CompanyDepartment(name=department_name)
            department.assert_session_has_permissions('c', handler.rpc_session)
            session.add(department)
            session.commit()
    message = db_models.Message()
    message.id = email_id
    message.campaign_id = campaign_id
    message.target_email = target_email
    message.first_name = first_name
    message.last_name = last_name
    if department is not None:
        message.company_department_id = department.id
    return message