Exemplo n.º 1
0
    def it_updates_a_member_dao(self, db, db_session, sample_member):
        dao_update_member(sample_member.id, email='*****@*****.**')

        member_from_db = Member.query.filter(
            Member.id == sample_member.id).first()

        assert member_from_db.email == '*****@*****.**'
Exemplo n.º 2
0
def unsubscribe_member(unsubcode):
    tokens = get_tokens(
        decrypt(unsubcode, current_app.config['EMAIL_UNSUB_SALT']))
    member = dao_get_member_by_id(
        tokens[current_app.config['EMAIL_TOKENS']['member_id']])
    dao_update_member(member.id, active=False)

    return jsonify({'message': '{} unsubscribed'.format(member.name)})
Exemplo n.º 3
0
    def it_doesnt_update_members_with_same_email(self, db_session, sample_member):
        member = create_member(email='*****@*****.**')
        with pytest.raises(expected_exception=IntegrityError):
            dao_update_member(str(member.id), email=sample_member.email)

        members = Member.query.all()
        assert len(members) == 2
        assert members[0].email == sample_member.email
        assert members[1].email == member.email
Exemplo n.º 4
0
def update_member(unsubcode):
    data = request.get_json(force=True)

    validate(data, post_update_member_schema)

    member = _get_member_from_unsubcode(unsubcode)
    old_name = member.name
    dao_update_member(member.id, name=data['name'], email=data['email'])

    return jsonify({'message': '{} updated'.format(old_name)})
Exemplo n.º 5
0
def unsubscribe_member(unsubcode):
    member = _get_member_from_unsubcode(unsubcode)
    dao_update_member(member.id, active=False)

    send_ga_event(f"Unsubscribed {member.id}", "members", "unsubscribe",
                  f"{member.id}")

    basic_html = get_email_html(
        email_type=BASIC,
        title='Unsubscribe',
        message=
        "{}, you have successfully unsubscribed from New Acropolis events and magazines"
        .format(member.name))
    send_email(member.email, 'New Acropolis unsubscription', basic_html)

    return jsonify({'message': '{} unsubscribed'.format(member.name)})