class Trails(MongoModel):
    """
    A model defining trails entity undertaken by hikers. It has embedded
    comments which reference the hiker.
    """
    trail_name = fields.CharField(max_length=100, required=True)
    distance = fields.FloatField(max_value=50, required=True)
    elevation = fields.FloatField(required=True)
    route_type = fields.CharField(max_length=20,
                                  choices=('Point to Point', 'Loop',
                                           'Out and Back'),
                                  required=True)
    difficulty = fields.CharField(max_length=20,
                                  choices=('Easy', 'Moderate', 'Difficult'),
                                  required=True)
    description = fields.CharField(max_length=600, required=True)
    centrepoint = fields.PointField(required=False)
    waypoints = fields.LineStringField(required=False)
    image = fields.URLField(required=True)
    embed_route = fields.CharField(max_length=800, required=True)
    location = fields.ReferenceField(Location)
    comments = fields.EmbeddedDocumentListField('Comment', required=False)

    def __str__(self):
        return self.trail_name
Exemple #2
0
class GraphNode(MongoModel):
    graph = fields.ReferenceField(Graph)
    index = fields.IntegerField()
    point = fields.PointField()

    class Meta:
        indexes = [IndexModel([('point', GEOSPHERE)])]
class Hospital(MongoModel):
    name = fields.CharField()
    location = fields.PointField()
    city = fields.CharField()
    state = fields.CharField()
    avg_reported = fields.EmbeddedDocumentListField(DRGData)
    avg_user = fields.EmbeddedDocumentListField(DRGData)

    class Meta:
        # Text index on content can be used for text search.
        indexes = [IndexModel([('name', TEXT)]), IndexModel([('location', GEOSPHERE)])]
Exemple #4
0
class Shop(MongoModel):
    name = fields.CharField(blank=True)
    location = fields.PointField(blank=True)
    products = fields.EmbeddedDocumentListField(Product, blank=True)
    address = fields.ReferenceField('Address', blank=True)
    createdAt = fields.DateTimeField()
    updatedAt = fields.DateTimeField(blank=True)

    class Meta:
        write_concern = WriteConcern(j=True)
        connection_alias = 'kuro'
        collection_name = 'shops'
Exemple #5
0
class Article(MongoModel):
    """
    Model example to work with Mongo DB

    List of possible fields
    https://pymodm.readthedocs.io/en/0.4.0/api/index.html#model-fields
    """
    #_id = fields.ObjectIdField(primary_key=True)
    truth = fields.BooleanField()  # Mostly True / Mostly False
    created = fields.DateTimeField(blank=True)
    url = fields.URLField()
    authors = fields.ListField(field=fields.CharField(), blank=True)
    date = fields.DateTimeField(blank=True)
    source = fields.CharField(blank=True)
    tags = fields.ListField(field=fields.CharField(), blank=True)
    location = fields.PointField(blank=True)
    title = fields.CharField(blank=True)
    text = fields.CharField(blank=True)
    abstract = fields.CharField(blank=True)
    keywords = fields.ListField(field=fields.CharField(), blank=True)
    similar_to = fields.ListField(field=fields.ObjectIdField(), blank=True)

    class Meta:
        connection_alias = APP_DB
Exemple #6
0
class Agents(MongoModel):
    email = fields.EmailField(required=True)
    password = fields.CharField(required=True)
    name = fields.CharField(required=True)
    primary_image = fields.URLField(required=True)
    background_image = fields.URLField(required=True)
    location = fields.PointField(required=True)
    category = fields.CharField(required=True)
    phone = fields.CharField(required=True)
    feedback = fields.FloatField(blank=True)
    totalreviews = fields.IntegerField(blank=True)
    redeemptstoggle = fields.BooleanField(required=True)
    starttime = fields.DateTimeField(required=True)
    endtime = fields.DateTimeField(required=True)

    #image url , offer template url , location , category , phone ,
    #reward points , offers , punch cards , feedback , birthtday
    created_at = fields.DateTimeField()
    updated_at = fields.DateTimeField()

    class Meta:
        indexes = [
            pymongo.IndexModel([('email', pymongo.ALL)],
                               name="AgentEmailUniqueIndex",
                               unique=True),
            pymongo.IndexModel([("location", pymongo.GEOSPHERE)]),
            pymongo.IndexModel([('name', pymongo.ALL),
                                ('consumer_id', pymongo.ALL)],
                               name="NameIndex")
        ]  # indexes


# asd= rest.objects.raw({'location': {'$near': SON([('$geometry', SON([('type', 'Point'), ('coordinates', [-122.406417,37.785834])])), ('$maxDistance', 500)])}})
# asd = rest.objects.raw({"location":{"$near": {"$geometry": {"type":"Point","coordinates":[-122.406417,37.785834]},"$maxDistance":500}}})
# for i in asd:
#     print i._data