class Answer(db.TimeStampedBase): prompt = db.String() response = db.Text() rating = db.Integer() # 1-5 def full(self): return "\n".join([self.prompt, self.response, str(self.rating)])
class Document(db.TimeStampedBase): owner = db.ForeignKey(kind=Member) logo = db.Binary() template = db.ForeignKey(kind=Template) name = db.String() injections = db.JSON() assembly = db.JSON() declarations = db.JSON() pdf = db.String() revision = db.Integer(default=0) signup_sheet = db.Boolean(default=True) table_of_contents = db.Boolean(default=True) declaration_page = db.Boolean(default=True) pretty_filenames = db.Boolean(default=True) section_page_breaks = db.Boolean(default=False) def summary(self): d = { "key": self.id(), "name": self.name, "revision": self.revision, "pdf": self.pdf, "created": str(self.created)[:19], "modified": str(self.modified)[:19], "declarations": self.declarations or {} } if self.template: t = self.template.get() d["template"] = {"key": t.id(), "name": t.name} return d def content(self, sections=None): return self.template.get().content( sections, page_breaks=self.section_page_breaks)
class Contribution(db.TimeStampedBase): codebase = db.ForeignKey(kind=Codebase) contributor = db.ForeignKey(kind=Contributor) count = db.Integer(default=0) def handle(self): return self.contributor.get().handle def membership(self): from .core import Person, Membership person = Person.query( Person.contributors.contains(self.contributor.urlsafe())).get() pod = db.get(self.codebase).pod return person and pod and Membership.query( Membership.pod == pod, Membership.person == person.key).get() def total(self): return self.count * ratios.code.line def process(self, cbatch, diff, total=0): cbase = self.codebase.get() self.membership().deposit( diff * ratios.code.line, cbatch, "code commits: %s@%s" % (self.handle(), cbase.repo), "variety: %s\nowner: %s\nbatch: %s\ntotal: %s" % (cbase.variety, cbase.owner, diff, total or diff), True) def refresh(self, total, cbatch): diff = total - self.count if diff: self.process(cbatch, diff, total) self.count = total self.put() return diff
class Race(db.ModelBase): draw_num = db.Integer() draw_date = db.DateTime() win_num = db.Integer() win_name = db.String() place_num = db.Integer() place_name = db.String() show_num = db.Integer() show_name = db.String() race_time = db.String() def data(self): return { "key": self.key.urlsafe(), "draw_date": str(self.draw_date), "draw_num": self.draw_num, "win_num": self.win_num, "win_name": self.win_name, "place_num": self.place_num, "place_name": self.place_name, "show_num": self.show_num, "show_name": self.show_name, "race_time": self.race_time }
class Delivery(Verifiable): driver = db.ForeignKey(kind="Person") miles = db.Integer() def signers(self): return [self.membership.get().person, self.driver] def fulfill(self): if self.passed or not self.verified(): return False self.pod().deposit(self.driver.get(), ratios.delivery + ratios.mileage * self.miles, self, "delivery: %s miles" % (self.miles, ), self.notes) self.passed = True self.put() return True
class Payment(db.TimeStampedBase): member = db.ForeignKey(kind=Member) successful = db.Boolean(default=False) amount = db.String() duration = db.Integer() # days message = db.Text()
class Answer(db.TimeStampedBase): person = db.ForeignKey(kind=Person) page = db.ForeignKey(kind=Page) question = db.Integer() response = db.Text()
class Building(Place): year = db.Integer() building_id = db.String() building_type = db.String() owner = db.ForeignKey(kind="owner") rent_control = db.Boolean()