Exemplo n.º 1
0
def _merge_users(target, source, **kwargs):
    from fossir.modules.attachments.models.attachments import Attachment, AttachmentFile
    from fossir.modules.attachments.models.principals import AttachmentPrincipal, AttachmentFolderPrincipal
    Attachment.find(user_id=source.id).update({Attachment.user_id: target.id})
    AttachmentFile.find(user_id=source.id).update(
        {AttachmentFile.user_id: target.id})
    AttachmentPrincipal.merge_users(target, source, 'attachment')
    AttachmentFolderPrincipal.merge_users(target, source, 'folder')
Exemplo n.º 2
0
 def materialToXMLMarc21(self, obj, out=None):
     if not out:
         out = self._XMLGen
     for attachment in (Attachment.find(~AttachmentFolder.is_deleted, AttachmentFolder.object == obj,
                                        is_deleted=False, _join=AttachmentFolder)
                                  .options(joinedload(Attachment.legacy_mapping))):
         if attachment.can_access(self.__user):
             self.resourceToXMLMarc21(attachment, out)
             self._generateAccessList(acl=self._attachment_access_list(attachment), out=out,
                                      objId=self._attachment_unique_id(attachment, add_prefix=False))
 def _build_base_query(self, added_since=None):
     query = Attachment.find(Attachment.type == AttachmentType.file,
                             ~AttachmentFolder.is_deleted,
                             ~Attachment.is_deleted,
                             AttachmentFolder.event == self.event,
                             _join=AttachmentFolder)
     if added_since is not None:
         query = query.join(Attachment.file).filter(
             cast(AttachmentFile.created_dt, Date) >= added_since)
     return query