Exemplo n.º 1
0
 def wrapper(*args, **kwargs):
     campaign_id = kwargs['id']
     c = campaign.get(campaign_id)
     organizer = campaign.organizer(c)
     if current_user._get_current_object() != organizer:
         return message, 401
     return fn(*args, **kwargs)
Exemplo n.º 2
0
def send_receipt_email(contrib_campaign, usr, ledger):
    organizer = campaign.organizer(contrib_campaign)
    poold_url = request.url_root.rstrip('/')
    campaign_url = '/'.join([
        poold_url,
        url_for('pool.view', id=contrib_campaign.id).lstrip('/')
    ])

    payment_fee = poold_fee = None
    for fee in ledger['fees']:
        if fee['name'] == 'stripe-transaction':
            payment_fee = fee['fee']
        if fee['name'] == 'poold-transaction':
            poold_fee = fee['fee']

    subs = dict(organizer_name=organizer.display_name,
                organizer_email=organizer.email,
                campaign_name=contrib_campaign.name,
                poold_url=poold_url,
                campaign_url=campaign_url,
                charge=ledger['charge']['final'],
                contribution=ledger['charge']['initial'],
                payment_fee=payment_fee,
                poold_fee=poold_fee)
    subject = "Receipt for you contribution to '%(campaign_name)s'!"
    subject %= subs
    text = app.jinja_env.get_template('email/receipt.txt')

    email_text = text.render(**subs)
    bccs = [app.config.get('BCC_RECEIPT_ADDRESS'), organizer.email]
    app.emailer.send_text(subject, email_text, [usr.email], bccs=bccs, disclose_recipients=False)
Exemplo n.º 3
0
def send_receipt_email(contrib_campaign, usr, ledger):
    organizer = campaign.organizer(contrib_campaign)
    poold_url = request.url_root.rstrip('/')
    campaign_url = '/'.join(
        [poold_url,
         url_for('pool.view', id=contrib_campaign.id).lstrip('/')])

    payment_fee = poold_fee = None
    for fee in ledger['fees']:
        if fee['name'] == 'stripe-transaction':
            payment_fee = fee['fee']
        if fee['name'] == 'poold-transaction':
            poold_fee = fee['fee']

    subs = dict(organizer_name=organizer.display_name,
                organizer_email=organizer.email,
                campaign_name=contrib_campaign.name,
                poold_url=poold_url,
                campaign_url=campaign_url,
                charge=ledger['charge']['final'],
                contribution=ledger['charge']['initial'],
                payment_fee=payment_fee,
                poold_fee=poold_fee)
    subject = "Receipt for you contribution to '%(campaign_name)s'!"
    subject %= subs
    text = app.jinja_env.get_template('email/receipt.txt')

    email_text = text.render(**subs)
    bccs = [app.config.get('BCC_RECEIPT_ADDRESS'), organizer.email]
    app.emailer.send_text(subject,
                          email_text, [usr.email],
                          bccs=bccs,
                          disclose_recipients=False)
Exemplo n.º 4
0
def send_update_email(update_campaign, emails, message):
    organizer = campaign.organizer(update_campaign)
    poold_url = request.url_root.rstrip('/')
    campaign_url = '/'.join(
        [poold_url,
         url_for('pool.view', id=update_campaign.id).lstrip('/')])

    subs = dict(organizer_name=organizer.display_name,
                organizer_email=organizer.email,
                message=message,
                campaign_name=update_campaign.name,
                poold_url=poold_url,
                campaign_url=campaign_url)
    subject = "We have an update for you regarding '%(campaign_name)s' from %(organizer_name)s (%(organizer_email)s)!"
    subject %= subs
    text = app.jinja_env.get_template('email/update.txt')

    email_text = text.render(**subs)
    ccs = [organizer.email]
    bccs = [app.config.get('BCC_CAMPAIGN_ADDRESS')]
    app.emailer.send_text(subject,
                          email_text,
                          emails,
                          ccs=ccs,
                          bccs=bccs,
                          disclose_recipients=False)
Exemplo n.º 5
0
def send_invite_email(invite_to_campaign, invites, message):
    organizer = campaign.organizer(invite_to_campaign)
    poold_url = request.url_root.rstrip('/')
    campaign_url = '/'.join([
        poold_url,
        url_for('pool.view', id=invite_to_campaign.id).lstrip('/')
    ])

    subs = dict(organizer_name=organizer.display_name,
                organizer_email=organizer.email,
                message=message,
                campaign_name=invite_to_campaign.name,
                poold_url=poold_url)
    subject = "%(organizer_name)s (%(organizer_email)s) has invited to participate in their poold.in campaign!"
    subject %= subs
    text = app.jinja_env.get_template('email/invite.txt')
    ccs = [organizer.email]
    bccs = [app.config.get('BCC_CAMPAIGN_ADDRESS')]
    for invite in invites:
        # This should be a shortened URL
        subs['campaign_url'] = '%s?invite=%s' % (campaign_url, invite.id)
        email_text = text.render(**subs)
        app.emailer.send_text(subject,
                              email_text, [invite.email],
                              ccs=ccs,
                              bccs=bccs)
Exemplo n.º 6
0
 def wrapper(*args, **kwargs):
     campaign_id = kwargs['id']
     c = campaign.get(campaign_id)
     organizer = campaign.organizer(c)
     if current_user._get_current_object() != organizer:
         return message, 401
     return fn(*args, **kwargs)
Exemplo n.º 7
0
def send_update_email(update_campaign, emails, message):
    organizer = campaign.organizer(update_campaign)
    poold_url = request.url_root.rstrip('/')
    campaign_url = '/'.join([
        poold_url,
        url_for('pool.view', id=update_campaign.id).lstrip('/')
    ])

    subs = dict(organizer_name=organizer.display_name,
                organizer_email=organizer.email,
                message=message,
                campaign_name=update_campaign.name,
                poold_url=poold_url,
                campaign_url=campaign_url)
    subject = "We have an update for you regarding '%(campaign_name)s' from %(organizer_name)s (%(organizer_email)s)!"
    subject %= subs
    text = app.jinja_env.get_template('email/update.txt')

    email_text = text.render(**subs)
    ccs = [organizer.email]
    bccs = [app.config.get('BCC_CAMPAIGN_ADDRESS')]
    app.emailer.send_text(subject, email_text, emails, ccs=ccs, bccs=bccs, disclose_recipients=False)
Exemplo n.º 8
0
def send_invite_email(invite_to_campaign, invites, message):
    organizer = campaign.organizer(invite_to_campaign)
    poold_url = request.url_root.rstrip('/')
    campaign_url = '/'.join([
        poold_url,
        url_for('pool.view', id=invite_to_campaign.id).lstrip('/')
    ])

    subs = dict(organizer_name=organizer.display_name,
                organizer_email=organizer.email,
                message=message,
                campaign_name=invite_to_campaign.name,
                poold_url=poold_url)
    subject = "%(organizer_name)s (%(organizer_email)s) has invited to participate in their poold.in campaign!"
    subject %= subs
    text = app.jinja_env.get_template('email/invite.txt')
    ccs = [organizer.email]
    bccs = [app.config.get('BCC_CAMPAIGN_ADDRESS')]
    for invite in invites:
        # This should be a shortened URL
        subs['campaign_url'] = '%s?invite=%s' % (campaign_url, invite.id)
        email_text = text.render(**subs)
        app.emailer.send_text(subject, email_text, [invite.email], ccs=ccs, bccs=bccs)
Exemplo n.º 9
0
def view(id):
    c = campaign.get(id)
    usr = current_user._get_current_object()
    if c is None:
        return '', 404

    organizer = campaign.organizer(c)
    organizer_is_viewing = usr == organizer

    if not usr.is_anonymous():
        campaign_association = [p for p in usr.campaigns if p.campaign == c]
        campaign_association = campaign_association[0] if campaign_association else None
        if campaign_association is not None:
            campaign_association.pledge = campaign_association.pledge.quantize(QUANTIZE_DOLLARS) if campaign_association.pledge else 0
    else:
        campaign_association = None
    is_participant = campaign_association is not None

    community = list()
    for participant in c.participants:
        gravatar_url = app.gravatar(participant.user.email or '*****@*****.**', size=60)
        joined_date_ms = calendar.timegm(participant.created.timetuple()) * 1000
        new = {'name': participant.user.display_name,
               'username': participant.user.username,
               'email': participant.user.email,
               'link': '/profile/%s' % participant.user.username,
               'gravatar': gravatar_url,
               'isOrganizer': participant.user == organizer,
               'joinedDate': joined_date_ms,
               'amount': str(participant.pledge) if participant.pledge else 0,
               'invitee': False}
        if not organizer_is_viewing:
            base_name = new['email'].split('@')[0]
            new['email'] = '%s@...' % base_name
        community.append(new)
    for invitee in c.invitees:
        if invitee.accepted is not None:
            continue

        gravatar_url = app.gravatar(invitee.user.email, size=60) if invitee.user else None
        gravatar_url = app.gravatar(invitee.email, size=60) if gravatar_url is None else gravatar_url
        invited_date_ms = calendar.timegm(invitee.created.timetuple()) * 1000
        new = {'name': invitee.user.display_name if invitee.user else None,
               'username': invitee.user.username if invitee.user else None,
               'email': invitee.email,
               'link': '/profile/%s' % participant.user.username if invitee.user else None,
               'gravatar': gravatar_url,
               'isOrganizer': False,
               'joinedDate': invited_date_ms,
               'invitee': True,
               'amount': 0}
        if not organizer_is_viewing:
            base_name = new['email'].split('@')[0]
            new['email'] = '%s@...' % base_name
        community.append(new)

    timestamp_ms = calendar.timegm(c.end.timetuple()) * 1000
    is_active = time.time() * 1000 <= timestamp_ms

    # This is a temporary shim while we transition campaign descriptions to
    # JSON data
    try:
        c.description = json.loads(c.description)
    except ValueError:
        c.description = {'text': c.description}
    context = dict(title="Pool: %s" % c.name,
                   campaign=c,
                   organizer=organizer,
                   participants=json.dumps(community),
                   timestamp=timestamp_ms,
                   invitees=c.participants,
                   is_organizer=organizer_is_viewing,
                   is_participant=is_participant,
                   is_active=is_active,
                   campaign_association=campaign_association)
    return render_template('pool/view.html', **context)
Exemplo n.º 10
0
def view(id):
    c = campaign.get(id)
    usr = current_user._get_current_object()
    if c is None:
        return '', 404

    organizer = campaign.organizer(c)
    organizer_is_viewing = usr == organizer

    if not usr.is_anonymous():
        campaign_association = [p for p in usr.campaigns if p.campaign == c]
        campaign_association = campaign_association[
            0] if campaign_association else None
        if campaign_association is not None:
            campaign_association.pledge = campaign_association.pledge.quantize(
                QUANTIZE_DOLLARS) if campaign_association.pledge else 0
    else:
        campaign_association = None
    is_participant = campaign_association is not None

    community = list()
    for participant in c.participants:
        gravatar_url = app.gravatar(participant.user.email
                                    or '*****@*****.**',
                                    size=60)
        joined_date_ms = calendar.timegm(
            participant.created.timetuple()) * 1000
        new = {
            'name': participant.user.display_name,
            'username': participant.user.username,
            'email': participant.user.email,
            'link': '/profile/%s' % participant.user.username,
            'gravatar': gravatar_url,
            'isOrganizer': participant.user == organizer,
            'joinedDate': joined_date_ms,
            'amount': str(participant.pledge) if participant.pledge else 0,
            'invitee': False
        }
        if not organizer_is_viewing:
            base_name = new['email'].split('@')[0]
            new['email'] = '%s@...' % base_name
        community.append(new)
    for invitee in c.invitees:
        if invitee.accepted is not None:
            continue

        gravatar_url = app.gravatar(invitee.user.email,
                                    size=60) if invitee.user else None
        gravatar_url = app.gravatar(
            invitee.email, size=60) if gravatar_url is None else gravatar_url
        invited_date_ms = calendar.timegm(invitee.created.timetuple()) * 1000
        new = {
            'name': invitee.user.display_name if invitee.user else None,
            'username': invitee.user.username if invitee.user else None,
            'email': invitee.email,
            'link': '/profile/%s' %
            participant.user.username if invitee.user else None,
            'gravatar': gravatar_url,
            'isOrganizer': False,
            'joinedDate': invited_date_ms,
            'invitee': True,
            'amount': 0
        }
        if not organizer_is_viewing:
            base_name = new['email'].split('@')[0]
            new['email'] = '%s@...' % base_name
        community.append(new)

    timestamp_ms = calendar.timegm(c.end.timetuple()) * 1000
    is_active = time.time() * 1000 <= timestamp_ms

    # This is a temporary shim while we transition campaign descriptions to
    # JSON data
    try:
        c.description = json.loads(c.description)
    except ValueError:
        c.description = {'text': c.description}
    context = dict(title="Pool: %s" % c.name,
                   campaign=c,
                   organizer=organizer,
                   participants=json.dumps(community),
                   timestamp=timestamp_ms,
                   invitees=c.participants,
                   is_organizer=organizer_is_viewing,
                   is_participant=is_participant,
                   is_active=is_active,
                   campaign_association=campaign_association)
    return render_template('pool/view.html', **context)