Exemple #1
0
    def insert(self, item):
        pfname = item['person_firstname']
        plname = item['person_lastname']
        pdob = item['person_dob']
        pcity = item['person_city']
        pphone = item['person_phone_number']
        pemail = item['person_email']

        if pfname and plname and pdob and pcity and pphone and pemail:
            dao = AdminDAO()
            dao.insert(pfname, plname, pdob, pcity, pphone, pemail)
            return jsonify(admin=self.build_attribute_dict(
                pfname, plname, pdob, pcity, pphone, pemail)), 201
        else:
            return jsonify(Error="Unexpected attributes in post request"), 400
Exemple #2
0
 def insertAdmin(self, form):
     if len(form) != 9:
         return jsonify(Error="Malformed post request"), 400
     else:
         u_name = form['u_name']
         u_lastname = form['u_lastname']
         u_email = form['u_email']
         u_password = form['u_password']
         u_address = form['u_address']
         u_city = form['u_city']
         u_region = form['u_region']
         u_phone = form['u_phone']
         u_age = form['u_age']
         if u_name and u_lastname and u_email and u_password and u_address and u_city and u_region and u_phone and u_age:
             dao = AdminDAO()
             admin_id = dao.insert(u_name, u_lastname, u_email, u_password,
                                   u_address, u_city, u_region, u_phone,
                                   u_age)
             result = self.build_admin_attributes(admin_id, u_name,
                                                  u_lastname, u_email,
                                                  u_password, u_address,
                                                  u_city, u_region, u_phone,
                                                  u_age)
             return jsonify(Admin=result), 201
         else:
             return jsonify(
                 Error="Unexpected attributes in post request"), 400
Exemple #3
0
    def insertAdmin(self, json):
        admin_firstname = json['admin_firstname']
        admin_lastname = json['admin_lastname']
        admin_date_birth = json['admin_date_birth']
        admin_email = json['admin_email']
        admin_phone = json['admin_phone']

        if admin_firstname and admin_lastname and admin_date_birth and admin_email and admin_phone:
            dao_user = UserDAO()
            user_id = dao_user.insert(admin_firstname, admin_lastname,
                                      admin_date_birth, admin_email)
            dao_phone = UserPhoneDAO()
            admin_phone_id = dao_phone.insert(user_id, admin_phone)
            dao_admin = AdminDAO()
            admin_id = dao_admin.insert(user_id)
            result = self.build_admin_attributes(user_id, admin_id,
                                                 admin_firstname,
                                                 admin_lastname,
                                                 admin_date_birth, admin_email,
                                                 admin_phone_id, admin_phone)
            return jsonify(Admin=result), 201
        else:
            return jsonify(Error="Unexpected attributes in post request"), 400