def show_permit(request, pk): id = pk if request.method == 'POST': form = PermitForm(request.POST) permit = PermitGateway.find_by_id(_id=pk) if form.is_valid(): permit.update_info(form) permit.save() perm = Permit.objects.get(id=id) permit_form = PermitForm(instance=perm) context = { 'permit': permit, 'form': permit_form, 'error': 0, 'method': 'post', 'id': id } else: context = {'error': 1} return context else: permit = PermitGateway.find_by_id(_id=pk) permit_form = PermitForm(instance=Permit.objects.get(id=id)) context = { 'reqobject': permit, 'form': permit_form, 'error': 0, 'method': 'get', 'id': id } return context
def print(request, pk): permit = PermitGateway.find_by_id(_id=pk) permit.status = u'PRI' permit.save() context = { 'permit': permit, } return context
def print_permit(pk): permit = PermitGateway.find_by_id(_id=pk) pos = PositionGateway.find_by_id(_id=permit.position_id) dep = DepartGateway.find_by_id(_id=permit.department_id) if pos != None: permit.position = pos.name if dep != None: permit.department = dep.full_name() permit.id = pk context = { 'permit': permit, } return context
def show_permit(request, pk): id = pk if request.method == 'POST': form = PermitForm(request.POST) permit = PermitGateway.find_by_id(_id=pk) if form.is_valid(): permit.update_info(form) permit.save() perm = Permit.objects.get(id=id) permit_form = PermitForm(instance=perm) context = { 'permit': permit, 'form': permit_form, 'error': 0, 'method': 'post', 'id': id } else: context = { 'error': 1 } return context else: permit = PermitGateway.find_by_id(_id=pk) permit_form = PermitForm(instance=Permit.objects.get(id=id)) context = { 'reqobject': permit, 'form': permit_form, 'error': 0, 'method': 'get', 'id': id } return context