def del_user(firm_id): hard_id = request.args.get('hard_id') if not hard_id: logger.debug('PERSON: Not found hard_id in request parameters') abort(405) person = Person.query.filter_by(firm_id=firm_id).\ filter_by(hard_id=hard_id).first() if not person: logger.debug('PERSON: Not found person') abort(404) result = Person.delete(person) if not result: abort(500) return render_template("person/success.xml").encode('cp1251')
def add_user(firm_id): search = {} for key in Person.MANDATORY_PARAMETERS: search_value = request.form.get(key) if not search_value: continue search[key] = search_value if len(search) != len(Person.MANDATORY_PARAMETERS): if not request.form.get(key): logger.debug('PERSON: Required parameters missing') abort(405) person = Person.query.filter_by(firm_id=firm_id).\ filter((Person.hard_id == search['hard_id']) | (Person.tabel_id == search['tabel_id'])).first() if person: force = request.form.get('force') if not force: logger.debug('PERSON: Duplicate person') abort(400) result = Person.delete(person) if not result: abort(500) person = Person() person.firm_id = firm_id for key, value in search.iteritems(): setattr(person, key, value) for key in Person.OPTIONAL_PARAMETERS: value = request.form.get(key) if not value: continue setattr(person, key, value) if not person.payment_id: person.payment_id = person.hard_id if not person.save(): abort(500) return render_template("person/person.xml", persons=(person,)).encode('cp1251')
def del_person(): parameters = get_parameters() if not parameters: abort(405) card_id = parameters.get('CardID') if not card_id: logger.debug('API: Not found CardID in request parameters') abort(405) person = Person.query.filter(Person.firm_id.in_(g.firms)).\ filter_by(id=card_id).first() if not person: logger.debug('API: Not found person') abort(404) result = Person.delete(person) if not result: abort(500) return get_success_result()