Просмотр исходного кода

technicall you can make groups (it does nothing)

cube 3 дней назад
Родитель
Сommit
13b46dd3b3
3 измененных файлов: 41 добавлений и 1 удалений
  1. 16
    1
      myriad/manage.py
  2. 1
    0
      myriad/templates/base.html
  3. 24
    0
      myriad/templates/manage/groups.html

+ 16
- 1
myriad/manage.py Просмотреть файл

@@ -232,4 +232,19 @@ def delete_ifiles():
232 232
         if not in_database:
233 233
             os.remove(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], icon))
234 234
 
235
-    return redirect(url_for("manage.assets"))
235
+    return redirect(url_for("manage.assets"))
236
+
237
+@bp.route("/groups", methods=('GET', 'POST'))
238
+@login_required
239
+def groups():
240
+    db = get_db()
241
+
242
+    if request.method == "POST":
243
+        name = request.form['name']
244
+        desc = request.form['desc']
245
+        db.execute("INSERT INTO groups (group_name, group_description) VALUES (?, ?)",(name, desc))
246
+        db.commit()
247
+        
248
+
249
+    groups = db.execute("SELECT * FROM groups").fetchall()
250
+    return render_template("manage/groups.html", groups=groups)

+ 1
- 0
myriad/templates/base.html Просмотреть файл

@@ -14,6 +14,7 @@
14 14
     {% if g.user %}
15 15
     <div class="heading">Manage</div>
16 16
     <div class="navitem">> <a href="{{ url_for('manage.new') }}">Add New Member</a></div>
17
+    <div class="navitem">> <a href="{{ url_for('manage.groups') }}">Member groups</a></div>
17 18
     <div class="navitem">> <a href="{{ url_for('manage.assets') }}">Site Assets</a></div>
18 19
     {% endif %}
19 20
 

+ 24
- 0
myriad/templates/manage/groups.html Просмотреть файл

@@ -0,0 +1,24 @@
1
+{% extends 'base.html' %}
2
+
3
+{% block header %}
4
+  <div class="title">{% block title %}Manage groups{% endblock %}</div>
5
+{% endblock %}
6
+
7
+{% block content %}
8
+
9
+  <div class="heading">Create new group</div>
10
+  <form method="post">
11
+    <label for="name">Name</label>
12
+    <input name="name" id="name" required><br>
13
+    <label for="desc">Description</label>
14
+    <textarea name="desc" id="desc"></textarea><br>
15
+    <input type="submit" value="Submit">
16
+  </form>
17
+
18
+  <div class="heading big">Groups</div>
19
+  {% for group in groups %}
20
+    <div class="heading">{{group[1]}}</div>
21
+    <div class="maintext">{{group[2]}}</div>
22
+  {% endfor %}
23
+
24
+{% endblock %}