|
|
|
@ -132,16 +132,22 @@ def basic_login_required(f): |
|
|
|
|
return wrapped_view |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def export_location(location: str) -> bool: |
|
|
|
|
def export_location(location_id: int) -> bool: |
|
|
|
|
""" |
|
|
|
|
Exports the comments for the location after the comment was accepted |
|
|
|
|
:param location: relative url of the hugo page |
|
|
|
|
:param location_id: The id of the store location to export |
|
|
|
|
""" |
|
|
|
|
try: |
|
|
|
|
# flush before query |
|
|
|
|
db.session.flush() |
|
|
|
|
|
|
|
|
|
print(f"Location: {location_id}") |
|
|
|
|
|
|
|
|
|
# Query |
|
|
|
|
loc_query = db.session.query(TLocation).filter(TLocation.location == location).first() |
|
|
|
|
loc_query = db.session.query(TLocation).filter(TLocation.id_location == location_id).first() |
|
|
|
|
|
|
|
|
|
if loc_query: |
|
|
|
|
print(f"has loc_query") |
|
|
|
|
comments = db.session.query(TComments).filter(TComments.is_spam != True) \ |
|
|
|
|
.filter(TComments.is_published == True) \ |
|
|
|
|
.filter(TComments.location_id == loc_query.id_location) \ |
|
|
|
@ -151,6 +157,7 @@ def export_location(location: str) -> bool: |
|
|
|
|
"comments": [] |
|
|
|
|
} |
|
|
|
|
for comment in comments: |
|
|
|
|
print(f"Data: {comment.comments_id}") |
|
|
|
|
bundle['comments'].append(alchemy_query_to_dict(comment)) |
|
|
|
|
|
|
|
|
|
path_loc = re_match(".*(?=/)", loc_query.location)[0] |
|
|
|
@ -163,6 +170,8 @@ def export_location(location: str) -> bool: |
|
|
|
|
folder.mkdir(parents=True, exist_ok=True) |
|
|
|
|
with out.open('w') as fp: |
|
|
|
|
json.dump(bundle, fp) |
|
|
|
|
print("Bundle here ---------- \n") |
|
|
|
|
print(bundle) |
|
|
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|