class Hardware(db.Document): # price per unit, name, total num, num available, extra rate? hardware_name = db.StringField(required=True, max_length=50) price_per_unit = db.FloatField(required=True) total_count = db.IntField(required=True) available_count = db.IntField(required=True) extra_time_rate = db.FloatField() def to_json(self): return { "hardware_name": self.hardware_name, "price_per_unit": self.price_per_unit, "total_count": self.total_count, "available_count": self.available_count, "extra_time_rate": self.extra_time_rate }
class AssignedRecord(db.Document): project = db.ReferenceField("Project", required=True) hardware = db.ReferenceField("Hardware", required=True) amount = db.IntField(required=True) def to_json(self): return {"hw_name": self.hardware.hardware_name, "amount": self.amount}
class Address(db.Document): first_name = db.StringField(required=True) last_name = db.StringField(required=True) phone_number = db.StringField(required=True) line1 = db.StringField(required=True) line2 = db.StringField() city = db.StringField(required=True) state = db.StringField(required=True) zipcode = db.IntField(required=True) default = db.BooleanField(required=True)
class RentRecord(db.Document): # user, hardware, date rented out, date expiring user = db.ReferenceField("User", required=True) hardware = db.ReferenceField("Hardware", required=True) amount = db.IntField(required=True) date_rented = db.DateTimeField(required=True) date_expired = db.DateTimeField(required=True) def to_json(self): return { # "user": self.user.username, "name": self.hardware.hardware_name, "amount": self.amount }
class Experiment(db.Document): exp_uid = db.StringField() exp_key = db.StringField() perm_key = db.StringField() app_id = db.StringField() name = db.StringField() description = db.StringField() instructions = db.StringField() debrief = db.StringField() params = db.DictField() status = db.StringField(default="staging") target_set = db.ReferenceField('TargetSet') query_tries = db.IntField() query_duration = db.IntField() info = db.DictField() # Use set's on any parameters that can be changed outside of a constructor. def set_status(self, status): self.status = status self.save() def set_exp_uid(self, exp_uid): self.exp_uid = exp_uid self.save() def set_exp_key(self, exp_key): self.exp_key = exp_key self.save() def set_perm_key(self, perm_key): self.perm_key = perm_key self.save() def set_info(self, info): self.info = info self.save()
class Task(Base): name = db.StringField(required=True) # title = db.StringField(required = True) createdBy = db.ReferenceField(User) assignedTo = db.ReferenceField(User) description = db.StringField() orderNumber = db.IntField() def transform(self): return { 'id': self.get_id(), 'name': self.name, 'createdBy': self.createdBy.transform(), 'assignedTo': self.assignedTo.transform(), 'description': self.description, 'orderNumber': self.orderNumber, 'createdAt': self.createdAt, 'updatedAt': self.updatedAt }
class List(Base): name = db.StringField(required=True) tasklists = db.ListField(db.ReferenceField(Task)) orderNumber = db.IntField() def transform(self): return { 'id': self.get_id(), 'tasklists': self.tasklists, 'orderNumber': self.orderNumber, 'name': self.name } def getAll(self): return { 'id': self.get_id(), 'tasklists': [task.transform() for task in self.tasklists], 'orderNumber': self.orderNumber, 'name': self.name }
class PaymentInformation(db.Document): first_name = db.StringField(required=True) last_name = db.StringField(required=True) card_number = db.StringField(required=True) expiration_month = db.IntField(required=True) expiration_year = db.IntField(required=True)