예제 #1
0
class BitBook(db.DynamicDocument):
    owners = db.ListField(db.ReferenceField('User'))
    editors = db.ListField(db.ReferenceField('User'))
    viewers = db.ListField(db.ReferenceField('User'))
    public = db.BooleanField(default=False)
    title = db.StringField(max_length=255, required=True)
    description = db.StringField(required=False)
    created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
    cover_fields = db.DictField(required=False)
    bitnotes = db.ListField(
        db.ReferenceField(BitNote, reverse_delete_rule=db.PULL))
    thumbnail = db.ImageField(size=(800, 600, True),
                              thumbnail_size=(150, 150, True))

    def share_to(self, to_user, from_user, msg, access):
        #create mailbox if does not exist:
        fr, to = user_mail_context(from_user, to_user)
        #manage access:
        manage_access(self, access, to, fr)
        message = BitMailItem(bitbook=self,
                              from_user=fr,
                              to_user=to,
                              message=msg)
        message.save()
        to.mail.inbox.append(message)
        to.mail.save()
        fr.mail.outbox.append(message)
        fr.mail.save()
예제 #2
0
class BitMail(db.Document):
    inbox = db.ListField(
        db.ReferenceField(BitMailItem, reverse_delete_rule=db.PULL))
    outbox = db.ListField(
        db.ReferenceField(BitMailItem, reverse_delete_rule=db.PULL))
    trash = db.ListField(
        db.ReferenceField(BitMailItem, reverse_delete_rule=db.PULL))
예제 #3
0
class BitNote(db.DynamicDocument):
    owners = db.ListField(db.ReferenceField('User'))
    editors = db.ListField(db.ReferenceField('User'))
    viewers = db.ListField(db.ReferenceField('User'))
    public = db.BooleanField(default=False)
    bitfields = db.ListField(db.EmbeddedDocumentField(BitField))
    created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
    title = db.StringField(max_length=255, required=False)
    meta = {'allow_inheritance': True}

    meta = {'indexes': ['-created_at'], 'ordering': ['-created_at']}

    def save_to_bitbook(self, bitbook):
        bitbook.bitnotes.append(self)
        for field in self.bitfields:
            if field.title not in bitbook.cover_fields:
                bitbook.cover_fields[field.title] = field
        bitbook.save()

    def share_to(self, to_user, from_user, msg, access):
        #create mailbox if does not exist:
        fr, to = user_mail_context(from_user, to_user)
        manage_access(self, access, to, fr)
        message = BitMailItem(bitnote=self,
                              from_user=fr,
                              to_user=to,
                              message=msg)
        message.save()
        to.mail.inbox.append(message)
        to.mail.save()
        fr.mail.outbox.append(message)
        fr.mail.save()
예제 #4
0
class User(db.Document, UserMixin):
    email = db.StringField(max_length=255, unique=True)
    password = db.StringField(max_length=255)
    active = db.BooleanField(default=True)
    confirmed_at = db.DateTimeField()
    roles = db.ListField(db.ReferenceField(Role), default=[])
    bitbooks = db.ListField(db.ReferenceField('BitBook'))
    mail = db.ReferenceField('BitMail')
예제 #5
0
class Availib(Device):
    avil_from = db.DateTimeField(default=datetime.datetime.now, required=True)
    avail_to = db.DateTimeField(required=False)
    allowed_usrs = db.ListField(db.ReferenceField(User))
    reservations = db.ListField(db.ReferenceField('Reservation'))
예제 #6
0
class CommentBox(BitField):
    comments = db.ListField(db.EmbeddedDocumentField('Comment'))

    def __unicode__(self):
        return self.title
예제 #7
0
class EmailList(BitField):
    email_list = db.ListField(db.EmailField())
예제 #8
0
class LinkList(BitField):
    linklist = db.ListField(db.ReferenceField('Link'), required=False)