Exemple #1
0
        def _create():
            errors = {}  #list of data entry errors

            if self.username is None or self.first_name is None or self.last_name is None:
                if self.username is None:
                    errors["username"] = "******"
                elif self.first_name is None:
                    errors["first_name"] = "No First Name"
                else:
                    errors["last_name"] = "No Last Name"
                return errors

            if self.username is None:
                raise ValueError("username was not supplied")
            elif self.first_name is None:
                raise ValueError("first name not entered")
            elif self.last_name is None:
                raise ValueError("last name not entered")

            user = User(self.username, self.first_name, self.last_name)
            user = _set_user(user)
            if _is_valid(user):
                try:
                    user.password = sha256_digest(password)
                except ValueError as err:
                    print(err.message)
                    raise ValueError("No password supplied")

                with transaction.manager:
                    DBSession.add(user)
            else:
                print("Invalid user")
Exemple #2
0
        def _create():
            requisition = Requisition()
            #requisition = _set_requisition(requisition)
            requisition.department = department_id
            requisition.expected_date = expected_date

            with transaction.manager:
                DBSession.add(requisition)
                transaction.commit()
Exemple #3
0
 def _create():
     with transaction.manager:
         item = Item(name)
         item.notes = notes
         item.category = category
         item.unit_of_measurement = unit_of_measurement
         item.created_by = user
         item.modified_by = user
         DBSession.add(item)
Exemple #4
0
 def _create():
     supplier = DBSession.query(Supplier).get(supplier_id)
     print(supplier.to_json)
     if supplier is None:
         raise TypeError("Could not find supplier with id: %s" %
                         supplier_id)
     branch = SupplierBranch(supplier_id)
     branch = _setattr(branch)
     del branch.id
     with transaction.manager:
         DBSession.add(branch)
Exemple #5
0
        def _create():
            """
            Create a new Group
            """
            group = Group(name)
            group.created_by = User.get_by_username(created_by)
            group.modified_by = User.get_by_username(modified_by)
            group.created_by = group.created_by.id
            group.modified_by = group.modified_by.id
            created_date = datetime.now()
            group.created_date = created_date
            group.modified_date = created_date

            with transaction.manager:
                DBSession.add(group)
                transaction.commit()
Exemple #6
0
 def _create():
     with transaction.manager:
         item_category = ItemCategory(name)
         item_category.notes = notes
         item_category.created_by = user
         item_category.modified_by = user
         j_item_category = DBSession.add(item_category)
         j_item_category = self.get(LAST=True)
         return j_item_category
Exemple #7
0
 def _create():
     with transaction.manager:
         supplier = Supplier(name)
         supplier.tel_1 = tel_1
         supplier.tel_2 = tel_2
         supplier.fax = notes
         supplier.email = email
         supplier.address = address
         supplier.notes = notes
         supplier.website = website
         supplier.created_by = user
         supplier.modified_by = user
         j_supplier = DBSession.add(supplier)
         j_supplier = self.get(LAST=True)
         return j_supplier
Exemple #8
0
        def _create():
            purchase_order = _set_purchase_order(LocalPurchaseOrder())

            with transaction.manager:
                DBSession.add(purchase_order)
                transaction.commit()