Browse Source

Improve file and page creating and rendering

JoostSijm 6 years ago
parent
commit
212e139686

+ 8 - 4
app/modules/backend/app.py

@@ -44,10 +44,14 @@ def render():
         menu.append(generate_menu(page))
 
     path_base = 'app/modules/static/pages/'
-    shutil.rmtree(path_base + "public")
-    shutil.rmtree(path_base + "private")
-    os.makedirs(path_base + "public")
-    os.makedirs(path_base + "private")
+    path_public = path_base + "public"
+    path_private = path_base + "private"
+    if os.path.exists(path_public):
+        shutil.rmtree(path_public)
+    os.makedirs(path_public)
+    if os.path.exists(path_private):
+        shutil.rmtree(path_private)
+    os.makedirs(path_private)
 
     for page in pages:
         render_page(path_base, page, menu)

+ 1 - 0
app/modules/backend/modules/file/app.py

@@ -55,6 +55,7 @@ def create():
             db.session.commit()
 
             flash('File "%s" successfully uploaded' % db_file.title, 'success')
+            return redirect(url_for('backend_file.view', file_id=db_file.id))
 
     return render_template('file/create.j2')
 

+ 1 - 0
app/modules/backend/modules/page/app.py

@@ -34,6 +34,7 @@ def create():
         db.session.commit()
 
         flash('Page "%s" successfully created' % page.title, 'success')
+        return redirect(url_for('backend_page.view', page_id=page.id))
 
     return render_template('page/create.j2', pages=pages)