sort of working, more changes
This commit is contained in:
@ -136,7 +136,7 @@ def upload():
|
||||
mreader = csv.DictReader(mf)
|
||||
if mreader.fieldnames != MEDIA_HEADERS:
|
||||
missing = set(MEDIA_HEADERS) - set(mreader.fieldnames or [])
|
||||
extra = set(reader.fieldnames or []) - set(MEDIA_HEADERS)
|
||||
extra = set(mreader.fieldnames or []) - set(MEDIA_HEADERS)
|
||||
os.remove(tmp_zip.name)
|
||||
flash(f"media.csv header mismatch. Missing: {missing}, Extra: {extra}", "danger")
|
||||
return redirect(request.url)
|
||||
@ -213,13 +213,13 @@ def upload():
|
||||
with open(src, "rb") as sf, open(dst, "wb") as df:
|
||||
df.write(sf.read())
|
||||
|
||||
# 🔧 FIXED: match your Media model exactly
|
||||
media = Media(
|
||||
user_id=current_user.id,
|
||||
plant_id=plant_obj.id,
|
||||
original_filename=os.path.basename(src),
|
||||
path=f"uploads/{current_user.id}/{plant_obj.id}/{fname}",
|
||||
file_url=f"uploads/{current_user.id}/{plant_obj.id}/{fname}",
|
||||
uploaded_at=datetime.fromisoformat(mrow["Uploaded At"]),
|
||||
source_type=mrow["Source Type"]
|
||||
uploader_id=current_user.id,
|
||||
caption=mrow["Source Type"],
|
||||
plant_id=plant_obj.id
|
||||
)
|
||||
db.session.add(media)
|
||||
added_media += 1
|
||||
@ -285,7 +285,7 @@ def upload():
|
||||
"mother_uuid": mother_uuid
|
||||
}
|
||||
review_list.append(item)
|
||||
session["pending_rows"].append(item)
|
||||
session["pending_rows"].append(item)
|
||||
|
||||
session["review_list"] = review_list
|
||||
return redirect(url_for("importer.review"))
|
||||
@ -336,7 +336,7 @@ def review():
|
||||
)
|
||||
db.session.add(scientific)
|
||||
db.session.flush()
|
||||
all_sci = all_scientific[scientific.name.lower()] = scientific
|
||||
all_scientific[scientific.name.lower()] = scientific
|
||||
|
||||
verified = not suggested or (suggested and accepted)
|
||||
|
||||
@ -352,6 +352,7 @@ def review():
|
||||
)
|
||||
db.session.add(plant)
|
||||
db.session.flush()
|
||||
|
||||
log = PlantOwnershipLog(
|
||||
plant_id = plant.id,
|
||||
user_id = current_user.id,
|
||||
|
Reference in New Issue
Block a user