def post(self): upload_files = self.get_uploads('gallery_images') id = self.request.get("team_id") team = Team.get_by_id(long(id)) redirect_url = self.uri_for('view-team', team_id = id ) logger.info('Uploaded files: ' + str(upload_files)) #logger.info('Get Request: ' + str(self.request.get())) if upload_files is not None and len(upload_files) > 0: files_count = len(upload_files) logger.info('no of files uploaded ' + str(files_count)) for x in xrange(files_count): blob_info = upload_files[x] media_obj = Media() #media_obj.name = self.form.media.__getitem__(x).data['name'] media_obj.type = constants.PHOTO media_obj.status = True #media_obj.primary = self.form.media.__getitem__(x).data['primary'] media_obj.link = blob_info.key() media_obj.url = images.get_serving_url(blob_info.key()) media_obj.entity_id = team.key media_obj.entity_type = constants.TEAM logger.info('Upload file detail: ' + str(media_obj)) #self.mediaDao.persist(media_obj) media_obj.put() logger.info('Link to picture file ' + images.get_serving_url(media_obj.link)) return self.redirect(redirect_url)
def upload_photos(self, photos): upload_files = self.get_uploads() if upload_files is not None and len(upload_files) > 0: files_count = len(upload_files) logger.info('no of files uploaded ' + str(files_count)) for x in xrange(files_count): blob_info = upload_files[x] media_obj = Media() media_obj.name = self.form.media.__getitem__(x).data['name'] media_obj.status = self.form.media.__getitem__( x).data['status'] media_obj.link = blob_info.key() photos.append(media_obj) logger.info('Link to picture file ' + media_obj.name + ', ' + images.get_serving_url(media_obj.link)) return photos
def upload_photos(self, key): upload_files = self.get_uploads() if upload_files is not None and len(upload_files) > 0: files_count = len(upload_files) logger.info('no of files uploaded ' + str(files_count)) for x in xrange(files_count): blob_info = upload_files[x] media_obj = Media() media_obj.name = self.form.media.__getitem__(x).data['name'] media_obj.type = constants.PHOTO media_obj.status = self.form.media.__getitem__(x).data['status'] media_obj.primary = self.form.media.__getitem__(x).data['primary'] media_obj.link = blob_info.key() media_obj.url = images.get_serving_url(blob_info.key()) media_obj.entity_id = key media_obj.entity_type = constants.PLAYGROUND self.mediaDao.persist(media_obj) logger.info('Link to picture file ' + media_obj.name + ', ' + images.get_serving_url(media_obj.link))