show groups and its members on groups page in sidebar
This commit is contained in:
@@ -51,4 +51,21 @@ def page(mid):
|
|||||||
icon = db.execute("SELECT icon_location FROM icons WHERE id=(?)",(member[6],)).fetchone()
|
icon = db.execute("SELECT icon_location FROM icons WHERE id=(?)",(member[6],)).fetchone()
|
||||||
all_icons = db.execute("SELECT icon_location FROM icons WHERE member_id=(?)",(mid,)).fetchall()
|
all_icons = db.execute("SELECT icon_location FROM icons WHERE member_id=(?)",(mid,)).fetchall()
|
||||||
|
|
||||||
return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons)
|
return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons)
|
||||||
|
|
||||||
|
@bp.route("/groups")
|
||||||
|
def groups():
|
||||||
|
db = get_db()
|
||||||
|
groups = db.execute("SELECT * FROM groups").fetchall()
|
||||||
|
group_members_db = db.execute("SELECT * FROM group_members").fetchall()
|
||||||
|
group_members = {}
|
||||||
|
for entry in group_members_db:
|
||||||
|
gid = entry[1]
|
||||||
|
mid = entry[2]
|
||||||
|
member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()
|
||||||
|
if gid in group_members:
|
||||||
|
group_members[gid].append(member)
|
||||||
|
else:
|
||||||
|
group_members[gid]=[member]
|
||||||
|
|
||||||
|
return render_template("groups.html", groups=groups, group_members=group_members)
|
||||||
@@ -17,21 +17,10 @@ def new():
|
|||||||
bio = request.form['bio']
|
bio = request.form['bio']
|
||||||
user_id = g.user[0]
|
user_id = g.user[0]
|
||||||
db = get_db()
|
db = get_db()
|
||||||
error = None
|
|
||||||
|
db.execute("INSERT INTO member (user_id, member_name, bio) VALUES (?, ?, ?)",(user_id, name, bio))
|
||||||
if not name:
|
db.commit()
|
||||||
error = 'Name is required.'
|
return redirect(url_for('home.full_list'))
|
||||||
|
|
||||||
if error is None:
|
|
||||||
db.execute(
|
|
||||||
"INSERT INTO member (user_id, member_name, bio) VALUES (?, ?, ?)",
|
|
||||||
(user_id, name, bio),
|
|
||||||
|
|
||||||
)
|
|
||||||
db.commit()
|
|
||||||
return redirect(url_for('home.full_list'))
|
|
||||||
|
|
||||||
return render_template('manage/new.html', error=error)
|
|
||||||
|
|
||||||
return render_template('manage/new.html')
|
return render_template('manage/new.html')
|
||||||
|
|
||||||
@@ -58,15 +47,6 @@ def edit(mid):
|
|||||||
db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename),)
|
db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename),)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
# this specific chunk here is checking whether icons in the myriad/static/icons folder have a link in the database
|
|
||||||
# in case the database was rebuilt, or something else happened, it is a waste of storage keeping an unlinked image
|
|
||||||
|
|
||||||
|
|
||||||
# and now for the same in reverse - clean the database of references to images that don't exist
|
|
||||||
|
|
||||||
|
|
||||||
# the above cleanup operations should be a button in the manage sidebar but for now they are here.
|
|
||||||
|
|
||||||
if "c9" in request.form:
|
if "c9" in request.form:
|
||||||
c9 = request.form["c9"]
|
c9 = request.form["c9"]
|
||||||
c10 = request.form["c10"]
|
c10 = request.form["c10"]
|
||||||
@@ -76,10 +56,6 @@ def edit(mid):
|
|||||||
c14 = request.form["c14"]
|
c14 = request.form["c14"]
|
||||||
c15 = request.form["c15"]
|
c15 = request.form["c15"]
|
||||||
c16 = request.form["c16"]
|
c16 = request.form["c16"]
|
||||||
#c17 = request.form["c17"]
|
|
||||||
#c18 = request.form["c18"]
|
|
||||||
#c19 = request.form["c19"]
|
|
||||||
#c20 = request.form["c20"]
|
|
||||||
c21 = request.form["c21"]
|
c21 = request.form["c21"]
|
||||||
c22 = request.form["c22"]
|
c22 = request.form["c22"]
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<div class="heading">Myriad</div>
|
<div class="heading">Myriad</div>
|
||||||
<div class="navitem">> <a href="{{ url_for('home.index') }}">Home</a></div>
|
<div class="navitem">> <a href="{{ url_for('home.index') }}">Home</a></div>
|
||||||
<div class="navitem">> <a href="{{ url_for('home.full_list') }}">Full List</a></div>
|
<div class="navitem">> <a href="{{ url_for('home.full_list') }}">Full List</a></div>
|
||||||
|
<div class="navitem">> <a href="{{ url_for('home.groups') }}">Groups</a></div>
|
||||||
|
|
||||||
{% if g.user %}
|
{% if g.user %}
|
||||||
<div class="heading">Manage</div>
|
<div class="heading">Manage</div>
|
||||||
|
|||||||
21
myriad/templates/groups.html
Normal file
21
myriad/templates/groups.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block header %}
|
||||||
|
<div class="title">{% block title %}Groups{% endblock %}</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% for group in groups %}
|
||||||
|
<div class="heading big">{{group[1]}}</div>
|
||||||
|
<div class="maintext">
|
||||||
|
{{group[2]}}<br><br>
|
||||||
|
{% if group[0] in group_members %}
|
||||||
|
{% for member in group_members[group[0]] %}
|
||||||
|
✰ <a href="{{ url_for('home.page', mid=member[0]) }}">{{ member[3] }}</a> <br>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user