def register_ifile_on_db(session, tid, internaltip_id, uploaded_file): now = datetime_now() itip = session.query(models.InternalTip) \ .filter(models.InternalTip.id == internaltip_id, models.InternalTip.tid == tid).one() itip.update_date = now itip.wb_last_access = now if itip.crypto_tip_pub_key: for k in ['name', 'type', 'size']: uploaded_file[k] = base64.b64encode( GCE.asymmetric_encrypt(itip.crypto_tip_pub_key, uploaded_file[k])) new_file = models.InternalFile() new_file.name = uploaded_file['name'] new_file.content_type = uploaded_file['type'] new_file.size = uploaded_file['size'] new_file.internaltip_id = internaltip_id new_file.filename = uploaded_file['filename'] new_file.submission = uploaded_file['submission'] new_file.internaltip_id = internaltip_id session.add(new_file) return serializers.serialize_ifile(session, new_file)
def register_ifile_on_db(store, uploaded_file, internaltip_id): internaltip = models.db_get(store, models.InternalTip, id=internaltip_id) internaltip.update_date = datetime_now() new_file = models.InternalFile() new_file.name = uploaded_file['name'] new_file.content_type = uploaded_file['type'] new_file.size = uploaded_file['size'] new_file.internaltip_id = internaltip_id new_file.submission = uploaded_file['submission'] new_file.file_path = uploaded_file['path'] store.add(new_file) return serializers.serialize_ifile(store, new_file)
def register_ifile_on_db(session, tid, uploaded_file, internaltip_id): now = datetime_now() session.query(models.InternalTip) \ .filter(models.InternalTip.id == internaltip_id, models.InternalTip.tid == tid) \ .update({'update_date': now, 'wb_last_access': now}) new_file = models.InternalFile() new_file.tid = tid new_file.name = uploaded_file['name'] new_file.content_type = uploaded_file['type'] new_file.size = uploaded_file['size'] new_file.internaltip_id = internaltip_id new_file.submission = uploaded_file['submission'] new_file.filename = uploaded_file['filename'] session.add(new_file) return serializers.serialize_ifile(session, new_file)
def register_ifile_on_db(session, tid, internaltip_id, uploaded_file): now = datetime_now() session.query(models.InternalTip) \ .filter(models.InternalTip.id == internaltip_id, models.InternalTip.tid == tid) \ .update({'update_date': now, 'wb_last_access': now}) new_file = models.InternalFile() new_file.name = uploaded_file['name'] new_file.content_type = uploaded_file['type'] new_file.size = uploaded_file['size'] new_file.internaltip_id = internaltip_id new_file.submission = uploaded_file['submission'] new_file.filename = uploaded_file['filename'] session.add(new_file) return serializers.serialize_ifile(session, new_file)
def register_ifile_on_db(store, uploaded_file, internaltip_id): internaltip = store.find(InternalTip, InternalTip.id == internaltip_id).one() if not internaltip: log.err("Cannot associate a file to a not existent internaltip!") raise errors.TipIdNotFound internaltip.update_date = datetime_now() new_file = InternalFile() new_file.name = uploaded_file['name'] new_file.content_type = uploaded_file['type'] new_file.size = uploaded_file['size'] new_file.internaltip_id = internaltip_id new_file.submission = uploaded_file['submission'] new_file.file_path = uploaded_file['path'] store.add(new_file) return serializers.serialize_ifile(new_file)
def register_ifile_on_db(store, uploaded_file, internaltip_id): internaltip = store.find(InternalTip, InternalTip.id == internaltip_id).one() if not internaltip: log.err("Cannot associate a file to a not existent internaltip!") raise errors.TipIdNotFound internaltip.update_date = datetime_now() new_file = InternalFile() new_file.name = uploaded_file['name'] new_file.content_type = uploaded_file['type'] new_file.size = uploaded_file['size'] new_file.internaltip_id = internaltip_id new_file.submission = uploaded_file['submission'] new_file.file_path = uploaded_file['path'] store.add(new_file) return serializers.serialize_ifile(new_file)
def register_ifile_on_db(session, tid, internaltip_id, uploaded_file): """ Register a file on the database :param session: An ORM session :param tid: A tenant id :param internaltip_id: A id of the submission on which attaching the file :param uploaded_file: A file to be attached :return: A descriptor of the file """ now = datetime_now() itip = session.query(models.InternalTip) \ .filter(models.InternalTip.id == internaltip_id, models.InternalTip.enable_attachments.is_(True), models.InternalTip.status != 'closed', models.InternalTip.tid == tid).one() itip.update_date = now itip.wb_last_access = now if itip.crypto_tip_pub_key: for k in ['name', 'type', 'size']: uploaded_file[k] = base64.b64encode( GCE.asymmetric_encrypt(itip.crypto_tip_pub_key, str(uploaded_file[k]))) new_file = models.InternalFile() new_file.name = uploaded_file['name'] new_file.content_type = uploaded_file['type'] new_file.size = uploaded_file['size'] new_file.internaltip_id = internaltip_id new_file.filename = uploaded_file['filename'] new_file.submission = uploaded_file['submission'] new_file.internaltip_id = internaltip_id session.add(new_file) return serializers.serialize_ifile(session, new_file)
def db_get_rfile_list(session, itip_id): ifiles = session.query(models.InternalFile) \ .filter(models.InternalFile.internaltip_id == itip_id, models.InternalTip.id == itip_id) return [serializers.serialize_ifile(session, ifile) for ifile in ifiles]