Exemplo n.º 1
0
def view_minutes(group_id='all'):
    if not ModuleAPI.can_read('pimpy'):
        return abort(403)
    if not (group_id == 'all' or group_id.isdigit()):
        return abort(404)
    if group_id != 'all' and not current_user.member_of_group(group_id):
        return abort(403)

    return PimpyAPI.get_minutes(group_id)
Exemplo n.º 2
0
def view_minute_raw(group_id, minute_id):
    if not ModuleAPI.can_read('pimpy'):
        return abort(403)
    if not (group_id == 'all' or group_id.isdigit()):
        return abort(404)

    if group_id != 'all' and not current_user.member_of_group(group_id):
        return abort(403)

    return (PimpyAPI.get_minute_raw(group_id, minute_id),
            {'Content-Type': 'text/plain; charset=utf-8'})
Exemplo n.º 3
0
def view_tasks_in_date_range(group_id='all'):
    if not ModuleAPI.can_read('pimpy'):
        return abort(403)
    if group_id != 'all' and not current_user.member_of_group(group_id):
        return abort(403)

    group_id = request.form['group_id']
    start_date = request.form['start_date']
    end_date = request.form['end_date']
    return PimpyAPI.get_tasks_in_date_range(
        group_id, False, start_date, end_date)
Exemplo n.º 4
0
def add_task(group_id='all'):
    if not ModuleAPI.can_write('pimpy'):
        return abort(403)
    if not (group_id == 'all' or group_id.isdigit()):
        return abort(404)
    if group_id != 'all' and not current_user.member_of_group(group_id):
        return abort(403)

    if group_id == '':
        group_id = 'all'

    form = AddTaskForm(request.form, default=group_id)
    if request.method == 'POST':
        # FIXME: validate does not seem to work :(, so we are doin' it
        # manually now
        message = ""
        if form.name.data == "":
            message = "Naam is vereist"
        elif form.group == "":
            message = "Groep is vereist"
        elif form.users.data == "":
            message = "Minimaal 1 gebruiker is vereist"

        result = message == ""

        if result:
            result, message = PimpyAPI.commit_task_to_db(
                form.name.data, form.content.data,
                form.group.data,
                form.users.data, form.line.data, -1, form.status.data)

        if result:
            flash('De taak is succesvol aangemaakt!', 'success')
            return redirect(url_for('pimpy.view_tasks',
                                    group_id=form.group.data))

        else:
            flash(message, 'danger')

    group = Group.query.filter(Group.id == group_id).first()
    form.load_groups(current_user.groups.order_by(Group.name.asc()).all())

    return render_template('pimpy/add_task.htm', group=group,
                           group_id=group_id, type='tasks', form=form,
                           title='PimPy')
Exemplo n.º 5
0
def add_minute(group_id='all'):
    if not ModuleAPI.can_write('pimpy'):
        return abort(403)
    if not (group_id == 'all' or group_id.isdigit()):
        return abort(404)
    if group_id != 'all' and not current_user.member_of_group(group_id):
        return abort(403)

    if group_id == '':
        group_id = 'all'
    group = Group.query.filter(Group.id == group_id).first()

    form = AddMinuteForm(request.form, default=group_id)
    if request.method == 'POST':

        # validate still does not work
        message = ""
        if form.content.data == "":
            message = "Content is vereist"
        elif request.form['date'] == "":
            message = "Datum is vereist"
        elif form.group == "":
            message = "Groep is vereist"

        result = message == ""

        if result:
            result, message = PimpyAPI.commit_minute_to_db(
                form.content.data, request.form['date'], form.group.data)
            if result and form.parse_tasks.data:
                tasks, dones, removes = PimpyAPI.parse_minute(
                    form.content.data, form.group.data, message)
                for task in tasks:
                    db.session.add(task)
                # for user in task.users:
                #     copernica_data = {
                #         "viaductID": task.base32_id(),
                #         "Actiepunt": task.title,
                #         "Status": task.get_status_string(),
                #         "Groep": task.group.name,
                #     }
                #     copernica.add_subprofile(
                #         copernica.SUBPROFILE_TASK, user.id, copernica_data)

                for done in dones:
                    done.update_status(4)
                # for user in done.users:
                #     copernica_data = {
                #         "Actiepunt": task.title,
                #         "Status": task.get_status_string(),
                #     }
                #     copernica.update_subprofile(copernica.SUBPROFILE_TASK,
                #                                 user.id, task.base32_id(),
                #                                 copernica_data)

                for remove in removes:
                    remove.update_status(5)
                # for user in remove.users:
                #     copernica_data = {
                #         "Actiepunt": task.title,
                #         "Status": task.get_status_string(),
                #     }
                #     copernica.update_subprofile(copernica.SUBPROFILE_TASK,
                #                                 user.id, task.base32_id(),
                #                                 copernica_data)
                db.session.commit()

                flash('De notulen zijn verwerkt!', 'success')

                return render_template('pimpy/view_parsed_tasks.htm',
                                       tasks=tasks, dones=dones,
                                       removes=removes, title='PimPy')
        else:
            flash(message, 'danger')

    form.load_groups(current_user.groups.order_by(Group.name.asc()).all())

    return render_template('pimpy/add_minute.htm', group=group,
                           group_id=group_id, type='minutes', form=form,
                           title='PimPy')