Esempio n. 1
0
    def send_welcome_mail(self, member):
        """Send welcom email with attachments"""
        config = Configuration()
        sender_address = config.get('WELCOME_MAIL_SENDER')
        subject = config.get('WELCOME_MAIL_SUBJECT')
        account_no = config.get('GIRO_ACCOUNT_NO')

        mail_template = Template(config.get('WELCOME_MAIL_TEXT'))

        data = {
            'member': member,
            'year': datetime.date.today().year,
            'accountno': account_no,
            'profile_url': constants.PROFILE_URL
        }
        body = mail_template.render(data)

        buf = cStringIO.StringIO()
        address = member.name + '\n' + member.address + '\n' + member.zipcode + ' ' + member.city
        if member.country.name != 'Norge':
            address = address + '\n' + member.country.name

        body_template = Template(config.get('GIRO_TEXT'))
        message_template = Template(config.get('GIRO_MESSAGE'))

        data = {
            'member_no': member.number,
            'account_no': account_no,
            'access_code': member.edit_access_code,
            'profile_url': constants.PROFILE_URL
        }

        due_date = datetime.datetime.now() + datetime.timedelta(days=14)
        due_date_str = due_date.strftime('%d.%m.%Y')

        current_date = datetime.datetime.now()
        if current_date.month >= 7:
            fee = member.member_type.fee / 2
        else:
            fee = member.member_type.fee

        pdf = PdfGenerator(member_address=address,
                           club_address=config.get('GIRO_ADDRESS'),
                           account_no=account_no,
                           member_no=member.number,
                           access_code=member.edit_access_code,
                           profile_url=constants.PROFILE_URL,
                           heading=config.get('GIRO_SUBJECT'),
                           body=body_template.render(data),
                           fee=fee,
                           due_date=due_date_str,
                           payment_message=message_template.render(data))

        pdf.generate_pdf(buf)

        mail.send_mail(sender_address,
                       member.email,
                       subject,
                       body,
                       attachments=[('kontingent.pdf', buf.getvalue())])
Esempio n. 2
0
    def get(self):
        self.response.headers['Content-Type'] = 'application/pdf'

        config = Configuration()

        address = 'Ola Nordmann\nNorskeveien 1\n9876 Olabyen'
        member_no = '9876'
        access_code = 'BBQLOL'
        fee = 400
        profile_url = constants.PROFILE_URL
        account_no = config.get('GIRO_ACCOUNT_NO')

        body_template = Template(config.get('GIRO_TEXT'))
        message_template = Template(config.get('GIRO_MESSAGE'))

        data = {
            'member_no': member_no,
            'account_no': account_no,
            'access_code': access_code,
            'profile_url': profile_url
        }

        pdf = PdfGenerator(member_address=address,
                           club_address=config.get('GIRO_ADDRESS'),
                           account_no=account_no,
                           member_no=member_no,
                           access_code=access_code,
                           profile_url=profile_url,
                           heading=config.get('GIRO_SUBJECT'),
                           body=body_template.render(data),
                           fee=fee,
                           due_date='12.12.2012',
                           payment_message=message_template.render(data))

        pdf.generate_pdf(self.response.out)
Esempio n. 3
0
    def send_welcome_mail(self, member):
        """Send welcom email with attachments"""
        config = Configuration()
        sender_address = config.get('WELCOME_MAIL_SENDER')
        subject = config.get('WELCOME_MAIL_SUBJECT')
        account_no = config.get('GIRO_ACCOUNT_NO')

        mail_template = Template(config.get('WELCOME_MAIL_TEXT'))

        data = {
            'member': member,
            'year': datetime.date.today().year,
            'accountno': account_no,
            'profile_url': constants.PROFILE_URL
        }
        body = mail_template.render(data)

        buf = cStringIO.StringIO()
        address = member.name + '\n' + member.address + \
            '\n' + member.zipcode + ' ' + member.city
        if member.country.name != 'Norge':
            address = address + '\n' + member.country.name

        body_template = Template(config.get('GIRO_TEXT'))
        message_template = Template(config.get('GIRO_MESSAGE'))

        data = {'member_no': member.number, 'account_no': account_no,
                'access_code': member.edit_access_code, 'profile_url': constants.PROFILE_URL}

        due_date = datetime.datetime.now() + datetime.timedelta(days=14)
        due_date_str = due_date.strftime('%d.%m.%Y')

        current_date = datetime.datetime.now()
        if current_date.month >= 7:
            fee = member.member_type.fee / 2
        else:
            fee = member.member_type.fee

        pdf = PdfGenerator(member_address=address, club_address=config.get('GIRO_ADDRESS'), account_no=account_no,
                           member_no=member.number, access_code=member.edit_access_code, profile_url=constants.PROFILE_URL,
                           heading=config.get('GIRO_SUBJECT'), body=body_template.render(data), fee=fee,
                           due_date=due_date_str, payment_message=message_template.render(data))

        pdf.generate_pdf(buf)

        mail.send_mail(sender_address, member.email, subject,
                       body, attachments=[('kontingent.pdf', buf.getvalue())])
Esempio n. 4
0
    def get(self):
        self.response.headers['Content-Type'] = 'application/pdf'

        config = Configuration()

        address = 'Ola Nordmann\nNorskeveien 1\n9876 Olabyen'
        member_no = '9876'
        access_code = 'BBQLOL'
        fee = 400
        profile_url = constants.PROFILE_URL
        account_no = config.get('GIRO_ACCOUNT_NO')


        body_template = Template(config.get('GIRO_TEXT'))
        message_template = Template(config.get('GIRO_MESSAGE'))

        data = { 'member_no': member_no, 'account_no': account_no, 'access_code': access_code, 'profile_url': profile_url }

        pdf = PdfGenerator(member_address=address, club_address=config.get('GIRO_ADDRESS'), account_no=account_no,
            member_no=member_no, access_code=access_code, profile_url=profile_url,
            heading=config.get('GIRO_SUBJECT'), body=body_template.render(data), fee=fee, due_date='12.12.2012', payment_message=message_template.render(data))

        pdf.generate_pdf(self.response.out)