Added get_file method to datasets

This commit is contained in:
2023-03-05 00:26:39 +00:00
parent c9ad8e87cd
commit 9a02048199
2 changed files with 8 additions and 5 deletions

View File

@ -8,7 +8,7 @@ from flask_login import current_user
from werkzeug.utils import secure_filename
from datetime import datetime
from json import dump
from json import dump, loads
from os import path, remove
from pathlib import Path
from uuid import uuid4
@ -116,6 +116,12 @@ class Dataset(db.Model):
file_path = path.join(data, 'questions', filename)
return file_path
def get_data(self):
dataset_path = self.get_file()
with open(dataset_path, 'r') as _dataset:
data = loads(_dataset.read())
return data
def update(self, data:list=None, default:bool=False):
self.date = datetime.now()
if default: self.make_default()