示例#1
0
def get_feedback():
    if request.method == 'POST':
        recipients = request.form.getlist('email')
        share = request.form.get('share-objectives')
        share_objectives = share == 'share-objectives'

        for recipient in recipients:
            user = current_user._get_current_object()
            other_user = User.objects.filter(email=recipient).first()

            entry = Entry()
            entry.requested_by = user.email
            entry.requested_from = other_user.email
            entry.requested_by_name = user.full_name
            entry.requested_from_name = other_user.full_name
            entry.template = request.form.get('feedback-template')
            entry.share_objectives = share_objectives
            if share_objectives:
                # get and attach objectives
                pass
            entry.save()

            log_entry = LogEntry()
            log_entry.entry_type = 'feedback'
            log_entry.owner = user
            log_entry.entry = entry
            log_entry.save()
            log_entry.add_tag('Feedback')

            _send_feedback_email(log_entry, user, other_user)
        flash('Submitted request')

    return render_template('feedback/get-feedback.html')
def test_feedback_with_valid_fields():
    entry = Entry()
    entry.requested_from = '*****@*****.**'
    entry.requested_by = '*****@*****.**'
    entry.details = 'details'
    entry.share_objectives = True
    entry.sent = True
    entry.replied = True
    entry.save()

    log_entry = LogEntry()
    log_entry.entry_type = 'feedback'
    log_entry.entry = entry
    log_entry.save()
示例#3
0
def test_feedback_with_valid_fields():
    entry = Entry()
    entry.requested_from = '*****@*****.**'
    entry.requested_by = '*****@*****.**'
    entry.details = 'details'
    entry.share_objectives = True
    entry.sent = True
    entry.replied = True
    entry.save()

    log_entry = LogEntry()
    log_entry.entry_type = 'feedback'
    log_entry.entry = entry
    log_entry.save()
def test_save_log_entry_with_feedback():
    entry = Entry()
    entry.requested_from = '*****@*****.**'
    entry.requested_by = '*****@*****.**'
    entry.details = 'details'
    entry.share_objectives = True
    entry.sent = True
    entry.replied = True
    entry.save()

    log_entry = LogEntry()
    log_entry.entry_type = 'feedback'
    log_entry.entry = entry
    log_entry.save()

    from_db = LogEntry.objects(id=log_entry.id).get()
    assert from_db.entry_type == 'feedback'
    assert from_db.entry.requested_from == '*****@*****.**'
    assert from_db.entry.requested_by == '*****@*****.**'
    assert from_db.entry.details == 'details'
    assert from_db.entry.share_objectives
    assert from_db.entry.sent
    assert from_db.entry.replied
示例#5
0
def test_save_log_entry_with_feedback():
    entry = Entry()
    entry.requested_from = '*****@*****.**'
    entry.requested_by = '*****@*****.**'
    entry.details = 'details'
    entry.share_objectives = True
    entry.sent = True
    entry.replied = True
    entry.save()

    log_entry = LogEntry()
    log_entry.entry_type = 'feedback'
    log_entry.entry = entry
    log_entry.save()

    from_db = LogEntry.objects(id=log_entry.id).get()
    assert from_db.entry_type == 'feedback'
    assert from_db.entry.requested_from == '*****@*****.**'
    assert from_db.entry.requested_by == '*****@*****.**'
    assert from_db.entry.details == 'details'
    assert from_db.entry.share_objectives
    assert from_db.entry.sent
    assert from_db.entry.replied