class MessageModelTest(ndb.Model): string = ndb.StringProperty() repeatedString = ndb.StringProperty(repeated=True) text = ndb.TextProperty() repeatedText = ndb.TextProperty(repeated=True) blob = ndb.BlobProperty() repeatedBlob = ndb.BlobProperty(repeated=True) keyProp = ndb.KeyProperty() repeatedKey = ndb.KeyProperty(repeated=True) boolean = ndb.BooleanProperty() repeatedBoolean = ndb.BooleanProperty(repeated=True) integer = ndb.IntegerProperty() repeatedInteger = ndb.IntegerProperty(repeated=True) float = ndb.FloatProperty() repeatedFloat = ndb.FloatProperty(repeated=True) datetime = ndb.DateTimeProperty() repeatedDatetime = ndb.DateTimeProperty(repeated=True) time = ndb.TimeProperty() date = ndb.DateProperty() geopt = ndb.GeoPtProperty() repeatedGeopt = ndb.GeoPtProperty(repeated=True) blobkey = ndb.BlobKeyProperty() repeatedBlobkey = ndb.BlobKeyProperty(repeated=True) structured = ndb.StructuredProperty(InnerModel) repeatedStructured = ndb.StructuredProperty(InnerModel, repeated=True)
class Picture(ndb.Model): size_max = ndb.BlobKeyProperty(required=True) size_med = ndb.BlobKeyProperty() size_thumb = ndb.BlobKeyProperty() caption = ndb.StringProperty(default="") etag = ndb.StringProperty(default="") name = ndb.StringProperty()
class PreCommitteePage(ndb.Model): """One page from one blob""" pdf = ndb.BlobKeyProperty() page = ndb.BlobKeyProperty() year = ndb.IntegerProperty() request_id = ndb.StringProperty( repeated=True) ## XX-YYY % (leading-item, req_code) date = ndb.DateProperty() last = ndb.BooleanProperty() kind = ndb.IntegerProperty() # 1 for request explanation, 2 for table
class Directory(ndb.Model): prev_directory = ndb.StringProperty() directory_name = ndb.StringProperty() directory_path = ndb.StringProperty() list_of_directories = ndb.StringProperty(repeated=True) list_of_files = ndb.StringProperty(repeated=True) blobs = ndb.BlobKeyProperty(repeated=True) shared_files = ndb.StringProperty(repeated=True) shared_files_blobs = ndb.BlobKeyProperty(repeated=True) shared_file_owner = ndb.StringProperty(repeated=True)
class StudentData(ndb.Model): """Model that represents student information to be associated with the specified profile. """ #: Education information of the student. education = ndb.StructuredProperty(education_model.Education, required=True) #: Number of proposals which have been submitted by the student. number_of_proposals = ndb.IntegerProperty(required=True, default=0) #: Number of projects which have been assigned to the student. #: Note that right now at most one project per student is supported. number_of_projects = ndb.IntegerProperty(required=True, default=0) #: Total number of project evaluations that have been passed by the student #: for all the projects that have been assigned to him or her. number_of_passed_evaluations = ndb.IntegerProperty(required=True, default=0) #: Total number of project evaluations that have been failed by the student #: for all the projects that have been assigned to him or her. number_of_failed_evaluations = ndb.IntegerProperty(required=True, default=0) #: List of organizations for which the student have been assigned a project. project_for_orgs = ndb.KeyProperty(repeated=True) #: Property pointing to the Blob storing student's tax form. tax_form = ndb.BlobKeyProperty() #: Property pointing to the Blob storing student's enrollment form. enrollment_form = ndb.BlobKeyProperty() #: Property telling whether the enrollment form is verified by #: a program administrator. is_enrollment_form_verified = ndb.BooleanProperty(default=False) #: Number of tasks completed by the student. number_of_completed_tasks = ndb.IntegerProperty(required=True, default=0) #: Property telling whether the student has completed at least one task. completed_task = ndb.ComputedProperty( lambda self: bool(self.number_of_completed_tasks)) #: Property pointing to the Blob storing student's parental consent form. consent_form = ndb.BlobKeyProperty() #: Property telling whether the consent form is verified by #: a program administrator. is_consent_form_verified = ndb.BooleanProperty(default=False) #: Organization for which the student is a winner. winner_for = ndb.KeyProperty() #: Property telling thether the student is a winner of the program. is_winner = ndb.ComputedProperty(lambda self: bool(self.winner_for))
class Project(ndb.Model): name = ndb.StringProperty() credentials = ndb.JsonProperty() profile_id = ndb.StringProperty() notes = ndb.TextProperty() status = msgprop.EnumProperty(ProjectStatus, required=True, default=ProjectStatus.INITIALIZED) feed = ndb.BlobKeyProperty() sheets_feed_url = ndb.StringProperty() assets = ndb.BlobKeyProperty(repeated=True) created_at = ndb.DateTimeProperty(auto_now_add=True) updated_at = ndb.DateTimeProperty(auto_now_add=True) last_run_at = ndb.DateTimeProperty() last_completed_at = ndb.DateTimeProperty()
class Wine(ndb.Model): grade = ndb.FloatProperty(default=12.0) size = ndb.IntegerProperty(default=75) varietals = ndb.StringProperty(repeated=True) do = ndb.BooleanProperty(default=False) price = ndb.FloatProperty() name = ndb.StringProperty(required=True) photo = ndb.BlobKeyProperty() cask = ndb.IntegerProperty() bottle = ndb.IntegerProperty() def json(self): data = { "url": self.key.urlsafe(), "grade": self.grade, "size": self.size, "varietals": self.varietals, "do": self.do, "price": self.price, "name": self.name, "cask": self.cask, "bottle": self.bottle, "photo": None } if self.photo: data['photo'] = self.photo.ToXml() return data
class Photo(ndb.Model): #to record all the photo blobKey = ndb.BlobKeyProperty() indice_aireDeJeux = ndb.StringProperty() photo_url = ndb.StringProperty() date_creation = ndb.DateTimeProperty(auto_now_add=True) valider = ndb.BooleanProperty(default=False)
class Tweet(ndb.Model): share_text = ndb.StringProperty() user_id = ndb.StringProperty() user_name = ndb.StringProperty() time = ndb.DateTimeProperty() avatar = ndb.BlobKeyProperty()
class Task(ndb.Model): candidate_lst = ndb.StringProperty(repeated=True) expense_id = ndb.StringProperty() task_id = ndb.StringProperty() task_name = ndb.StringProperty() photo_blobkey = ndb.BlobKeyProperty() creater_email = ndb.StringProperty() description = ndb.StringProperty() assigned = ndb.BooleanProperty() charger_email = ndb.StringProperty() finished = ndb.BooleanProperty() def getChargerNickName(self): chargers = User.query(User.user_email == self.charger_email).fetch() charger = chargers[0] return charger.nick_name def getCreaterNickName(self): creaters = User.query(User.user_email == self.creater_email).fetch() creater = creaters[0] return creater.nick_name def getCandidateListString(self): candidate_str = "" for candicate_mail in self.candidate_lst: candidate_str = candidate_str + candicate_mail + "," candidate_str = candidate_str[:-1] return candidate_str
class Vessel(ndb.Model): vessel = ndb.StringProperty() vessel_lower = ndb.ComputedProperty(lambda self: self.vessel.lower()) voyage = ndb.StringProperty() voyage_lower = ndb.ComputedProperty(lambda self: self.voyage.lower()) port = ndb.StringProperty() port_lower = ndb.ComputedProperty(lambda self: self.port.lower()) loaded = ndb.StringProperty() blob = ndb.BlobKeyProperty() manifest = ndb.KeyProperty("Manifest") created = ndb.DateProperty(auto_now_add=True) updated = ndb.DateProperty(auto_now=True) @classmethod # def find_manifest(self, _voyage, _port, _vessel): def find_manifest(self, _voyage, _port): port = str(_port).lower() voyage = str(_voyage).lower() q = Manifest.query() q = q.filter(Manifest.voyage_lower == voyage) q = q.filter(Manifest.port_lower >= port) return q.get() @classmethod def update_manifest(self, qry): manifest = Manifest().query(ancestor=qry.manifest).get() manifest.vessel = qry.key manifest.put() return manifest
class Profile(ndb.Model): """ Information about this user. There is only 1 of these per user. """ name = ndb.StringProperty() location = ndb.StringProperty() description = ndb.TextProperty() picture = ndb.BlobKeyProperty() dob = ndb.DateProperty()
class Gift(ndb.Model): date = ndb.DateTimeProperty(auto_now_add=True) article = ndb.StringProperty() image = ndb.BlobKeyProperty() price = ndb.StringProperty() hyperLink = ndb.StringProperty( ) #true for selling post. false for social sharing
class Uploads(ndb.Model): ''' Native tags like, HomePage, Event, TeachersPage, Profile, etc... There can be custom tags also. (to be done) ''' tag = ndb.StringProperty() file = ndb.BlobKeyProperty()
class ImageModel(ndb.Model): #Origin is hash code when image is uploaded #basicly contains origin of the image easy, to track dup origin = ndb.StringProperty() image = ndb.BlobKeyProperty() in_gallery_dup = ndb.BooleanProperty() all_gallery_dup = ndb.BooleanProperty()
class Individual(ndb.Model): genome = ndb.PickleProperty(compressed=True) generation = ndb.IntegerProperty(required=True) parents = ndb.KeyProperty(kind='Individual', repeated=True) score = ndb.FloatProperty() # Fitness score within this generation rank = ndb.IntegerProperty() # Rank within this generation image = ndb.BlobKeyProperty(required=True) random = ndb.ComputedProperty(lambda self: random.random()) @classmethod def create(cls, genome, generation, parents, store=False): fun = piclang.stackparse(genome, normalize=True) if piclang.is_atom(fun): return None image = piclang.render(fun, points=8192) if not image: return None filename = files.blobstore.create(mime_type='image/png') with files.open(filename, 'a') as f: image.save(f, "PNG") files.finalize(filename) blob_key = files.blobstore.get_blob_key(filename) individual = cls(genome=genome, generation=generation, parents=parents, image=blob_key) if store: individual.put() return individual def image_url(self, size=None): return images.get_serving_url(self.image, size=size) def as_dict(self, size=None): return {'id': self.key.id(), 'image': self.image_url(size)}
class Task(ndb.Model): """The Entity used to save task data in the datastore between requests""" blob = ndb.BlobKeyProperty(indexed = False) app = ndb.StringProperty(indexed = False) date = ndb.DateTimeProperty(auto_now_add = True) completed = ndb.BooleanProperty(default = False, indexed = False) response = ndb.TextProperty()
class Post(ndb.Model): title = ndb.StringProperty() media_url = ndb.StringProperty() likes = ndb.IntegerProperty(default=0) date = ndb.DateTimeProperty(auto_now_add=True) media_key = ndb.BlobKeyProperty() def get_comments(self): return Comment.query(Comment.post == self.key) def comment_count(self): count = dumbmemcache.get('{}_comment_count'.format(self.key.id())) if not count: count = self.get_comments().count() dumbmemcache.set('{}_comment_count', count) return count def get_absolute_url(self): return "/post/" + str(self.key.id()) @classmethod def _post_delete_hook(cls, key, future): comment_keys = Comment.query(Comment.post == key).fetch(keys_only=True) ndb.delete_multi_async(comment_keys) logging.info("deleted {} comments for post {}".format( len(comment_keys), key.id()))
class FileModel(ndb.Model): fileName = ndb.StringProperty() fileId = ndb.StringProperty() parentDirectory = ndb.StringProperty() blob = ndb.BlobKeyProperty() createdBy = ndb.StringProperty() permissionGranted = ndb.StringProperty(repeated=True)
class Image(ndb.Model): stream_id = ndb.StringProperty() image_id = ndb.StringProperty() blob_key = ndb.BlobKeyProperty() create_date = ndb.DateTimeProperty(auto_now_add=True) @classmethod def getImage(cls,img_id): img = cls.query(cls.image_id == img_id).fetch() return img[0] if img else img def delete(self): blob_info = blobstore.BlobInfo.get(self.blob_key) if blob_info: blob_info.delete() self.key.delete() @classmethod def dump(cls): return [{k:v if v is None else (str(v) if not hasattr(v,'__iter__') else map(str,v)) for k,v in o.to_dict().items()} for o in cls.query()] @classmethod def clear(cls): for i in cls.query(): i.delete() @classmethod def exists(cls,image_id): return cls.query(cls.image_id == image_id).count() > 0
class UserScreenshot(ndb.Model): user = ndb.StringProperty(indexed=True) blob_key = ndb.BlobKeyProperty(indexed=False) filename = ndb.StringProperty(indexed=False) index = ndb.IntegerProperty(indexed=True) processed = ndb.BooleanProperty(indexed=True) cards = ndb.TextProperty(indexed=False)
class Channel(ndb.Model): name = ndb.StringProperty(required=True) # Repeated strings/list of keys # Repeated, not required, empty key is fine classes = ndb.KeyProperty(repeated=True) active = ndb.BooleanProperty(required=True) icon = ndb.BlobKeyProperty()
class challengeModel(ndb.Model): ownerID = ndb.StringProperty() question = ndb.TextProperty() answer = ndb.TextProperty() score = ndb.IntegerProperty() name = ndb.StringProperty() blob_key = ndb.BlobKeyProperty()
class PostDb(ndb.Model): pst = ndb.BlobKeyProperty() postby = ndb.KeyProperty(kind='MyUser') cap = ndb.StringProperty() time = ndb.DateTimeProperty() comment = ndb.KeyProperty(kind='Comment', repeated=True) like = ndb.KeyProperty(kind='MyUser', repeated=True)
class Player(ndb.Model): """A CUHC Member""" name = ndb.StringProperty() team = ndb.KeyProperty(kind=Team) shirt = ndb.IntegerProperty() index = ndb.IntegerProperty() profile = ndb.TextProperty() picture = ndb.BlobKeyProperty() @classmethod def common_ancestor(cls, year=0): if year == 0: year = setting.get("currentyear") return ndb.Key("year", year) @classmethod def create(cls, year=0): h = cls(parent=cls.common_ancestor(year)) return h @classmethod def list(cls, tm, year=0): return cls.query(ancestor=cls.common_ancestor(year), projection=['name', 'picture']) \ .filter(cls.team == tm.key) \ .order(cls.index)
class OurUser(auth_user.User, BaseClass): role = ndb.KeyProperty() tenant_domain = ndb.StringProperty() tenant_key = ndb.KeyProperty(kind=Tenant) blob_key = ndb.BlobKeyProperty() project_permission = ndb.BooleanProperty() def set_password(self, raw_password): self.password = security.generate_password_hash(raw_password, length=12) @classmethod def get_by_auth_token(cls, user_id, token, subject='auth'): token_key = cls.token_model.get_key(user_id, subject, token) user_key = ndb.Key(cls, user_id) # Use get_multi() to save a RPC call. valid_token, user = ndb.get_multi([token_key, user_key]) if valid_token and user: timestamp = int(time.mktime(valid_token.created.timetuple())) return user, timestamp return None, None def get_all(self): res = self.query().fetch() return res @classmethod def _pre_delete_hook(cls, key): us = key.get() auth_user.Unique.delete_multi( map(lambda s: '%s.auth_id:' % (cls.__name__) + s, us.auth_ids))
class Question(ndb.Model): category = ndb.KeyProperty() categoryText = ndb.StringProperty() question = ndb.StringProperty() answer1 = ndb.StringProperty() answer2 = ndb.StringProperty() answer3 = ndb.StringProperty() answer4 = ndb.StringProperty() answerid = ndb.StringProperty() creator = ndb.StringProperty(default="user") correctAnswers = ndb.IntegerProperty(default=0) incorrectAnswers = ndb.IntegerProperty(default=0) answer1Selections = ndb.IntegerProperty(default=0) answer2Selections = ndb.IntegerProperty(default=0) answer3Selections = ndb.IntegerProperty(default=0) answer4Selections = ndb.IntegerProperty(default=0) totalAnswers = ndb.IntegerProperty(default=0) explanation = ndb.StringProperty() create_date = ndb.DateProperty(auto_now_add=True) accepted = ndb.BooleanProperty(default=False) up_voters = ndb.StringProperty(repeated=True) down_voters = ndb.StringProperty(repeated=True) up_votes = ndb.IntegerProperty(default = 0) down_votes = ndb.IntegerProperty(default = 0) rating = ndb.ComputedProperty(lambda self: self.up_votes - self.down_votes) score = ndb.IntegerProperty(default=0) image_urlQ = ndb.BlobKeyProperty() urlkey = ndb.StringProperty() deleted = ndb.BooleanProperty(default=False)
class Channel(ndb.Model): name = ndb.StringProperty(required = True) classes = ndb.KeyProperty(repeated = True) active = ndb.BooleanProperty(required = True) icon = ndb.BlobKeyProperty() startTime = ndb.TimeProperty(auto_now = True) endTime = ndb.TimeProperty(auto_now = True)
class Post(ndb.Model): def to_dict(self): items = {} items['id'] = self.key.id() items['title'] = self.title items['quote'] = self.quote try: items['image'] = images.get_serving_url(self.image) except: pass items['creator'] = self.creator.email() items['created'] = self.made_on.isoformat() # items['created']=self.made_on.strftime('%Y-%m-%dT%H:%M:%S') items['url'] = self.uri items['votesum'] = self.votesum items['comments'] = self.comments return items title = ndb.StringProperty(required=True) quote = ndb.StringProperty() uri = ndb.StringProperty() rank = ndb.StringProperty() image = ndb.BlobKeyProperty() creation_order = ndb.StringProperty(default=" ") votesum = ndb.IntegerProperty(default=0) created = ndb.IntegerProperty(default=0) made_on = ndb.DateTimeProperty(auto_now_add=True) creator = ndb.UserProperty() comments = ndb.IntegerProperty(default=0)
class Post(ndb.Model): image_name = ndb.StringProperty() uploads = ndb.BlobKeyProperty() caption = ndb.StringProperty() upload_time = ndb.DateTimeProperty(auto_now_add = True) post_by = ndb.KeyProperty() comments = ndb.StructuredProperty(Comments, repeated = True)