def upload(): data = request.get_json() start = datetime.datetime.strptime(data["start_time"], '%Y-%m-%d %H:%M:%S') end = datetime.datetime.strptime(data["end_time"], '%Y-%m-%d %H:%M:%S') new_task = Video(camera_id=data["camera_id"], start_time=start, end_time=end, filepath=data["filepath"]) db.session.add(new_task) db.session.commit() return jsonify({"message": "Video Data uploaded successfully"})
def setUp(self): app.config['TESTING'] = True app.config['CSRF_ENABLED'] = False app.config['DEBUG'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join( BASE_DIR, TEST_DB) self.app = app.test_client() db.create_all() self.user = User('TestUser') self.user.save('testpassword') self.video = Video('TestVideo') self.video.save(hash='Teststring', user=self.user)
def upload(): form = enterdata() if form.is_submitted(): s_time = form.start_time.data e_time = form.end_time.data new_task = Video(camera_id=form.camera_id.data, start_time=form.start_time.data, end_time=form.end_time.data, filepath=form.filepath.data) db.session.add(new_task) db.session.commit() return redirect(url_for('video.upload')) return render_template('post.html', form=form)
def save_video(video_file, title): ext = secure_filename(video_file.filename).split('.')[-1] video_hash = md5(video_file.read()).hexdigest() video_file.seek(0) video = Video(title) video.save(video_hash, cur_user()) videos.save(video_file, folder=str(video.id), name='video.' + ext) video.add_path(join_path(app.config['VIDEO_SAVE_PATH'], video.id)) try: prepare_video(video.id, ext) except OSError: video.delete_video() return None return video
def add_video_by_competition(request): if request.method == 'POST': print("Llego al servicio y se revisa llegada de id competition") competition_id = request.POST.get('competition_id') new_video = Video( name=request.POST.get('name'), surname=request.POST.get('surname'), state=False, user_email=request.POST.get('user_email'), message=request.POST.get('message'), original_video=request.FILES['original_video'], uploadDate=datetime.datetime.now(), competition=Competition.objects.filter(id=competition_id).get()) new_video.save() return JsonResponse({'ok': 'video guardado'}, status=200)
def setUp(self): app.config['TESTING'] = True app.config['CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + TEST_DB_PATH self.client = app.test_client() db.create_all() self.user = User('TestUser') self.user.save('testpassword') self.video = Video('TestVideo') self.video.save(hash='Teststring', user=self.user) self.video_id = self.video.id self.comment = Comment('Text', self.video.id, self.user.id) self.comment.save() self.anonuser = Device() self.anonuser2 = Device() self.room = Room('roomname', self.anonuser.id) self.room.save(self.video.id)
def test_history_with_50_items(self): with app.app_context(): tester = User.query.filter_by(email=tester_email).first() videos = [] for i in range(51): new_video = Video(url='http://test.video_{}.url'.format(i), user_id=tester.id, video_id=generate_secret_key(10).decode(), provider='techika.com') db.session.add(new_video) videos.append(new_video) db.session.commit() check = Video.limit_history_videos(user_id=tester.id) assert check == videos[0].id del videos[0] for i in videos: db.session.delete(i) db.session.commit()