def assign_contract(self, flow=None, contract=None): flow = flow if flow else self.flow contract = contract if contract else self.contract1 assign_a_contract(contract, flow, self.conductor) return contract.children[0]
def assign_contract(self, flow=None, contract=None): flow = flow if flow else self.flow contract = contract if contract else self.contract1 assign_a_contract(contract, flow, self.conductor, start_time=datetime.datetime.now()) return contract.children[0]
def assign_contract(self, flow=None, contract=None, start_time=None): flow = flow if flow else self.flow contract = contract if contract else self.contract1 start_time = start_time if start_time else datetime.datetime.now() assign_a_contract(contract, flow, self.conductor, start_time=start_time) return contract.children[0]
def start_work(contract_id=-1): contract = ContractBase.query.get(contract_id) contract = contract if contract else ContractBase() form = NewContractForm(obj=contract) if form.validate_on_submit(): if contract_id == -1: contract, _ = get_or_create( db.session, ContractBase, description=form.data.get('description'), department=form.data.get('department'), is_visible=False ) else: contract = ContractBase.clone(contract) contract.description = form.data.get('description') contract.department = form.data.get('department') db.session.add(contract) db.session.commit() assigned = assign_a_contract(contract, form.data.get('flow'), form.data.get('assigned').id, clone=False) db.session.commit() if assigned: flash('Successfully assigned {} to {}!'.format(assigned.description, assigned.assigned.email), 'alert-success') return redirect(url_for('conductor.detail', contract_id=assigned.id)) else: flash("That flow doesn't exist!", 'alert-danger') return render_template('conductor/new.html', form=form, contract_id=contract_id)
def assign(contract_id, flow_id, user_id): '''Assign & start work on a contract to an admin or a conductor ''' contract = ContractBase.query.get(contract_id) flow = Flow.query.get(flow_id) assigned = assign_a_contract(contract, flow, user_id) if assigned: flash('Successfully assigned {} to {}!'.format(assigned.description, assigned.assigned.email), 'alert-success') return redirect(url_for('conductor.index')) else: flash("That flow doesn't exist!", 'alert-danger') return redirect(url_for('conductor.index'))
def start_work(contract_id=-1): '''Start work on a contract When new work is started on a contract, a new contract is created (either as a clone of an existing contract, or as brand new work), assigned to the :py:class:`~purchasing.data.flows.Flow` and :py:class:`~purchasing.users.models.User` indicated in the :py:class:`~purchasing.conductor.forms.NewContractForm` :param contract_id: Primary key ID for a :py:class:`~purchasing.data.contracts.ContractBase` .. seealso:: :py:meth:`~purchasing.data.contracts.ContractBase.clone` for more information on how new contracts get started, and :py:class:`~purchasing.conductor.forms.NewContractForm` for more on the form to start new work. :status 200: Render the new contract view :status 302: Create or start new work on a cloned contract ''' contract = ContractBase.query.get(contract_id) if contract: first_stage = contract.get_first_stage() if first_stage and first_stage.stage_id != contract.current_stage_id: return redirect( url_for('conductor.detail', contract_id=contract.id)) elif first_stage: contract.start = localize_datetime( contract.get_first_stage().entered) else: contract = ContractBase() form = NewContractForm(obj=contract) if form.validate_on_submit(): if contract_id == -1: contract, _ = get_or_create( db.session, ContractBase, description=form.data.get('description'), department=form.data.get('department'), is_visible=False) elif not first_stage: contract = ContractBase.clone(contract) contract.description = form.data.get('description') contract.department = form.data.get('department') db.session.add(contract) db.session.commit() assigned = assign_a_contract( contract, form.data.get('flow'), form.data.get('assigned'), start_time=form.data.get('start').astimezone( pytz.UTC).replace(tzinfo=None), clone=False) db.session.commit() if assigned: flash( 'Successfully assigned {} to {}!'.format( assigned.description, assigned.assigned.email), 'alert-success') return redirect( url_for('conductor.detail', contract_id=assigned.id)) else: flash("That flow doesn't exist!", 'alert-danger') return render_template('conductor/new.html', form=form, contract_id=contract_id, contract=contract)
def start_work(contract_id=-1): '''Start work on a contract When new work is started on a contract, a new contract is created (either as a clone of an existing contract, or as brand new work), assigned to the :py:class:`~purchasing.data.flows.Flow` and :py:class:`~purchasing.users.models.User` indicated in the :py:class:`~purchasing.conductor.forms.NewContractForm` :param contract_id: Primary key ID for a :py:class:`~purchasing.data.contracts.ContractBase` .. seealso:: :py:meth:`~purchasing.data.contracts.ContractBase.clone` for more information on how new contracts get started, and :py:class:`~purchasing.conductor.forms.NewContractForm` for more on the form to start new work. :status 200: Render the new contract view :status 302: Create or start new work on a cloned contract ''' contract = ContractBase.query.get(contract_id) if contract: first_stage = contract.get_first_stage() if first_stage and contract.completed_last_stage(): pass elif first_stage and first_stage.stage_id != contract.current_stage_id: return redirect(url_for('conductor.detail', contract_id=contract.id)) elif first_stage: contract.start = localize_datetime(contract.get_first_stage().entered) else: contract = ContractBase() form = NewContractForm(obj=contract) if form.validate_on_submit(): if contract_id == -1: contract, _ = get_or_create( db.session, ContractBase, description=form.data.get('description'), department=form.data.get('department'), is_visible=False ) elif not first_stage or contract.completed_last_stage(): contract = ContractBase.clone(contract) contract.description = form.data.get('description') contract.department = form.data.get('department') db.session.add(contract) db.session.commit() assigned = assign_a_contract( contract, form.data.get('flow'), form.data.get('assigned'), start_time=form.data.get('start').astimezone(pytz.UTC).replace(tzinfo=None), clone=False ) db.session.commit() if assigned: flash('Successfully assigned {} to {}!'.format(assigned.description, assigned.assigned.email), 'alert-success') return redirect(url_for('conductor.detail', contract_id=assigned.id)) else: flash("That flow doesn't exist!", 'alert-danger') return render_template('conductor/new.html', form=form, contract_id=contract_id, contract=contract)