Browse Source

add room_planner main page route

weichen 4 years ago
parent
commit
99d989721c
3 changed files with 57 additions and 3 deletions
  1. 2 0
      backstage/__init__.py
  2. 14 0
      backstage/room_planner/routes.py
  3. 41 3
      backstage/templates/room_planner.html

+ 2 - 0
backstage/__init__.py

@@ -10,11 +10,13 @@ def create_app():
     from backstage.collections.routes import collections_app
     from backstage.editor.routes import editor_app
     from backstage.home.routes import home_app
+    from backstage.room_planner.routes import room_planner_app
     from backstage.blogs.routes import blogs_app
 
     app.register_blueprint(collections_app)
     app.register_blueprint(editor_app)
     app.register_blueprint(home_app)
     app.register_blueprint(blogs_app)
+    app.register_blueprint(room_planner_app)
 
     return app

+ 14 - 0
backstage/room_planner/routes.py

@@ -0,0 +1,14 @@
+from flask import render_template, Blueprint, request, redirect, url_for
+import requests
+from collections import defaultdict
+from backstage.utils.routes import update_manage_table
+
+room_planner_app = Blueprint('room_planner', __name__)
+
+
+@room_planner_app.route('/backstage/room_planner')
+def main():
+    response = requests.get('http://127.0.0.1:5000/api/manages/data?page=room_planner')
+    return render_template('room_planner.html',
+                            title='規劃師服務',
+                            contents=response.json())

+ 41 - 3
backstage/templates/room_planner.html

@@ -1,4 +1,42 @@
 {% extends "layout.html" %}
-{% block content %}
-    <h1>room_planner</h1>
-{% endblock content %}
+{% block main %}
+<h1>{{ title }}</h1>
+{% for content in contents %}
+  <form action="{{ url_for('room_planner.update', page='room_planner', section_class=content.sectionClass) }}" method="POST">
+  <table id="example" class="table table-striped table-bordered" cellspacing="0" width="60%">
+    <thead>
+      <tr>
+        <th>數量</th>
+        <th>類型</th>
+        <th>內容</th>
+        <th style="text-align:center;width:100px;">
+            <input class="btn btn-primary" type="submit" value="提交">
+        </th>
+      </tr>
+    </thead>
+    {% for key, value in content.items() %}
+      {% if key != 'sectionClass' %}
+        {% for data in value %}
+          <tbody>
+            <tr>
+              <td>{{ loop.index }}</td>
+              <td>{{ key }}</td>
+              <td>
+                <input name="{{ key }}-{{ loop.index }}" class="form-control form-control-lg" value="{{ data }}">
+              </td>
+              <td>
+                <div>
+                  <form action="#" method="POST">
+                    <input class="btn btn-danger" type="submit" value="刪除">
+                  </form>
+                </div>
+              </td>
+            </tr>
+          </tbody>
+        {% endfor %}
+      {% endif %}
+    {% endfor %}
+  </table>
+</form>
+{% endfor %}
+{% endblock main %}