class _SlotRecord(db.Model): """Represents an output slot. Key name is a randomly assigned UUID. No parent for slots of child pipelines. For the outputs of root pipelines, the parent entity is the root _PipelineRecord (see Pipeline.start()). Properties: root_pipeline: The root of the workflow. filler: The pipeline that filled this slot. value: Serialized value for this slot. status: The current status of the slot. fill_time: When the slot was filled by the filler. """ FILLED = 'filled' WAITING = 'waiting' root_pipeline = db.ReferenceProperty(_PipelineRecord) filler = db.ReferenceProperty(_PipelineRecord, collection_name='filled_slots_set') # One of these two will be set, depending on the size of the value. value_text = db.TextProperty(name='value') value_blob = blobstore.BlobReferenceProperty(name='value_blob', indexed=False) status = db.StringProperty(choices=(FILLED, WAITING), default=WAITING, indexed=False) fill_time = db.DateTimeProperty(indexed=False) @classmethod def kind(cls): return '_AE_Pipeline_Slot' @property def value(self): """Returns the value of this Slot.""" if hasattr(self, '_value_decoded'): return self._value_decoded if self.value_blob is not None: encoded_value = self.value_blob.open().read() else: encoded_value = self.value_text self._value_decoded = simplejson.loads(encoded_value, cls=util.JsonDecoder) return self._value_decoded
class UploadedFile(BaseModel): fileBlob = db.BlobProperty() thumbnailBlob = db.BlobProperty() fileBlobRef = blobstore.BlobReferenceProperty() fileName = db.StringProperty(default=None) fileType = db.StringProperty(default=None) fileSize = db.IntegerProperty(default=0) width = db.IntegerProperty(default=0) height = db.IntegerProperty(default=0) is_private = db.BooleanProperty() ip = db.StringProperty(default=None) url = db.StringProperty(default=None) thumbnail = db.StringProperty(default=None) tags = db.StringProperty(default=None)
class OSALauncherApp(db.Model): user = db.UserProperty() timestamp = db.IntegerProperty() app_id = db.StringProperty() version_code = db.IntegerProperty(indexed=False) package = blobstore.BlobReferenceProperty() @classmethod def create_key(cls, app_id): return db.Key.from_path(cls.kind(), app_id) @classmethod def get_by_app_id(cls, app_id): key = cls.create_key(app_id) return cls.get(key)
class Sample(db.Model): rnd = db.FloatProperty() created = db.DateTimeProperty(auto_now_add = True) ip = db.StringProperty(default = '?') type = db.StringProperty(default = 'unknown') notes = db.StringProperty(default = '') data = blobstore.BlobReferenceProperty() processed = blobstore.BlobReferenceProperty() filename = db.StringProperty(default = 'unknown') size = db.IntegerProperty(default = 0) mime = db.StringProperty(default = 'unknown') @classmethod def new(cls, *args, **kwargs): from random import random return cls(rnd = random(), *args, **kwargs) @classmethod def choose_random(cls, type, rnd, rng): '''rnd is [0..1]''' s = Sample.all().order('rnd').filter('rnd >=', rnd).get() if s == None: i = 10 while i > 0 and s == None: if rng: r = rng.random() s = Sample.all().order('rnd').filter('rnd <', r).get() i = i + 1 return s def serve_url(self): return '/sample/%i' % self.key().id()
class GCIStudent(soc.models.student.Student): """GCI Student model extends the basic student model. """ #: Set to True if the reminder mail to upload parental consent #: form is sent to students parental_form_mail = db.BooleanProperty(default=False) #: Property pointing to the consent form consent_form = blobstore.BlobReferenceProperty( required=False, verbose_name=ugettext('Parental Consent Form')) consent_form.help_text = ugettext( 'A signed Parental Consent Form from your legal parent or guardian') #: Property pointing to the second page of the consent form consent_form_two = blobstore.BlobReferenceProperty( required=False, verbose_name=ugettext('Parental Consent Form (page 2)')) consent_form_two.help_text = ugettext( 'Page two of the Parental Consent Form (if applicable)') #: Property pointing to the student id form student_id_form = blobstore.BlobReferenceProperty( required=False, verbose_name=ugettext('Student ID form')) student_id_form.help_text = ugettext( 'A scan of your student ID to verify your student status and birthday.' ) #: Property containing the Grade of the student if the school type #: is High School. grade = db.IntegerProperty(required=False, verbose_name=ugettext('Grade')) grade.group = ugettext("5. Education") grade.help_text = ugettext( 'Please enter your grade in the school, e.g. 8 if you are in 8th' ' grade. In some parts of the world it is called as, e.g. 8th' ' Standard')
class ePubFile(db.Model): timeCreated = db.DateTimeProperty(auto_now_add=True) timeEdited = db.DateTimeProperty(auto_now=True) book = db.ReferenceProperty(Book) blob = blobstore.BlobReferenceProperty() cover_path = db.StringProperty() license = db.StringProperty() language = db.StringProperty() title = db.StringProperty() creator = db.StringProperty() publisher = db.StringProperty() rights = db.StringProperty() contributor = db.StringProperty() identifier = db.StringProperty() date = db.StringProperty() description = db.TextProperty() def internals(self, only_chapters=False): internals = InternalFile.all().filter("epub = ", self) if (only_chapters): internals = internals.filter("order >", -1) return internals.order("order") if only_chapters else internals.order( "path") def entries(self): return LibraryEntry.all().filter("epub = ", self) def entry_count(self): return LibraryEntry.all().filter("epub = ", self).count() def get_cover(self, force_recheck=False): if self.cover_path is None or force_recheck: potential_cover = None for file in self.internals(): if file.data is not None and file.path.endswith( "png") or file.path.endswith( "jpg") or file.path.endswith("jpeg"): if potential_cover is None or file.name.lower().find( "cover") > 0 or len(file.data) > len( potential_cover.data): potential_cover = file if potential_cover is not None: self.cover_path = potential_cover.path self.put() return self.cover_path def isPublicAccess(self): return self.license == "Public Domain" or self.license == "Creative Commons"
class Gift(db.Model): ident = db.StringProperty(required=True) created = db.DateTimeProperty(auto_now_add=True) updated = db.DateTimeProperty(auto_now=True) description = db.StringProperty() message = db.StringProperty() picture = blobstore.BlobReferenceProperty() giver = db.ReferenceProperty(User, collection_name='give_set', required=True) taker = db.ReferenceProperty(User, collection_name='take_set') def put(self): res = super(Gift, self).put() memcache.delete("home.gifts") memcache.delete("gifts.count") for page in range(1, 31): cache_key = "gifts.json.%d" % (page) memcache.delete(cache_key) memcache.delete("stats.gifts") memcache.delete("gift.%s" % (self.ident)) return res @property def is_complete(self): return self.description and self.message and self.picture @property def url(self): if self.picture: return images.get_serving_url(self.picture) @property def thumbnail_url(self): if self.picture: return images.get_serving_url(self.picture, 250, False) @property def grid_url(self): if self.picture: return images.get_serving_url(self.picture, 150, True) @property def orbit_url(self): if self.picture: return images.get_serving_url(self.picture, 383, True)
class CSVFile(db.Model): filename = db.StringProperty(required=True) creation_timestamp = db.DateTimeProperty(auto_now_add=True, required=True) event = db.ReferenceProperty(event_db.Event, required=True) blob = blobstore.BlobReferenceProperty(required=True) encoding = db.StringProperty(required=True, default='utf8') total_row_count = db.IntegerProperty(required=True) analysed_row_count = db.IntegerProperty(default=0, required=True) valid_row_count = db.IntegerProperty(default=0, required=True) invalid_row_count = db.IntegerProperty(default=0, required=True) saved_count = db.IntegerProperty(default=0, required=True) header_present = db.BooleanProperty(default=True, required=True) analysis_complete = db.BooleanProperty(default=False, required=True) analysis_failed = db.BooleanProperty(default=False, required=True) saving = db.BooleanProperty(default=False, required=True) deleting = db.BooleanProperty(default=False, required=True)
class SessionData(db.Model): presenter = db.ListProperty(unicode, default=None) user_id = db.StringProperty() name = db.StringProperty() room = db.StringProperty(indexed=True) date = db.StringProperty() time = db.StringProperty() dotw = db.StringProperty() #date_time = db.DateTimeProperty() create_date = db.DateTimeProperty(auto_now_add=True) module = db.StringProperty(default=module) blob_store_key = blobstore.BlobReferenceProperty() filename = db.StringProperty() uploaded_to_dbox = db.BooleanProperty(default=False) dbox_path = db.CategoryProperty(default=None) dbox_size = db.StringProperty(default=None)
class SolutionLoyaltySlide(db.Model): timestamp = db.IntegerProperty() name = db.StringProperty(indexed=False) time = db.IntegerProperty(indexed=False) item = blobstore.BlobReferenceProperty() gcs_filename = db.StringProperty(indexed=False) content_type = db.StringProperty(indexed=False) deleted = db.BooleanProperty(default=False) @property def id(self): return self.key().id() @property def function_dependencies(self): return 0 def item_url(self): if self.gcs_filename: k = blobstore.create_gs_key('/gs' + self.gcs_filename) else: k = self.item return unicode(images.get_serving_url(k, secure_url=True)) def slide_url(self): from rogerthat.settings import get_server_settings server_settings = get_server_settings() if self.gcs_filename: return get_serving_url(self.gcs_filename) return unicode("%s/unauthenticated/loyalty/slide?%s" % (server_settings.baseUrl, urllib.urlencode(dict(slide_key=self.item.key())))) @property def service_identity_user(self): return users.User(self.parent_key().name()) @property def service_user(self): return get_service_user_from_service_identity_user( self.service_identity_user) @property def service_identity(self): return get_identity_from_service_identity_user( self.service_identity_user)
class GCIWorkSubmission(soc.models.base.ModelWithFieldAttributes): """Model for work submissions for a task by students. Scope will be set to the Organization to which this work has been submitted. scope_path will be set to the task key name under which this work was submitted. """ #: User who submitted this work user = db.ReferenceProperty(reference_class=soc.models.user.User, required=True, collection_name='work_submissions') #: Organization to which this work belongs to org = db.ReferenceProperty(reference_class=gci_org_model.GCIOrganization, required=True, collection_name='work_submissions') #: Program to which this work belongs to program = db.ReferenceProperty( reference_class=gci_program_model.GCIProgram, required=True, collection_name='work_submissions') #: Property allowing you to store information about your work information = db.TextProperty(required=False, verbose_name=ugettext('Info')) information.help_text = ugettext( 'Information about the work you submit for this task') #: Property containing an URL to this work or more information about it url_to_work = db.LinkProperty(required=False, verbose_name=ugettext('URL to your Work')) url_to_work.help_text = ugettext( 'URL to a resource containing your work or more information about it') #: Property pointing to the work uploaded as a file or archive upload_of_work = blobstore.BlobReferenceProperty( required=False, verbose_name=ugettext('Upload of Work')) upload_of_work.help_text = ugettext( 'Your work uploaded as a single file or as archive') #: Property containing the date when the work was submitted submitted_on = db.DateTimeProperty(required=True, auto_now_add=True, verbose_name=ugettext('Submitted on'))
class DocImage(LandStreamModel): oilGasLease = db.ReferenceProperty(OilGasLease, collection_name='Images') image = blobstore.BlobReferenceProperty() def __str__(self): return self.oilGaseLease.Key().ID() + '-' + self.page @classmethod def WriteToZip(cls, items, zipFile): for docImage in items: image = docImage.image lease = docImage.oilGasLease path = lease.state + '/' + lease.county + '/' + str( lease.filingDate.year) + '/' + lease.fileName zipFile.writestr(path.encode('utf-8'), blobstore.BlobReader(image.key()).read())
class BlobModel(db.Model): ''' Superclass for models that store a blobfile ''' image = blobstore.BlobReferenceProperty() mime_type = db.StringProperty() url = db.StringProperty() def upload_image(self, blob, filename): mime_type = 'image/png' if filename.split('.')[-1] == 'jpg' or filename.split( '.')[-1] == 'jpeg': mime_type = 'image/jpeg' bucket_name = os.environ.get( 'BUCKET_NAME', app_identity.get_default_gcs_bucket_name()) bucket = '/' + bucket_name filename_final = bucket + '/' + str(uuid.uuid4()) # Create a GCS file with GCS client. with gcs.open(filename_final, 'w') as f: f.write(blob) f.close() # Blobstore API requires extra /gs to distinguish against blobstore files. blobstore_filename = '/gs' + filename_final # Get the file's blob key blob_key = blobstore.create_gs_key(blobstore_filename) # Store it self.image = blob_key self.mime_type = mime_type self.url = get_serving_url(blob_key) def get_blob_response(self): response = HttpResponse() response[blobstore.BLOB_KEY_HEADER] = self.image.key() if self.mime_type: response['Content-Type'] = self.mime_type else: response['Content-Type'] = "image/png" return response
class Design(db.Model): created = db.DateTimeProperty(auto_now_add=True) designTitle = db.StringProperty(required=True) imageBlobCommon = blobstore.BlobReferenceProperty() imageBlobs = db.ListProperty(blobstore.BlobKey) designerName = db.StringProperty(required=True) designerPosition = db.StringProperty(required=True) designerDetails = db.TextProperty(required=True) desc = db.TextProperty(required=True) garmentDetails = db.TextProperty(required=True) videoUrl = db.StringProperty(required=True) videoShareUrl = db.StringProperty(required=False) voteCount1 = db.IntegerProperty(default=0) voteCount2 = db.IntegerProperty(default=0) voteCount3 = db.IntegerProperty(default=0) ipaddress = db.StringListProperty(default=[])
class Oferta(db.Model): IdOft = db.StringProperty() IdEmp = db.StringProperty() IdCat = db.IntegerProperty() Oferta = db.StringProperty() BlobKey = blobstore.BlobReferenceProperty(required=False, validator=None) #BlobKey = db.StringProperty() Empresa = db.StringProperty() Descripcion = db.TextProperty() Codigo = db.StringProperty() Precio = db.StringProperty() Descuento = db.StringProperty() Promocion = db.StringProperty() Enlinea = db.BooleanProperty() Url = db.StringProperty() Tarjetas = db.StringProperty() Meses = db.StringProperty() FechaHoraPub = db.DateTimeProperty() StatusPub = db.BooleanProperty() FechaHora = db.DateTimeProperty()
class CaseAction(JurisModel): """Immutable once fully created (by the `make` classmethod).""" action = db.StringProperty(required=True, choices=CASE_ACTIONS) case = db.ReferenceProperty(Case, required=True) actor = db.ReferenceProperty(User, required=True) purpose = db.StringProperty(required=False, choices=PURPOSES) notes = db.TextProperty(required=False) upload = blobstore.BlobReferenceProperty(required=False) def json(self): """Return JSON-serializable form.""" d = { 'cls': 'Action', 'case': self.case.json(), 'actor': self.actor.json() } if self.purpose: d['purpose'] = self.purpose if self.notes: d['notes'] = self.notes if self.upload: d['upload'] = str(self.upload.key()) d['timestamp'] = self.timestamp.isoformat() return d @classmethod def make(cls, **k): """Create and put an action, and log information about it.""" # TODO: send info about the action to the latrop logging.info('********** ') logging.info('********** NEW ACTION: %s', k) logging.info('********** JSON: %r', simplejson.dumps(k, skipkeys=True, cls=ModelEncoder)) logging.info('********** ') action = cls(**k) action.put() @classmethod def query_by_case(cls, case, action=None):
class UploadedFile(db.Model): blob = blobstore.BlobReferenceProperty(required=True) content_type = db.StringProperty() modified = db.DateTimeProperty() @property def filename(self): n = self.key().name() return n[n.rindex('/') + 1:] @property def guessed_type(self): if self.content_type == 'application/octet-stream' \ or not self.content_type: mime_type, unused_parameters = mimetypes.guess_type(self.filename) return mime_type or 'text/plain' else: return self.content_type or 'text/plain' def delete(self): super(UploadedFile, self).delete() self.blob.delete()
class UserProfile(BaseModel): name = db.StringProperty(default=None) email = db.EmailProperty(required=True) password = db.StringProperty(required=True) image = blobstore.BlobReferenceProperty(indexed=False, required=False) @classmethod def get_by_email(cls, email): if not email: return return cls.all().filter('email =', email.lower().strip()).get() @classmethod def create(cls, email, password): assert email and password email = email.lower().strip() assert email existing_user = cls.get_by_email(email) assert not existing_user e = cls(email=email, password=util.get_hash(password)) e.put() return e def check_password(self, password): """ Check to see if a password matches what we've got stored """ assert self.password and password return self.password == util.get_hash(password) def json(self): return { 'user_id': self.id, 'name': self.name, 'email': self.email, 'has_password': bool(self.password), 'date': self.json_date(self.date), }
class Responder(db.Model): """Represents a particular RDM product / device.""" manufacturer = db.ReferenceProperty(Manufacturer, required=True) # The Device Model ID field from DEVICE_INFO device_model_id = db.IntegerProperty() # The DEVICE_MODEL_DESCRIPTION model_description = db.StringProperty(required=True) # The product category product_category = db.ReferenceProperty(ProductCategory, collection_name='responder_set') # link to the product page link = db.LinkProperty() # url of the source image image_url = db.LinkProperty() # the blob for the image data image_data = blobstore.BlobReferenceProperty() # the url we're serving the image on image_serving_url = db.LinkProperty() # the scoring rank score = db.IntegerProperty() # the score penalty, used to demote responders score_penalty = db.IntegerProperty() # test score, this is updated with the latest score rdm_responder_rating = db.RatingProperty()
class Question(db.Model): """Represents a question that is used in an exam""" text = db.StringProperty() answers = db.StringListProperty() correct_answers = db.ListProperty(int) value = db.IntegerProperty() image = blobstore.BlobReferenceProperty() def to_json(self): """Obtain a JSON representation of the model""" return json.dumps({ 'text': self.text, 'answers': [a for a in self.answers], 'weight': self.weight }) def find_question(self, question_id): return Question.get_by_id(question_id) def get_all(self): query_str = "SELECT * FROM Question" return db.GqlQuery(query_str).fetch(limit=5)
class Text(db.Model): title = db.StringProperty() content = blobstore.BlobReferenceProperty( ) #AUN SE DESCONOCE PERO SE PROPONE uploaded_time = db.TimeProperty() number_views = db.IntegerProperty() description = db.StringProperty() ext_format = db.StringProperty() size = db.IntegerProperty() def get_text(self, text_id): return Text.get_by_id(text_id) def get_all(self): query_str = "SELECT * FROM Text" return db.GqlQuery(query_str).fetch(limit=5) def get_text_content(self, content): query_str = "SELECT content FROM Text WHERE content=:content" return db.GqlQuery(query_str, content=content).get() def get_number_views(self, text_instance): return text_instance.number_views
class UserSubmission(db.Model): """Model for Blob submissions made by users. """ #: User who made this submission user = db.ReferenceProperty(reference_class=User, required=True, collection_name='submissions') #: Program to which this submission belongs to program = db.ReferenceProperty(reference_class=Program, required=True, collection_name='submissions') #: Organization to which this submission belongs to org = db.ReferenceProperty(reference_class=Organization, required=True, collection_name='submissions') #: Property allowing the user to store information about this submission information = db.TextProperty(required=False, verbose_name=ugettext('Info')) information.help_text = ugettext( 'Information about the work you submit for this task') #: Property pointing to the work uploaded as a file or archive upload_of_work = blobstore.BlobReferenceProperty( required=False, verbose_name=ugettext('Upload of Work')) upload_of_work.help_text = ugettext( 'Your work uploaded as a single file or as archive ' '(max file size: 32 MB)') #: Property containing the date when the work was submitted submitted_on = db.DateTimeProperty(required=True, auto_now_add=True, verbose_name=ugettext('Submitted on'))
class File(db.Model): user_ref = db.ReferenceProperty(User) user = db.UserProperty() #Deprecated name = db.StringProperty(required=True) blob_key = blobstore.BlobReferenceProperty() created = db.DateTimeProperty(auto_now_add=True)
class FileRecord(db.Model): blob = blobstore.BlobReferenceProperty()
class _PipelineRecord(db.Model): """Represents a Pipeline. Key name is a randomly assigned UUID. No parent entity. Properties: class_path: Path of the Python class to use for this pipeline. root_pipeline: The root of the whole workflow; set to itself this pipeline is its own root. fanned_out: List of child _PipelineRecords that were started when this generator pipeline moved from WAITING to RUN. start_time: For pipelines with no start _BarrierRecord, when this pipeline was enqueued to run immediately. finalized_time: When this pipeline moved from WAITING or RUN to DONE. params: Serialized parameter dictionary. status: The current status of the pipeline. current_attempt: The current attempt (starting at 0) to run. max_attempts: Maximum number of attempts (starting at 0) to run. next_retry_time: ETA of the next retry attempt. retry_message: Why the last attempt failed; None or empty if no message. Root pipeline properties: is_root_pipeline: This is a root pipeline. abort_message: Why the whole pipeline was aborted; only saved on root pipelines. abort_requested: If an abort signal has been requested for this root pipeline; only saved on root pipelines """ WAITING = 'waiting' RUN = 'run' DONE = 'done' ABORTED = 'aborted' class_path = db.StringProperty() root_pipeline = db.SelfReferenceProperty( collection_name='child_pipelines_set') fanned_out = db.ListProperty(db.Key, indexed=False) start_time = db.DateTimeProperty(indexed=True) finalized_time = db.DateTimeProperty(indexed=False) # One of these two will be set, depending on the size of the params. params_text = db.TextProperty(name='params') params_blob = blobstore.BlobReferenceProperty(name='params_blob', indexed=False) status = db.StringProperty(choices=(WAITING, RUN, DONE, ABORTED), default=WAITING) # Retry behavior current_attempt = db.IntegerProperty(default=0, indexed=False) max_attempts = db.IntegerProperty(default=1, indexed=False) next_retry_time = db.DateTimeProperty(indexed=False) retry_message = db.TextProperty() # Root pipeline properties is_root_pipeline = db.BooleanProperty() abort_message = db.TextProperty() abort_requested = db.BooleanProperty(indexed=False) @classmethod def kind(cls): return '_AE_Pipeline_Record' @property def params(self): """Returns the dictionary of parameters for this Pipeline.""" if hasattr(self, '_params_decoded'): return self._params_decoded if self.params_blob is not None: value_encoded = self.params_blob.open().read() else: value_encoded = self.params_text value = simplejson.loads(value_encoded, cls=util.JsonDecoder) if isinstance(value, dict): kwargs = value.get('kwargs') if kwargs: adjusted_kwargs = {} for arg_key, arg_value in kwargs.iteritems(): # Python only allows non-unicode strings as keyword arguments. adjusted_kwargs[str(arg_key)] = arg_value value['kwargs'] = adjusted_kwargs self._params_decoded = value return self._params_decoded
class BlobStoreData(db.Model): nickname = db.StringProperty() blobkey = blobstore.BlobReferenceProperty()
class RealEstate(db.Model): _REGISTERED = 0 _TRIAL = 1 _TRIAL_END = 2 _ENABLED = 3 _NO_PAYMENT = 4 @classmethod def new(cls): rs = RealEstate(status=RealEstate._TRIAL, managed_domain=0) rs.tpl_title = u'Hacemos más fácil, rápida y segura su operación inmobiliaria' rs.tpl_text = u'Nuestra inmobiliaria se ha convertido en una empresa moderna y dinámica. Hoy cuenta con los más modernos sistemas de comercialización, con los recursos humanos y con la tecnología necesarios para realizar con éxito sus negocios inmobiliarios.' rs.is_tester = False return rs @classmethod def get_realestate_sharing_key(cls, string_key, realestate=None): prefix = 'fe_' if string_key is not None and string_key.strip() != '': return prefix + string_key return prefix + str(realestate.key()) def get_web_theme(self): if self.web_theme is not None and self.web_theme.strip() != '': return self.web_theme return 'theme_grey' logo = blobstore.BlobReferenceProperty() #--Borrar-- logo_url = db.StringProperty(indexed=False) name = db.StringProperty() website = db.StringProperty(indexed=False) email = db.EmailProperty(indexed=False) email_image = blobstore.BlobReferenceProperty() #--Borrar-- email_image_url = db.StringProperty(indexed=False) tpl_title = db.StringProperty(indexed=False) tpl_text = db.TextProperty(indexed=False) title = db.StringProperty() fax_number = db.StringProperty(indexed=False) telephone_number = db.StringProperty(indexed=False) telephone_number2 = db.StringProperty(indexed=False) open_at = db.StringProperty(indexed=False) address = db.StringProperty(indexed=False) zip_code = db.StringProperty() updated_at = db.DateTimeProperty(auto_now=True) created_at = db.DateTimeProperty(auto_now_add=True) enable = db.IntegerProperty() status = db.IntegerProperty() managed_domain = db.IntegerProperty() is_tester = db.BooleanProperty() web_theme = db.StringProperty(indexed=False) domain_id = db.StringProperty() plan = db.ReferenceProperty(Plan) last_email = db.DateProperty() last_invoice = db.DateProperty() last_login = db.DateTimeProperty() def is_in_trial(self): return self.status == RealEstate._TRIAL @staticmethod def public_attributes(): """Returns a set of simple attributes on Immovable Property entities.""" return [ 'logo', 'name', 'website', 'email', 'title', 'fax_number', 'telephone_number', 'telephone_number2', 'address', 'zip_code', 'enable' ] def __repr__(self): return self.name def put(self): if self.email and len(self.email): blob_key = render_text_into_blob(self.email) self.email_image = blob_key self.email_image_url = get_serving_url(blob_key) super(RealEstate, self).put() def save(self): _change_email = db.get(self.key()).email != self.email if _change_email: if self.email_image: blobstore.delete(self.email_image.key()) self.email_image = None self.email_image_url = '' if self.email and len(self.email): blob_key = render_text_into_blob(self.email) self.email_image = blob_key self.email_image_url = get_serving_url(blob_key) super(RealEstate, self).save()
class Property(GeoModel): _PUBLISHED = 1 _NOT_PUBLISHED = 2 _DELETED = 3 # realestates_frontend => al ampliar oferta @staticmethod def new(realestate): return Property(realestate=realestate, status=Property._PUBLISHED, image_count=0) status = db.IntegerProperty() def is_deleted(self): return self.status == Property._DELETED def is_published(self): return self.status == Property._PUBLISHED def is_not_published(self): return self.status == Property._NOT_PUBLISHED # Information Fields headline = db.StringProperty() main_description = db.TextProperty() country = db.StringProperty(indexed=False) state = db.StringProperty(indexed=False) city = db.StringProperty(indexed=False) neighborhood = db.StringProperty(indexed=False) street_name = db.StringProperty(indexed=False) street_number = db.IntegerProperty(indexed=False) zip_code = db.StringProperty(indexed=False) cardinal_direction = db.StringProperty(indexed=False) floor = db.StringProperty(indexed=False) building_floors = db.IntegerProperty(indexed=False) images_count = db.IntegerProperty() neighborhood_name = db.StringProperty(indexed=False) user = db.ReferenceProperty(User) # ===================================================== # # Search fields # # ===================================================== # # AREA FIELDS area_indoor = db.IntegerProperty(indexed=False) # 1 # 0-40 # 2 # 40-50 # 3 # 50-60 # 4 # 60-70 # 5 # 60-100 # 6 # 100-200 # 7 # 200-300 # 8 # 300 o más area_outdoor = db.IntegerProperty(indexed=False) # 1 # 0-10 # 2 # 10-20 # 3 # 20-50 # 4 # 50-100 # 5 # 100 o más # ROOMS FIELDS rooms = db.IntegerProperty(indexed=False) # 1 a 5 - P es >= 6 bathrooms = db.IntegerProperty(indexed=False) # 1 a 3 - P es >= 4 bedrooms = db.IntegerProperty(indexed=False) # 1 a 4 - P es >= 5 # PRICES FIELDS price_sell = db.FloatProperty(indexed=False) price_rent = db.FloatProperty(indexed=False) price_expensas = db.FloatProperty(indexed=False, default=0.0) _CURRENCY_RATE = 4 _CURRENCY_ARS = 'ARS' _CURRENCY_USD = 'USD' price_sell_currency = db.StringProperty(indexed=False) price_rent_currency = db.StringProperty(indexed=False) price_sell_computed = db.FloatProperty() price_rent_computed = db.FloatProperty() # AMENITIES FIELDS GROUP 1 appurtenance = db.IntegerProperty(indexed=False) balcony = db.IntegerProperty(indexed=False) doorman = db.IntegerProperty(indexed=False) elevator = db.IntegerProperty(indexed=False) fireplace = db.IntegerProperty(indexed=False) furnished = db.IntegerProperty(indexed=False) garage = db.IntegerProperty(indexed=False) # AMENITIES FIELDS GROUP 2 garden = db.IntegerProperty(indexed=False) grillroom = db.IntegerProperty(indexed=False) gym = db.IntegerProperty(indexed=False) live_work = db.IntegerProperty(indexed=False) luxury = db.IntegerProperty(indexed=False) pool = db.IntegerProperty(indexed=False) terrace = db.IntegerProperty(indexed=False) # AMENITIES FIELDS GROUP 3 & YEAR BUILT washer_dryer = db.IntegerProperty(indexed=False) sum = db.IntegerProperty(indexed=False) # LAS DE EMO QUE NO ESTABAN agua_corriente = db.IntegerProperty(indexed=False) gas_natural = db.IntegerProperty(indexed=False) gas_envasado = db.IntegerProperty(indexed=False) luz = db.IntegerProperty(indexed=False) cloacas = db.IntegerProperty(indexed=False) telefono = db.IntegerProperty(indexed=False) tv_cable = db.IntegerProperty(indexed=False) internet = db.IntegerProperty(indexed=False) vigilancia = db.IntegerProperty(indexed=False) monitoreo = db.IntegerProperty(indexed=False) # ADDED BY MaRiAn patio = db.IntegerProperty(indexed=False) year_built = db.IntegerProperty(indexed=False) # 1 # A estrenar # 2 # menor a 5 años # 3 # entre 5 y 10 años # 4 # entre 10 y 20 años # 5 # entre 20 y 50 años # 6 # más de 50 años # DATETIMEs updated_at = db.DateTimeProperty(auto_now=True) created_at = db.DateTimeProperty(auto_now_add=True) # PUBLISHER realestate = db.ReferenceProperty(RealEstate) # PROPERTY TYPES prop_type_id = db.StringProperty(indexed=False) #prop_type_id_cell = db.StringListProperty() # PROPERTY STATE & OPERATION & OWNER prop_state_id = db.IntegerProperty(indexed=False) # Nuevo 1 # A reciclar 2 # Reciclado 3 # Regular 4 # Bueno 5 # Muy bueno 6 # Excelente 7 _OPER_STATE_NADA = 1 _OPER_STATE_VENDIDO = 2 _OPER_STATE_ALQUILADO = 4 _OPER_STATE_RESERVADO = 8 _OPER_STATE_SUSPENDIDO = 16 _OPER_STATE_DE_POZO = 32 _OPER_STATE_APTO_CREDITO = 64 _OPER_STATE_IMPECABLE = 128 _OPER_STATE_INVERSION = 256 _OPER_STATE_OPORTUNIDAD = 512 prop_operation_state_id = db.IntegerProperty(indexed=False) prop_owner_id = db.IntegerProperty(indexed=False) # Inmobiliaria 1 # Dueño directo 2 _OPER_SELL = 1 _OPER_RENT = 2 prop_operation_id = db.IntegerProperty(indexed=False) # Venta 1 # Alquiler 2 main_image = blobstore.BlobReferenceProperty() #--Borrar-- main_image_url = db.StringProperty(indexed=False) # # ======================================================= # # # PROPIEDADES PARA DEFINIR RANGOS A PARTIR DE OTRAS PROPS # # area_indoor_id = db.IntegerProperty() # 0-40 # area_outdoor_id = db.IntegerProperty() # 0-10 # rooms_id = db.IntegerProperty() # 6 o más # bathrooms_id = db.IntegerProperty() # 3 o más # bedrooms_id = db.IntegerProperty() # 5 o más # year_built_id = db.IntegerProperty() # A estrenar # # ======================================================= # visits = db.IntegerProperty(indexed=False, default=0) def has_images(self): if self.images_count is not None and self.images_count != 0: return 1 return 0 def calculate_inner_values(self): # Calculamos los precios en pesos self.price_rent_computed = calculate_price(self.price_rent, self.price_rent_currency, 'ARS') self.price_sell_computed = calculate_price(self.price_sell, self.price_sell_currency, 'ARS') # Armamos para la busqueda en backend address = [] for item in [ 'country', 'state', 'city', 'neighborhood', 'street_name' ]: if getattr(self, item) is not None and getattr(self, item).strip() != '': try: s = unicodedata.normalize('NFKD', getattr(self, item)).encode( 'ascii', 'ignore').lower() # HACK if s != u'ciudad autonoma de buenos aires': address += map(lambda x: '_' + x, s.split(' ')) except Exception, e: pass self.location_geocells = self.check_options_ex() + address
class UserVideo(ndb.Model): user = ndb.StringProperty() blob_key = blobstore.BlobReferenceProperty()
class StaticBlobStoreFile(db.Model): """A reference to a static blob to serve.""" blob = blobstore.BlobReferenceProperty(required=True) # The corresponding file name of this object. blob.filename contains the # original file name. filename = db.StringProperty(required=True)