Example #1
0
class Discussion(db.Document):
    user = db.ReferenceField('User')
    subject = db.GenericReferenceField()
    title = db.StringField(required=True)
    discussion = db.ListField(db.EmbeddedDocumentField(Message))
    created = db.DateTimeField(default=datetime.now, required=True)
    closed = db.DateTimeField()
    closed_by = db.ReferenceField('User')
    extras = db.ExtrasField()

    meta = {
        'indexes': [
            'user',
            'subject',
            '-created'
        ],
        'ordering': ['-created'],
    }

    def person_involved(self, person):
        """Return True if the given person has been involved in the

        discussion, False otherwise.
        """
        return any(message.posted_by == person for message in self.discussion)

    @property
    def external_url(self):
        return self.subject.url_for(
            _anchor='discussion-{id}'.format(id=self.id),
            _external=True)
Example #2
0
class Transfer(db.Document):
    owner = db.GenericReferenceField(required=True)
    recipient = db.GenericReferenceField(required=True)
    subject = db.GenericReferenceField(required=True)
    comment = db.StringField()
    status = db.StringField(choices=list(TRANSFER_STATUS), default='pending')

    created = db.DateTimeField(default=datetime.now, required=True)

    responded = db.DateTimeField()
    responder = db.ReferenceField('User')
    response_comment = db.StringField()

    meta = {
        'indexes': [
            'owner',
            'recipient',
            'created',
            'status',
        ]
    }
Example #3
0
class Issue(db.Document):
    user = db.ReferenceField('User')
    subject = db.GenericReferenceField()
    title = db.StringField(required=True)
    discussion = db.ListField(db.EmbeddedDocumentField(Message))
    created = db.DateTimeField(default=datetime.now, required=True)
    closed = db.DateTimeField()
    closed_by = db.ReferenceField('User')

    meta = {
        'indexes': ['user', 'subject', '-created'],
        'ordering': ['-created'],
    }
Example #4
0
class Follow(db.Document):
    follower = db.ReferenceField('User', required=True)
    following = db.GenericReferenceField()
    since = db.DateTimeField(required=True, default=datetime.now)
    until = db.DateTimeField()

    meta = {
        'indexes': [
            'follower',
            'following',
            ('follower', 'until'),
            ('following', 'until'),
        ],
        'queryset_class':
        FollowQuerySet,
    }
Example #5
0
class Model(db.Document):
    name = db.StringField()
    target = db.GenericReferenceField()
Example #6
0
class WithGenericChoices(db.Document):
    name = db.StringField()
    nested = db.GenericReferenceField(choices=[Nested, Nested2])
Example #7
0
class WithGeneric(db.Document):
    name = db.StringField()
    nested = db.GenericReferenceField()