Beispiel #1
0
class CovidRequest(DynamicDocument):
    request_source = StringField(required=True)
    request_location_name = StringField()
    request_location_geo = GeoPointField()
    requested_resource_type = StringField()
    request_text = StringField()
    request_time = DateTimeField()
    request_url = StringField()
Beispiel #2
0
class Shifters(Document):
    meta = {'queryset_class': Qualified}
    id = StringField(required=True, primary_key=True)
    shifterid = StringField(required=True)
    existingshifterjpid = StringField(required=False, default=None)
    position = ListField(required=False)
    rating = IntField(required=False)
    location = GeoPointField(required=False)
    shifteravailability = ListField(required=False)
Beispiel #3
0
class Event(Document):
    name = StringField()
    sport = StringField()
    level = StringField()
    where = StringField()
    location = GeoPointField()
    when = DateTimeField()
    will_host = BooleanField()
    will_travel = BooleanField()
    fees = StringField()
    restrictions = StringField()
    comments = StringField()
    text = BooleanField()
    call = BooleanField()
    email = BooleanField()
    modified = DateTimeField()
    contact = ReferenceField('User')

    @classmethod
    def near(cls, location, sport_filter=[], max_distance=10):
        """ Get all events with a geographic location
        @param location: dict of longitude and latitude
        @param max_distance: maximum distance in miles
        """

        query = cls.objects(
            location__near=[location['longitude'], location['latitude']],
            location__max_distance=max_distance)

        sports = {}
        events = []
        try:
            for event in query:
                if not event.sport.lower() in sports:
                    sports[event.sport.lower()] = event.sport.lower(
                    ) in sport_filter

                if sport_filter:
                    if event.sport.lower() in sport_filter:
                        events.append(event)
                else:
                    events.append(event)
        except RuntimeError as e:
            # Mongo engine is not 3.7 ready, so it bubbles up StopInteration. Catch it here
            # if str(e) == 'generator raised StopIteration':
            pass

        return events, sports

    @classmethod
    def find_or_create(cls):
        pass

    def __unicode__(self):
        return self.name
Beispiel #4
0
class Post(Document):
    @property
    def id(self):
        return str(self.pk)

    author = ReferenceField(User)
    title = StringField(required=True, max_length=20)
    location = GeoPointField(required=True)
    location_name = StringField(max_length=512)
    distance = IntField(required=True, default=DISTANCE[0])
    created_at = DateTimeField(default=datetime.datetime.utcnow, required=True)
    active_time = DateTimeField(required=True)
    category = IntField(required=True, default=CATEGORY['PUBLIC'])
    followers = ListField(ReferenceField(User))
    receivers = ListField(ReferenceField(User))
    content = StringField(required=True)
    imagekey = StringField()
    wavekey = StringField()

    meta = {'ordering': ['-active_time']}
Beispiel #5
0
class Observation(Document):
    observation_hash = StringField(max_length=64, unique=True)
    latitude = FloatField()
    longitude = FloatField()
    loc = GeoPointField()
    loc_city = StringField(max_length=64)
    loc_country = StringField(max_length=64)
    start = DateTimeField()
    finish = DateTimeField()
    duration = IntField()  #duration in milliseconds, finish-start
    no_smoking = IntField()
    other_adults = IntField()
    lone_adult = IntField()
    child = IntField()
    device_id = StringField(max_length=128)
    device_type = StringField(max_length=128)
    upload_timestamp = DateTimeField()
    user = ReferenceField(RegisteredObserver)
    details = ListField(EmbeddedDocumentField(Detail))

    def __unicode__(self):
        return u"Start: {0} Finish: {1} By: {2}".format(
            self.start, self.finish, self.user)
Beispiel #6
0
class Garden(Document):
    name = StringField()
    username = StringField(unique_with="name")
    location = GeoPointField()
    width = IntField()
    height = IntField()
Beispiel #7
0
class Shifts(Document):
    id = StringField(required=True, primary_key=True)
    shiftid = StringField(required=True)
    jobproviderid = StringField(required=False)
    location = GeoPointField(required=False)
    shiftdetail = ListField(required=False)
class Location(Document):
    userID = GeoPointField(required=True)
    uame = StringField(required=False, default='current')
    description = StringField(required=False)