Ejemplo n.º 1
0
def event_edit(project_id, event_id):
    event = Event.query.get(event_id)

    form = EventForm(obj=event)
    if form.validate_on_submit():
        form.populate_obj(event)
        db.session.commit()

        flash('Data saved successfully', 'success')
        return redirect(url_for('web.project_events', project_id=project_id))

    return render_template('events/edit.html', project_id=project_id, event_id=event_id, form=form)
Ejemplo n.º 2
0
def event_edit(project_id, event_id):
    event = Event.query.get(event_id)

    form = EventForm(obj=event)
    if form.validate_on_submit():
        form.populate_obj(event)
        db.session.commit()

        flash('Data saved successfully', 'success')
        return redirect(url_for('web.project_events', project_id=project_id))

    return render_template('events/edit.html',
                           project_id=project_id,
                           event_id=event_id,
                           form=form)
Ejemplo n.º 3
0
def event_add(project_id):
    form = EventForm(request.form)
    if request.method == 'POST':
        if form.validate():
            event = Event()
            form.populate_obj(event)
            event.project_id = project_id
            db.session.add(event)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.project_events', project_id=project_id))

        flash('Data not valid, please review the fields')

    return render_template('events/add.html', project_id=project_id, form=form)
Ejemplo n.º 4
0
def event_form(client):
    from autoconstruccion.web.forms import EventForm
    event = {
        'name': 'Pintar',
        'description': 'Hay que pintar las paredes de un 6 piso',
        'start_date': '24/12/2015'
    }
    return EventForm(data=event)
Ejemplo n.º 5
0
def event_add(project_id):

    form = EventForm(request.form)
    if request.method == 'POST':

        if form.validate():
            event = Event()
            form.populate_obj(event)
            event.project_id = project_id
            db.session.add(event)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.project_view', project_id=project_id))

        flash('Data not valid, please review the fields')
    return render_template('events/add.html', project_id=project_id, form=form)
Ejemplo n.º 6
0
 def test_should_not_accept_when_there_no_description(self):
     self.fixture['description'] = ''
     event = EventForm(data=self.fixture)
     assert not event.description.validate(event)
Ejemplo n.º 7
0
 def test_should_ok_when_description_has_3_letters(self):
     self.fixture['description'] = 'des'
     event = EventForm(data=self.fixture)
     assert event.description.validate(event)
Ejemplo n.º 8
0
 def test_should_not_accept_when_there_no_name(self):
     self.fixture['name'] = ''
     event = EventForm(data=self.fixture)
     assert not event.name.validate(event)
Ejemplo n.º 9
0
 def test_should_ok_when_name_has_3_letters(self):
     self.fixture['name'] = 'alv'
     event = EventForm(data=self.fixture)
     assert event.name.validate(event)
Ejemplo n.º 10
0
 def test_event_valid_must_be_valid(self):
     event = EventForm(data=self.fixture)
     assert event.validate()